diff options
author | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 12:59:26 +0000 |
---|---|---|
committer | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 12:59:26 +0000 |
commit | 9c42337e64706082a768eac51f842da987f26e6f (patch) | |
tree | 9899a9e0088ded1f0f4df4076f64b55926838df9 /ash | |
parent | 266ddd2c033113179a26532c25657ad615856b2e (diff) | |
download | chromium_src-9c42337e64706082a768eac51f842da987f26e6f.zip chromium_src-9c42337e64706082a768eac51f842da987f26e6f.tar.gz chromium_src-9c42337e64706082a768eac51f842da987f26e6f.tar.bz2 |
Make chrome icon moveable
1) Added LauncherItemController for browser shortcut.
2) Merged Stefan's alt+n implementation.
BUG=156953
TEST= unit_tests, ash_unittests, browser_tests
Review URL: https://chromiumcodereview.appspot.com/11596003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/launcher/launcher.cc | 27 | ||||
-rw-r--r-- | ash/launcher/launcher_delegate.h | 14 | ||||
-rw-r--r-- | ash/launcher/launcher_model.cc | 19 | ||||
-rw-r--r-- | ash/launcher/launcher_model_unittest.cc | 68 | ||||
-rw-r--r-- | ash/launcher/launcher_navigator_unittest.cc | 10 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 28 | ||||
-rw-r--r-- | ash/launcher/launcher_view_unittest.cc | 78 | ||||
-rw-r--r-- | ash/shell/launcher_delegate_impl.cc | 12 | ||||
-rw-r--r-- | ash/shell/launcher_delegate_impl.h | 2 | ||||
-rw-r--r-- | ash/test/test_launcher_delegate.cc | 7 | ||||
-rw-r--r-- | ash/test/test_launcher_delegate.h | 2 |
11 files changed, 113 insertions, 154 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index f37b05c..952c6f5 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -63,14 +63,16 @@ Launcher::~Launcher() { // static Launcher* Launcher::ForPrimaryDisplay() { - return internal::RootWindowController::ForLauncher( - Shell::GetPrimaryRootWindow())->shelf()->launcher(); + ShelfWidget* shelf_widget = internal::RootWindowController::ForLauncher( + Shell::GetPrimaryRootWindow())->shelf(); + return shelf_widget ? shelf_widget->launcher() : NULL; } // static Launcher* Launcher::ForWindow(aura::Window* window) { - return internal::RootWindowController::ForLauncher(window)-> - shelf()->launcher(); + ShelfWidget* shelf_widget = + internal::RootWindowController::ForLauncher(window)->shelf(); + return shelf_widget ? shelf_widget->launcher() : NULL; } void Launcher::SetAlignment(ShelfAlignment alignment) { @@ -108,20 +110,6 @@ void Launcher::ActivateLauncherItem(int index) { ui::VKEY_UNKNOWN, // The actual key gets ignored. ui::EF_NONE, false); - // TODO(skuhne): Remove this temporary fix once M28 is out and CL 11596003 - // has landed. Note that all unit tests which use this function need to remove - // the "kChromeItemOffset" as well. - // Note: The index gets only decremented for the per app instance of the - // launcher. The old per browser launcher does not get impacted here. - if (delegate_->IsPerAppLauncher() && --index <= 0) { - LauncherItem item; - // Create a fake launcher item with an invalid ID so that - // our ChromeLauncherControllerPerApp can handle it accordingly. This is - // only a temporary fix until CL 11596003 has landed. - item.id = ash::kAppIdForBrowserSwitching; - delegate_->ItemSelected(item, event); - return; - } const ash::LauncherItems& items = launcher_view_->model()->items(); @@ -177,8 +165,7 @@ void Launcher::SwitchToWindow(int window_index) { // Iterating until we have hit the index we are interested in which // is true once indexes_left becomes negative. for (int i = 0; i < item_count && indexes_left >= 0; i++) { - if (items[i].type != TYPE_APP_LIST && - items[i].type != TYPE_BROWSER_SHORTCUT) { + if (items[i].type != TYPE_APP_LIST) { found_index = i; indexes_left--; } diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h index 0bd8ec6..a5c1842 100644 --- a/ash/launcher/launcher_delegate.h +++ b/ash/launcher/launcher_delegate.h @@ -21,11 +21,6 @@ class Event; namespace ash { class Launcher; -// When passed to LauncherDelegate::ItemSelected, the browser item will be -// addressed for switching. -// TODO(skuhne): Remove this constant once CL 11596003 has landed. -const LauncherID kAppIdForBrowserSwitching = -1; - // A special menu model which keeps track of an "active" menu item. class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel { public: @@ -46,11 +41,6 @@ class ASH_EXPORT LauncherDelegate { // Launcher owns the delegate. virtual ~LauncherDelegate() {} - // Invoked when the user clicks on button in the launcher to open last used - // window (or create a new one if there is no last used window). - // |event_flags| is the flags of the click event. - virtual void OnBrowserShortcutClicked(int event_flags) = 0; - // Invoked when the user clicks on a window entry in the launcher. // |event| is the click event. The |event| is dispatched by a view // and has an instance of |views::View| as the event target @@ -60,10 +50,6 @@ class ASH_EXPORT LauncherDelegate { virtual void ItemSelected(const LauncherItem& item, const ui::Event& event) = 0; - // Returns the resource id of the image to show on the browser shortcut - // button. - virtual int GetBrowserShortcutResourceId() = 0; - // Returns the title to display for the specified launcher item. virtual base::string16 GetTitle(const LauncherItem& item) = 0; diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc index f3581fe..cac37c0 100644 --- a/ash/launcher/launcher_model.cc +++ b/ash/launcher/launcher_model.cc @@ -15,21 +15,20 @@ namespace { int LauncherItemTypeToWeight(LauncherItemType type) { switch (type) { case TYPE_BROWSER_SHORTCUT: - return 0; case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: - return 1; + return 0; case TYPE_TABBED: case TYPE_PLATFORM_APP: - return 2; + return 1; case TYPE_APP_LIST: - return 3; + return 2; case TYPE_APP_PANEL: - return 4; + return 3; } NOTREACHED() << "Invalid type " << type; - return 2; + return 1; } bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { @@ -42,13 +41,7 @@ LauncherModel::LauncherModel() : next_id_(1), status_(STATUS_NORMAL) { LauncherItem app_list; app_list.type = TYPE_APP_LIST; app_list.is_incognito = false; - - LauncherItem browser_shortcut; - browser_shortcut.type = TYPE_BROWSER_SHORTCUT; - browser_shortcut.is_incognito = false; - - AddAt(0, browser_shortcut); - AddAt(1, app_list); + AddAt(0, app_list); } LauncherModel::~LauncherModel() { diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc index fb29267..0491ccd 100644 --- a/ash/launcher/launcher_model_unittest.cc +++ b/ash/launcher/launcher_model_unittest.cc @@ -77,17 +77,16 @@ TEST(LauncherModel, BasicAssertions) { TestLauncherModelObserver observer; LauncherModel model; - // Model is initially populated with two items. - EXPECT_EQ(2, model.item_count()); - // Two initial items should have different ids. - EXPECT_NE(model.items()[0].id, model.items()[1].id); + // Model is initially populated with item. + EXPECT_EQ(1, model.item_count()); // Add an item. model.AddObserver(&observer); LauncherItem item; int index = model.Add(item); - EXPECT_EQ(3, model.item_count()); + EXPECT_EQ(2, model.item_count()); EXPECT_EQ("added=1", observer.StateStringAndClear()); + // Verifies all the items get unique ids. std::set<LauncherID> ids; for (int i = 0; i < model.item_count(); ++i) @@ -103,7 +102,7 @@ TEST(LauncherModel, BasicAssertions) { // Remove the item. model.RemoveItemAt(index); - EXPECT_EQ(2, model.item_count()); + EXPECT_EQ(1, model.item_count()); EXPECT_EQ("removed=1", observer.StateStringAndClear()); // Add an app item. @@ -135,45 +134,49 @@ TEST(LauncherModel, AddIndices) { TestLauncherModelObserver observer; LauncherModel model; - // Model is initially populated with two items. - EXPECT_EQ(2, model.item_count()); - // Two initial items should have different ids. - EXPECT_NE(model.items()[0].id, model.items()[1].id); + // Model is initially populated with one item. + EXPECT_EQ(1, model.item_count()); - // Items come after the browser. - int browser = 0; - ASSERT_EQ(ash::TYPE_BROWSER_SHORTCUT, model.items()[browser].type); + // Insert browser short cut at index 0. + LauncherItem browser_shortcut; + browser_shortcut.type = TYPE_BROWSER_SHORTCUT; + int browser_shortcut_index = model.Add(browser_shortcut); + EXPECT_EQ(0, browser_shortcut_index); - // Tabbed items should be after shortcut. + // Tabbed items should be after browser shortcut. LauncherItem item; int tabbed_index1 = model.Add(item); - EXPECT_EQ(browser + 1, tabbed_index1); + EXPECT_EQ(1, tabbed_index1); // Add another tabbed item, it should follow first. int tabbed_index2 = model.Add(item); - EXPECT_EQ(browser + 2, tabbed_index2); + EXPECT_EQ(2, tabbed_index2); - // APP_SHORTCUT preceed browsers. + // APP_SHORTCUT's priority is higher than TABBED but same as + // BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT. item.type = TYPE_APP_SHORTCUT; int app_shortcut_index1 = model.Add(item); - EXPECT_EQ(browser + 1, app_shortcut_index1); + EXPECT_EQ(1, app_shortcut_index1); item.type = TYPE_APP_SHORTCUT; int app_shortcut_index2 = model.Add(item); - EXPECT_EQ(browser + 2, app_shortcut_index2); + EXPECT_EQ(2, app_shortcut_index2); // Check that AddAt() figures out the correct indexes for app shortcuts. + // APP_SHORTCUT and BROWSER_SHORTCUT has the same weight. + // So APP_SHORTCUT is located at index 0. And, BROWSER_SHORTCUT is located at + // index 1. item.type = TYPE_APP_SHORTCUT; int app_shortcut_index3 = model.AddAt(0, item); - EXPECT_EQ(browser + 1, app_shortcut_index3); + EXPECT_EQ(0, app_shortcut_index3); item.type = TYPE_APP_SHORTCUT; int app_shortcut_index4 = model.AddAt(5, item); - EXPECT_EQ(browser + 4, app_shortcut_index4); + EXPECT_EQ(4, app_shortcut_index4); item.type = TYPE_APP_SHORTCUT; int app_shortcut_index5 = model.AddAt(2, item); - EXPECT_EQ(browser + 2, app_shortcut_index5); + EXPECT_EQ(2, app_shortcut_index5); // Before there are any panels, no icons should be right aligned. EXPECT_EQ(model.item_count(), model.FirstPanelIndex()); @@ -181,33 +184,32 @@ TEST(LauncherModel, AddIndices) { // Check that AddAt() figures out the correct indexes for tabs and panels. item.type = TYPE_TABBED; int tabbed_index3 = model.AddAt(2, item); - EXPECT_EQ(browser + 6, tabbed_index3); + EXPECT_EQ(6, tabbed_index3); item.type = TYPE_APP_PANEL; int app_panel_index1 = model.AddAt(2, item); - EXPECT_EQ(browser + 10, app_panel_index1); + EXPECT_EQ(10, app_panel_index1); item.type = TYPE_TABBED; int tabbed_index4 = model.AddAt(11, item); - EXPECT_EQ(browser + 9, tabbed_index4); + EXPECT_EQ(9, tabbed_index4); item.type = TYPE_APP_PANEL; int app_panel_index2 = model.AddAt(12, item); - EXPECT_EQ(browser + 12, app_panel_index2); + EXPECT_EQ(12, app_panel_index2); item.type = TYPE_TABBED; int tabbed_index5 = model.AddAt(7, item); - EXPECT_EQ(browser + 7, tabbed_index5); + EXPECT_EQ(7, tabbed_index5); item.type = TYPE_APP_PANEL; int app_panel_index3 = model.AddAt(13, item); - EXPECT_EQ(browser + 13, app_panel_index3); + EXPECT_EQ(13, app_panel_index3); // Right aligned index should be the first app panel index. - EXPECT_EQ(browser + 12, model.FirstPanelIndex()); + EXPECT_EQ(12, model.FirstPanelIndex()); - // Browser shortcut and app list should still be first and second. - EXPECT_EQ(TYPE_BROWSER_SHORTCUT, model.items()[0].type); + EXPECT_EQ(TYPE_BROWSER_SHORTCUT, model.items()[1].type); EXPECT_EQ(TYPE_APP_LIST, model.items()[model.FirstPanelIndex() - 1].type); } @@ -216,7 +218,7 @@ TEST(LauncherModel, LauncherIDTests) { TestLauncherModelObserver observer; LauncherModel model; - EXPECT_EQ(2, model.item_count()); + EXPECT_EQ(1, model.item_count()); // Get the next to use ID counter. LauncherID id = model.next_id(); @@ -228,7 +230,7 @@ TEST(LauncherModel, LauncherIDTests) { // but it will not change the item count and retrieving the next ID should // produce something new. EXPECT_EQ(model.reserve_external_id(), id); - EXPECT_EQ(2, model.item_count()); + EXPECT_EQ(1, model.item_count()); LauncherID id2 = model.next_id(); EXPECT_NE(id2, id); diff --git a/ash/launcher/launcher_navigator_unittest.cc b/ash/launcher/launcher_navigator_unittest.cc index 6c91717..6013390 100644 --- a/ash/launcher/launcher_navigator_unittest.cc +++ b/ash/launcher/launcher_navigator_unittest.cc @@ -21,6 +21,16 @@ class LauncherNavigatorTest : public testing::Test { protected: virtual void SetUp() OVERRIDE { model_.reset(new LauncherModel); + + // Initially, applist launcher item is only created. + int total_num = model_->item_count(); + EXPECT_EQ(1, total_num); + EXPECT_TRUE(model_->items()[0].type == TYPE_APP_LIST); + + // Add BROWSER_SHORTCUT for test. + LauncherItem browser_shortcut; + browser_shortcut.type = TYPE_BROWSER_SHORTCUT; + model_->Add(browser_shortcut); } void SetupMockLauncherModel(LauncherItemType* types, diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 4c2dbf2..f24a1f5 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -878,6 +878,7 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { break; } + case TYPE_BROWSER_SHORTCUT: case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: @@ -909,18 +910,6 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { break; } - case TYPE_BROWSER_SHORTCUT: { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - LauncherButton* button = LauncherButton::Create( - this, this, tooltip_->shelf_layout_manager()); - int image_id = delegate_ ? - delegate_->GetBrowserShortcutResourceId() : - IDR_AURA_LAUNCHER_BROWSER_SHORTCUT; - button->SetImage(*rb.GetImageNamed(image_id).ToImageSkia()); - view = button; - break; - } - default: break; } @@ -1030,10 +1019,11 @@ bool LauncherView::SameDragType(LauncherItemType typea, case TYPE_PLATFORM_APP: return (typeb == TYPE_TABBED || typeb == TYPE_PLATFORM_APP); case TYPE_APP_SHORTCUT: + case TYPE_BROWSER_SHORTCUT: + return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); case TYPE_WINDOWED_APP: case TYPE_APP_LIST: case TYPE_APP_PANEL: - case TYPE_BROWSER_SHORTCUT: return typeb == typea; } NOTREACHED(); @@ -1424,15 +1414,13 @@ base::string16 LauncherView::GetAccessibleName(const views::View* view) { case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: + case TYPE_BROWSER_SHORTCUT: return delegate_->GetTitle(model_->items()[view_index]); case TYPE_APP_LIST: return model_->status() == LauncherModel::STATUS_LOADING ? l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_SYNCING_TITLE) : l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); - - case TYPE_BROWSER_SHORTCUT: - return Shell::GetInstance()->delegate()->GetProductName(); } return base::string16(); } @@ -1473,6 +1461,7 @@ void LauncherView::ButtonPressed(views::Button* sender, case TYPE_APP_SHORTCUT: case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: + case TYPE_BROWSER_SHORTCUT: Shell::GetInstance()->delegate()->RecordUserMetricsAction( UMA_LAUNCHER_CLICK_ON_APP); // Fallthrough @@ -1491,13 +1480,6 @@ void LauncherView::ButtonPressed(views::Button* sender, ash::switches::kAshDragAndDropAppListToLauncher)) Shell::GetInstance()->SetDragAndDropHostOfCurrentAppList(this); break; - - case TYPE_BROWSER_SHORTCUT: - // Click on browser icon is counted in app clicks. - Shell::GetInstance()->delegate()->RecordUserMetricsAction( - UMA_LAUNCHER_CLICK_ON_APP); - delegate_->OnBrowserShortcutClicked(event.flags()); - break; } } diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc index 8edcc51f..0470b88 100644 --- a/ash/launcher/launcher_view_unittest.cc +++ b/ash/launcher/launcher_view_unittest.cc @@ -34,10 +34,6 @@ #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" -namespace { -const int kExpectedAppIndex = 1; -} - namespace ash { namespace test { @@ -208,7 +204,10 @@ class LauncherViewTest : public AshTestBase { test_api_.reset(new LauncherViewTestAPI(launcher_view_)); test_api_->SetAnimationDuration(1); // Speeds up animation for test. - } + + // Add browser shortcut launcher item at index 0 for test. + AddBrowserShortcut(); + } virtual void TearDown() OVERRIDE { test_api_.reset(); @@ -216,6 +215,17 @@ class LauncherViewTest : public AshTestBase { } protected: + LauncherID AddBrowserShortcut() { + LauncherItem browser_shortcut; + browser_shortcut.type = TYPE_BROWSER_SHORTCUT; + browser_shortcut.is_incognito = false; + + LauncherID id = model_->next_id(); + model_->AddAt(0, browser_shortcut); + test_api_->RunMessageLoopUntilAnimationsDone(); + return id; + } + LauncherID AddAppShortcut() { LauncherItem item; item.type = TYPE_APP_SHORTCUT; @@ -321,20 +331,17 @@ class LauncherViewTest : public AshTestBase { views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, int button_index, int destination_index) { - // Add kExpectedAppIndex to each button index to allow default icons. internal::LauncherButtonHost* button_host = launcher_view_; // Mouse down. - views::View* button = - test_api_->GetButton(kExpectedAppIndex + button_index); + views::View* button = test_api_->GetButton(button_index); ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, button->bounds().origin(), button->bounds().origin(), 0); button_host->PointerPressedOnButton(button, pointer, click_event); // Drag. - views::View* destination = - test_api_->GetButton(kExpectedAppIndex + destination_index); + views::View* destination = test_api_->GetButton(destination_index); ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, destination->bounds().origin(), destination->bounds().origin(), 0); @@ -354,7 +361,9 @@ class LauncherViewTest : public AshTestBase { // Add 5 app launcher buttons for testing. for (int i = 0; i < 5; ++i) { LauncherID id = AddAppShortcut(); - id_map->insert(id_map->begin() + (kExpectedAppIndex + i), + // browser shortcut is located at index 0. So we should start to add app + // shortcut at index 1. + id_map->insert(id_map->begin() + (i + 1), std::make_pair(id, GetButtonByID(id))); } ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); @@ -586,27 +595,40 @@ TEST_F(LauncherViewTest, ModelChangesWhileDragging) { std::vector<std::pair<LauncherID, views::View*> > id_map; SetupForDragTest(&id_map); - // Dragging changes model order. + // Dragging browser shortcut at index 0. + EXPECT_TRUE(model_->items()[0].type == TYPE_BROWSER_SHORTCUT); views::View* dragged_button = SimulateDrag( internal::LauncherButtonHost::MOUSE, 0, 2); - std::rotate(id_map.begin() + kExpectedAppIndex, - id_map.begin() + kExpectedAppIndex + 1, - id_map.begin() + kExpectedAppIndex + 3); + std::rotate(id_map.begin(), + id_map.begin() + 1, + id_map.begin() + 3); + ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); + button_host->PointerReleasedOnButton(dragged_button, + internal::LauncherButtonHost::MOUSE, + false); + EXPECT_TRUE(model_->items()[2].type == TYPE_BROWSER_SHORTCUT); + + // Dragging changes model order. + dragged_button = SimulateDrag( + internal::LauncherButtonHost::MOUSE, 0, 2); + std::rotate(id_map.begin(), + id_map.begin() + 1, + id_map.begin() + 3); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); // Cancelling the drag operation restores previous order. button_host->PointerReleasedOnButton(dragged_button, internal::LauncherButtonHost::MOUSE, true); - std::rotate(id_map.begin() + kExpectedAppIndex, - id_map.begin() + kExpectedAppIndex + 2, - id_map.begin() + kExpectedAppIndex + 3); + std::rotate(id_map.begin(), + id_map.begin() + 2, + id_map.begin() + 3); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); // Deleting an item keeps the remaining intact. dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2); - model_->RemoveItemAt(kExpectedAppIndex + 1); - id_map.erase(id_map.begin() + kExpectedAppIndex + 1); + model_->RemoveItemAt(1); + id_map.erase(id_map.begin() + 1); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); button_host->PointerReleasedOnButton(dragged_button, internal::LauncherButtonHost::MOUSE, @@ -615,7 +637,7 @@ TEST_F(LauncherViewTest, ModelChangesWhileDragging) { // Adding a launcher item cancels the drag and respects the order. dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2); LauncherID new_id = AddAppShortcut(); - id_map.insert(id_map.begin() + kExpectedAppIndex + 4, + id_map.insert(id_map.begin() + 5, std::make_pair(new_id, GetButtonByID(new_id))); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); button_host->PointerReleasedOnButton(dragged_button, @@ -626,7 +648,7 @@ TEST_F(LauncherViewTest, ModelChangesWhileDragging) { // the order. dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2); new_id = AddPanel(); - id_map.insert(id_map.begin() + kExpectedAppIndex + 6, + id_map.insert(id_map.begin() + 7, std::make_pair(new_id, GetButtonByID(new_id))); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); button_host->PointerReleasedOnButton(dragged_button, @@ -644,9 +666,9 @@ TEST_F(LauncherViewTest, SimultaneousDrag) { // Start a mouse drag. views::View* dragged_button_mouse = SimulateDrag( internal::LauncherButtonHost::MOUSE, 0, 2); - std::rotate(id_map.begin() + kExpectedAppIndex, - id_map.begin() + kExpectedAppIndex + 1, - id_map.begin() + kExpectedAppIndex + 3); + std::rotate(id_map.begin(), + id_map.begin() + 1, + id_map.begin() + 3); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); // Attempt a touch drag before the mouse drag finishes. views::View* dragged_button_touch = SimulateDrag( @@ -664,9 +686,9 @@ TEST_F(LauncherViewTest, SimultaneousDrag) { // Now start a touch drag. dragged_button_touch = SimulateDrag( internal::LauncherButtonHost::TOUCH, 3, 1); - std::rotate(id_map.begin() + kExpectedAppIndex + 2, - id_map.begin() + kExpectedAppIndex + 3, - id_map.begin() + kExpectedAppIndex + 4); + std::rotate(id_map.begin() + 2, + id_map.begin() + 3, + id_map.begin() + 4); ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); // And attempt a mouse drag before the touch drag finishes. diff --git a/ash/shell/launcher_delegate_impl.cc b/ash/shell/launcher_delegate_impl.cc index 601adac..f933119 100644 --- a/ash/shell/launcher_delegate_impl.cc +++ b/ash/shell/launcher_delegate_impl.cc @@ -21,14 +21,6 @@ LauncherDelegateImpl::LauncherDelegateImpl(WindowWatcher* watcher) LauncherDelegateImpl::~LauncherDelegateImpl() { } -// In the shell we'll create a window all the time. -void LauncherDelegateImpl::OnBrowserShortcutClicked(int event_flags) { - ash::shell::ToplevelWindow::CreateParams create_params; - create_params.can_resize = true; - create_params.can_maximize = true; - ash::shell::ToplevelWindow::CreateToplevelWindow(create_params); -} - void LauncherDelegateImpl::ItemSelected(const ash::LauncherItem& item, const ui::Event& event) { aura::Window* window = watcher_->GetWindowByID(item.id); @@ -38,10 +30,6 @@ void LauncherDelegateImpl::ItemSelected(const ash::LauncherItem& item, ash::wm::ActivateWindow(window); } -int LauncherDelegateImpl::GetBrowserShortcutResourceId() { - return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT; -} - base::string16 LauncherDelegateImpl::GetTitle(const ash::LauncherItem& item) { return watcher_->GetWindowByID(item.id)->title(); } diff --git a/ash/shell/launcher_delegate_impl.h b/ash/shell/launcher_delegate_impl.h index 26b1dfd..754ee69 100644 --- a/ash/shell/launcher_delegate_impl.h +++ b/ash/shell/launcher_delegate_impl.h @@ -25,10 +25,8 @@ class LauncherDelegateImpl : public ash::LauncherDelegate { void set_watcher(WindowWatcher* watcher) { watcher_ = watcher; } // LauncherDelegate overrides: - virtual void OnBrowserShortcutClicked(int event_flags) OVERRIDE; virtual void ItemSelected(const ash::LauncherItem& item, const ui::Event& event) OVERRIDE; - virtual int GetBrowserShortcutResourceId() OVERRIDE; virtual base::string16 GetTitle(const ash::LauncherItem& item) OVERRIDE; virtual ui::MenuModel* CreateContextMenu( const ash::LauncherItem& item, diff --git a/ash/test/test_launcher_delegate.cc b/ash/test/test_launcher_delegate.cc index 3a4fccd..e71fd344 100644 --- a/ash/test/test_launcher_delegate.cc +++ b/ash/test/test_launcher_delegate.cc @@ -63,9 +63,6 @@ void TestLauncherDelegate::OnWillRemoveWindow(aura::Window* window) { } } -void TestLauncherDelegate::OnBrowserShortcutClicked(int event_flags) { -} - void TestLauncherDelegate::ItemSelected(const ash::LauncherItem& item, const ui::Event& event) { aura::Window* window = GetWindowByID(item.id); @@ -75,10 +72,6 @@ void TestLauncherDelegate::ItemSelected(const ash::LauncherItem& item, ash::wm::ActivateWindow(window); } -int TestLauncherDelegate::GetBrowserShortcutResourceId() { - return IDR_AURA_LAUNCHER_BROWSER_SHORTCUT; -} - base::string16 TestLauncherDelegate::GetTitle(const ash::LauncherItem& item) { aura::Window* window = GetWindowByID(item.id); return window ? window->title() : base::string16(); diff --git a/ash/test/test_launcher_delegate.h b/ash/test/test_launcher_delegate.h index 65dc634..60d7411 100644 --- a/ash/test/test_launcher_delegate.h +++ b/ash/test/test_launcher_delegate.h @@ -35,10 +35,8 @@ class TestLauncherDelegate : public LauncherDelegate, virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; // LauncherDelegate implementation. - virtual void OnBrowserShortcutClicked(int event_flags) OVERRIDE; virtual void ItemSelected(const LauncherItem& item, const ui::Event& event) OVERRIDE; - virtual int GetBrowserShortcutResourceId() OVERRIDE; virtual base::string16 GetTitle(const LauncherItem& item) OVERRIDE; virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item, aura::RootWindow* root) OVERRIDE; |