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

Side by Side Diff: extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc

Issue 597653002: Make extension APIs work in MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@work-pdf-zoom2-dbg
Patch Set: Created 6 years, 3 months 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
« no previous file with comments | « extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 5 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
11 #include "extensions/browser/api/extensions_api_client.h" 11 #include "extensions/browser/api/extensions_api_client.h"
12 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/extension_system.h" 13 #include "extensions/browser/extension_system.h"
14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h" 14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h"
15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t_delegate.h" 15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t_delegate.h"
16 #include "extensions/browser/process_manager.h" 16 #include "extensions/browser/process_manager.h"
17 #include "extensions/common/extension_messages.h"
17 #include "extensions/common/feature_switch.h" 18 #include "extensions/common/feature_switch.h"
18 #include "extensions/common/guest_view/guest_view_constants.h" 19 #include "extensions/common/guest_view/guest_view_constants.h"
19 #include "extensions/strings/grit/extensions_strings.h" 20 #include "extensions/strings/grit/extensions_strings.h"
21 #include "ipc/ipc_message_macros.h"
20 #include "net/base/url_util.h" 22 #include "net/base/url_util.h"
21 23
22 using content::WebContents; 24 using content::WebContents;
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 // static 28 // static
27 const char MimeHandlerViewGuest::Type[] = "mimehandler"; 29 const char MimeHandlerViewGuest::Type[] = "mimehandler";
28 30
29 // static 31 // static
(...skipping 10 matching lines...) Expand all
40 content::BrowserContext* browser_context, 42 content::BrowserContext* browser_context,
41 int guest_instance_id) 43 int guest_instance_id)
42 : GuestView<MimeHandlerViewGuest>(browser_context, guest_instance_id), 44 : GuestView<MimeHandlerViewGuest>(browser_context, guest_instance_id),
43 delegate_(ExtensionsAPIClient::Get()->CreateMimeHandlerViewGuestDelegate( 45 delegate_(ExtensionsAPIClient::Get()->CreateMimeHandlerViewGuestDelegate(
44 this)) { 46 this)) {
45 } 47 }
46 48
47 MimeHandlerViewGuest::~MimeHandlerViewGuest() { 49 MimeHandlerViewGuest::~MimeHandlerViewGuest() {
48 } 50 }
49 51
52 WindowController* MimeHandlerViewGuest::GetExtensionWindowController() const {
53 return NULL;
54 }
55
56 WebContents* MimeHandlerViewGuest::GetAssociatedWebContents() const {
57 return web_contents();
58 }
59
50 const char* MimeHandlerViewGuest::GetAPINamespace() const { 60 const char* MimeHandlerViewGuest::GetAPINamespace() const {
51 return "mimeHandlerViewGuestInternal"; 61 return "mimeHandlerViewGuestInternal";
52 } 62 }
53 63
54 int MimeHandlerViewGuest::GetTaskPrefix() const { 64 int MimeHandlerViewGuest::GetTaskPrefix() const {
55 return IDS_EXTENSION_TASK_MANAGER_MIMEHANDLERVIEW_TAG_PREFIX; 65 return IDS_EXTENSION_TASK_MANAGER_MIMEHANDLERVIEW_TAG_PREFIX;
56 } 66 }
57 67
58 // |embedder_extension_id| is empty for mime handler view. 68 // |embedder_extension_id| is empty for mime handler view.
59 void MimeHandlerViewGuest::CreateWebContents( 69 void MimeHandlerViewGuest::CreateWebContents(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool success = attach_params()->GetString(mime_handler_view::kSrc, &src); 117 bool success = attach_params()->GetString(mime_handler_view::kSrc, &src);
108 DCHECK(success && !src.empty()); 118 DCHECK(success && !src.empty());
109 web_contents()->GetController().LoadURL( 119 web_contents()->GetController().LoadURL(
110 GURL(src), 120 GURL(src),
111 content::Referrer(), 121 content::Referrer(),
112 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 122 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
113 std::string()); 123 std::string());
114 } 124 }
115 125
116 void MimeHandlerViewGuest::DidInitialize() { 126 void MimeHandlerViewGuest::DidInitialize() {
127 extension_function_dispatcher_.reset(
128 new ExtensionFunctionDispatcher(browser_context(), this));
117 if (delegate_) 129 if (delegate_)
118 delegate_->AttachHelpers(); 130 delegate_->AttachHelpers();
119 } 131 }
120 132
121 void MimeHandlerViewGuest::HandleKeyboardEvent( 133 void MimeHandlerViewGuest::HandleKeyboardEvent(
122 WebContents* source, 134 WebContents* source,
123 const content::NativeWebKeyboardEvent& event) { 135 const content::NativeWebKeyboardEvent& event) {
124 if (!attached()) 136 if (!attached())
125 return; 137 return;
126 138
127 // Send the keyboard events back to the embedder to reprocess them. 139 // Send the keyboard events back to the embedder to reprocess them.
128 // TODO(fsamuel): This introduces the possibility of out-of-order keyboard 140 // TODO(fsamuel): This introduces the possibility of out-of-order keyboard
129 // events because the guest may be arbitrarily delayed when responding to 141 // events because the guest may be arbitrarily delayed when responding to
130 // keyboard events. In that time, the embedder may have received and processed 142 // keyboard events. In that time, the embedder may have received and processed
131 // additional key events. This needs to be fixed as soon as possible. 143 // additional key events. This needs to be fixed as soon as possible.
132 // See http://crbug.com/229882. 144 // See http://crbug.com/229882.
133 embedder_web_contents()->GetDelegate()->HandleKeyboardEvent(web_contents(), 145 embedder_web_contents()->GetDelegate()->HandleKeyboardEvent(web_contents(),
134 event); 146 event);
135 } 147 }
136 148
149 bool MimeHandlerViewGuest::OnMessageReceived(const IPC::Message& message) {
150 bool handled = true;
151 IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewGuest, message)
152 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
153 IPC_MESSAGE_UNHANDLED(handled = false)
154 IPC_END_MESSAGE_MAP()
155 return handled;
156 }
157
158 void MimeHandlerViewGuest::OnRequest(
159 const ExtensionHostMsg_Request_Params& params) {
160 if (extension_function_dispatcher_) {
161 extension_function_dispatcher_->Dispatch(
162 params, web_contents()->GetRenderViewHost());
163 }
164 }
165
137 } // namespace extensions 166 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698