| 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_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const blink::WebRect& clip_rect, | 79 const blink::WebRect& clip_rect, |
| 80 const blink::WebRect& unobscured_rect, | 80 const blink::WebRect& unobscured_rect, |
| 81 const blink::WebVector<blink::WebRect>& cut_outs_rects, | 81 const blink::WebVector<blink::WebRect>& cut_outs_rects, |
| 82 bool is_visible) override; | 82 bool is_visible) override; |
| 83 void updateFocus(bool focused, blink::WebFocusType focus_type) override; | 83 void updateFocus(bool focused, blink::WebFocusType focus_type) override; |
| 84 void updateVisibility(bool visible) override; | 84 void updateVisibility(bool visible) override; |
| 85 bool acceptsInputEvents() override; | 85 bool acceptsInputEvents() override; |
| 86 blink::WebInputEventResult handleInputEvent( | 86 blink::WebInputEventResult handleInputEvent( |
| 87 const blink::WebInputEvent& event, | 87 const blink::WebInputEvent& event, |
| 88 blink::WebCursorInfo& cursor_info) override; | 88 blink::WebCursorInfo& cursor_info) override; |
| 89 void didReceiveResponse(const blink::WebURLResponse& response) override; | 89 void didReceiveResponse(const blink::WebURLResponse& response) override {} |
| 90 void didReceiveData(const char* data, int data_length) override; | 90 void didReceiveData(const char* data, int data_length) override {} |
| 91 void didFinishLoading() override; | 91 void didFinishLoading() override {} |
| 92 void didFailLoading(const blink::WebURLError& error) override; | 92 void didFailLoading(const blink::WebURLError& error) override {} |
| 93 void didFinishLoadingFrameRequest(const blink::WebURL& url, | |
| 94 void* notify_data) override; | |
| 95 void didFailLoadingFrameRequest(const blink::WebURL& url, | |
| 96 void* notify_data, | |
| 97 const blink::WebURLError& error) override; | |
| 98 bool isPlaceholder() override; | 93 bool isPlaceholder() override; |
| 99 | 94 |
| 100 // WebPlugin implementation: | 95 // WebPlugin implementation: |
| 101 void SetWindow(gfx::PluginWindowHandle window) override; | 96 void SetWindow(gfx::PluginWindowHandle window) override; |
| 102 void SetAcceptsInputEvents(bool accepts) override; | 97 void SetAcceptsInputEvents(bool accepts) override; |
| 103 void WillDestroyWindow(gfx::PluginWindowHandle window) override; | 98 void WillDestroyWindow(gfx::PluginWindowHandle window) override; |
| 104 void CancelResource(unsigned long id) override; | 99 void CancelResource(unsigned long id) override; |
| 105 void Invalidate() override; | 100 void Invalidate() override; |
| 106 void InvalidateRect(const gfx::Rect& rect) override; | 101 void InvalidateRect(const gfx::Rect& rect) override; |
| 107 NPObject* GetWindowScriptNPObject() override; | 102 NPObject* GetWindowScriptNPObject() override; |
| 108 NPObject* GetPluginElement() override; | 103 NPObject* GetPluginElement() override; |
| 109 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) override; | 104 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) override; |
| 110 void SetCookie(const GURL& url, | 105 void SetCookie(const GURL& url, |
| 111 const GURL& first_party_for_cookies, | 106 const GURL& first_party_for_cookies, |
| 112 const std::string& cookie) override; | 107 const std::string& cookie) override; |
| 113 std::string GetCookies(const GURL& url, | 108 std::string GetCookies(const GURL& url, |
| 114 const GURL& first_party_for_cookies) override; | 109 const GURL& first_party_for_cookies) override; |
| 115 void HandleURLRequest(const char* url, | |
| 116 const char* method, | |
| 117 const char* target, | |
| 118 const char* buf, | |
| 119 unsigned int len, | |
| 120 int notify_id, | |
| 121 bool popups_allowed, | |
| 122 bool notify_redirects) override; | |
| 123 void CancelDocumentLoad() override; | 110 void CancelDocumentLoad() override; |
| 124 void InitiateHTTPRangeRequest(const char* url, | |
| 125 const char* range_info, | |
| 126 int pending_request_id) override; | |
| 127 void DidStartLoading() override; | 111 void DidStartLoading() override; |
| 128 void DidStopLoading() override; | 112 void DidStopLoading() override; |
| 129 bool IsOffTheRecord() override; | 113 bool IsOffTheRecord() override; |
| 130 void SetDeferResourceLoading(unsigned long resource_id, bool defer) override; | 114 void SetDeferResourceLoading(unsigned long resource_id, bool defer) override; |
| 131 void URLRedirectResponse(bool allow, int resource_id) override; | 115 void URLRedirectResponse(bool allow, int resource_id) override; |
| 132 bool CheckIfRunInsecureContent(const GURL& url) override; | 116 bool CheckIfRunInsecureContent(const GURL& url) override; |
| 133 #if defined(OS_WIN) | 117 #if defined(OS_WIN) |
| 134 void SetWindowlessData(HANDLE pump_messages_event, | 118 void SetWindowlessData(HANDLE pump_messages_event, |
| 135 gfx::NativeViewId dummy_activation_window) override {} | 119 gfx::NativeViewId dummy_activation_window) override {} |
| 136 void ReparentPluginWindow(HWND window, HWND parent) { } | 120 void ReparentPluginWindow(HWND window, HWND parent) { } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // Given a download request, check if we need to route the output to a frame. | 152 // Given a download request, check if we need to route the output to a frame. |
| 169 // Returns ROUTED if the load is done and routed to a frame, NOT_ROUTED or | 153 // Returns ROUTED if the load is done and routed to a frame, NOT_ROUTED or |
| 170 // corresponding error codes otherwise. | 154 // corresponding error codes otherwise. |
| 171 RoutingStatus RouteToFrame(const char* url, | 155 RoutingStatus RouteToFrame(const char* url, |
| 172 bool is_javascript_url, | 156 bool is_javascript_url, |
| 173 bool popups_allowed, | 157 bool popups_allowed, |
| 174 const char* method, | 158 const char* method, |
| 175 const char* target, | 159 const char* target, |
| 176 const char* buf, | 160 const char* buf, |
| 177 unsigned int len, | 161 unsigned int len, |
| 178 int notify_id, | |
| 179 ReferrerValue referrer_flag); | 162 ReferrerValue referrer_flag); |
| 180 | 163 |
| 181 // Returns the next avaiable resource id. Returns 0 if the operation fails. | 164 // Returns the next avaiable resource id. Returns 0 if the operation fails. |
| 182 // It may fail if the page has already been closed. | 165 // It may fail if the page has already been closed. |
| 183 unsigned long GetNextResourceId(); | 166 unsigned long GetNextResourceId(); |
| 184 | 167 |
| 185 // Initiates HTTP GET/POST requests. | |
| 186 // Returns true on success. | |
| 187 bool InitiateHTTPRequest(unsigned long resource_id, | |
| 188 WebPluginResourceClient* client, | |
| 189 const GURL& url, | |
| 190 const char* method, | |
| 191 const char* buf, | |
| 192 int len, | |
| 193 const char* range_info, | |
| 194 ReferrerValue referrer_flag, | |
| 195 bool notify_redirects, | |
| 196 bool check_mixed_scripting); | |
| 197 | |
| 198 gfx::Rect GetWindowClipRect(const gfx::Rect& rect); | 168 gfx::Rect GetWindowClipRect(const gfx::Rect& rect); |
| 199 | 169 |
| 200 // Sets the actual Widget for the plugin. | 170 // Sets the actual Widget for the plugin. |
| 201 void SetContainer(blink::WebPluginContainer* container); | 171 void SetContainer(blink::WebPluginContainer* container); |
| 202 | 172 |
| 203 // Destroys the plugin instance. | 173 // Destroys the plugin instance. |
| 204 // The response_handle_to_ignore parameter if not NULL indicates the | 174 // The response_handle_to_ignore parameter if not NULL indicates the |
| 205 // resource handle to be left valid during plugin shutdown. | 175 // resource handle to be left valid during plugin shutdown. |
| 206 void TearDownPluginInstance(blink::WebURLLoader* loader_to_ignore); | 176 void TearDownPluginInstance(blink::WebURLLoader* loader_to_ignore); |
| 207 | 177 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 232 // request given a handle. | 202 // request given a handle. |
| 233 void RemoveClient(blink::WebURLLoader* loader); | 203 void RemoveClient(blink::WebURLLoader* loader); |
| 234 | 204 |
| 235 // Handles HTTP multipart responses, i.e. responses received with a HTTP | 205 // Handles HTTP multipart responses, i.e. responses received with a HTTP |
| 236 // status code of 206. | 206 // status code of 206. |
| 237 // Returns false if response is not multipart (may be if we requested | 207 // Returns false if response is not multipart (may be if we requested |
| 238 // single range). | 208 // single range). |
| 239 bool HandleHttpMultipartResponse(const blink::WebURLResponse& response, | 209 bool HandleHttpMultipartResponse(const blink::WebURLResponse& response, |
| 240 WebPluginResourceClient* client); | 210 WebPluginResourceClient* client); |
| 241 | 211 |
| 242 void HandleURLRequestInternal(const char* url, | |
| 243 const char* method, | |
| 244 const char* target, | |
| 245 const char* buf, | |
| 246 unsigned int len, | |
| 247 int notify_id, | |
| 248 bool popups_allowed, | |
| 249 ReferrerValue referrer_flag, | |
| 250 bool notify_redirects, | |
| 251 bool check_mixed_scripting); | |
| 252 | |
| 253 // Tears down the existing plugin instance and creates a new plugin instance | 212 // Tears down the existing plugin instance and creates a new plugin instance |
| 254 // to handle the response identified by the loader parameter. | 213 // to handle the response identified by the loader parameter. |
| 255 bool ReinitializePluginForResponse(blink::WebURLLoader* loader); | 214 bool ReinitializePluginForResponse(blink::WebURLLoader* loader); |
| 256 | 215 |
| 257 // Delayed task for downloading the plugin source URL. | |
| 258 void OnDownloadPluginSrcUrl(); | |
| 259 | |
| 260 struct ClientInfo; | 216 struct ClientInfo; |
| 261 | 217 |
| 262 // Helper functions | 218 // Helper functions |
| 263 WebPluginResourceClient* GetClientFromLoader(blink::WebURLLoader* loader); | 219 WebPluginResourceClient* GetClientFromLoader(blink::WebURLLoader* loader); |
| 264 ClientInfo* GetClientInfoFromLoader(blink::WebURLLoader* loader); | 220 ClientInfo* GetClientInfoFromLoader(blink::WebURLLoader* loader); |
| 265 | 221 |
| 266 // Helper function to set the referrer on the request passed in. | 222 // Helper function to set the referrer on the request passed in. |
| 267 void SetReferrer(blink::WebURLRequest* request, ReferrerValue referrer_flag); | 223 void SetReferrer(blink::WebURLRequest* request, ReferrerValue referrer_flag); |
| 268 | 224 |
| 269 // Check for invalid chars like @, ;, \ before the first / (in path). | 225 // Check for invalid chars like @, ;, \ before the first / (in path). |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 double finishTime, | 308 double finishTime, |
| 353 int64_t total_encoded_data_length) override; | 309 int64_t total_encoded_data_length) override; |
| 354 void didFail(blink::WebURLLoader*, const blink::WebURLError&) override; | 310 void didFail(blink::WebURLLoader*, const blink::WebURLError&) override; |
| 355 | 311 |
| 356 private: | 312 private: |
| 357 WebPluginImpl* parent_; | 313 WebPluginImpl* parent_; |
| 358 }; | 314 }; |
| 359 | 315 |
| 360 LoaderClient loader_client_; | 316 LoaderClient loader_client_; |
| 361 | 317 |
| 362 base::WeakPtrFactory<WebPluginImpl> weak_factory_; | |
| 363 | |
| 364 DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); | 318 DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); |
| 365 }; | 319 }; |
| 366 | 320 |
| 367 } // namespace content | 321 } // namespace content |
| 368 | 322 |
| 369 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 323 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| OLD | NEW |