Suppress tabs permission warning if there is already a browsingHistory warning.
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client.h
blob7b7e264120a5d94216739b43b793557369b0e16b
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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
6 #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "content/public/renderer/content_renderer_client.h"
16 #include "ipc/ipc_channel_proxy.h"
17 #include "third_party/WebKit/public/web/WebLocalFrame.h"
19 class ChromeRenderProcessObserver;
20 class PrescientNetworkingDispatcher;
21 class RendererNetPredictor;
22 class SearchBouncer;
23 #if defined(ENABLE_SPELLCHECK)
24 class SpellCheck;
25 class SpellCheckProvider;
26 #endif
28 struct ChromeViewHostMsg_GetPluginInfo_Output;
30 namespace content {
31 struct WebPluginInfo;
34 namespace extensions {
35 class Dispatcher;
36 class Extension;
37 class ExtensionSet;
38 class RendererPermissionsPolicyDelegate;
41 namespace prerender {
42 class PrerenderDispatcher;
45 namespace safe_browsing {
46 class PhishingClassifierFilter;
49 namespace visitedlink {
50 class VisitedLinkSlave;
53 namespace blink {
54 class WebSecurityOrigin;
57 #if defined(ENABLE_WEBRTC)
58 class WebRtcLoggingMessageFilter;
59 #endif
61 class ChromeContentRendererClient : public content::ContentRendererClient {
62 public:
63 ChromeContentRendererClient();
64 virtual ~ChromeContentRendererClient();
66 virtual void RenderThreadStarted() OVERRIDE;
67 virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
68 virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE;
69 virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
70 virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
71 virtual SkBitmap* GetSadWebViewBitmap() OVERRIDE;
72 virtual std::string GetDefaultEncoding() OVERRIDE;
73 virtual bool OverrideCreatePlugin(
74 content::RenderFrame* render_frame,
75 blink::WebLocalFrame* frame,
76 const blink::WebPluginParams& params,
77 blink::WebPlugin** plugin) OVERRIDE;
78 virtual blink::WebPlugin* CreatePluginReplacement(
79 content::RenderFrame* render_frame,
80 const base::FilePath& plugin_path) OVERRIDE;
81 virtual bool HasErrorPage(int http_status_code,
82 std::string* error_domain) OVERRIDE;
83 virtual bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
84 const GURL& url) OVERRIDE;
85 virtual void GetNavigationErrorStrings(
86 content::RenderView* render_view,
87 blink::WebFrame* frame,
88 const blink::WebURLRequest& failed_request,
89 const blink::WebURLError& error,
90 std::string* error_html,
91 base::string16* error_description) OVERRIDE;
92 virtual void DeferMediaLoad(content::RenderFrame* render_frame,
93 const base::Closure& closure) OVERRIDE;
94 virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE;
95 virtual bool AllowPopup() OVERRIDE;
96 virtual bool ShouldFork(blink::WebFrame* frame,
97 const GURL& url,
98 const std::string& http_method,
99 bool is_initial_navigation,
100 bool is_server_redirect,
101 bool* send_referrer) OVERRIDE;
102 virtual bool WillSendRequest(blink::WebFrame* frame,
103 content::PageTransition transition_type,
104 const GURL& url,
105 const GURL& first_party_for_cookies,
106 GURL* new_url) OVERRIDE;
107 virtual void DidCreateScriptContext(blink::WebFrame* frame,
108 v8::Handle<v8::Context> context,
109 int extension_group,
110 int world_id) OVERRIDE;
111 virtual unsigned long long VisitedLinkHash(const char* canonical_url,
112 size_t length) OVERRIDE;
113 virtual bool IsLinkVisited(unsigned long long link_hash) OVERRIDE;
114 virtual blink::WebPrescientNetworking* GetPrescientNetworking() OVERRIDE;
115 virtual bool ShouldOverridePageVisibilityState(
116 const content::RenderFrame* render_frame,
117 blink::WebPageVisibilityState* override_state) OVERRIDE;
118 virtual bool AllowBrowserPlugin(
119 blink::WebPluginContainer* container) OVERRIDE;
120 virtual const void* CreatePPAPIInterface(
121 const std::string& interface_name) OVERRIDE;
122 virtual bool IsExternalPepperPlugin(const std::string& module_name) OVERRIDE;
123 virtual blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
124 blink::WebSpeechSynthesizerClient* client) OVERRIDE;
125 virtual bool ShouldReportDetailedMessageForSource(
126 const base::string16& source) const OVERRIDE;
127 virtual bool ShouldEnableSiteIsolationPolicy() const OVERRIDE;
128 virtual blink::WebWorkerPermissionClientProxy*
129 CreateWorkerPermissionClientProxy(content::RenderFrame* render_frame,
130 blink::WebFrame* frame) OVERRIDE;
131 virtual bool AllowPepperMediaStreamAPI(const GURL& url) OVERRIDE;
132 virtual void AddKeySystems(
133 std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;
135 // For testing.
136 void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher);
138 #if defined(ENABLE_SPELLCHECK)
139 // Sets a new |spellcheck|. Used for testing only.
140 // Takes ownership of |spellcheck|.
141 void SetSpellcheck(SpellCheck* spellcheck);
142 #endif
144 static blink::WebPlugin* CreatePlugin(
145 content::RenderFrame* render_frame,
146 blink::WebLocalFrame* frame,
147 const blink::WebPluginParams& params,
148 const ChromeViewHostMsg_GetPluginInfo_Output& output);
150 static bool IsExtensionOrSharedModuleWhitelisted(
151 const GURL& url, const std::set<std::string>& whitelist);
153 // TODO(mpcomplete): remove after we collect histogram data.
154 // http://crbug.com/100411
155 static bool IsAdblockInstalled();
156 static bool IsAdblockPlusInstalled();
157 static bool IsAdblockWithWebRequestInstalled();
158 static bool IsAdblockPlusWithWebRequestInstalled();
159 static bool IsOtherExtensionWithWebRequestInstalled();
161 private:
162 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
163 FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest,
164 ShouldSuppressErrorPage);
166 // Gets extension by the given origin, regardless of whether the extension
167 // is active in the current process.
168 const extensions::Extension* GetExtensionByOrigin(
169 const blink::WebSecurityOrigin& origin) const;
171 // Returns true if the frame is navigating to an URL either into or out of an
172 // extension app's extent.
173 bool CrossesExtensionExtents(blink::WebFrame* frame,
174 const GURL& new_url,
175 const extensions::ExtensionSet& extensions,
176 bool is_extension_url,
177 bool is_initial_navigation);
179 static GURL GetNaClContentHandlerURL(const std::string& actual_mime_type,
180 const content::WebPluginInfo& plugin);
182 // Determines if a NaCl app is allowed, and modifies params to pass the app's
183 // permissions to the trusted NaCl plugin.
184 static bool IsNaClAllowed(const GURL& manifest_url,
185 const GURL& app_url,
186 bool is_nacl_unrestricted,
187 const extensions::Extension* extension,
188 blink::WebPluginParams* params);
190 scoped_ptr<ChromeRenderProcessObserver> chrome_observer_;
191 scoped_ptr<extensions::Dispatcher> extension_dispatcher_;
192 scoped_ptr<extensions::RendererPermissionsPolicyDelegate>
193 permissions_policy_delegate_;
194 scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
195 scoped_ptr<RendererNetPredictor> net_predictor_;
196 #if defined(ENABLE_SPELLCHECK)
197 scoped_ptr<SpellCheck> spellcheck_;
198 #endif
199 scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
200 scoped_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
201 scoped_ptr<prerender::PrerenderDispatcher> prerender_dispatcher_;
202 #if defined(ENABLE_WEBRTC)
203 scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
204 #endif
205 scoped_ptr<SearchBouncer> search_bouncer_;
208 #endif // CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_