OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CONTENT_RENDERER_CONTENT_RENDERER_CLIENT_H_ | |
6 #define CONTENT_RENDERER_CONTENT_RENDERER_CLIENT_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/string16.h" | |
12 #include "ipc/ipc_message.h" | |
13 #include "content/common/content_client.h" | |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityStat
e.h" | |
15 | |
16 class FilePath; | |
17 class GURL; | |
18 class RenderView; | |
19 class SkBitmap; | |
20 | |
21 namespace WebKit { | |
22 class WebFrame; | |
23 class WebPlugin; | |
24 class WebURLRequest; | |
25 struct WebPluginParams; | |
26 struct WebURLError; | |
27 } | |
28 | |
29 namespace v8 { | |
30 class Context; | |
31 template<class T> class Handle; | |
32 } | |
33 | |
34 namespace content { | |
35 | |
36 // Embedder API for participating in renderer logic. | |
37 class ContentRendererClient { | |
38 public: | |
39 virtual ~ContentRendererClient() {} | |
40 | |
41 // Notifies us that the RenderThread has been created. | |
42 virtual void RenderThreadStarted() = 0; | |
43 | |
44 // Notifies that a new RenderView has been created. | |
45 virtual void RenderViewCreated(RenderView* render_view) = 0; | |
46 | |
47 // Sets a number of views/tabs opened in this process. | |
48 virtual void SetNumberOfViews(int number_of_views) = 0; | |
49 | |
50 // Returns the bitmap to show when a plugin crashed, or NULL for none. | |
51 virtual SkBitmap* GetSadPluginBitmap() = 0; | |
52 | |
53 // Returns the default text encoding. | |
54 virtual std::string GetDefaultEncoding() = 0; | |
55 | |
56 // Allows the embedder to override creating a plugin. If it returns true, then | |
57 // |plugin| will contain the created plugin, although it could be NULL. If it | |
58 // returns false, the content layer will create the plugin. | |
59 virtual bool OverrideCreatePlugin( | |
60 RenderView* render_view, | |
61 WebKit::WebFrame* frame, | |
62 const WebKit::WebPluginParams& params, | |
63 WebKit::WebPlugin** plugin) = 0; | |
64 | |
65 // Give the embedder the ability to set an error page. | |
66 virtual void ShowErrorPage(RenderView* render_view, | |
67 WebKit::WebFrame* frame, | |
68 int http_status_code) = 0; | |
69 | |
70 // Returns the html to display when a navigation error occurs. | |
71 virtual std::string GetNavigationErrorHtml( | |
72 const WebKit::WebURLRequest& failed_request, | |
73 const WebKit::WebURLError& error) = 0; | |
74 | |
75 // Returns true if the renderer process should schedule the idle handler when | |
76 // all widgets are hidden. | |
77 virtual bool RunIdleHandlerWhenWidgetsHidden() = 0; | |
78 | |
79 // Returns true if the given url can create popup windows. | |
80 virtual bool AllowPopup(const GURL& creator) = 0; | |
81 | |
82 // Returns true if we should fork a new process for the given navigation. | |
83 virtual bool ShouldFork(WebKit::WebFrame* frame, | |
84 const GURL& url, | |
85 bool is_content_initiated, | |
86 bool is_initial_navigation, | |
87 bool* send_referrer) = 0; | |
88 | |
89 // Notifies the embedder that the given frame is requesting the resource at | |
90 // |url|. If the function returns true, the url is changed to |new_url|. | |
91 virtual bool WillSendRequest(WebKit::WebFrame* frame, | |
92 const GURL& url, | |
93 GURL* new_url) = 0; | |
94 | |
95 // Whether to pump events when sending sync cookie messages. Needed if the | |
96 // embedder can potentiall put up a modal dialog on the UI thread as a result. | |
97 virtual bool ShouldPumpEventsDuringCookieMessage() = 0; | |
98 | |
99 // See the corresponding functions in WebKit::WebFrameClient. | |
100 virtual void DidCreateScriptContext(WebKit::WebFrame* frame, | |
101 v8::Handle<v8::Context> context, | |
102 int world_id) = 0; | |
103 virtual void WillReleaseScriptContext(WebKit::WebFrame* frame, | |
104 v8::Handle<v8::Context>, | |
105 int world_id) = 0; | |
106 | |
107 // See WebKit::WebKitPlatformSupport. | |
108 virtual unsigned long long VisitedLinkHash(const char* canonical_url, | |
109 size_t length) = 0; | |
110 virtual bool IsLinkVisited(unsigned long long link_hash) = 0; | |
111 virtual void PrefetchHostName(const char* hostname, size_t length) = 0; | |
112 virtual bool ShouldOverridePageVisibilityState( | |
113 const RenderView* render_view, | |
114 WebKit::WebPageVisibilityState* override_state) const = 0; | |
115 | |
116 // Return true if the GetCookie request will be handled by the embedder. | |
117 // Cookies are returned in the cookie parameter. | |
118 virtual bool HandleGetCookieRequest(RenderView* sender, | |
119 const GURL& url, | |
120 const GURL& first_party_for_cookies, | |
121 std::string* cookies) = 0; | |
122 | |
123 // Return true if the SetCookie request will be handled by the embedder. | |
124 // Cookies to be set are passed in the value parameter. | |
125 virtual bool HandleSetCookieRequest(RenderView* sender, | |
126 const GURL& url, | |
127 const GURL& first_party_for_cookies, | |
128 const std::string& value) = 0; | |
129 | |
130 // True if the protocol implemented to serve |url| supports features required | |
131 // by the media engine. | |
132 virtual bool IsProtocolSupportedForMedia(const GURL& url) = 0; | |
133 }; | |
134 | |
135 } // namespace content | |
136 | |
137 #endif // CONTENT_RENDERER_CONTENT_RENDERER_CLIENT_H_ | |
OLD | NEW |