OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CONTA
INER_H_ | 5 #ifndef EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CONTA
INER_H_ |
6 #define EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CONTA
INER_H_ | 6 #define EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CONTA
INER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "components/guest_view/renderer/guest_view_container.h" | 15 #include "components/guest_view/renderer/guest_view_container.h" |
16 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 16 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderClient.h" |
17 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | |
18 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
19 #include "url/gurl.h" | 18 #include "url/gurl.h" |
20 #include "v8/include/v8.h" | 19 #include "v8/include/v8.h" |
21 | 20 |
| 21 namespace blink { |
| 22 class WebAssociatedURLLoader; |
| 23 } // namespace blink |
| 24 |
22 namespace extensions { | 25 namespace extensions { |
23 | 26 |
24 // A container for loading up an extension inside a BrowserPlugin to handle a | 27 // A container for loading up an extension inside a BrowserPlugin to handle a |
25 // MIME type. A request for the URL of the data to load inside the container is | 28 // MIME type. A request for the URL of the data to load inside the container is |
26 // made and a url is sent back in response which points to the URL which the | 29 // made and a url is sent back in response which points to the URL which the |
27 // container should be navigated to. There are two cases for making this URL | 30 // container should be navigated to. There are two cases for making this URL |
28 // request, the case where the plugin is embedded and the case where it is top | 31 // request, the case where the plugin is embedded and the case where it is top |
29 // level: | 32 // level: |
30 // 1) In the top level case a URL request for the data to load has already been | 33 // 1) In the top level case a URL request for the data to load has already been |
31 // made by the renderer on behalf of the plugin. The |DidReceiveData| and | 34 // made by the renderer on behalf of the plugin. The |DidReceiveData| and |
32 // |DidFinishLoading| callbacks (from BrowserPluginDelegate) will be called | 35 // |DidFinishLoading| callbacks (from BrowserPluginDelegate) will be called |
33 // when data is received and when it has finished being received, | 36 // when data is received and when it has finished being received, |
34 // respectively. | 37 // respectively. |
35 // 2) In the embedded case, no URL request is automatically made by the | 38 // 2) In the embedded case, no URL request is automatically made by the |
36 // renderer. We make a URL request for the data inside the container using | 39 // renderer. We make a URL request for the data inside the container using |
37 // a WebURLLoader. In this case, the |didReceiveData| and |didFinishLoading| | 40 // a WebAssociatedURLLoader. In this case, the |didReceiveData| and |
38 // (from WebURLLoaderClient) when data is received and when it has finished | 41 // |didFinishLoading| (from WebAssociatedURLLoaderClient) when data is |
39 // being received. | 42 // received and when it has finished being received. |
40 class MimeHandlerViewContainer : public guest_view::GuestViewContainer, | 43 class MimeHandlerViewContainer : public guest_view::GuestViewContainer, |
41 public blink::WebURLLoaderClient { | 44 public blink::WebAssociatedURLLoaderClient { |
42 public: | 45 public: |
43 MimeHandlerViewContainer(content::RenderFrame* render_frame, | 46 MimeHandlerViewContainer(content::RenderFrame* render_frame, |
44 const std::string& mime_type, | 47 const std::string& mime_type, |
45 const GURL& original_url); | 48 const GURL& original_url); |
46 | 49 |
47 static std::vector<MimeHandlerViewContainer*> FromRenderFrame( | 50 static std::vector<MimeHandlerViewContainer*> FromRenderFrame( |
48 content::RenderFrame* render_frame); | 51 content::RenderFrame* render_frame); |
49 | 52 |
50 // GuestViewContainer implementation. | 53 // GuestViewContainer implementation. |
51 bool OnMessage(const IPC::Message& message) override; | 54 bool OnMessage(const IPC::Message& message) override; |
52 void OnReady() override; | 55 void OnReady() override; |
53 | 56 |
54 // BrowserPluginDelegate implementation. | 57 // BrowserPluginDelegate implementation. |
55 void DidFinishLoading() override; | 58 void DidFinishLoading() override; |
56 void DidReceiveData(const char* data, int data_length) override; | 59 void DidReceiveData(const char* data, int data_length) override; |
57 void DidResizeElement(const gfx::Size& new_size) override; | 60 void DidResizeElement(const gfx::Size& new_size) override; |
58 v8::Local<v8::Object> V8ScriptableObject(v8::Isolate*) override; | 61 v8::Local<v8::Object> V8ScriptableObject(v8::Isolate*) override; |
59 | 62 |
60 // WebURLLoaderClient overrides. | 63 // WebAssociatedURLLoaderClient overrides. |
61 void didReceiveData(blink::WebURLLoader* loader, | 64 void didReceiveData(const char* data, int data_length) override; |
62 const char* data, | 65 void didFinishLoading(double finish_time) override; |
63 int data_length, | |
64 int encoded_data_length, | |
65 int encoded_body_length) override; | |
66 void didFinishLoading(blink::WebURLLoader* loader, | |
67 double finish_time, | |
68 int64_t total_encoded_data_length) override; | |
69 | 66 |
70 // GuestViewContainer overrides. | 67 // GuestViewContainer overrides. |
71 void OnRenderFrameDestroyed() override; | 68 void OnRenderFrameDestroyed() override; |
72 | 69 |
73 // Post a JavaScript message to the guest. | 70 // Post a JavaScript message to the guest. |
74 void PostMessage(v8::Isolate* isolate, v8::Local<v8::Value> message); | 71 void PostMessage(v8::Isolate* isolate, v8::Local<v8::Value> message); |
75 | 72 |
76 // Post |message| to the guest. | 73 // Post |message| to the guest. |
77 void PostMessageFromValue(const base::Value& message); | 74 void PostMessageFromValue(const base::Value& message); |
78 | 75 |
(...skipping 19 matching lines...) Expand all Loading... |
98 bool is_embedded_; | 95 bool is_embedded_; |
99 | 96 |
100 // The original URL of the plugin. | 97 // The original URL of the plugin. |
101 GURL original_url_; | 98 GURL original_url_; |
102 | 99 |
103 // The RenderView routing ID of the guest. | 100 // The RenderView routing ID of the guest. |
104 int guest_proxy_routing_id_; | 101 int guest_proxy_routing_id_; |
105 | 102 |
106 // A URL loader to load the |original_url_| when the plugin is embedded. In | 103 // A URL loader to load the |original_url_| when the plugin is embedded. In |
107 // the embedded case, no URL request is made automatically. | 104 // the embedded case, no URL request is made automatically. |
108 std::unique_ptr<blink::WebURLLoader> loader_; | 105 std::unique_ptr<blink::WebAssociatedURLLoader> loader_; |
109 | 106 |
110 // The scriptable object that backs the plugin. | 107 // The scriptable object that backs the plugin. |
111 v8::Global<v8::Object> scriptable_object_; | 108 v8::Global<v8::Object> scriptable_object_; |
112 | 109 |
113 // Pending postMessage messages that need to be sent to the guest. These are | 110 // Pending postMessage messages that need to be sent to the guest. These are |
114 // queued while the guest is loading and once it is fully loaded they are | 111 // queued while the guest is loading and once it is fully loaded they are |
115 // delivered so that messages aren't lost. | 112 // delivered so that messages aren't lost. |
116 std::vector<v8::Global<v8::Value>> pending_messages_; | 113 std::vector<v8::Global<v8::Value>> pending_messages_; |
117 | 114 |
118 // True if the guest page has fully loaded and its JavaScript onload function | 115 // True if the guest page has fully loaded and its JavaScript onload function |
119 // has been called. | 116 // has been called. |
120 bool guest_loaded_; | 117 bool guest_loaded_; |
121 | 118 |
122 // The size of the element. | 119 // The size of the element. |
123 gfx::Size element_size_; | 120 gfx::Size element_size_; |
124 | 121 |
125 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; | 122 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; |
126 | 123 |
127 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); | 124 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); |
128 }; | 125 }; |
129 | 126 |
130 } // namespace extensions | 127 } // namespace extensions |
131 | 128 |
132 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CO
NTAINER_H_ | 129 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_CO
NTAINER_H_ |
OLD | NEW |