| 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/net/predictor.h" | 9 #include "chrome/browser/net/predictor.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ChromeRenderViewHostObserver::InitRenderViewForExtensions() { | 99 void ChromeRenderViewHostObserver::InitRenderViewForExtensions() { |
| 100 const Extension* extension = GetExtension(); | 100 const Extension* extension = GetExtension(); |
| 101 if (!extension) | 101 if (!extension) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 content::RenderProcessHost* process = render_view_host()->GetProcess(); | 104 content::RenderProcessHost* process = render_view_host()->GetProcess(); |
| 105 | 105 |
| 106 if (extension->is_app()) { | 106 if (extension->is_app()) { |
| 107 Send(new ExtensionMsg_ActivateApplication(extension->id())); |
| 107 // Though we already record the associated process ID for the renderer in | 108 // Though we already record the associated process ID for the renderer in |
| 108 // InitRenderViewHostForExtensions, the process might have crashed and been | 109 // InitRenderViewHostForExtensions, the process might have crashed and been |
| 109 // restarted (hence the re-initialization), so we need to update that | 110 // restarted (hence the re-initialization), so we need to update that |
| 110 // mapping. | 111 // mapping. |
| 111 profile_->GetExtensionService()->SetInstalledAppForRenderer( | 112 profile_->GetExtensionService()->SetInstalledAppForRenderer( |
| 112 process->GetID(), extension); | 113 process->GetID(), extension); |
| 113 } | 114 } |
| 114 | 115 |
| 115 // Some extensions use chrome:// URLs. | 116 // Some extensions use chrome:// URLs. |
| 116 Extension::Type type = extension->GetType(); | 117 Extension::Type type = extension->GetType(); |
| 117 if (type == Extension::TYPE_EXTENSION || | 118 if (type == Extension::TYPE_EXTENSION || |
| 118 type == Extension::TYPE_PACKAGED_APP) { | 119 type == Extension::TYPE_PACKAGED_APP) { |
| 119 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 120 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
| 120 process->GetID(), chrome::kChromeUIScheme); | 121 process->GetID(), chrome::kChromeUIScheme); |
| 121 | 122 |
| 122 if (profile_->GetExtensionService()->extension_prefs()->AllowFileAccess( | 123 if (profile_->GetExtensionService()->extension_prefs()->AllowFileAccess( |
| 123 extension->id())) { | 124 extension->id())) { |
| 124 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 125 ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
| 125 process->GetID(), chrome::kFileScheme); | 126 process->GetID(), chrome::kFileScheme); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 switch (type) { | 130 if (type == Extension::TYPE_EXTENSION || |
| 130 case Extension::TYPE_EXTENSION: | 131 type == Extension::TYPE_USER_SCRIPT || |
| 131 case Extension::TYPE_USER_SCRIPT: | 132 type == Extension::TYPE_PACKAGED_APP || |
| 132 case Extension::TYPE_HOSTED_APP: | 133 type == Extension::TYPE_PLATFORM_APP || |
| 133 case Extension::TYPE_PACKAGED_APP: | 134 (type == Extension::TYPE_HOSTED_APP && |
| 134 case Extension::TYPE_PLATFORM_APP: | 135 extension->location() == Extension::COMPONENT)) { |
| 135 Send(new ExtensionMsg_ActivateExtension(extension->id())); | 136 Send(new ExtensionMsg_ActivateExtension(extension->id())); |
| 136 break; | |
| 137 | |
| 138 case Extension::TYPE_UNKNOWN: | |
| 139 case Extension::TYPE_THEME: | |
| 140 break; | |
| 141 | |
| 142 default: | |
| 143 NOTREACHED(); | |
| 144 } | 137 } |
| 145 } | 138 } |
| 146 | 139 |
| 147 const Extension* ChromeRenderViewHostObserver::GetExtension() { | 140 const Extension* ChromeRenderViewHostObserver::GetExtension() { |
| 148 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps | 141 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps |
| 149 // (excluding bookmark apps) will have a chrome-extension:// URL for their | 142 // (excluding bookmark apps) will have a chrome-extension:// URL for their |
| 150 // site, so we can ignore that wrinkle here. | 143 // site, so we can ignore that wrinkle here. |
| 151 SiteInstance* site_instance = render_view_host()->GetSiteInstance(); | 144 SiteInstance* site_instance = render_view_host()->GetSiteInstance(); |
| 152 const GURL& site = site_instance->GetSite(); | 145 const GURL& site = site_instance->GetSite(); |
| 153 | 146 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 177 if (process_manager) | 170 if (process_manager) |
| 178 process_manager->UnregisterRenderViewHost(rvh); | 171 process_manager->UnregisterRenderViewHost(rvh); |
| 179 } | 172 } |
| 180 | 173 |
| 181 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { | 174 void ChromeRenderViewHostObserver::OnFocusedEditableNodeTouched() { |
| 182 content::NotificationService::current()->Notify( | 175 content::NotificationService::current()->Notify( |
| 183 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, | 176 chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, |
| 184 content::Source<RenderViewHost>(render_view_host()), | 177 content::Source<RenderViewHost>(render_view_host()), |
| 185 content::NotificationService::NoDetails()); | 178 content::NotificationService::NoDetails()); |
| 186 } | 179 } |
| OLD | NEW |