Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | |
| 5 #include "chrome/browser/extensions/extension_process_manager.h" | 6 #include "chrome/browser/extensions/extension_process_manager.h" |
| 6 | 7 |
| 7 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 8 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
| 9 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| 10 #include "chrome/browser/extensions/extension_host_mac.h" | 11 #include "chrome/browser/extensions/extension_host_mac.h" |
| 11 #endif | 12 #endif |
| 12 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_switches.h" | |
| 17 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 19 #include "content/browser/site_instance.h" | 21 #include "content/browser/site_instance.h" |
| 20 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 21 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 // Incognito profiles use this process manager. It is mostly a shim that decides | 27 // Incognito profiles use this process manager. It is mostly a shim that decides |
| 26 // whether to fall back on the original profile's ExtensionProcessManager based | 28 // whether to fall back on the original profile's ExtensionProcessManager based |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 48 // Returns the extension for an URL, which can either be a chrome-extension | 50 // Returns the extension for an URL, which can either be a chrome-extension |
| 49 // URL or a web app URL. | 51 // URL or a web app URL. |
| 50 const Extension* GetExtensionOrAppByURL(const GURL& url); | 52 const Extension* GetExtensionOrAppByURL(const GURL& url); |
| 51 | 53 |
| 52 // Returns true if the extension is allowed to run in incognito mode. | 54 // Returns true if the extension is allowed to run in incognito mode. |
| 53 bool IsIncognitoEnabled(const Extension* extension); | 55 bool IsIncognitoEnabled(const Extension* extension); |
| 54 | 56 |
| 55 ExtensionProcessManager* original_manager_; | 57 ExtensionProcessManager* original_manager_; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 static void CreateBackgroundHost( | 60 static void MaybeCreateBackgroundHost( |
| 59 ExtensionProcessManager* manager, const Extension* extension) { | 61 ExtensionProcessManager* manager, const Extension* extension) { |
| 60 // Start the process for the master page, if it exists. | 62 // Start the process for the master page, if it exists and we're not lazy. |
| 61 if (extension->background_url().is_valid()) | 63 if (extension->background_url().is_valid() && |
| 64 !CommandLine::ForCurrentProcess()->HasSwitch( | |
|
Aaron Boodman
2011/08/17 04:24:15
If you put this check in CreateBackgroundHosts() t
Tessa MacDuff
2011/08/17 17:51:24
But then I'd only be handling the background pages
Aaron Boodman
2011/08/17 18:13:35
Oh, good point. Nevermind.
| |
| 65 switches::kEnableLazyBackgroundPages)) | |
| 62 manager->CreateBackgroundHost(extension, extension->background_url()); | 66 manager->CreateBackgroundHost(extension, extension->background_url()); |
| 63 } | 67 } |
| 64 | 68 |
| 65 static void CreateBackgroundHosts( | 69 static void CreateBackgroundHosts( |
| 66 ExtensionProcessManager* manager, const ExtensionList* extensions) { | 70 ExtensionProcessManager* manager, const ExtensionList* extensions) { |
| 67 for (ExtensionList::const_iterator extension = extensions->begin(); | 71 for (ExtensionList::const_iterator extension = extensions->begin(); |
| 68 extension != extensions->end(); ++extension) { | 72 extension != extensions->end(); ++extension) { |
| 69 CreateBackgroundHost(manager, *extension); | 73 MaybeCreateBackgroundHost(manager, *extension); |
| 70 } | 74 } |
| 71 } | 75 } |
| 72 | 76 |
| 73 } // namespace | 77 } // namespace |
| 74 | 78 |
| 75 extern bool g_log_bug53991; | 79 extern bool g_log_bug53991; |
| 76 | 80 |
| 77 // | 81 // |
| 78 // ExtensionProcessManager | 82 // ExtensionProcessManager |
| 79 // | 83 // |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 CreateBackgroundHosts(this, | 295 CreateBackgroundHosts(this, |
| 292 Source<Profile>(source).ptr()->GetExtensionService()->extensions()); | 296 Source<Profile>(source).ptr()->GetExtensionService()->extensions()); |
| 293 break; | 297 break; |
| 294 } | 298 } |
| 295 | 299 |
| 296 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 300 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| 297 ExtensionService* service = | 301 ExtensionService* service = |
| 298 Source<Profile>(source).ptr()->GetExtensionService(); | 302 Source<Profile>(source).ptr()->GetExtensionService(); |
| 299 if (service->is_ready()) { | 303 if (service->is_ready()) { |
| 300 const Extension* extension = Details<const Extension>(details).ptr(); | 304 const Extension* extension = Details<const Extension>(details).ptr(); |
| 301 ::CreateBackgroundHost(this, extension); | 305 ::MaybeCreateBackgroundHost(this, extension); |
| 302 } | 306 } |
| 303 break; | 307 break; |
| 304 } | 308 } |
| 305 | 309 |
| 306 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 310 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
| 307 const Extension* extension = | 311 const Extension* extension = |
| 308 Details<UnloadedExtensionInfo>(details)->extension; | 312 Details<UnloadedExtensionInfo>(details)->extension; |
| 309 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 313 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
| 310 iter != background_hosts_.end(); ++iter) { | 314 iter != background_hosts_.end(); ++iter) { |
| 311 ExtensionHost* host = *iter; | 315 ExtensionHost* host = *iter; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 if (service && service->is_ready()) | 488 if (service && service->is_ready()) |
| 485 CreateBackgroundHosts(this, service->extensions()); | 489 CreateBackgroundHosts(this, service->extensions()); |
| 486 } | 490 } |
| 487 break; | 491 break; |
| 488 } | 492 } |
| 489 default: | 493 default: |
| 490 ExtensionProcessManager::Observe(type, source, details); | 494 ExtensionProcessManager::Observe(type, source, details); |
| 491 break; | 495 break; |
| 492 } | 496 } |
| 493 } | 497 } |
| OLD | NEW |