OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
33 #include "chrome/browser/extensions/launch_util.h" | 33 #include "chrome/browser/extensions/launch_util.h" |
34 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/ui/app_list/app_list_service.h" | 35 #include "chrome/browser/ui/app_list/app_list_service.h" |
36 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 36 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
37 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 37 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
38 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 38 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
39 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
40 #include "chrome/browser/ui/browser_commands.h" | 40 #include "chrome/browser/ui/browser_commands.h" |
41 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
42 #include "chrome/browser/ui/browser_iterator.h" | |
43 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
44 #include "chrome/browser/ui/browser_window.h" | 43 #include "chrome/browser/ui/browser_window.h" |
45 #include "chrome/browser/ui/chrome_pages.h" | 44 #include "chrome/browser/ui/chrome_pages.h" |
46 #include "chrome/browser/ui/extensions/app_launch_params.h" | 45 #include "chrome/browser/ui/extensions/app_launch_params.h" |
47 #include "chrome/browser/ui/extensions/application_launch.h" | 46 #include "chrome/browser/ui/extensions/application_launch.h" |
48 #include "chrome/browser/ui/host_desktop.h" | 47 #include "chrome/browser/ui/host_desktop.h" |
49 #include "chrome/browser/ui/settings_window_manager.h" | 48 #include "chrome/browser/ui/settings_window_manager.h" |
50 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 49 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
51 #include "chrome/browser/web_applications/web_app.h" | 50 #include "chrome/browser/web_applications/web_app.h" |
52 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(), | 139 generator->MoveMouseTo(all_apps_rect.CenterPoint().x(), |
141 all_apps_rect.CenterPoint().y()); | 140 all_apps_rect.CenterPoint().y()); |
142 generator->ClickLeftButton(); | 141 generator->ClickLeftButton(); |
143 base::MessageLoop::current()->RunUntilIdle(); | 142 base::MessageLoop::current()->RunUntilIdle(); |
144 // Run Layout() to effectively complete the animation to the apps page. | 143 // Run Layout() to effectively complete the animation to the apps page. |
145 controller_test.LayoutContentsView(); | 144 controller_test.LayoutContentsView(); |
146 } | 145 } |
147 | 146 |
148 // Find the browser that associated with |app_name|. | 147 // Find the browser that associated with |app_name|. |
149 Browser* FindBrowserForApp(const std::string& app_name) { | 148 Browser* FindBrowserForApp(const std::string& app_name) { |
150 Browser* browser = nullptr; | 149 for (auto* browser : *BrowserList::GetInstance()) { |
151 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
152 std::string browser_app_name = | 150 std::string browser_app_name = |
153 web_app::GetExtensionIdFromApplicationName((*it)->app_name()); | 151 web_app::GetExtensionIdFromApplicationName(browser->app_name()); |
154 if (browser_app_name == app_name) { | 152 if (browser_app_name == app_name) |
155 browser = *it; | 153 return browser; |
156 break; | |
157 } | |
158 } | 154 } |
159 return browser; | 155 return nullptr; |
160 } | 156 } |
161 | 157 |
162 // Close |app_browser| and wait until it's closed. | 158 // Close |app_browser| and wait until it's closed. |
163 void CloseAppBrowserWindow(Browser* app_browser) { | 159 void CloseAppBrowserWindow(Browser* app_browser) { |
164 content::WindowedNotificationObserver close_observer( | 160 content::WindowedNotificationObserver close_observer( |
165 chrome::NOTIFICATION_BROWSER_CLOSED, | 161 chrome::NOTIFICATION_BROWSER_CLOSED, |
166 content::Source<Browser>(app_browser)); | 162 content::Source<Browser>(app_browser)); |
167 app_browser->window()->Close(); | 163 app_browser->window()->Close(); |
168 close_observer.Wait(); | 164 close_observer.Wait(); |
169 } | 165 } |
(...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2285 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2290 | 2286 |
2291 // There should be two new browsers. | 2287 // There should be two new browsers. |
2292 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); | 2288 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); |
2293 | 2289 |
2294 // The apps should now be running, with the last opened app active. | 2290 // The apps should now be running, with the last opened app active. |
2295 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2291 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2296 EXPECT_EQ(ash::STATUS_ACTIVE, | 2292 EXPECT_EQ(ash::STATUS_ACTIVE, |
2297 model_->ItemByID(bookmark_app_shelf_id)->status); | 2293 model_->ItemByID(bookmark_app_shelf_id)->status); |
2298 } | 2294 } |
OLD | NEW |