Merge from Chromium at DEPS revision r205460
This commit was generated by merge_to_master.py.
Change-Id: I4a744a5e426bd3bb378d887cfa56fe054742a540
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index 952c6f5..c19a0c2 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -52,8 +52,6 @@
launcher_view_->Init();
shelf_widget_->GetContentsView()->AddChildView(launcher_view_);
shelf_widget_->GetNativeView()->SetName(kNativeViewName);
- shelf_widget_->GetNativeView()->SetProperty(
- internal::kStayInSameRootWindowKey, true);
delegate_->OnLauncherCreated(this);
}
diff --git a/ash/launcher/launcher_button_host.h b/ash/launcher/launcher_button_host.h
index c867a68..46f2e59 100644
--- a/ash/launcher/launcher_button_host.h
+++ b/ash/launcher/launcher_button_host.h
@@ -6,7 +6,7 @@
#define ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#include "ash/ash_export.h"
-#include "base/string16.h"
+#include "base/strings/string16.h"
namespace ui {
class LocatedEvent;
diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h
index a5c1842..cb80588 100644
--- a/ash/launcher/launcher_delegate.h
+++ b/ash/launcher/launcher_delegate.h
@@ -7,7 +7,7 @@
#include "ash/ash_export.h"
#include "ash/launcher/launcher_types.h"
-#include "base/string16.h"
+#include "base/strings/string16.h"
#include "ui/base/models/simple_menu_model.h"
namespace aura {
diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc
index 0491ccd..382f224 100644
--- a/ash/launcher/launcher_model_unittest.cc
+++ b/ash/launcher/launcher_model_unittest.cc
@@ -8,7 +8,7 @@
#include <string>
#include "ash/launcher/launcher_model_observer.h"
-#include "base/stringprintf.h"
+#include "base/strings/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h
index b4cd20b..852c30c 100644
--- a/ash/launcher/launcher_tooltip_manager.h
+++ b/ash/launcher/launcher_tooltip_manager.h
@@ -9,7 +9,7 @@
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/shelf/shelf_types.h"
#include "base/basictypes.h"
-#include "base/string16.h"
+#include "base/strings/string16.h"
#include "ui/base/events/event_handler.h"
#include "ui/gfx/rect.h"
#include "ui/views/bubble/bubble_border.h"
diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc
index 4ceef35..6a38d09 100644
--- a/ash/launcher/launcher_tooltip_manager_unittest.cc
+++ b/ash/launcher/launcher_tooltip_manager_unittest.cc
@@ -11,7 +11,7 @@
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_util.h"
-#include "base/string16.h"
+#include "base/strings/string16.h"
#include "base/time.h"
#include "ui/aura/root_window.h"
#include "ui/base/events/event.h"
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index ead0879..8585e49 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -472,7 +472,8 @@
LauncherButton* button =
static_cast<LauncherButton*>(view_model_->view_at(index));
gfx::Rect icon_bounds = button->GetIconBounds();
- return gfx::Rect(ideal_bounds.x() + icon_bounds.x(),
+ return gfx::Rect(GetMirroredXWithWidthInView(
+ ideal_bounds.x() + icon_bounds.x(), icon_bounds.width()),
ideal_bounds.y() + icon_bounds.y(),
icon_bounds.width(),
icon_bounds.height());
@@ -485,19 +486,21 @@
if (current_index < first_panel_index)
return;
+ gfx::Point midpoint_in_view(GetMirroredXInView(midpoint.x()),
+ midpoint.y());
ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
int target_index = current_index;
while (target_index > first_panel_index &&
shelf->PrimaryAxisValue(view_model_->ideal_bounds(target_index).x(),
view_model_->ideal_bounds(target_index).y()) >
- shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) {
+ shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) {
--target_index;
}
while (target_index < view_model_->view_size() - 1 &&
shelf->PrimaryAxisValue(
view_model_->ideal_bounds(target_index).right(),
view_model_->ideal_bounds(target_index).bottom()) <
- shelf->PrimaryAxisValue(midpoint.x(), midpoint.y())) {
+ shelf->PrimaryAxisValue(midpoint_in_view.x(), midpoint_in_view.y())) {
++target_index;
}
if (current_index != target_index)
@@ -545,6 +548,7 @@
const gfx::Point& location_in_screen_coordinates,
const gfx::ImageSkia& icon,
views::View* replaced_view,
+ const gfx::Vector2d& cursor_offset_from_center,
float scale_factor) {
drag_replaced_view_ = replaced_view;
drag_image_.reset(new ash::internal::DragImageView(
@@ -553,7 +557,8 @@
gfx::Size size = drag_image_->GetPreferredSize();
size.set_width(size.width() * scale_factor);
size.set_height(size.height() * scale_factor);
- drag_image_offset_ = gfx::Vector2d(size.width() / 2, size.height() / 2);
+ drag_image_offset_ = gfx::Vector2d(size.width() / 2, size.height() / 2) +
+ cursor_offset_from_center;
gfx::Rect drag_image_bounds(
GetPositionInScreen(location_in_screen_coordinates,
drag_replaced_view_) - drag_image_offset_, size);
@@ -1482,8 +1487,8 @@
Shell::GetInstance()->ToggleAppList(GetWidget()->GetNativeView());
// By setting us as DnD recipient, the app list knows that we can
// handle items.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- ash::switches::kAshDragAndDropAppListToLauncher))
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshDisableDragAndDropAppListToLauncher))
Shell::GetInstance()->SetDragAndDropHostOfCurrentAppList(this);
break;
}
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index e91f07b..a431d12 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -105,6 +105,7 @@
const gfx::Point& location_in_screen_coordinates,
const gfx::ImageSkia& icon,
views::View* replaced_view,
+ const gfx::Vector2d& cursor_offset_from_center,
float scale_factor) OVERRIDE;
virtual void UpdateDragIconProxy(
const gfx::Point& location_in_screen_coordinates) OVERRIDE;
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 0470b88..3297f04 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -30,7 +30,9 @@
#include "ui/aura/window.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
+#include "ui/views/view_model.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -386,6 +388,50 @@
DISALLOW_COPY_AND_ASSIGN(LauncherViewTest);
};
+class LauncherViewTextDirectionTest
+ : public LauncherViewTest,
+ public testing::WithParamInterface<bool> {
+ public:
+ LauncherViewTextDirectionTest() : is_rtl_(GetParam()) {}
+ virtual ~LauncherViewTextDirectionTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ LauncherViewTest::SetUp();
+ original_locale_ = l10n_util::GetApplicationLocale(std::string());
+ if (is_rtl_)
+ base::i18n::SetICUDefaultLocale("he");
+ ASSERT_EQ(is_rtl_, base::i18n::IsRTL());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ if (is_rtl_)
+ base::i18n::SetICUDefaultLocale(original_locale_);
+ LauncherViewTest::TearDown();
+ }
+
+ private:
+ bool is_rtl_;
+ std::string original_locale_;
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherViewTextDirectionTest);
+};
+
+// Checks that the ideal item icon bounds match the view's bounds in the screen
+// in both LTR and RTL.
+TEST_P(LauncherViewTextDirectionTest, IdealBoundsOfItemIcon) {
+ LauncherID id = AddTabbedBrowser();
+ internal::LauncherButton* button = GetButtonByID(id);
+ gfx::Rect item_bounds = button->GetBoundsInScreen();
+ gfx::Point icon_offset = button->GetIconBounds().origin();
+ item_bounds.Offset(icon_offset.OffsetFromOrigin());
+ gfx::Rect ideal_bounds = launcher_view_->GetIdealBoundsOfItemIcon(id);
+ gfx::Point screen_origin;
+ views::View::ConvertPointToScreen(launcher_view_, &screen_origin);
+ ideal_bounds.Offset(screen_origin.x(), screen_origin.y());
+ EXPECT_EQ(item_bounds.x(), ideal_bounds.x());
+ EXPECT_EQ(item_bounds.y(), ideal_bounds.y());
+}
+
// Adds browser button until overflow and verifies that the last added browser
// button is hidden.
TEST_F(LauncherViewTest, AddBrowserUntilOverflow) {
@@ -921,5 +967,7 @@
EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width());
}
+INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool());
+
} // namespace test
} // namespace ash