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/extensions/tab_helper.h" | 5 #include "chrome/browser/extensions/tab_helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 const content::LoadCommittedDetails& details, | 236 const content::LoadCommittedDetails& details, |
237 const content::FrameNavigateParams& params) { | 237 const content::FrameNavigateParams& params) { |
238 #if defined(ENABLE_EXTENSIONS) | 238 #if defined(ENABLE_EXTENSIONS) |
239 if (ExtensionSystem::Get(profile_)->extension_service() && | 239 if (ExtensionSystem::Get(profile_)->extension_service() && |
240 RulesRegistryService::Get(profile_)) { | 240 RulesRegistryService::Get(profile_)) { |
241 RulesRegistryService::Get(profile_)->content_rules_registry()-> | 241 RulesRegistryService::Get(profile_)->content_rules_registry()-> |
242 DidNavigateMainFrame(web_contents(), details, params); | 242 DidNavigateMainFrame(web_contents(), details, params); |
243 } | 243 } |
244 #endif // defined(ENABLE_EXTENSIONS) | 244 #endif // defined(ENABLE_EXTENSIONS) |
245 | 245 |
246 Profile* profile = | 246 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
247 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 247 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
248 ExtensionService* service = profile->GetExtensionService(); | 248 const ExtensionSet& enabled_extensions = registry->enabled_extensions(); |
249 if (!service) | |
250 return; | |
251 | 249 |
252 if (CommandLine::ForCurrentProcess()->HasSwitch( | 250 if (CommandLine::ForCurrentProcess()->HasSwitch( |
253 switches::kEnableStreamlinedHostedApps)) { | 251 switches::kEnableStreamlinedHostedApps)) { |
254 #if !defined(OS_ANDROID) | 252 #if !defined(OS_ANDROID) |
255 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 253 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
256 if (browser && browser->is_app()) { | 254 if (browser && browser->is_app()) { |
257 SetExtensionApp(service->GetInstalledExtension( | 255 SetExtensionApp(registry->GetExtensionById( |
258 web_app::GetExtensionIdFromApplicationName(browser->app_name()))); | 256 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
| 257 ExtensionRegistry::EVERYTHING)); |
259 } else { | 258 } else { |
260 UpdateExtensionAppIcon(service->GetInstalledExtensionByUrl(params.url)); | 259 UpdateExtensionAppIcon( |
| 260 enabled_extensions.GetExtensionOrAppByURL(params.url)); |
261 } | 261 } |
262 #endif | 262 #endif |
263 } else { | 263 } else { |
264 UpdateExtensionAppIcon(service->GetInstalledExtensionByUrl(params.url)); | 264 UpdateExtensionAppIcon( |
| 265 enabled_extensions.GetExtensionOrAppByURL(params.url)); |
265 } | 266 } |
266 | 267 |
267 if (details.is_in_page) | 268 if (details.is_in_page) |
268 return; | 269 return; |
269 | 270 |
270 ExtensionActionManager* extension_action_manager = | 271 ExtensionActionManager* extension_action_manager = |
271 ExtensionActionManager::Get(profile); | 272 ExtensionActionManager::Get(Profile::FromBrowserContext(context)); |
272 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 273 for (ExtensionSet::const_iterator it = enabled_extensions.begin(); |
273 it != service->extensions()->end(); ++it) { | 274 it != enabled_extensions.end(); |
| 275 ++it) { |
274 ExtensionAction* browser_action = | 276 ExtensionAction* browser_action = |
275 extension_action_manager->GetBrowserAction(*it->get()); | 277 extension_action_manager->GetBrowserAction(*it->get()); |
276 if (browser_action) { | 278 if (browser_action) { |
277 browser_action->ClearAllValuesForTab(SessionID::IdForTab(web_contents())); | 279 browser_action->ClearAllValuesForTab(SessionID::IdForTab(web_contents())); |
278 content::NotificationService::current()->Notify( | 280 content::NotificationService::current()->Notify( |
279 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 281 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
280 content::Source<ExtensionAction>(browser_action), | 282 content::Source<ExtensionAction>(browser_action), |
281 content::NotificationService::NoDetails()); | 283 content::NotificationService::NoDetails()); |
282 } | 284 } |
283 } | 285 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 567 } |
566 } | 568 } |
567 | 569 |
568 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 570 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
569 render_view_host->Send( | 571 render_view_host->Send( |
570 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 572 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
571 SessionID::IdForTab(web_contents()))); | 573 SessionID::IdForTab(web_contents()))); |
572 } | 574 } |
573 | 575 |
574 } // namespace extensions | 576 } // namespace extensions |
OLD | NEW |