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

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

Issue 701713003: Support embedded plugins with MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-guest-view-container
Patch Set: Created 6 years, 1 month 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 "extensions/renderer/guest_view/guest_view_container.h" 8 #include "extensions/renderer/guest_view/guest_view_container.h"
9 #include "third_party/WebKit/public/platform/WebURLLoader.h"
10 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
11 #include "url/gurl.h"
9 12
10 namespace extensions { 13 namespace extensions {
11 14
12 class MimeHandlerViewContainer : public GuestViewContainer { 15 // 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
17 // 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
19 // request, the case where the plugin is embedded and the case where it is top
20 // level:
21 // 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
23 // |DidFinishLoading| callbacks (from BrowserPluginDelegate) will be called
24 // when data is received and when it has finished being received,
25 // respectively.
26 // 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
28 // a WebURLLoader. In this case, the |didReceiveData| and |didFinishLoading|
29 // (from WebURLLoaderClient) when data is received and when it has finished
30 // being received.
31 class MimeHandlerViewContainer : public GuestViewContainer,
32 public blink::WebURLLoaderClient {
13 public: 33 public:
14 MimeHandlerViewContainer(content::RenderFrame* render_frame, 34 MimeHandlerViewContainer(content::RenderFrame* render_frame,
15 const std::string& mime_type); 35 const std::string& mime_type,
36 const GURL& original_url);
16 ~MimeHandlerViewContainer() override; 37 ~MimeHandlerViewContainer() override;
17 38
18 // BrowserPluginDelegate implementation. 39 // BrowserPluginDelegate implementation.
19 void DidFinishLoading() override; 40 void DidFinishLoading() override;
20 void DidReceiveData(const char* data, int data_length) override; 41 void DidReceiveData(const char* data, int data_length) override;
42 void Ready() override;
21 43
22 // GuestViewContainer override. 44 // GuestViewContainer overrides.
23 bool HandlesMessage(const IPC::Message& message) override; 45 bool HandlesMessage(const IPC::Message& message) override;
24 bool OnMessage(const IPC::Message& message) override; 46 bool OnMessage(const IPC::Message& message) override;
25 47
48 // WebURLLoaderClient overrides.
49 void didReceiveData(blink::WebURLLoader* loader,
50 const char* data,
51 int data_length,
52 int encoded_data_length) override;
53 void didFinishLoading(blink::WebURLLoader* loader,
54 double finish_time,
55 int64_t total_encoded_data_length) override;
56
26 private: 57 private:
58 // Message handlers.
27 void OnCreateMimeHandlerViewGuestACK(int element_instance_id); 59 void OnCreateMimeHandlerViewGuestACK(int element_instance_id);
28 60
61 void CreateMimeHandlerViewGuest();
62
63 // The MIME type of the plugin.
29 const std::string mime_type_; 64 const std::string mime_type_;
65
66 // The URL of the extension to navigate to.
30 std::string html_string_; 67 std::string html_string_;
31 68
69 // Whether the plugin is embedded or not.
70 bool is_embedded_;
71
72 // The original URL of the plugin.
73 GURL original_url_;
74
75 // A URL loader to load the |original_url_| when the plugin is embedded. In
76 // the embedded case, no URL request is made automatically.
77 scoped_ptr<blink::WebURLLoader> loader_;
78
32 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer); 79 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewContainer);
33 }; 80 };
34 81
35 } // namespace extensions 82 } // namespace extensions
36 83
37 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_ 84 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_MIME_HANDLER_VIEW_CONTAINER_H_
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | extensions/renderer/guest_view/mime_handler_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698