| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 double finish_time, | 59 double finish_time, |
| 59 int64_t total_encoded_data_length) override; | 60 int64_t total_encoded_data_length) override; |
| 60 | 61 |
| 61 // Post a JavaScript message to the guest. | 62 // Post a JavaScript message to the guest. |
| 62 void PostMessage(v8::Isolate* isolate, | 63 void PostMessage(v8::Isolate* isolate, |
| 63 v8::Handle<v8::Value> message); | 64 v8::Handle<v8::Value> message); |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 // Message handlers. | 67 // Message handlers. |
| 67 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); | 68 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); |
| 69 void OnMimeHandlerViewGuestOnLoadCompleted(int element_instance_id); |
| 68 void OnGuestAttached(int element_instance_id, | 70 void OnGuestAttached(int element_instance_id, |
| 69 int guest_proxy_routing_id); | 71 int guest_proxy_routing_id); |
| 70 | 72 |
| 71 void CreateMimeHandlerViewGuest(); | 73 void CreateMimeHandlerViewGuest(); |
| 72 | 74 |
| 73 // The MIME type of the plugin. | 75 // The MIME type of the plugin. |
| 74 const std::string mime_type_; | 76 const std::string mime_type_; |
| 75 | 77 |
| 76 // The URL of the extension to navigate to. | 78 // The URL of the extension to navigate to. |
| 77 std::string html_string_; | 79 std::string html_string_; |
| 78 | 80 |
| 79 // Whether the plugin is embedded or not. | 81 // Whether the plugin is embedded or not. |
| 80 bool is_embedded_; | 82 bool is_embedded_; |
| 81 | 83 |
| 82 // The original URL of the plugin. | 84 // The original URL of the plugin. |
| 83 GURL original_url_; | 85 GURL original_url_; |
| 84 | 86 |
| 85 // Save the RenderView RoutingID of the guest here so it can be used to route | 87 // Save the RenderView RoutingID of the guest here so it can be used to route |
| 86 // PostMessage calls. | 88 // PostMessage calls. |
| 87 int guest_proxy_routing_id_; | 89 int guest_proxy_routing_id_; |
| 88 | 90 |
| 89 // A URL loader to load the |original_url_| when the plugin is embedded. In | 91 // A URL loader to load the |original_url_| when the plugin is embedded. In |
| 90 // the embedded case, no URL request is made automatically. | 92 // the embedded case, no URL request is made automatically. |
| 91 scoped_ptr<blink::WebURLLoader> loader_; | 93 scoped_ptr<blink::WebURLLoader> loader_; |
| 92 | 94 |
| 93 // The scriptable object that backs the plugin. | 95 // The scriptable object that backs the plugin. |
| 94 ScopedPersistent<v8::Object> scriptable_object_; | 96 ScopedPersistent<v8::Object> scriptable_object_; |
| 95 | 97 |
| 98 // Pending postMessage messages that need to be sent to the guest. These are |
| 99 // queued while the guest is loading and once it is fully loaded they are |
| 100 // delivered so that messages aren't lost. |
| 101 std::vector<linked_ptr<ScopedPersistent<v8::Value>>> pending_messages_; |
| 102 |
| 103 // True if the guest page has fully loaded and its JavaScript onload function |
| 104 // has been called. |
| 105 bool guest_loaded_; |
| 106 |
| 96 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; | 107 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_; |
| 97 | 108 |
| 98 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); | 109 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); |
| 99 }; | 110 }; |
| 100 | 111 |
| 101 } // namespace extensions | 112 } // namespace extensions |
| 102 | 113 |
| 103 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ | 114 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ |
| OLD | NEW |