OLD | NEW |
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/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 refocus_pattern.Parse(refocus_url_.spec()); | 170 refocus_pattern.Parse(refocus_url_.spec()); |
171 } | 171 } |
172 | 172 |
173 const Extension* extension = | 173 const Extension* extension = |
174 launcher_controller()->GetExtensionForAppID(app_id()); | 174 launcher_controller()->GetExtensionForAppID(app_id()); |
175 | 175 |
176 // It is possible to come here While an extension gets loaded. | 176 // It is possible to come here While an extension gets loaded. |
177 if (!extension) | 177 if (!extension) |
178 return items; | 178 return items; |
179 | 179 |
180 const BrowserList* ash_browser_list = | 180 for (auto& browser : *BrowserList::GetInstance()) { |
181 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | |
182 for (BrowserList::const_iterator it = ash_browser_list->begin(); | |
183 it != ash_browser_list->end(); ++it) { | |
184 Browser* browser = *it; | |
185 if (!launcher_controller()->IsBrowserFromActiveUser(browser)) | 181 if (!launcher_controller()->IsBrowserFromActiveUser(browser)) |
186 continue; | 182 continue; |
187 TabStripModel* tab_strip = browser->tab_strip_model(); | 183 TabStripModel* tab_strip = browser->tab_strip_model(); |
188 for (int index = 0; index < tab_strip->count(); index++) { | 184 for (int index = 0; index < tab_strip->count(); index++) { |
189 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); | 185 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); |
190 if (WebContentMatchesApp( | 186 if (WebContentMatchesApp( |
191 extension, refocus_pattern, web_contents, browser)) | 187 extension, refocus_pattern, web_contents, browser)) |
192 items.push_back(web_contents); | 188 items.push_back(web_contents); |
193 } | 189 } |
194 } | 190 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 refocus_pattern.Parse(refocus_url_.spec()); | 239 refocus_pattern.Parse(refocus_url_.spec()); |
244 } | 240 } |
245 | 241 |
246 const Extension* extension = | 242 const Extension* extension = |
247 launcher_controller()->GetExtensionForAppID(app_id()); | 243 launcher_controller()->GetExtensionForAppID(app_id()); |
248 | 244 |
249 // We may get here while the extension is loading (and NULL). | 245 // We may get here while the extension is loading (and NULL). |
250 if (!extension) | 246 if (!extension) |
251 return NULL; | 247 return NULL; |
252 | 248 |
253 const BrowserList* ash_browser_list = | 249 const BrowserList* browser_list = BrowserList::GetInstance(); |
254 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 250 for (BrowserList::const_reverse_iterator it = |
255 for (BrowserList::const_reverse_iterator | 251 browser_list->begin_last_active(); |
256 it = ash_browser_list->begin_last_active(); | 252 it != browser_list->end_last_active(); ++it) { |
257 it != ash_browser_list->end_last_active(); ++it) { | |
258 Browser* browser = *it; | 253 Browser* browser = *it; |
259 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) | 254 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) |
260 continue; | 255 continue; |
261 TabStripModel* tab_strip = browser->tab_strip_model(); | 256 TabStripModel* tab_strip = browser->tab_strip_model(); |
262 // We start to enumerate from the active index. | 257 // We start to enumerate from the active index. |
263 int active_index = tab_strip->active_index(); | 258 int active_index = tab_strip->active_index(); |
264 for (int index = 0; index < tab_strip->count(); index++) { | 259 for (int index = 0; index < tab_strip->count(); index++) { |
265 content::WebContents* web_contents = tab_strip->GetWebContentsAt( | 260 content::WebContents* web_contents = tab_strip->GetWebContentsAt( |
266 (index + active_index) % tab_strip->count()); | 261 (index + active_index) % tab_strip->count()); |
267 if (WebContentMatchesApp( | 262 if (WebContentMatchesApp( |
268 extension, refocus_pattern, web_contents, browser)) | 263 extension, refocus_pattern, web_contents, browser)) |
269 return web_contents; | 264 return web_contents; |
270 } | 265 } |
271 } | 266 } |
272 // Coming here our application was not in the LRU list. This could have | 267 // Coming here our application was not in the LRU list. This could have |
273 // happened because it did never get activated yet. So check the browser list | 268 // happened because it did never get activated yet. So check the browser list |
274 // as well. | 269 // as well. |
275 for (BrowserList::const_iterator it = ash_browser_list->begin(); | 270 for (BrowserList::const_iterator it = browser_list->begin(); |
276 it != ash_browser_list->end(); ++it) { | 271 it != browser_list->end(); ++it) { |
277 Browser* browser = *it; | 272 Browser* browser = *it; |
278 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) | 273 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) |
279 continue; | 274 continue; |
280 TabStripModel* tab_strip = browser->tab_strip_model(); | 275 TabStripModel* tab_strip = browser->tab_strip_model(); |
281 for (int index = 0; index < tab_strip->count(); index++) { | 276 for (int index = 0; index < tab_strip->count(); index++) { |
282 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); | 277 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); |
283 if (WebContentMatchesApp( | 278 if (WebContentMatchesApp( |
284 extension, refocus_pattern, web_contents, browser)) | 279 extension, refocus_pattern, web_contents, browser)) |
285 return web_contents; | 280 return web_contents; |
286 } | 281 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 369 |
375 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 370 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
376 if (last_launch_attempt_.is_null() || | 371 if (last_launch_attempt_.is_null() || |
377 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 372 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
378 kClickSuppressionInMS) < base::Time::Now()) { | 373 kClickSuppressionInMS) < base::Time::Now()) { |
379 last_launch_attempt_ = base::Time::Now(); | 374 last_launch_attempt_ = base::Time::Now(); |
380 return true; | 375 return true; |
381 } | 376 } |
382 return false; | 377 return false; |
383 } | 378 } |
OLD | NEW |