Chromium Code Reviews| 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/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 Loading... | |
| 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. |
|
James Cook
2017/04/04 15:34:45
Aside: I wonder if this "experiment" is still arou
msw
2017/04/04 18:53:09
No idea, I can followup as needed.
| |
| 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 AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create( |
| 65 const ash::AppLaunchId& app_launch_id, | 64 const ash::AppLaunchId& app_launch_id) { |
| 66 ChromeLauncherController* controller) { | |
| 67 if (app_launch_id.app_id() == ArcSupportHost::kHostAppId || | 65 if (app_launch_id.app_id() == ArcSupportHost::kHostAppId || |
| 68 app_launch_id.app_id() == arc::kPlayStoreAppId) { | 66 app_launch_id.app_id() == arc::kPlayStoreAppId) { |
| 69 return new ArcPlaystoreShortcutLauncherItemController(controller); | 67 return new ArcPlaystoreShortcutLauncherItemController(); |
| 70 } | 68 } |
| 71 return new AppShortcutLauncherItemController(app_launch_id, controller); | 69 return new AppShortcutLauncherItemController(app_launch_id); |
| 72 } | 70 } |
| 73 | 71 |
| 74 // Item controller for an app shortcut. Shortcuts track app and launcher ids, | 72 // 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 | 73 // but do not have any associated windows (opening a shortcut will replace the |
| 76 // item with the appropriate LauncherItemController type). | 74 // item with the appropriate ash::ShelfItemDelegate type). |
| 77 AppShortcutLauncherItemController::AppShortcutLauncherItemController( | 75 AppShortcutLauncherItemController::AppShortcutLauncherItemController( |
| 78 const ash::AppLaunchId& app_launch_id, | 76 const ash::AppLaunchId& app_launch_id) |
| 79 ChromeLauncherController* controller) | 77 : 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 | 78 // 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. | 79 // used URL. This will also work with applications like Google Drive. |
| 84 const Extension* extension = | 80 const Extension* extension = GetExtensionForAppID( |
| 85 GetExtensionForAppID(app_launch_id.app_id(), controller->profile()); | 81 app_launch_id.app_id(), ChromeLauncherController::instance()->profile()); |
| 86 // Some unit tests have no real extension. | 82 // Some unit tests have no real extension. |
| 87 if (extension) { | 83 if (extension) { |
| 88 set_refocus_url(GURL( | 84 set_refocus_url(GURL( |
| 89 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); | 85 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); |
| 90 } | 86 } |
| 91 } | 87 } |
| 92 | 88 |
| 93 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {} | 89 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {} |
| 94 | 90 |
| 95 void AppShortcutLauncherItemController::ItemSelected( | 91 void AppShortcutLauncherItemController::ItemSelected( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 112 // they open a window. Since there is currently no other way to detect if an | 108 // 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. | 109 // app was started we suppress any further clicks within a special time out. |
| 114 if (IsV2App() && !AllowNextLaunchAttempt()) { | 110 if (IsV2App() && !AllowNextLaunchAttempt()) { |
| 115 callback.Run(ash::SHELF_ACTION_NONE, | 111 callback.Run(ash::SHELF_ACTION_NONE, |
| 116 GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); | 112 GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); |
| 117 return; | 113 return; |
| 118 } | 114 } |
| 119 | 115 |
| 120 // Launching some items replaces this item controller instance, which | 116 // Launching some items replaces this item controller instance, which |
| 121 // destroys its AppLaunchId string pair; making copies avoid crashes. | 117 // destroys its AppLaunchId string pair; making copies avoid crashes. |
| 122 launcher_controller()->LaunchApp(ash::AppLaunchId(app_launch_id()), source, | 118 ChromeLauncherController::instance()->LaunchApp( |
| 123 ui::EF_NONE); | 119 ash::AppLaunchId(app_launch_id()), source, ui::EF_NONE); |
| 124 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); | 120 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); |
| 125 return; | 121 return; |
| 126 } | 122 } |
| 127 | 123 |
| 128 const ash::ShelfAction action = ActivateContent(content); | 124 const ash::ShelfAction action = ActivateContent(content); |
| 129 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); | 125 callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); |
| 130 } | 126 } |
| 131 | 127 |
| 132 MenuItemList AppShortcutLauncherItemController::GetAppMenuItems( | 128 ash::MenuItemList AppShortcutLauncherItemController::GetAppMenuItems( |
| 133 int event_flags) { | 129 int event_flags) { |
| 134 MenuItemList items; | 130 ash::MenuItemList items; |
| 135 app_menu_items_ = GetRunningApplications(); | 131 app_menu_items_ = GetRunningApplications(); |
| 132 ChromeLauncherController* controller = ChromeLauncherController::instance(); | |
| 136 for (size_t i = 0; i < app_menu_items_.size(); i++) { | 133 for (size_t i = 0; i < app_menu_items_.size(); i++) { |
| 137 content::WebContents* tab = app_menu_items_[i]; | 134 content::WebContents* tab = app_menu_items_[i]; |
| 138 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); | 135 ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); |
| 139 item->command_id = base::checked_cast<uint32_t>(i); | 136 item->command_id = base::checked_cast<uint32_t>(i); |
| 140 item->label = launcher_controller()->GetAppListTitle(tab); | 137 item->label = controller->GetAppListTitle(tab); |
| 141 item->image = *launcher_controller()->GetAppListIcon(tab).ToSkBitmap(); | 138 item->image = *controller->GetAppListIcon(tab).ToSkBitmap(); |
| 142 items.push_back(std::move(item)); | 139 items.push_back(std::move(item)); |
| 143 } | 140 } |
| 144 return items; | 141 return items; |
| 145 } | 142 } |
| 146 | 143 |
| 147 void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id, | 144 void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id, |
| 148 int32_t event_flags) { | 145 int32_t event_flags) { |
| 149 if (static_cast<size_t>(command_id) >= app_menu_items_.size()) { | 146 if (static_cast<size_t>(command_id) >= app_menu_items_.size()) { |
| 150 app_menu_items_.clear(); | 147 app_menu_items_.clear(); |
| 151 return; | 148 return; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 169 browser->window()->Activate(); | 166 browser->window()->Activate(); |
| 170 } | 167 } |
| 171 } | 168 } |
| 172 | 169 |
| 173 app_menu_items_.clear(); | 170 app_menu_items_.clear(); |
| 174 } | 171 } |
| 175 | 172 |
| 176 void AppShortcutLauncherItemController::Close() { | 173 void AppShortcutLauncherItemController::Close() { |
| 177 // Close all running 'programs' of this type. | 174 // Close all running 'programs' of this type. |
| 178 std::vector<content::WebContents*> content = | 175 std::vector<content::WebContents*> content = |
| 179 launcher_controller()->GetV1ApplicationsFromAppId(app_id()); | 176 ChromeLauncherController::instance()->GetV1ApplicationsFromAppId( |
| 177 app_id()); | |
| 180 for (size_t i = 0; i < content.size(); i++) { | 178 for (size_t i = 0; i < content.size(); i++) { |
| 181 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); | 179 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); |
| 182 if (!browser || !IsBrowserFromActiveUser(browser)) | 180 if (!browser || !IsBrowserFromActiveUser(browser)) |
| 183 continue; | 181 continue; |
| 184 TabStripModel* tab_strip = browser->tab_strip_model(); | 182 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 185 int index = tab_strip->GetIndexOfWebContents(content[i]); | 183 int index = tab_strip->GetIndexOfWebContents(content[i]); |
| 186 DCHECK(index != TabStripModel::kNoTab); | 184 DCHECK(index != TabStripModel::kNoTab); |
| 187 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE); | 185 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE); |
| 188 } | 186 } |
| 189 } | 187 } |
| 190 | 188 |
| 191 std::vector<content::WebContents*> | 189 std::vector<content::WebContents*> |
| 192 AppShortcutLauncherItemController::GetRunningApplications() { | 190 AppShortcutLauncherItemController::GetRunningApplications() { |
| 193 std::vector<content::WebContents*> items; | 191 std::vector<content::WebContents*> items; |
| 194 | 192 |
| 195 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); | 193 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); |
| 196 refocus_pattern.SetMatchAllURLs(true); | 194 refocus_pattern.SetMatchAllURLs(true); |
| 197 | 195 |
| 198 if (!refocus_url_.is_empty()) { | 196 if (!refocus_url_.is_empty()) { |
| 199 refocus_pattern.SetMatchAllURLs(false); | 197 refocus_pattern.SetMatchAllURLs(false); |
| 200 refocus_pattern.Parse(refocus_url_.spec()); | 198 refocus_pattern.Parse(refocus_url_.spec()); |
| 201 } | 199 } |
| 202 | 200 |
| 203 const Extension* extension = | 201 const Extension* extension = GetExtensionForAppID( |
| 204 GetExtensionForAppID(app_id(), launcher_controller()->profile()); | 202 app_id(), ChromeLauncherController::instance()->profile()); |
| 205 | 203 |
| 206 // It is possible to come here While an extension gets loaded. | 204 // It is possible to come here While an extension gets loaded. |
| 207 if (!extension) | 205 if (!extension) |
| 208 return items; | 206 return items; |
| 209 | 207 |
| 210 for (auto* browser : *BrowserList::GetInstance()) { | 208 for (auto* browser : *BrowserList::GetInstance()) { |
| 211 if (!IsBrowserFromActiveUser(browser)) | 209 if (!IsBrowserFromActiveUser(browser)) |
| 212 continue; | 210 continue; |
| 213 TabStripModel* tab_strip = browser->tab_strip_model(); | 211 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 214 for (int index = 0; index < tab_strip->count(); index++) { | 212 for (int index = 0; index < tab_strip->count(); index++) { |
| 215 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); | 213 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); |
| 216 if (WebContentMatchesApp( | 214 if (WebContentMatchesApp( |
| 217 extension, refocus_pattern, web_contents, browser)) | 215 extension, refocus_pattern, web_contents, browser)) |
| 218 items.push_back(web_contents); | 216 items.push_back(web_contents); |
| 219 } | 217 } |
| 220 } | 218 } |
| 221 return items; | 219 return items; |
| 222 } | 220 } |
| 223 | 221 |
| 224 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { | 222 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { |
| 225 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); | 223 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); |
| 226 refocus_pattern.SetMatchAllURLs(true); | 224 refocus_pattern.SetMatchAllURLs(true); |
| 227 | 225 |
| 228 if (!refocus_url_.is_empty()) { | 226 if (!refocus_url_.is_empty()) { |
| 229 refocus_pattern.SetMatchAllURLs(false); | 227 refocus_pattern.SetMatchAllURLs(false); |
| 230 refocus_pattern.Parse(refocus_url_.spec()); | 228 refocus_pattern.Parse(refocus_url_.spec()); |
| 231 } | 229 } |
| 232 | 230 |
| 231 ChromeLauncherController* controller = ChromeLauncherController::instance(); | |
| 233 const Extension* extension = | 232 const Extension* extension = |
| 234 GetExtensionForAppID(app_id(), launcher_controller()->profile()); | 233 GetExtensionForAppID(app_id(), controller->profile()); |
| 235 | 234 |
| 236 // We may get here while the extension is loading (and NULL). | 235 // We may get here while the extension is loading (and NULL). |
| 237 if (!extension) | 236 if (!extension) |
| 238 return NULL; | 237 return NULL; |
| 239 | 238 |
| 240 const BrowserList* browser_list = BrowserList::GetInstance(); | 239 const BrowserList* browser_list = BrowserList::GetInstance(); |
| 241 for (BrowserList::const_reverse_iterator it = | 240 for (BrowserList::const_reverse_iterator it = |
| 242 browser_list->begin_last_active(); | 241 browser_list->begin_last_active(); |
| 243 it != browser_list->end_last_active(); ++it) { | 242 it != browser_list->end_last_active(); ++it) { |
| 244 Browser* browser = *it; | 243 Browser* browser = *it; |
| 245 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) | 244 if (!CanBrowserBeUsedForDirectActivation(browser, controller)) |
| 246 continue; | 245 continue; |
| 247 TabStripModel* tab_strip = browser->tab_strip_model(); | 246 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 248 // We start to enumerate from the active index. | 247 // We start to enumerate from the active index. |
| 249 int active_index = tab_strip->active_index(); | 248 int active_index = tab_strip->active_index(); |
| 250 for (int index = 0; index < tab_strip->count(); index++) { | 249 for (int index = 0; index < tab_strip->count(); index++) { |
| 251 content::WebContents* web_contents = tab_strip->GetWebContentsAt( | 250 content::WebContents* web_contents = tab_strip->GetWebContentsAt( |
| 252 (index + active_index) % tab_strip->count()); | 251 (index + active_index) % tab_strip->count()); |
| 253 if (WebContentMatchesApp( | 252 if (WebContentMatchesApp( |
| 254 extension, refocus_pattern, web_contents, browser)) | 253 extension, refocus_pattern, web_contents, browser)) |
| 255 return web_contents; | 254 return web_contents; |
| 256 } | 255 } |
| 257 } | 256 } |
| 258 // Coming here our application was not in the LRU list. This could have | 257 // 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 | 258 // happened because it did never get activated yet. So check the browser list |
| 260 // as well. | 259 // as well. |
| 261 for (BrowserList::const_iterator it = browser_list->begin(); | 260 for (BrowserList::const_iterator it = browser_list->begin(); |
| 262 it != browser_list->end(); ++it) { | 261 it != browser_list->end(); ++it) { |
| 263 Browser* browser = *it; | 262 Browser* browser = *it; |
| 264 if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller())) | 263 if (!CanBrowserBeUsedForDirectActivation( |
| 264 browser, ChromeLauncherController::instance())) | |
| 265 continue; | 265 continue; |
| 266 TabStripModel* tab_strip = browser->tab_strip_model(); | 266 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 267 for (int index = 0; index < tab_strip->count(); index++) { | 267 for (int index = 0; index < tab_strip->count(); index++) { |
| 268 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); | 268 content::WebContents* web_contents = tab_strip->GetWebContentsAt(index); |
| 269 if (WebContentMatchesApp( | 269 if (WebContentMatchesApp( |
| 270 extension, refocus_pattern, web_contents, browser)) | 270 extension, refocus_pattern, web_contents, browser)) |
| 271 return web_contents; | 271 return web_contents; |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 return NULL; | 274 return NULL; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 293 // tabs. | 293 // tabs. |
| 294 if (extensions::LaunchesInWindow(browser->profile(), extension)) | 294 if (extensions::LaunchesInWindow(browser->profile(), extension)) |
| 295 return false; | 295 return false; |
| 296 | 296 |
| 297 // There are three ways to identify the association of a URL with this | 297 // There are three ways to identify the association of a URL with this |
| 298 // extension: | 298 // extension: |
| 299 // - The refocus pattern is matched (needed for apps like drive). | 299 // - The refocus pattern is matched (needed for apps like drive). |
| 300 // - The extension's origin + extent gets matched. | 300 // - The extension's origin + extent gets matched. |
| 301 // - The launcher controller knows that the tab got created for this app. | 301 // - The launcher controller knows that the tab got created for this app. |
| 302 const GURL tab_url = web_contents->GetURL(); | 302 const GURL tab_url = web_contents->GetURL(); |
| 303 return ((!refocus_pattern.match_all_urls() && | 303 return ( |
| 304 refocus_pattern.MatchesURL(tab_url)) || | 304 (!refocus_pattern.match_all_urls() && |
| 305 (extension->OverlapsWithOrigin(tab_url) && | 305 refocus_pattern.MatchesURL(tab_url)) || |
| 306 extension->web_extent().MatchesURL(tab_url)) || | 306 (extension->OverlapsWithOrigin(tab_url) && |
| 307 launcher_controller()->IsWebContentHandledByApplication(web_contents, | 307 extension->web_extent().MatchesURL(tab_url)) || |
| 308 app_id())); | 308 ChromeLauncherController::instance()->IsWebContentHandledByApplication( |
| 309 web_contents, app_id())); | |
| 309 } | 310 } |
| 310 | 311 |
| 311 ash::ShelfAction AppShortcutLauncherItemController::ActivateContent( | 312 ash::ShelfAction AppShortcutLauncherItemController::ActivateContent( |
| 312 content::WebContents* content) { | 313 content::WebContents* content) { |
| 313 Browser* browser = chrome::FindBrowserWithWebContents(content); | 314 Browser* browser = chrome::FindBrowserWithWebContents(content); |
| 314 TabStripModel* tab_strip = browser->tab_strip_model(); | 315 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 315 int index = tab_strip->GetIndexOfWebContents(content); | 316 int index = tab_strip->GetIndexOfWebContents(content); |
| 316 DCHECK_NE(TabStripModel::kNoTab, index); | 317 DCHECK_NE(TabStripModel::kNoTab, index); |
| 317 | 318 |
| 318 int old_index = tab_strip->active_index(); | 319 int old_index = tab_strip->active_index(); |
| 319 if (index != old_index) | 320 if (index != old_index) |
| 320 tab_strip->ActivateTabAt(index, false); | 321 tab_strip->ActivateTabAt(index, false); |
| 321 return launcher_controller()->ActivateWindowOrMinimizeIfActive( | 322 return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive( |
| 322 browser->window(), | 323 browser->window(), |
| 323 index == old_index && GetRunningApplications().size() == 1); | 324 index == old_index && GetRunningApplications().size() == 1); |
| 324 } | 325 } |
| 325 | 326 |
| 326 bool AppShortcutLauncherItemController::AdvanceToNextApp() { | 327 bool AppShortcutLauncherItemController::AdvanceToNextApp() { |
| 327 std::vector<content::WebContents*> items = GetRunningApplications(); | 328 std::vector<content::WebContents*> items = GetRunningApplications(); |
| 328 if (items.size() >= 1) { | 329 if (items.size() >= 1) { |
| 329 Browser* browser = chrome::FindBrowserWithWindow( | 330 Browser* browser = chrome::FindBrowserWithWindow( |
| 330 ash::wm::GetActiveWindow()); | 331 ash::wm::GetActiveWindow()); |
| 331 if (browser) { | 332 if (browser) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 345 ActivateContent(items[index]); | 346 ActivateContent(items[index]); |
| 346 } | 347 } |
| 347 return true; | 348 return true; |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 } | 351 } |
| 351 return false; | 352 return false; |
| 352 } | 353 } |
| 353 | 354 |
| 354 bool AppShortcutLauncherItemController::IsV2App() { | 355 bool AppShortcutLauncherItemController::IsV2App() { |
| 355 const Extension* extension = | 356 const Extension* extension = GetExtensionForAppID( |
| 356 GetExtensionForAppID(app_id(), launcher_controller()->profile()); | 357 app_id(), ChromeLauncherController::instance()->profile()); |
| 357 return extension && extension->is_platform_app(); | 358 return extension && extension->is_platform_app(); |
| 358 } | 359 } |
| 359 | 360 |
| 360 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 361 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
| 361 if (last_launch_attempt_.is_null() || | 362 if (last_launch_attempt_.is_null() || |
| 362 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 363 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
| 363 kClickSuppressionInMS) < base::Time::Now()) { | 364 kClickSuppressionInMS) < base::Time::Now()) { |
| 364 last_launch_attempt_ = base::Time::Now(); | 365 last_launch_attempt_ = base::Time::Now(); |
| 365 return true; | 366 return true; |
| 366 } | 367 } |
| 367 return false; | 368 return false; |
| 368 } | 369 } |
| OLD | NEW |