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_CONTAINER_H_ | 5 #ifndef EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ |
6 #define EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ | 6 #define EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ |
7 | 7 |
| 8 #include "base/memory/linked_ptr.h" |
8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
9 #include "extensions/renderer/guest_view/guest_view_container.h" | 10 #include "extensions/renderer/guest_view/guest_view_container.h" |
10 #include "extensions/renderer/scoped_persistent.h" | 11 #include "extensions/renderer/scoped_persistent.h" |
11 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 12 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
12 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 13 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
15 | 16 |
16 namespace extensions { | 17 namespace extensions { |
17 | 18 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 double finish_time, | 56 double finish_time, |
56 int64_t total_encoded_data_length) override; | 57 int64_t total_encoded_data_length) override; |
57 | 58 |
58 // Post a JavaScript message to the guest. | 59 // Post a JavaScript message to the guest. |
59 void PostMessage(v8::Isolate* isolate, | 60 void PostMessage(v8::Isolate* isolate, |
60 v8::Handle<v8::Value> message); | 61 v8::Handle<v8::Value> message); |
61 | 62 |
62 private: | 63 private: |
63 // Message handlers. | 64 // Message handlers. |
64 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 65 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); |
| 66 void OnMimeHandlerViewGuestOnLoadCompleted(int element_instance_id); |
65 void OnGuestAttached(int element_instance_id, | 67 void OnGuestAttached(int element_instance_id, |
66 int guest_proxy_routing_id); | 68 int guest_proxy_routing_id); |
67 | 69 |
68 void CreateMimeHandlerViewGuest(); | 70 void CreateMimeHandlerViewGuest(); |
69 | 71 |
70 // The MIME type of the plugin. | 72 // The MIME type of the plugin. |
71 const std::string mime_type_; | 73 const std::string mime_type_; |
72 | 74 |
73 // The URL of the extension to navigate to. | 75 // The URL of the extension to navigate to. |
74 std::string html_string_; | 76 std::string html_string_; |
75 | 77 |
76 // Whether the plugin is embedded or not. | 78 // Whether the plugin is embedded or not. |
77 bool is_embedded_; | 79 bool is_embedded_; |
78 | 80 |
79 // The original URL of the plugin. | 81 // The original URL of the plugin. |
80 GURL original_url_; | 82 GURL original_url_; |
81 | 83 |
82 // The RenderView routing ID of the guest. | 84 // The RenderView routing ID of the guest. |
83 int guest_proxy_routing_id_; | 85 int guest_proxy_routing_id_; |
84 | 86 |
85 // A URL loader to load the |original_url_| when the plugin is embedded. In | 87 // A URL loader to load the |original_url_| when the plugin is embedded. In |
86 // the embedded case, no URL request is made automatically. | 88 // the embedded case, no URL request is made automatically. |
87 scoped_ptr<blink::WebURLLoader> loader_; | 89 scoped_ptr<blink::WebURLLoader> loader_; |
88 | 90 |
89 // The scriptable object that backs the plugin. | 91 // The scriptable object that backs the plugin. |
90 ScopedPersistent<v8::Object> scriptable_object_; | 92 ScopedPersistent<v8::Object> scriptable_object_; |
91 | 93 |
| 94 // Pending postMessage messages that need to be sent to the guest. These are |
| 95 // queued while the guest is loading and once it is fully loaded they are |
| 96 // delivered so that messages aren't lost. |
| 97 std::vector<linked_ptr<ScopedPersistent<v8::Value>>> pending_messages_; |
| 98 |
| 99 // True if the guest page has fully loaded and its JavaScript onload function |
| 100 // has been called. |
| 101 bool guest_loaded_; |
| 102 |
92 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; | 103 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; |
93 | 104 |
94 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); | 105 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); |
95 }; | 106 }; |
96 | 107 |
97 } // namespace extensions | 108 } // namespace extensions |
98 | 109 |
99 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ | 110 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ |
OLD | NEW |