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 CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ |
6 #define CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ | 6 #define CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityStat e.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityStat e.h" |
16 #include "v8/include/v8.h" | |
16 | 17 |
17 class FilePath; | 18 class FilePath; |
18 class GURL; | 19 class GURL; |
19 class SkBitmap; | 20 class SkBitmap; |
20 | 21 |
21 namespace WebKit { | 22 namespace WebKit { |
22 class WebAudioSourceProvider; | 23 class WebAudioSourceProvider; |
23 class WebFrame; | 24 class WebFrame; |
24 class WebMediaPlayerClient; | 25 class WebMediaPlayerClient; |
25 class WebPlugin; | 26 class WebPlugin; |
(...skipping 14 matching lines...) Expand all Loading... | |
40 class MediaLog; | 41 class MediaLog; |
41 class MessageLoopFactory; | 42 class MessageLoopFactory; |
42 } | 43 } |
43 | 44 |
44 namespace webkit_media { | 45 namespace webkit_media { |
45 class MediaStreamClient; | 46 class MediaStreamClient; |
46 class WebMediaPlayerDelegate; | 47 class WebMediaPlayerDelegate; |
47 class WebMediaPlayerImpl; | 48 class WebMediaPlayerImpl; |
48 } | 49 } |
49 | 50 |
50 namespace v8 { | |
51 class Context; | |
52 template<class T> class Handle; | |
tfarina
2012/05/30 00:10:33
why not keep these forward declarations? I guess i
jam
2012/05/30 14:50:21
I had to include v8.h after I inlined some methods
| |
53 } | |
54 | |
55 namespace content { | 51 namespace content { |
56 | 52 |
57 class RenderView; | 53 class RenderView; |
58 | 54 |
59 // Embedder API for participating in renderer logic. | 55 // Embedder API for participating in renderer logic. |
60 class ContentRendererClient { | 56 class CONTENT_EXPORT ContentRendererClient { |
61 public: | 57 public: |
62 virtual ~ContentRendererClient() {} | 58 virtual ~ContentRendererClient() {} |
63 | 59 |
64 // Notifies us that the RenderThread has been created. | 60 // Notifies us that the RenderThread has been created. |
65 virtual void RenderThreadStarted() = 0; | 61 virtual void RenderThreadStarted() {} |
66 | 62 |
67 // Notifies that a new RenderView has been created. | 63 // Notifies that a new RenderView has been created. |
68 virtual void RenderViewCreated(RenderView* render_view) = 0; | 64 virtual void RenderViewCreated(RenderView* render_view) {} |
69 | 65 |
70 // Sets a number of views/tabs opened in this process. | 66 // Sets a number of views/tabs opened in this process. |
71 virtual void SetNumberOfViews(int number_of_views) = 0; | 67 virtual void SetNumberOfViews(int number_of_views) {} |
72 | 68 |
73 // Returns the bitmap to show when a plugin crashed, or NULL for none. | 69 // Returns the bitmap to show when a plugin crashed, or NULL for none. |
74 virtual SkBitmap* GetSadPluginBitmap() = 0; | 70 virtual SkBitmap* GetSadPluginBitmap(); |
75 | 71 |
76 // Returns the default text encoding. | 72 // Returns the default text encoding. |
77 virtual std::string GetDefaultEncoding() = 0; | 73 virtual std::string GetDefaultEncoding(); |
78 | 74 |
79 // Allows the embedder to override creating a plugin. If it returns true, then | 75 // Allows the embedder to override creating a plugin. If it returns true, then |
80 // |plugin| will contain the created plugin, although it could be NULL. If it | 76 // |plugin| will contain the created plugin, although it could be NULL. If it |
81 // returns false, the content layer will create the plugin. | 77 // returns false, the content layer will create the plugin. |
82 virtual bool OverrideCreatePlugin( | 78 virtual bool OverrideCreatePlugin( |
83 RenderView* render_view, | 79 RenderView* render_view, |
84 WebKit::WebFrame* frame, | 80 WebKit::WebFrame* frame, |
85 const WebKit::WebPluginParams& params, | 81 const WebKit::WebPluginParams& params, |
86 WebKit::WebPlugin** plugin) = 0; | 82 WebKit::WebPlugin** plugin); |
87 | 83 |
88 // Creates a replacement plug-in that is shown when the plug-in at |file_path| | 84 // Creates a replacement plug-in that is shown when the plug-in at |file_path| |
89 // couldn't be loaded. This allows the embedder to show a custom placeholder. | 85 // couldn't be loaded. This allows the embedder to show a custom placeholder. |
90 virtual WebKit::WebPlugin* CreatePluginReplacement( | 86 virtual WebKit::WebPlugin* CreatePluginReplacement( |
91 RenderView* render_view, | 87 RenderView* render_view, |
92 const FilePath& plugin_path) = 0; | 88 const FilePath& plugin_path); |
93 | 89 |
94 // Returns true if the embedder has an error page to show for the given http | 90 // Returns true if the embedder has an error page to show for the given http |
95 // status code. If so |error_domain| should be set to according to WebURLError | 91 // status code. If so |error_domain| should be set to according to WebURLError |
96 // and the embedder's GetNavigationErrorHtml will be called afterwards to get | 92 // and the embedder's GetNavigationErrorHtml will be called afterwards to get |
97 // the error html. | 93 // the error html. |
98 virtual bool HasErrorPage(int http_status_code, | 94 virtual bool HasErrorPage(int http_status_code, |
99 std::string* error_domain) = 0; | 95 std::string* error_domain); |
100 | 96 |
101 // Returns the information to display when a navigation error occurs. | 97 // Returns the information to display when a navigation error occurs. |
102 // If |error_html| is not null then it may be set to a HTML page containing | 98 // If |error_html| is not null then it may be set to a HTML page containing |
103 // the details of the error and maybe links to more info. | 99 // the details of the error and maybe links to more info. |
104 // If |error_description| is not null it may be set to contain a brief | 100 // If |error_description| is not null it may be set to contain a brief |
105 // message describing the error that has occurred. | 101 // message describing the error that has occurred. |
106 // Either of the out parameters may be not written to in certain cases | 102 // Either of the out parameters may be not written to in certain cases |
107 // (lack of information on the error code) so the caller should take care to | 103 // (lack of information on the error code) so the caller should take care to |
108 // initialize the string values with safe defaults before the call. | 104 // initialize the string values with safe defaults before the call. |
109 virtual void GetNavigationErrorStrings( | 105 virtual void GetNavigationErrorStrings( |
110 const WebKit::WebURLRequest& failed_request, | 106 const WebKit::WebURLRequest& failed_request, |
111 const WebKit::WebURLError& error, | 107 const WebKit::WebURLError& error, |
112 std::string* error_html, | 108 std::string* error_html, |
113 string16* error_description) = 0; | 109 string16* error_description) {} |
114 | 110 |
115 // Allows embedder to override creating a WebMediaPlayerImpl. If it returns | 111 // Allows embedder to override creating a WebMediaPlayerImpl. If it returns |
116 // NULL the content layer will create the media player. | 112 // NULL the content layer will create the media player. |
117 virtual webkit_media::WebMediaPlayerImpl* OverrideCreateWebMediaPlayer( | 113 virtual webkit_media::WebMediaPlayerImpl* OverrideCreateWebMediaPlayer( |
118 RenderView* render_view, | 114 RenderView* render_view, |
119 WebKit::WebFrame* frame, | 115 WebKit::WebFrame* frame, |
120 WebKit::WebMediaPlayerClient* client, | 116 WebKit::WebMediaPlayerClient* client, |
121 base::WeakPtr<webkit_media::WebMediaPlayerDelegate> delegate, | 117 base::WeakPtr<webkit_media::WebMediaPlayerDelegate> delegate, |
122 media::FilterCollection* collection, | 118 media::FilterCollection* collection, |
123 WebKit::WebAudioSourceProvider* audio_source_provider, | 119 WebKit::WebAudioSourceProvider* audio_source_provider, |
124 media::MessageLoopFactory* message_loop_factory, | 120 media::MessageLoopFactory* message_loop_factory, |
125 webkit_media::MediaStreamClient* media_stream_client, | 121 webkit_media::MediaStreamClient* media_stream_client, |
126 media::MediaLog* media_log) = 0; | 122 media::MediaLog* media_log); |
127 | 123 |
128 // Returns true if the renderer process should schedule the idle handler when | 124 // Returns true if the renderer process should schedule the idle handler when |
129 // all widgets are hidden. | 125 // all widgets are hidden. |
130 virtual bool RunIdleHandlerWhenWidgetsHidden() = 0; | 126 virtual bool RunIdleHandlerWhenWidgetsHidden(); |
131 | 127 |
132 // Returns true if the given url can create popup windows. | 128 // Returns true if the given url can create popup windows. |
133 virtual bool AllowPopup(const GURL& creator) = 0; | 129 virtual bool AllowPopup(const GURL& creator); |
134 | 130 |
135 // Returns true if we should fork a new process for the given navigation. | 131 // Returns true if we should fork a new process for the given navigation. |
136 virtual bool ShouldFork(WebKit::WebFrame* frame, | 132 virtual bool ShouldFork(WebKit::WebFrame* frame, |
137 const GURL& url, | 133 const GURL& url, |
138 bool is_initial_navigation, | 134 bool is_initial_navigation, |
139 bool* send_referrer) = 0; | 135 bool* send_referrer); |
140 | 136 |
141 // Notifies the embedder that the given frame is requesting the resource at | 137 // Notifies the embedder that the given frame is requesting the resource at |
142 // |url|. If the function returns true, the url is changed to |new_url|. | 138 // |url|. If the function returns true, the url is changed to |new_url|. |
143 virtual bool WillSendRequest(WebKit::WebFrame* frame, | 139 virtual bool WillSendRequest(WebKit::WebFrame* frame, |
144 const GURL& url, | 140 const GURL& url, |
145 GURL* new_url) = 0; | 141 GURL* new_url); |
146 | 142 |
147 // Whether to pump events when sending sync cookie messages. Needed if the | 143 // Whether to pump events when sending sync cookie messages. Needed if the |
148 // embedder can potentiall put up a modal dialog on the UI thread as a result. | 144 // embedder can potentiall put up a modal dialog on the UI thread as a result. |
149 virtual bool ShouldPumpEventsDuringCookieMessage() = 0; | 145 virtual bool ShouldPumpEventsDuringCookieMessage(); |
150 | 146 |
151 // See the corresponding functions in WebKit::WebFrameClient. | 147 // See the corresponding functions in WebKit::WebFrameClient. |
152 virtual void DidCreateScriptContext(WebKit::WebFrame* frame, | 148 virtual void DidCreateScriptContext(WebKit::WebFrame* frame, |
153 v8::Handle<v8::Context> context, | 149 v8::Handle<v8::Context> context, |
154 int extension_group, | 150 int extension_group, |
155 int world_id) = 0; | 151 int world_id) {} |
156 virtual void WillReleaseScriptContext(WebKit::WebFrame* frame, | 152 virtual void WillReleaseScriptContext(WebKit::WebFrame* frame, |
157 v8::Handle<v8::Context>, | 153 v8::Handle<v8::Context>, |
158 int world_id) = 0; | 154 int world_id) {} |
159 | 155 |
160 // See WebKit::WebKitPlatformSupport. | 156 // See WebKit::WebKitPlatformSupport. |
161 virtual unsigned long long VisitedLinkHash(const char* canonical_url, | 157 virtual unsigned long long VisitedLinkHash(const char* canonical_url, |
162 size_t length) = 0; | 158 size_t length); |
163 virtual bool IsLinkVisited(unsigned long long link_hash) = 0; | 159 virtual bool IsLinkVisited(unsigned long long link_hash); |
164 virtual void PrefetchHostName(const char* hostname, size_t length) = 0; | 160 virtual void PrefetchHostName(const char* hostname, size_t length) {} |
165 virtual bool ShouldOverridePageVisibilityState( | 161 virtual bool ShouldOverridePageVisibilityState( |
166 const RenderView* render_view, | 162 const RenderView* render_view, |
167 WebKit::WebPageVisibilityState* override_state) const = 0; | 163 WebKit::WebPageVisibilityState* override_state) const; |
168 | 164 |
169 // Return true if the GetCookie request will be handled by the embedder. | 165 // Return true if the GetCookie request will be handled by the embedder. |
170 // Cookies are returned in the cookie parameter. | 166 // Cookies are returned in the cookie parameter. |
171 virtual bool HandleGetCookieRequest(RenderView* sender, | 167 virtual bool HandleGetCookieRequest(RenderView* sender, |
172 const GURL& url, | 168 const GURL& url, |
173 const GURL& first_party_for_cookies, | 169 const GURL& first_party_for_cookies, |
174 std::string* cookies) = 0; | 170 std::string* cookies); |
175 | 171 |
176 // Return true if the SetCookie request will be handled by the embedder. | 172 // Return true if the SetCookie request will be handled by the embedder. |
177 // Cookies to be set are passed in the value parameter. | 173 // Cookies to be set are passed in the value parameter. |
178 virtual bool HandleSetCookieRequest(RenderView* sender, | 174 virtual bool HandleSetCookieRequest(RenderView* sender, |
179 const GURL& url, | 175 const GURL& url, |
180 const GURL& first_party_for_cookies, | 176 const GURL& first_party_for_cookies, |
181 const std::string& value) = 0; | 177 const std::string& value); |
182 | 178 |
183 virtual void RegisterPPAPIInterfaceFactories( | 179 virtual void RegisterPPAPIInterfaceFactories( |
184 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) = 0; | 180 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) {} |
185 }; | 181 }; |
186 | 182 |
187 } // namespace content | 183 } // namespace content |
188 | 184 |
189 #endif // CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ | 185 #endif // CONTENT_PUBLIC_RENDERER_CONTENT_RENDERER_CLIENT_H_ |
OLD | NEW |