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/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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 content::RenderProcessHost* process = render_view_host()->GetProcess(); | 95 content::RenderProcessHost* process = render_view_host()->GetProcess(); |
96 | 96 |
97 // Some extensions use chrome:// URLs. | 97 // Some extensions use chrome:// URLs. |
98 Extension::Type type = extension->GetType(); | 98 Extension::Type type = extension->GetType(); |
99 if (type == Extension::TYPE_EXTENSION || | 99 if (type == Extension::TYPE_EXTENSION || |
100 type == Extension::TYPE_LEGACY_PACKAGED_APP) { | 100 type == Extension::TYPE_LEGACY_PACKAGED_APP) { |
101 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 101 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
102 process->GetID(), chrome::kChromeUIScheme); | 102 process->GetID(), chrome::kChromeUIScheme); |
103 | 103 |
104 if (profile_->GetExtensionService()->extension_prefs()->AllowFileAccess( | 104 if (extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
105 extension->id())) { | 105 extension_prefs()->AllowFileAccess(extension->id())) { |
106 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 106 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
107 process->GetID(), chrome::kFileScheme); | 107 process->GetID(), chrome::kFileScheme); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 switch (type) { | 111 switch (type) { |
112 case Extension::TYPE_EXTENSION: | 112 case Extension::TYPE_EXTENSION: |
113 case Extension::TYPE_USER_SCRIPT: | 113 case Extension::TYPE_USER_SCRIPT: |
114 case Extension::TYPE_HOSTED_APP: | 114 case Extension::TYPE_HOSTED_APP: |
115 case Extension::TYPE_LEGACY_PACKAGED_APP: | 115 case Extension::TYPE_LEGACY_PACKAGED_APP: |
(...skipping 17 matching lines...) Expand all Loading... |
133 const Extension* ChromeRenderViewHostObserver::GetExtension() { | 133 const Extension* ChromeRenderViewHostObserver::GetExtension() { |
134 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps | 134 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps |
135 // (excluding bookmark apps) will have a chrome-extension:// URL for their | 135 // (excluding bookmark apps) will have a chrome-extension:// URL for their |
136 // site, so we can ignore that wrinkle here. | 136 // site, so we can ignore that wrinkle here. |
137 SiteInstance* site_instance = render_view_host()->GetSiteInstance(); | 137 SiteInstance* site_instance = render_view_host()->GetSiteInstance(); |
138 const GURL& site = site_instance->GetSiteURL(); | 138 const GURL& site = site_instance->GetSiteURL(); |
139 | 139 |
140 if (!site.SchemeIs(extensions::kExtensionScheme)) | 140 if (!site.SchemeIs(extensions::kExtensionScheme)) |
141 return NULL; | 141 return NULL; |
142 | 142 |
143 ExtensionService* service = profile_->GetExtensionService(); | 143 ExtensionService* service = |
| 144 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
144 if (!service) | 145 if (!service) |
145 return NULL; | 146 return NULL; |
146 | 147 |
147 // Reload the extension if it has crashed. | 148 // Reload the extension if it has crashed. |
148 // TODO(yoz): This reload doesn't happen synchronously for unpacked | 149 // TODO(yoz): This reload doesn't happen synchronously for unpacked |
149 // extensions. It seems to be fast enough, but there is a race. | 150 // extensions. It seems to be fast enough, but there is a race. |
150 // We should delay loading until the extension has reloaded. | 151 // We should delay loading until the extension has reloaded. |
151 if (service->GetTerminatedExtension(site.host())) | 152 if (service->GetTerminatedExtension(site.host())) |
152 service->ReloadExtension(site.host()); | 153 service->ReloadExtension(site.host()); |
153 | 154 |
154 // May be null if the extension doesn't exist, for example if somebody typos | 155 // May be null if the extension doesn't exist, for example if somebody typos |
155 // a chrome-extension:// URL. | 156 // a chrome-extension:// URL. |
156 return service->extensions()->GetByID(site.host()); | 157 return service->extensions()->GetByID(site.host()); |
157 } | 158 } |
158 | 159 |
159 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( | 160 void ChromeRenderViewHostObserver::RemoveRenderViewHostForExtensions( |
160 RenderViewHost* rvh) { | 161 RenderViewHost* rvh) { |
161 ExtensionProcessManager* process_manager = | 162 ExtensionProcessManager* process_manager = |
162 extensions::ExtensionSystem::Get(profile_)->process_manager(); | 163 extensions::ExtensionSystem::Get(profile_)->process_manager(); |
163 if (process_manager) | 164 if (process_manager) |
164 process_manager->UnregisterRenderViewHost(rvh); | 165 process_manager->UnregisterRenderViewHost(rvh); |
165 } | 166 } |
166 | 167 |
167 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 168 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
168 content::NotificationService::current()->Notify( | 169 content::NotificationService::current()->Notify( |
169 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 170 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
170 content::Source<RenderViewHost>(render_view_host()), | 171 content::Source<RenderViewHost>(render_view_host()), |
171 content::NotificationService::NoDetails()); | 172 content::NotificationService::NoDetails()); |
172 } | 173 } |
OLD | NEW |