Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h

Issue 729333002: Add PostMessage support for MimeHandlerView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/weak_ptr.h"
8 #include "extensions/renderer/guest_view/guest_view_container.h" 9 #include "extensions/renderer/guest_view/guest_view_container.h"
10 #include "extensions/renderer/scoped_persistent.h"
9 #include "third_party/WebKit/public/platform/WebURLLoader.h" 11 #include "third_party/WebKit/public/platform/WebURLLoader.h"
10 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 12 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
11 #include "url/gurl.h" 13 #include "url/gurl.h"
14 #include "v8/include/v8.h"
12 15
13 namespace extensions { 16 namespace extensions {
14 17
15 // A container for loading up an extension inside a BrowserPlugin to handle a 18 // A container for loading up an extension inside a BrowserPlugin to handle a
16 // MIME type. A request for the URL of the data to load inside the container is 19 // MIME type. A request for the URL of the data to load inside the container is
17 // made and a url is sent back in response which points to the URL which the 20 // made and a url is sent back in response which points to the URL which the
18 // container should be navigated to. There are two cases for making this URL 21 // container should be navigated to. There are two cases for making this URL
19 // request, the case where the plugin is embedded and the case where it is top 22 // request, the case where the plugin is embedded and the case where it is top
20 // level: 23 // level:
21 // 1) In the top level case a URL request for the data to load has already been 24 // 1) In the top level case a URL request for the data to load has already been
22 // made by the renderer on behalf of the plugin. The |DidReceiveData| and 25 // made by the renderer on behalf of the plugin. The |DidReceiveData| and
23 // |DidFinishLoading| callbacks (from BrowserPluginDelegate) will be called 26 // |DidFinishLoading| callbacks (from BrowserPluginDelegate) will be called
24 // when data is received and when it has finished being received, 27 // when data is received and when it has finished being received,
25 // respectively. 28 // respectively.
26 // 2) In the embedded case, no URL request is automatically made by the 29 // 2) In the embedded case, no URL request is automatically made by the
27 // renderer. We make a URL request for the data inside the container using 30 // renderer. We make a URL request for the data inside the container using
28 // a WebURLLoader. In this case, the |didReceiveData| and |didFinishLoading| 31 // a WebURLLoader. In this case, the |didReceiveData| and |didFinishLoading|
29 // (from WebURLLoaderClient) when data is received and when it has finished 32 // (from WebURLLoaderClient) when data is received and when it has finished
30 // being received. 33 // being received.
31 class MimeHandlerViewContainer : public GuestViewContainer, 34 class MimeHandlerViewContainer : public GuestViewContainer,
32 public blink::WebURLLoaderClient { 35 public blink::WebURLLoaderClient {
33 public: 36 public:
34 MimeHandlerViewContainer(content::RenderFrame* render_frame, 37 MimeHandlerViewContainer(content::RenderFrame* render_frame,
35 const std::string& mime_type, 38 const std::string& mime_type,
36 const GURL& original_url); 39 const GURL& original_url);
37 ~MimeHandlerViewContainer() override; 40 ~MimeHandlerViewContainer() override;
38 41
39 // BrowserPluginDelegate implementation. 42 // BrowserPluginDelegate implementation.
43 void Ready() override;
40 void DidFinishLoading() override; 44 void DidFinishLoading() override;
41 void DidReceiveData(const char* data, int data_length) override; 45 void DidReceiveData(const char* data, int data_length) override;
42 void Ready() override; 46 v8::Local<v8::Object> v8ScriptableObject(v8::Isolate*) override;
43 47
44 // GuestViewContainer overrides. 48 // GuestViewContainer overrides.
45 bool HandlesMessage(const IPC::Message& message) override; 49 bool HandlesMessage(const IPC::Message& message) override;
46 bool OnMessage(const IPC::Message& message) override; 50 bool OnMessage(const IPC::Message& message) override;
47 51
48 // WebURLLoaderClient overrides. 52 // WebURLLoaderClient overrides.
49 void didReceiveData(blink::WebURLLoader* loader, 53 void didReceiveData(blink::WebURLLoader* loader,
50 const char* data, 54 const char* data,
51 int data_length, 55 int data_length,
52 int encoded_data_length) override; 56 int encoded_data_length) override;
53 void didFinishLoading(blink::WebURLLoader* loader, 57 void didFinishLoading(blink::WebURLLoader* loader,
54 double finish_time, 58 double finish_time,
55 int64_t total_encoded_data_length) override; 59 int64_t total_encoded_data_length) override;
56 60
61 // Post a JavaScript message to the guest.
62 void PostMessage(v8::Isolate* isolate,
63 v8::Handle<v8::Value> message);
64
57 private: 65 private:
58 // Message handlers. 66 // Message handlers.
59 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); 67 void OnCreateMimeHandlerViewGuestACK(int element_instance_id);
68 void OnGuestAttached(int element_instance_id,
69 int guest_proxy_routing_id);
60 70
61 void CreateMimeHandlerViewGuest(); 71 void CreateMimeHandlerViewGuest();
62 72
63 // The MIME type of the plugin. 73 // The MIME type of the plugin.
64 const std::string mime_type_; 74 const std::string mime_type_;
65 75
66 // The URL of the extension to navigate to. 76 // The URL of the extension to navigate to.
67 std::string html_string_; 77 std::string html_string_;
68 78
69 // Whether the plugin is embedded or not. 79 // Whether the plugin is embedded or not.
70 bool is_embedded_; 80 bool is_embedded_;
71 81
72 // The original URL of the plugin. 82 // The original URL of the plugin.
73 GURL original_url_; 83 GURL original_url_;
74 84
85 // Save the RenderView RoutingID of the guest here so it can be used to route
Sam McNally 2014/12/18 05:36:47 This comment should be where the routing ID is sav
raymes 2014/12/19 00:00:16 Done.
raymes 2014/12/19 00:00:16 Done.
86 // PostMessage calls.
87 int guest_proxy_routing_id_;
88
75 // A URL loader to load the |original_url_| when the plugin is embedded. In 89 // A URL loader to load the |original_url_| when the plugin is embedded. In
76 // the embedded case, no URL request is made automatically. 90 // the embedded case, no URL request is made automatically.
77 scoped_ptr<blink::WebURLLoader> loader_; 91 scoped_ptr<blink::WebURLLoader> loader_;
78 92
93 // The scriptable object that backs the plugin.
94 ScopedPersistent<v8::Object> scriptable_object_;
95
96 base::WeakPtrFactory<MimeHandlerViewContainer> weak_factory_;
97
79 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); 98 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer);
80 }; 99 };
81 100
82 } // namespace extensions 101 } // namespace extensions
83 102
84 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ 103 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698