| 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 #ifndef CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ | 5 #ifndef CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ |
| 6 #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ | 6 #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "content/public/renderer/content_renderer_client.h" | 17 #include "content/public/renderer/content_renderer_client.h" |
| 18 #include "ipc/ipc_channel_proxy.h" | 18 #include "ipc/ipc_channel_proxy.h" |
| 19 #include "v8/include/v8.h" | 19 #include "v8/include/v8.h" |
| 20 | 20 |
| 21 class ChromeExtensionsDispatcherDelegate; | |
| 22 class ChromeRenderProcessObserver; | 21 class ChromeRenderProcessObserver; |
| 23 #if defined(ENABLE_PRINT_PREVIEW) | 22 #if defined(ENABLE_PRINT_PREVIEW) |
| 24 class ChromePDFPrintClient; | 23 class ChromePDFPrintClient; |
| 25 #endif | 24 #endif |
| 26 class PrescientNetworkingDispatcher; | 25 class PrescientNetworkingDispatcher; |
| 27 #if defined(ENABLE_SPELLCHECK) | 26 #if defined(ENABLE_SPELLCHECK) |
| 28 class SpellCheck; | 27 class SpellCheck; |
| 29 class SpellCheckProvider; | 28 class SpellCheckProvider; |
| 30 #endif | 29 #endif |
| 31 | 30 |
| 32 struct ChromeViewHostMsg_GetPluginInfo_Output; | 31 struct ChromeViewHostMsg_GetPluginInfo_Output; |
| 33 | 32 |
| 34 namespace content { | 33 namespace content { |
| 35 class BrowserPluginDelegate; | 34 class BrowserPluginDelegate; |
| 36 struct WebPluginInfo; | 35 struct WebPluginInfo; |
| 37 } | 36 } |
| 38 | 37 |
| 39 namespace network_hints { | 38 namespace network_hints { |
| 40 class PrescientNetworkingDispatcher; | 39 class PrescientNetworkingDispatcher; |
| 41 } | 40 } |
| 42 | 41 |
| 43 namespace extensions { | 42 namespace extensions { |
| 44 class Dispatcher; | 43 class Dispatcher; |
| 45 class Extension; | 44 class Extension; |
| 46 class ExtensionSet; | |
| 47 class ExtensionsGuestViewContainerDispatcher; | |
| 48 class RendererPermissionsPolicyDelegate; | |
| 49 class ResourceRequestPolicy; | |
| 50 } | 45 } |
| 51 | 46 |
| 52 namespace prerender { | 47 namespace prerender { |
| 53 class PrerenderDispatcher; | 48 class PrerenderDispatcher; |
| 54 } | 49 } |
| 55 | 50 |
| 56 namespace safe_browsing { | 51 namespace safe_browsing { |
| 57 class PhishingClassifierFilter; | 52 class PhishingClassifierFilter; |
| 58 } | 53 } |
| 59 | 54 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void AddImageContextMenuProperties( | 149 void AddImageContextMenuProperties( |
| 155 const blink::WebURLResponse& response, | 150 const blink::WebURLResponse& response, |
| 156 std::map<std::string, std::string>* properties) override; | 151 std::map<std::string, std::string>* properties) override; |
| 157 void DidInitializeServiceWorkerContextOnWorkerThread( | 152 void DidInitializeServiceWorkerContextOnWorkerThread( |
| 158 v8::Local<v8::Context> context, | 153 v8::Local<v8::Context> context, |
| 159 const GURL& url) override; | 154 const GURL& url) override; |
| 160 void WillDestroyServiceWorkerContextOnWorkerThread( | 155 void WillDestroyServiceWorkerContextOnWorkerThread( |
| 161 v8::Local<v8::Context> context, | 156 v8::Local<v8::Context> context, |
| 162 const GURL& url) override; | 157 const GURL& url) override; |
| 163 bool ShouldEnforceWebRTCRoutingPreferences() override; | 158 bool ShouldEnforceWebRTCRoutingPreferences() override; |
| 164 #if defined(ENABLE_EXTENSIONS) | |
| 165 // Takes ownership. | |
| 166 void SetExtensionDispatcherForTest( | |
| 167 extensions::Dispatcher* extension_dispatcher); | |
| 168 extensions::Dispatcher* GetExtensionDispatcherForTest(); | |
| 169 #endif | |
| 170 | 159 |
| 171 #if defined(ENABLE_SPELLCHECK) | 160 #if defined(ENABLE_SPELLCHECK) |
| 172 // Sets a new |spellcheck|. Used for testing only. | 161 // Sets a new |spellcheck|. Used for testing only. |
| 173 // Takes ownership of |spellcheck|. | 162 // Takes ownership of |spellcheck|. |
| 174 void SetSpellcheck(SpellCheck* spellcheck); | 163 void SetSpellcheck(SpellCheck* spellcheck); |
| 175 #endif | 164 #endif |
| 176 | 165 |
| 177 #if defined(ENABLE_PLUGINS) | 166 #if defined(ENABLE_PLUGINS) |
| 178 static blink::WebPlugin* CreatePlugin( | 167 static blink::WebPlugin* CreatePlugin( |
| 179 content::RenderFrame* render_frame, | 168 content::RenderFrame* render_frame, |
| 180 blink::WebLocalFrame* frame, | 169 blink::WebLocalFrame* frame, |
| 181 const blink::WebPluginParams& params, | 170 const blink::WebPluginParams& params, |
| 182 const ChromeViewHostMsg_GetPluginInfo_Output& output); | 171 const ChromeViewHostMsg_GetPluginInfo_Output& output); |
| 183 #endif | 172 #endif |
| 184 | 173 |
| 185 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) | 174 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
| 186 static bool IsExtensionOrSharedModuleWhitelisted( | 175 static bool IsExtensionOrSharedModuleWhitelisted( |
| 187 const GURL& url, const std::set<std::string>& whitelist); | 176 const GURL& url, const std::set<std::string>& whitelist); |
| 188 #endif | 177 #endif |
| 189 | 178 |
| 190 static bool WasWebRequestUsedBySomeExtensions(); | |
| 191 | |
| 192 private: | 179 private: |
| 193 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction); | 180 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction); |
| 194 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, | 181 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, |
| 195 ShouldSuppressErrorPage); | 182 ShouldSuppressErrorPage); |
| 196 | 183 |
| 197 #if defined(ENABLE_EXTENSIONS) | |
| 198 // Gets extension by the given origin, regardless of whether the extension | |
| 199 // is active in the current process. | |
| 200 const extensions::Extension* GetExtensionByOrigin( | |
| 201 const blink::WebSecurityOrigin& origin) const; | |
| 202 | |
| 203 // Returns true if the frame is navigating to an URL either into or out of an | |
| 204 // extension app's extent. | |
| 205 bool CrossesExtensionExtents(blink::WebLocalFrame* frame, | |
| 206 const GURL& new_url, | |
| 207 bool is_extension_url, | |
| 208 bool is_initial_navigation); | |
| 209 #endif | |
| 210 | |
| 211 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type, | 184 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type, |
| 212 const content::WebPluginInfo& plugin); | 185 const content::WebPluginInfo& plugin); |
| 213 | 186 |
| 214 #if !defined(DISABLE_NACL) | 187 #if !defined(DISABLE_NACL) |
| 215 // Determines if a NaCl app is allowed, and modifies params to pass the app's | 188 // Determines if a NaCl app is allowed, and modifies params to pass the app's |
| 216 // permissions to the trusted NaCl plugin. | 189 // permissions to the trusted NaCl plugin. |
| 217 static bool IsNaClAllowed(const GURL& manifest_url, | 190 static bool IsNaClAllowed(const GURL& manifest_url, |
| 218 const GURL& app_url, | 191 const GURL& app_url, |
| 219 bool is_nacl_unrestricted, | 192 bool is_nacl_unrestricted, |
| 220 const extensions::Extension* extension, | 193 const extensions::Extension* extension, |
| 221 blink::WebPluginParams* params); | 194 blink::WebPluginParams* params); |
| 222 #endif | 195 #endif |
| 223 | 196 |
| 224 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_; | 197 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_; |
| 225 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_; | 198 scoped_ptr<web_cache::WebCacheRenderProcessObserver> web_cache_observer_; |
| 226 | 199 |
| 227 // TODO(thestig): Extract into a separate file if possible. Cleanup | |
| 228 // ENABLE_EXTENSIONS ifdefs in the .cc file as well. | |
| 229 #if defined(ENABLE_EXTENSIONS) | |
| 230 scoped_ptr<ChromeExtensionsDispatcherDelegate> extension_dispatcher_delegate_; | |
| 231 scoped_ptr<extensions::Dispatcher> extension_dispatcher_; | |
| 232 scoped_ptr<extensions::RendererPermissionsPolicyDelegate> | |
| 233 permissions_policy_delegate_; | |
| 234 scoped_ptr<extensions::ExtensionsGuestViewContainerDispatcher> | |
| 235 guest_view_container_dispatcher_; | |
| 236 scoped_ptr<extensions::ResourceRequestPolicy> resource_request_policy_; | |
| 237 #endif | |
| 238 | |
| 239 scoped_ptr<network_hints::PrescientNetworkingDispatcher> | 200 scoped_ptr<network_hints::PrescientNetworkingDispatcher> |
| 240 prescient_networking_dispatcher_; | 201 prescient_networking_dispatcher_; |
| 241 scoped_ptr<password_manager::CredentialManagerClient> | 202 scoped_ptr<password_manager::CredentialManagerClient> |
| 242 credential_manager_client_; | 203 credential_manager_client_; |
| 204 |
| 243 #if defined(ENABLE_SPELLCHECK) | 205 #if defined(ENABLE_SPELLCHECK) |
| 244 scoped_ptr<SpellCheck> spellcheck_; | 206 scoped_ptr<SpellCheck> spellcheck_; |
| 245 #endif | 207 #endif |
| 246 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; | 208 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; |
| 247 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_; | 209 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_; |
| 248 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_; | 210 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_; |
| 249 #if defined(ENABLE_WEBRTC) | 211 #if defined(ENABLE_WEBRTC) |
| 250 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_; | 212 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_; |
| 251 #endif | 213 #endif |
| 252 #if defined(ENABLE_PRINT_PREVIEW) | 214 #if defined(ENABLE_PRINT_PREVIEW) |
| 253 scoped_ptr<ChromePDFPrintClient> pdf_print_client_; | 215 scoped_ptr<ChromePDFPrintClient> pdf_print_client_; |
| 254 #endif | 216 #endif |
| 255 #if defined(ENABLE_PLUGINS) | 217 #if defined(ENABLE_PLUGINS) |
| 256 std::set<std::string> allowed_camera_device_origins_; | 218 std::set<std::string> allowed_camera_device_origins_; |
| 257 std::set<std::string> allowed_compositor_origins_; | 219 std::set<std::string> allowed_compositor_origins_; |
| 258 #endif | 220 #endif |
| 259 }; | 221 }; |
| 260 | 222 |
| 261 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ | 223 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ |
| OLD | NEW |