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

Side by Side Diff: chrome/browser/renderer_host/chrome_render_view_host_observer.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
OLDNEW
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/renderer_host/chrome_render_view_host_observer.h" 5 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/net/predictor.h" 10 #include "chrome/browser/net/predictor.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 content::RenderProcessHost* process = render_view_host()->GetProcess(); 81 content::RenderProcessHost* process = render_view_host()->GetProcess();
82 82
83 // Some extensions use chrome:// URLs. 83 // Some extensions use chrome:// URLs.
84 Extension::Type type = extension->GetType(); 84 Extension::Type type = extension->GetType();
85 if (type == Extension::TYPE_EXTENSION || 85 if (type == Extension::TYPE_EXTENSION ||
86 type == Extension::TYPE_LEGACY_PACKAGED_APP) { 86 type == Extension::TYPE_LEGACY_PACKAGED_APP) {
87 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( 87 ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
88 process->GetID(), chrome::kChromeUIScheme); 88 process->GetID(), chrome::kChromeUIScheme);
89 89
90 if (profile_->GetExtensionService()->extension_prefs()->AllowFileAccess( 90 if (extensions::ExtensionSystem::Get(profile_)->extension_service()->
91 extension->id())) { 91 extension_prefs()->AllowFileAccess(extension->id())) {
92 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( 92 ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
93 process->GetID(), chrome::kFileScheme); 93 process->GetID(), chrome::kFileScheme);
94 } 94 }
95 } 95 }
96 96
97 switch (type) { 97 switch (type) {
98 case Extension::TYPE_EXTENSION: 98 case Extension::TYPE_EXTENSION:
99 case Extension::TYPE_USER_SCRIPT: 99 case Extension::TYPE_USER_SCRIPT:
100 case Extension::TYPE_HOSTED_APP: 100 case Extension::TYPE_HOSTED_APP:
101 case Extension::TYPE_LEGACY_PACKAGED_APP: 101 case Extension::TYPE_LEGACY_PACKAGED_APP:
(...skipping 17 matching lines...) Expand all
119 const Extension* ChromeRenderViewHostObserver::GetExtension() { 119 const Extension* ChromeRenderViewHostObserver::GetExtension() {
120 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps 120 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps
121 // (excluding bookmark apps) will have a chrome-extension:// URL for their 121 // (excluding bookmark apps) will have a chrome-extension:// URL for their
122 // site, so we can ignore that wrinkle here. 122 // site, so we can ignore that wrinkle here.
123 SiteInstance* site_instance = render_view_host()->GetSiteInstance(); 123 SiteInstance* site_instance = render_view_host()->GetSiteInstance();
124 const GURL& site = site_instance->GetSiteURL(); 124 const GURL& site = site_instance->GetSiteURL();
125 125
126 if (!site.SchemeIs(extensions::kExtensionScheme)) 126 if (!site.SchemeIs(extensions::kExtensionScheme))
127 return NULL; 127 return NULL;
128 128
129 ExtensionService* service = profile_->GetExtensionService(); 129 ExtensionService* service =
130 extensions::ExtensionSystem::Get(profile_)->extension_service();
130 if (!service) 131 if (!service)
131 return NULL; 132 return NULL;
132 133
133 // Reload the extension if it has crashed. 134 // Reload the extension if it has crashed.
134 // TODO(yoz): This reload doesn't happen synchronously for unpacked 135 // TODO(yoz): This reload doesn't happen synchronously for unpacked
135 // extensions. It seems to be fast enough, but there is a race. 136 // extensions. It seems to be fast enough, but there is a race.
136 // We should delay loading until the extension has reloaded. 137 // We should delay loading until the extension has reloaded.
137 if (service->GetTerminatedExtension(site.host())) 138 if (service->GetTerminatedExtension(site.host()))
138 service->ReloadExtension(site.host()); 139 service->ReloadExtension(site.host());
139 140
140 // May be null if the extension doesn't exist, for example if somebody typos 141 // May be null if the extension doesn't exist, for example if somebody typos
141 // a chrome-extension:// URL. 142 // a chrome-extension:// URL.
142 return service->extensions()->GetByID(site.host()); 143 return service->extensions()->GetByID(site.host());
143 } 144 }
144 145
145 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( 146 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions(
146 RenderViewHost* rvh) { 147 RenderViewHost* rvh) {
147 ExtensionProcessManager* process_manager = 148 ExtensionProcessManager* process_manager =
148 extensions::ExtensionSystem::Get(profile_)->process_manager(); 149 extensions::ExtensionSystem::Get(profile_)->process_manager();
149 if (process_manager) 150 if (process_manager)
150 process_manager->UnregisterRenderViewHost(rvh); 151 process_manager->UnregisterRenderViewHost(rvh);
151 } 152 }
152 153
153 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { 154 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() {
154 content::NotificationService::current()->Notify( 155 content::NotificationService::current()->Notify(
155 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, 156 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED,
156 content::Source<RenderViewHost>(render_view_host()), 157 content::Source<RenderViewHost>(render_view_host()),
157 content::NotificationService::NoDetails()); 158 content::NotificationService::NoDetails());
158 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.cc ('k') | chrome/browser/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698