Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: extensions/browser/process_manager.cc

Issue 147923005: Split ExtensionSystem interface from ExtensionSystemImpl implementation, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/process_manager.h" 5 #include "extensions/browser/process_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/api/runtime/runtime_api.h" 17 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
18 #include "chrome/browser/extensions/extension_host.h" 18 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/extensions/extension_util.h" 20 #include "chrome/browser/extensions/extension_util.h"
22 #include "chrome/common/extensions/extension_messages.h" 21 #include "chrome/common/extensions/extension_messages.h"
23 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/devtools_agent_host.h" 24 #include "content/public/browser/devtools_agent_host.h"
26 #include "content/public/browser/devtools_manager.h" 25 #include "content/public/browser/devtools_manager.h"
27 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/site_instance.h" 30 #include "content/public/browser/site_instance.h"
32 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_contents_delegate.h" 32 #include "content/public/browser/web_contents_delegate.h"
34 #include "content/public/browser/web_contents_observer.h" 33 #include "content/public/browser/web_contents_observer.h"
35 #include "content/public/browser/web_contents_user_data.h" 34 #include "content/public/browser/web_contents_user_data.h"
36 #include "content/public/common/renderer_preferences.h" 35 #include "content/public/common/renderer_preferences.h"
37 #include "extensions/browser/extension_registry.h" 36 #include "extensions/browser/extension_registry.h"
37 #include "extensions/browser/extension_system.h"
38 #include "extensions/browser/extensions_browser_client.h" 38 #include "extensions/browser/extensions_browser_client.h"
39 #include "extensions/browser/view_type_utils.h" 39 #include "extensions/browser/view_type_utils.h"
40 #include "extensions/common/extension.h" 40 #include "extensions/common/extension.h"
41 #include "extensions/common/manifest_handlers/background_info.h" 41 #include "extensions/common/manifest_handlers/background_info.h"
42 #include "extensions/common/manifest_handlers/incognito_info.h" 42 #include "extensions/common/manifest_handlers/incognito_info.h"
43 #include "extensions/common/switches.h" 43 #include "extensions/common/switches.h"
44 44
45 using content::BrowserContext; 45 using content::BrowserContext;
46 using content::RenderViewHost; 46 using content::RenderViewHost;
47 using content::SiteInstance; 47 using content::SiteInstance;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 : public content::WebContentsObserver, 122 : public content::WebContentsObserver,
123 public content::WebContentsUserData<RenderViewHostDestructionObserver> { 123 public content::WebContentsUserData<RenderViewHostDestructionObserver> {
124 public: 124 public:
125 virtual ~RenderViewHostDestructionObserver() {} 125 virtual ~RenderViewHostDestructionObserver() {}
126 126
127 private: 127 private:
128 explicit RenderViewHostDestructionObserver(WebContents* web_contents) 128 explicit RenderViewHostDestructionObserver(WebContents* web_contents)
129 : WebContentsObserver(web_contents) { 129 : WebContentsObserver(web_contents) {
130 BrowserContext* context = web_contents->GetBrowserContext(); 130 BrowserContext* context = web_contents->GetBrowserContext();
131 process_manager_ = 131 process_manager_ =
132 ExtensionSystem::GetForBrowserContext(context)->process_manager(); 132 ExtensionSystem::Get(context)->process_manager();
133 } 133 }
134 134
135 friend class content::WebContentsUserData<RenderViewHostDestructionObserver>; 135 friend class content::WebContentsUserData<RenderViewHostDestructionObserver>;
136 136
137 // content::WebContentsObserver overrides. 137 // content::WebContentsObserver overrides.
138 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE { 138 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE {
139 process_manager_->UnregisterRenderViewHost(render_view_host); 139 process_manager_->UnregisterRenderViewHost(render_view_host);
140 } 140 }
141 141
142 ProcessManager* process_manager_; 142 ProcessManager* process_manager_;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // This increment / decrement is to simulate an instantaneous event. This 563 // This increment / decrement is to simulate an instantaneous event. This
564 // has the effect of invalidating close_sequence_id, preventing any in 564 // has the effect of invalidating close_sequence_id, preventing any in
565 // progress closes from completing and starting a new close process if 565 // progress closes from completing and starting a new close process if
566 // necessary. 566 // necessary.
567 IncrementLazyKeepaliveCount(extension); 567 IncrementLazyKeepaliveCount(extension);
568 DecrementLazyKeepaliveCount(extension); 568 DecrementLazyKeepaliveCount(extension);
569 } 569 }
570 } 570 }
571 571
572 void ProcessManager::OnBrowserWindowReady() { 572 void ProcessManager::OnBrowserWindowReady() {
573 ExtensionService* service = ExtensionSystem::GetForBrowserContext( 573 ExtensionService* service = ExtensionSystem::Get(
574 GetBrowserContext())->extension_service(); 574 GetBrowserContext())->extension_service();
575 // On Chrome OS, a login screen is implemented as a browser. 575 // On Chrome OS, a login screen is implemented as a browser.
576 // This browser has no extension service. In this case, 576 // This browser has no extension service. In this case,
577 // service will be NULL. 577 // service will be NULL.
578 if (!service || !service->is_ready()) 578 if (!service || !service->is_ready())
579 return; 579 return;
580 580
581 CreateBackgroundHostsForProfileStartup(); 581 CreateBackgroundHostsForProfileStartup();
582 } 582 }
583 583
(...skipping 22 matching lines...) Expand all
606 // (or an incognito profile from this profile) is ready. 606 // (or an incognito profile from this profile) is ready.
607 if (DeferLoadingBackgroundHosts()) 607 if (DeferLoadingBackgroundHosts())
608 break; 608 break;
609 609
610 CreateBackgroundHostsForProfileStartup(); 610 CreateBackgroundHostsForProfileStartup();
611 break; 611 break;
612 } 612 }
613 613
614 case chrome::NOTIFICATION_EXTENSION_LOADED: { 614 case chrome::NOTIFICATION_EXTENSION_LOADED: {
615 BrowserContext* context = content::Source<BrowserContext>(source).ptr(); 615 BrowserContext* context = content::Source<BrowserContext>(source).ptr();
616 ExtensionSystem* system = ExtensionSystem::GetForBrowserContext(context); 616 ExtensionSystem* system = ExtensionSystem::Get(context);
617 if (system->ready().is_signaled()) { 617 if (system->ready().is_signaled()) {
618 // The extension system is ready, so create the background host. 618 // The extension system is ready, so create the background host.
619 const Extension* extension = 619 const Extension* extension =
620 content::Details<const Extension>(details).ptr(); 620 content::Details<const Extension>(details).ptr();
621 CreateBackgroundHostForExtensionLoad(this, extension); 621 CreateBackgroundHostForExtensionLoad(this, extension);
622 } 622 }
623 break; 623 break;
624 } 624 }
625 625
626 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 626 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 846 }
847 847
848 // 848 //
849 // IncognitoProcessManager 849 // IncognitoProcessManager
850 // 850 //
851 851
852 IncognitoProcessManager::IncognitoProcessManager( 852 IncognitoProcessManager::IncognitoProcessManager(
853 BrowserContext* incognito_context, 853 BrowserContext* incognito_context,
854 BrowserContext* original_context) 854 BrowserContext* original_context)
855 : ProcessManager(incognito_context, original_context), 855 : ProcessManager(incognito_context, original_context),
856 original_manager_(ExtensionSystem::GetForBrowserContext( 856 original_manager_(ExtensionSystem::Get(
857 original_context)->process_manager()) { 857 original_context)->process_manager()) {
858 DCHECK(incognito_context->IsOffTheRecord()); 858 DCHECK(incognito_context->IsOffTheRecord());
859 859
860 // The original profile will have its own ProcessManager to 860 // The original profile will have its own ProcessManager to
861 // load the background pages of the spanning extensions. This process 861 // load the background pages of the spanning extensions. This process
862 // manager need only worry about the split mode extensions, which is handled 862 // manager need only worry about the split mode extensions, which is handled
863 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. 863 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler.
864 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, 864 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
865 content::Source<BrowserContext>(original_context)); 865 content::Source<BrowserContext>(original_context));
866 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, 866 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED,
(...skipping 18 matching lines...) Expand all
885 const Extension* extension = 885 const Extension* extension =
886 registry->enabled_extensions().GetExtensionOrAppByURL(url); 886 registry->enabled_extensions().GetExtensionOrAppByURL(url);
887 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 887 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
888 return original_manager_->GetSiteInstanceForURL(url); 888 return original_manager_->GetSiteInstanceForURL(url);
889 } 889 }
890 } 890 }
891 return ProcessManager::GetSiteInstanceForURL(url); 891 return ProcessManager::GetSiteInstanceForURL(url);
892 } 892 }
893 893
894 } // namespace extensions 894 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698