| 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 "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "chrome/browser/favicon/favicon_tab_helper.h" | 8 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
| 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list_impl.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/extensions/native_app_window.h" | 18 #include "chrome/browser/ui/extensions/native_app_window.h" |
| 19 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 | 22 |
| 22 using extensions::Extension; | 23 using extensions::Extension; |
| 23 | 24 |
| 24 // Item controller for an app shortcut. Shortcuts track app and launcher ids, | 25 // Item controller for an app shortcut. Shortcuts track app and launcher ids, |
| 25 // but do not have any associated windows (opening a shortcut will replace the | 26 // but do not have any associated windows (opening a shortcut will replace the |
| 26 // item with the appropriate LauncherItemController type). | 27 // item with the appropriate LauncherItemController type). |
| 27 AppShortcutLauncherItemController::AppShortcutLauncherItemController( | 28 AppShortcutLauncherItemController::AppShortcutLauncherItemController( |
| 28 const std::string& app_id, | 29 const std::string& app_id, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 refocus_pattern.SetMatchAllURLs(true); | 138 refocus_pattern.SetMatchAllURLs(true); |
| 138 | 139 |
| 139 if (!refocus_url_.is_empty()) { | 140 if (!refocus_url_.is_empty()) { |
| 140 refocus_pattern.SetMatchAllURLs(false); | 141 refocus_pattern.SetMatchAllURLs(false); |
| 141 refocus_pattern.Parse(refocus_url_.spec()); | 142 refocus_pattern.Parse(refocus_url_.spec()); |
| 142 } | 143 } |
| 143 | 144 |
| 144 const Extension* extension = | 145 const Extension* extension = |
| 145 launcher_controller()->GetExtensionForAppID(app_id()); | 146 launcher_controller()->GetExtensionForAppID(app_id()); |
| 146 | 147 |
| 147 for (BrowserList::const_reverse_iterator it = | 148 const chrome::BrowserListImpl* ash_browser_list = |
| 148 BrowserList::begin_last_active(); | 149 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 149 it != BrowserList::end_last_active(); ++it) { | 150 for (chrome::BrowserListImpl::const_reverse_iterator it = |
| 151 ash_browser_list->begin_last_active(); |
| 152 it != ash_browser_list->end_last_active(); ++it) { |
| 150 Browser* browser = *it; | 153 Browser* browser = *it; |
| 151 TabStripModel* tab_strip = browser->tab_strip_model(); | 154 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 152 // We start to enumerate from the active index. | 155 // We start to enumerate from the active index. |
| 153 int active_index = tab_strip->active_index(); | 156 int active_index = tab_strip->active_index(); |
| 154 for (int index = 0; index < tab_strip->count(); index++) { | 157 for (int index = 0; index < tab_strip->count(); index++) { |
| 155 content::WebContents* web_contents = tab_strip->GetWebContentsAt( | 158 content::WebContents* web_contents = tab_strip->GetWebContentsAt( |
| 156 (index + active_index) % tab_strip->count()); | 159 (index + active_index) % tab_strip->count()); |
| 157 const GURL tab_url = web_contents->GetURL(); | 160 const GURL tab_url = web_contents->GetURL(); |
| 158 // There are three ways to identify the association of a URL with this | 161 // There are three ways to identify the association of a URL with this |
| 159 // extension: | 162 // extension: |
| 160 // - The refocus pattern is matched (needed for apps like drive). | 163 // - The refocus pattern is matched (needed for apps like drive). |
| 161 // - The extension's origin + extent gets matched. | 164 // - The extension's origin + extent gets matched. |
| 162 // - The launcher controller knows that the tab got created for this app. | 165 // - The launcher controller knows that the tab got created for this app. |
| 163 if ((!refocus_pattern.match_all_urls() && | 166 if ((!refocus_pattern.match_all_urls() && |
| 164 refocus_pattern.MatchesURL(tab_url)) || | 167 refocus_pattern.MatchesURL(tab_url)) || |
| 165 (extension->OverlapsWithOrigin(tab_url) && | 168 (extension->OverlapsWithOrigin(tab_url) && |
| 166 extension->web_extent().MatchesURL(tab_url)) || | 169 extension->web_extent().MatchesURL(tab_url)) || |
| 167 launcher_controller()->GetPerAppInterface()-> | 170 launcher_controller()->GetPerAppInterface()-> |
| 168 IsWebContentHandledByApplication(web_contents, app_id())) | 171 IsWebContentHandledByApplication(web_contents, app_id())) |
| 169 items.push_back(web_contents); | 172 items.push_back(web_contents); |
| 170 } | 173 } |
| 171 } | 174 } |
| 172 return items; | 175 return items; |
| 173 } | 176 } |
| OLD | NEW |