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" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 refocus_pattern.SetMatchAllURLs(true); | 138 refocus_pattern.SetMatchAllURLs(true); |
139 | 139 |
140 if (!refocus_url_.is_empty()) { | 140 if (!refocus_url_.is_empty()) { |
141 refocus_pattern.SetMatchAllURLs(false); | 141 refocus_pattern.SetMatchAllURLs(false); |
142 refocus_pattern.Parse(refocus_url_.spec()); | 142 refocus_pattern.Parse(refocus_url_.spec()); |
143 } | 143 } |
144 | 144 |
145 const Extension* extension = | 145 const Extension* extension = |
146 launcher_controller()->GetExtensionForAppID(app_id()); | 146 launcher_controller()->GetExtensionForAppID(app_id()); |
147 | 147 |
| 148 // It is possible to come here While an extension gets loaded. |
| 149 if (!extension) |
| 150 return items; |
| 151 |
148 const chrome::BrowserListImpl* ash_browser_list = | 152 const chrome::BrowserListImpl* ash_browser_list = |
149 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 153 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
150 for (chrome::BrowserListImpl::const_reverse_iterator it = | 154 for (chrome::BrowserListImpl::const_reverse_iterator it = |
151 ash_browser_list->begin_last_active(); | 155 ash_browser_list->begin_last_active(); |
152 it != ash_browser_list->end_last_active(); ++it) { | 156 it != ash_browser_list->end_last_active(); ++it) { |
153 Browser* browser = *it; | 157 Browser* browser = *it; |
154 TabStripModel* tab_strip = browser->tab_strip_model(); | 158 TabStripModel* tab_strip = browser->tab_strip_model(); |
155 // We start to enumerate from the active index. | 159 // We start to enumerate from the active index. |
156 int active_index = tab_strip->active_index(); | 160 int active_index = tab_strip->active_index(); |
157 for (int index = 0; index < tab_strip->count(); index++) { | 161 for (int index = 0; index < tab_strip->count(); index++) { |
158 content::WebContents* web_contents = tab_strip->GetWebContentsAt( | 162 content::WebContents* web_contents = tab_strip->GetWebContentsAt( |
159 (index + active_index) % tab_strip->count()); | 163 (index + active_index) % tab_strip->count()); |
160 const GURL tab_url = web_contents->GetURL(); | 164 const GURL tab_url = web_contents->GetURL(); |
161 // There are three ways to identify the association of a URL with this | 165 // There are three ways to identify the association of a URL with this |
162 // extension: | 166 // extension: |
163 // - The refocus pattern is matched (needed for apps like drive). | 167 // - The refocus pattern is matched (needed for apps like drive). |
164 // - The extension's origin + extent gets matched. | 168 // - The extension's origin + extent gets matched. |
165 // - The launcher controller knows that the tab got created for this app. | 169 // - The launcher controller knows that the tab got created for this app. |
166 if ((!refocus_pattern.match_all_urls() && | 170 if ((!refocus_pattern.match_all_urls() && |
167 refocus_pattern.MatchesURL(tab_url)) || | 171 refocus_pattern.MatchesURL(tab_url)) || |
168 (extension->OverlapsWithOrigin(tab_url) && | 172 (extension->OverlapsWithOrigin(tab_url) && |
169 extension->web_extent().MatchesURL(tab_url)) || | 173 extension->web_extent().MatchesURL(tab_url)) || |
170 launcher_controller()->GetPerAppInterface()-> | 174 launcher_controller()->GetPerAppInterface()-> |
171 IsWebContentHandledByApplication(web_contents, app_id())) | 175 IsWebContentHandledByApplication(web_contents, app_id())) |
172 items.push_back(web_contents); | 176 items.push_back(web_contents); |
173 } | 177 } |
174 } | 178 } |
175 return items; | 179 return items; |
176 } | 180 } |
OLD | NEW |