Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc

Issue 2791803002: mash: Move LauncherItemController to ash, rename ShelfItemDelegate. (Closed)
Patch Set: Sync and rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/app_shortcut_launcher_item_controller.h " 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "chrome/browser/chromeos/arc/arc_support_host.h" 11 #include "chrome/browser/chromeos/arc/arc_support_host.h"
12 #include "chrome/browser/extensions/launch_util.h" 12 #include "chrome/browser/extensions/launch_util.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
14 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h" 14 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h"
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
17 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 17 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
18 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 18 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
19 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
20 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
21 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 20 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
22 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/browser/web_applications/web_app.h" 26 #include "chrome/browser/web_applications/web_app.h"
28 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 27 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
29 #include "content/public/browser/navigation_entry.h" 28 #include "content/public/browser/navigation_entry.h"
(...skipping 11 matching lines...) Expand all
41 namespace { 40 namespace {
42 41
43 // The time delta between clicks in which clicks to launch V2 apps are ignored. 42 // The time delta between clicks in which clicks to launch V2 apps are ignored.
44 const int kClickSuppressionInMS = 1000; 43 const int kClickSuppressionInMS = 1000;
45 44
46 // Check if a browser can be used for activation. This addresses a special use 45 // Check if a browser can be used for activation. This addresses a special use
47 // case in the M31 multi profile mode where a user activates a V1 app which only 46 // case in the M31 multi profile mode where a user activates a V1 app which only
48 // exists yet on another users desktop, but they expect to get only their own 47 // exists yet on another users desktop, but they expect to get only their own
49 // app items and not the ones from other users through activation. 48 // app items and not the ones from other users through activation.
50 // TODO(skuhne): Remove this function and replace the call with 49 // TODO(skuhne): Remove this function and replace the call with
51 // launcher_controller()->IsBrowserFromActiveUser(browser) once this experiment 50 // ChromeLauncherController::IsBrowserFromActiveUser(browser) once this
52 // goes away. 51 // experiment goes away.
53 bool CanBrowserBeUsedForDirectActivation(Browser* browser, 52 bool CanBrowserBeUsedForDirectActivation(Browser* browser,
54 ChromeLauncherController* launcher) { 53 ChromeLauncherController* launcher) {
55 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 54 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
56 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF) 55 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF)
57 return true; 56 return true;
58 return multi_user_util::IsProfileFromActiveUser(browser->profile()); 57 return multi_user_util::IsProfileFromActiveUser(browser->profile());
59 } 58 }
60 59
61 } // namespace 60 } // namespace
62 61
63 // static 62 // static
64 AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create( 63 std::unique_ptr<AppShortcutLauncherItemController>
65 const ash::AppLaunchId& app_launch_id, 64 AppShortcutLauncherItemController::Create(
66 ChromeLauncherController* controller) { 65 const ash::AppLaunchId& app_launch_id) {
67 if (app_launch_id.app_id() == ArcSupportHost::kHostAppId || 66 if (app_launch_id.app_id() == ArcSupportHost::kHostAppId ||
68 app_launch_id.app_id() == arc::kPlayStoreAppId) { 67 app_launch_id.app_id() == arc::kPlayStoreAppId) {
69 return new ArcPlaystoreShortcutLauncherItemController(controller); 68 return base::MakeUnique<ArcPlaystoreShortcutLauncherItemController>();
70 } 69 }
71 return new AppShortcutLauncherItemController(app_launch_id, controller); 70 return base::WrapUnique<AppShortcutLauncherItemController>(
71 new AppShortcutLauncherItemController(app_launch_id));
72 } 72 }
73 73
74 // Item controller for an app shortcut. Shortcuts track app and launcher ids, 74 // Item controller for an app shortcut. Shortcuts track app and launcher ids,
75 // but do not have any associated windows (opening a shortcut will replace the 75 // but do not have any associated windows (opening a shortcut will replace the
76 // item with the appropriate LauncherItemController type). 76 // item with the appropriate ash::ShelfItemDelegate type).
77 AppShortcutLauncherItemController::AppShortcutLauncherItemController( 77 AppShortcutLauncherItemController::AppShortcutLauncherItemController(
78 const ash::AppLaunchId& app_launch_id, 78 const ash::AppLaunchId& app_launch_id)
79 ChromeLauncherController* controller) 79 : ash::ShelfItemDelegate(app_launch_id) {
80 : LauncherItemController(app_launch_id, controller),
81 chrome_launcher_controller_(controller) {
82 // To detect V1 applications we use their domain and match them against the 80 // To detect V1 applications we use their domain and match them against the
83 // used URL. This will also work with applications like Google Drive. 81 // used URL. This will also work with applications like Google Drive.
84 const Extension* extension = 82 const Extension* extension = GetExtensionForAppID(
85 GetExtensionForAppID(app_launch_id.app_id(), controller->profile()); 83 app_launch_id.app_id(), ChromeLauncherController::instance()->profile());
86 // Some unit tests have no real extension. 84 // Some unit tests have no real extension.
87 if (extension) { 85 if (extension) {
88 set_refocus_url(GURL( 86 set_refocus_url(GURL(
89 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); 87 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*"));
90 } 88 }
91 } 89 }
92 90
93 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {} 91 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {}
94 92
95 void AppShortcutLauncherItemController::ItemSelected( 93 void AppShortcutLauncherItemController::ItemSelected(
(...skipping 16 matching lines...) Expand all
112 // they open a window. Since there is currently no other way to detect if an 110 // they open a window. Since there is currently no other way to detect if an
113 // app was started we suppress any further clicks within a special time out. 111 // app was started we suppress any further clicks within a special time out.
114 if (IsV2App() && !AllowNextLaunchAttempt()) { 112 if (IsV2App() && !AllowNextLaunchAttempt()) {
115 callback.Run(ash::SHELF_ACTION_NONE, 113 callback.Run(ash::SHELF_ACTION_NONE,
116 GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); 114 GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
117 return; 115 return;
118 } 116 }
119 117
120 // Launching some items replaces this item controller instance, which 118 // Launching some items replaces this item controller instance, which
121 // destroys its AppLaunchId string pair; making copies avoid crashes. 119 // destroys its AppLaunchId string pair; making copies avoid crashes.
122 launcher_controller()->LaunchApp(ash::AppLaunchId(app_launch_id()), source, 120 ChromeLauncherController::instance()->LaunchApp(
123 ui::EF_NONE); 121 ash::AppLaunchId(app_launch_id()), source, ui::EF_NONE);
124 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); 122 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt);
125 return; 123 return;
126 } 124 }
127 125
128 const ash::ShelfAction action = ActivateContent(content); 126 const ash::ShelfAction action = ActivateContent(content);
129 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); 127 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
130 } 128 }
131 129
132 MenuItemList AppShortcutLauncherItemController::GetAppMenuItems( 130 ash::MenuItemList AppShortcutLauncherItemController::GetAppMenuItems(
133 int event_flags) { 131 int event_flags) {
134 MenuItemList items; 132 ash::MenuItemList items;
135 app_menu_items_ = GetRunningApplications(); 133 app_menu_items_ = GetRunningApplications();
134 ChromeLauncherController* controller = ChromeLauncherController::instance();
136 for (size_t i = 0; i < app_menu_items_.size(); i++) { 135 for (size_t i = 0; i < app_menu_items_.size(); i++) {
137 content::WebContents* tab = app_menu_items_[i]; 136 content::WebContents* tab = app_menu_items_[i];
138 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); 137 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New());
139 item->command_id = base::checked_cast<uint32_t>(i); 138 item->command_id = base::checked_cast<uint32_t>(i);
140 item->label = launcher_controller()->GetAppListTitle(tab); 139 item->label = controller->GetAppListTitle(tab);
141 item->image = *launcher_controller()->GetAppListIcon(tab).ToSkBitmap(); 140 item->image = *controller->GetAppListIcon(tab).ToSkBitmap();
142 items.push_back(std::move(item)); 141 items.push_back(std::move(item));
143 } 142 }
144 return items; 143 return items;
145 } 144 }
146 145
147 void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id, 146 void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id,
148 int32_t event_flags) { 147 int32_t event_flags) {
149 if (static_cast<size_t>(command_id) >= app_menu_items_.size()) { 148 if (static_cast<size_t>(command_id) >= app_menu_items_.size()) {
150 app_menu_items_.clear(); 149 app_menu_items_.clear();
151 return; 150 return;
(...skipping 17 matching lines...) Expand all
169 browser->window()->Activate(); 168 browser->window()->Activate();
170 } 169 }
171 } 170 }
172 171
173 app_menu_items_.clear(); 172 app_menu_items_.clear();
174 } 173 }
175 174
176 void AppShortcutLauncherItemController::Close() { 175 void AppShortcutLauncherItemController::Close() {
177 // Close all running 'programs' of this type. 176 // Close all running 'programs' of this type.
178 std::vector<content::WebContents*> content = 177 std::vector<content::WebContents*> content =
179 launcher_controller()->GetV1ApplicationsFromAppId(app_id()); 178 ChromeLauncherController::instance()->GetV1ApplicationsFromAppId(
179 app_id());
180 for (size_t i = 0; i < content.size(); i++) { 180 for (size_t i = 0; i < content.size(); i++) {
181 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); 181 Browser* browser = chrome::FindBrowserWithWebContents(content[i]);
182 if (!browser || !IsBrowserFromActiveUser(browser)) 182 if (!browser || !IsBrowserFromActiveUser(browser))
183 continue; 183 continue;
184 TabStripModel* tab_strip = browser->tab_strip_model(); 184 TabStripModel* tab_strip = browser->tab_strip_model();
185 int index = tab_strip->GetIndexOfWebContents(content[i]); 185 int index = tab_strip->GetIndexOfWebContents(content[i]);
186 DCHECK(index != TabStripModel::kNoTab); 186 DCHECK(index != TabStripModel::kNoTab);
187 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE); 187 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE);
188 } 188 }
189 } 189 }
190 190
191 std::vector<content::WebContents*> 191 std::vector<content::WebContents*>
192 AppShortcutLauncherItemController::GetRunningApplications() { 192 AppShortcutLauncherItemController::GetRunningApplications() {
193 std::vector<content::WebContents*> items; 193 std::vector<content::WebContents*> items;
194 194
195 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); 195 URLPattern refocus_pattern(URLPattern::SCHEME_ALL);
196 refocus_pattern.SetMatchAllURLs(true); 196 refocus_pattern.SetMatchAllURLs(true);
197 197
198 if (!refocus_url_.is_empty()) { 198 if (!refocus_url_.is_empty()) {
199 refocus_pattern.SetMatchAllURLs(false); 199 refocus_pattern.SetMatchAllURLs(false);
200 refocus_pattern.Parse(refocus_url_.spec()); 200 refocus_pattern.Parse(refocus_url_.spec());
201 } 201 }
202 202
203 const Extension* extension = 203 const Extension* extension = GetExtensionForAppID(
204 GetExtensionForAppID(app_id(), launcher_controller()->profile()); 204 app_id(), ChromeLauncherController::instance()->profile());
205 205
206 // It is possible to come here While an extension gets loaded. 206 // It is possible to come here While an extension gets loaded.
207 if (!extension) 207 if (!extension)
208 return items; 208 return items;
209 209
210 for (auto* browser : *BrowserList::GetInstance()) { 210 for (auto* browser : *BrowserList::GetInstance()) {
211 if (!IsBrowserFromActiveUser(browser)) 211 if (!IsBrowserFromActiveUser(browser))
212 continue; 212 continue;
213 TabStripModel* tab_strip = browser->tab_strip_model(); 213 TabStripModel* tab_strip = browser->tab_strip_model();
214 for (int index = 0; index < tab_strip->count(); index++) { 214 for (int index = 0; index < tab_strip->count(); index++) {
215 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); 215 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index);
216 if (WebContentMatchesApp( 216 if (WebContentMatchesApp(
217 extension, refocus_pattern, web_contents, browser)) 217 extension, refocus_pattern, web_contents, browser))
218 items.push_back(web_contents); 218 items.push_back(web_contents);
219 } 219 }
220 } 220 }
221 return items; 221 return items;
222 } 222 }
223 223
224 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { 224 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
225 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); 225 URLPattern refocus_pattern(URLPattern::SCHEME_ALL);
226 refocus_pattern.SetMatchAllURLs(true); 226 refocus_pattern.SetMatchAllURLs(true);
227 227
228 if (!refocus_url_.is_empty()) { 228 if (!refocus_url_.is_empty()) {
229 refocus_pattern.SetMatchAllURLs(false); 229 refocus_pattern.SetMatchAllURLs(false);
230 refocus_pattern.Parse(refocus_url_.spec()); 230 refocus_pattern.Parse(refocus_url_.spec());
231 } 231 }
232 232
233 ChromeLauncherController* controller = ChromeLauncherController::instance();
233 const Extension* extension = 234 const Extension* extension =
234 GetExtensionForAppID(app_id(), launcher_controller()->profile()); 235 GetExtensionForAppID(app_id(), controller->profile());
235 236
236 // We may get here while the extension is loading (and NULL). 237 // We may get here while the extension is loading (and NULL).
237 if (!extension) 238 if (!extension)
238 return NULL; 239 return NULL;
239 240
240 const BrowserList* browser_list = BrowserList::GetInstance(); 241 const BrowserList* browser_list = BrowserList::GetInstance();
241 for (BrowserList::const_reverse_iterator it = 242 for (BrowserList::const_reverse_iterator it =
242 browser_list->begin_last_active(); 243 browser_list->begin_last_active();
243 it != browser_list->end_last_active(); ++it) { 244 it != browser_list->end_last_active(); ++it) {
244 Browser* browser = *it; 245 Browser* browser = *it;
245 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) 246 if (!CanBrowserBeUsedForDirectActivation(browser, controller))
246 continue; 247 continue;
247 TabStripModel* tab_strip = browser->tab_strip_model(); 248 TabStripModel* tab_strip = browser->tab_strip_model();
248 // We start to enumerate from the active index. 249 // We start to enumerate from the active index.
249 int active_index = tab_strip->active_index(); 250 int active_index = tab_strip->active_index();
250 for (int index = 0; index < tab_strip->count(); index++) { 251 for (int index = 0; index < tab_strip->count(); index++) {
251 content::WebContents* web_contents = tab_strip->GetWebContentsAt( 252 content::WebContents* web_contents = tab_strip->GetWebContentsAt(
252 (index + active_index) % tab_strip->count()); 253 (index + active_index) % tab_strip->count());
253 if (WebContentMatchesApp( 254 if (WebContentMatchesApp(
254 extension, refocus_pattern, web_contents, browser)) 255 extension, refocus_pattern, web_contents, browser))
255 return web_contents; 256 return web_contents;
256 } 257 }
257 } 258 }
258 // Coming here our application was not in the LRU list. This could have 259 // Coming here our application was not in the LRU list. This could have
259 // happened because it did never get activated yet. So check the browser list 260 // happened because it did never get activated yet. So check the browser list
260 // as well. 261 // as well.
261 for (BrowserList::const_iterator it = browser_list->begin(); 262 for (BrowserList::const_iterator it = browser_list->begin();
262 it != browser_list->end(); ++it) { 263 it != browser_list->end(); ++it) {
263 Browser* browser = *it; 264 Browser* browser = *it;
264 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) 265 if (!CanBrowserBeUsedForDirectActivation(
266 browser, ChromeLauncherController::instance()))
265 continue; 267 continue;
266 TabStripModel* tab_strip = browser->tab_strip_model(); 268 TabStripModel* tab_strip = browser->tab_strip_model();
267 for (int index = 0; index < tab_strip->count(); index++) { 269 for (int index = 0; index < tab_strip->count(); index++) {
268 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); 270 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index);
269 if (WebContentMatchesApp( 271 if (WebContentMatchesApp(
270 extension, refocus_pattern, web_contents, browser)) 272 extension, refocus_pattern, web_contents, browser))
271 return web_contents; 273 return web_contents;
272 } 274 }
273 } 275 }
274 return NULL; 276 return NULL;
(...skipping 18 matching lines...) Expand all
293 // tabs. 295 // tabs.
294 if (extensions::LaunchesInWindow(browser->profile(), extension)) 296 if (extensions::LaunchesInWindow(browser->profile(), extension))
295 return false; 297 return false;
296 298
297 // There are three ways to identify the association of a URL with this 299 // There are three ways to identify the association of a URL with this
298 // extension: 300 // extension:
299 // - The refocus pattern is matched (needed for apps like drive). 301 // - The refocus pattern is matched (needed for apps like drive).
300 // - The extension's origin + extent gets matched. 302 // - The extension's origin + extent gets matched.
301 // - The launcher controller knows that the tab got created for this app. 303 // - The launcher controller knows that the tab got created for this app.
302 const GURL tab_url = web_contents->GetURL(); 304 const GURL tab_url = web_contents->GetURL();
303 return ((!refocus_pattern.match_all_urls() && 305 return (
304 refocus_pattern.MatchesURL(tab_url)) || 306 (!refocus_pattern.match_all_urls() &&
305 (extension->OverlapsWithOrigin(tab_url) && 307 refocus_pattern.MatchesURL(tab_url)) ||
306 extension->web_extent().MatchesURL(tab_url)) || 308 (extension->OverlapsWithOrigin(tab_url) &&
307 launcher_controller()->IsWebContentHandledByApplication(web_contents, 309 extension->web_extent().MatchesURL(tab_url)) ||
308 app_id())); 310 ChromeLauncherController::instance()->IsWebContentHandledByApplication(
311 web_contents, app_id()));
309 } 312 }
310 313
311 ash::ShelfAction AppShortcutLauncherItemController::ActivateContent( 314 ash::ShelfAction AppShortcutLauncherItemController::ActivateContent(
312 content::WebContents* content) { 315 content::WebContents* content) {
313 Browser* browser = chrome::FindBrowserWithWebContents(content); 316 Browser* browser = chrome::FindBrowserWithWebContents(content);
314 TabStripModel* tab_strip = browser->tab_strip_model(); 317 TabStripModel* tab_strip = browser->tab_strip_model();
315 int index = tab_strip->GetIndexOfWebContents(content); 318 int index = tab_strip->GetIndexOfWebContents(content);
316 DCHECK_NE(TabStripModel::kNoTab, index); 319 DCHECK_NE(TabStripModel::kNoTab, index);
317 320
318 int old_index = tab_strip->active_index(); 321 int old_index = tab_strip->active_index();
319 if (index != old_index) 322 if (index != old_index)
320 tab_strip->ActivateTabAt(index, false); 323 tab_strip->ActivateTabAt(index, false);
321 return launcher_controller()->ActivateWindowOrMinimizeIfActive( 324 return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive(
322 browser->window(), 325 browser->window(),
323 index == old_index && GetRunningApplications().size() == 1); 326 index == old_index && GetRunningApplications().size() == 1);
324 } 327 }
325 328
326 bool AppShortcutLauncherItemController::AdvanceToNextApp() { 329 bool AppShortcutLauncherItemController::AdvanceToNextApp() {
327 std::vector<content::WebContents*> items = GetRunningApplications(); 330 std::vector<content::WebContents*> items = GetRunningApplications();
328 if (items.size() >= 1) { 331 if (items.size() >= 1) {
329 Browser* browser = chrome::FindBrowserWithWindow( 332 Browser* browser = chrome::FindBrowserWithWindow(
330 ash::wm::GetActiveWindow()); 333 ash::wm::GetActiveWindow());
331 if (browser) { 334 if (browser) {
(...skipping 13 matching lines...) Expand all
345 ActivateContent(items[index]); 348 ActivateContent(items[index]);
346 } 349 }
347 return true; 350 return true;
348 } 351 }
349 } 352 }
350 } 353 }
351 return false; 354 return false;
352 } 355 }
353 356
354 bool AppShortcutLauncherItemController::IsV2App() { 357 bool AppShortcutLauncherItemController::IsV2App() {
355 const Extension* extension = 358 const Extension* extension = GetExtensionForAppID(
356 GetExtensionForAppID(app_id(), launcher_controller()->profile()); 359 app_id(), ChromeLauncherController::instance()->profile());
357 return extension && extension->is_platform_app(); 360 return extension && extension->is_platform_app();
358 } 361 }
359 362
360 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { 363 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() {
361 if (last_launch_attempt_.is_null() || 364 if (last_launch_attempt_.is_null() ||
362 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( 365 last_launch_attempt_ + base::TimeDelta::FromMilliseconds(
363 kClickSuppressionInMS) < base::Time::Now()) { 366 kClickSuppressionInMS) < base::Time::Now()) {
364 last_launch_attempt_ = base::Time::Now(); 367 last_launch_attempt_ = base::Time::Now();
365 return true; 368 return true;
366 } 369 }
367 return false; 370 return false;
368 } 371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698