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

Side by Side Diff: extensions/renderer/extension_helper.cc

Issue 709933002: Add frameId to MessageSender (extension messaging API) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test: sender.tab.status = 'complete' 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
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | extensions/renderer/messaging_bindings.h » ('j') | 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/renderer/extension_helper.h" 5 #include "extensions/renderer/extension_helper.h"
6 6
7 #include "content/public/renderer/render_view.h" 7 #include "content/public/renderer/render_view.h"
8 #include "content/public/renderer/render_view_visitor.h" 8 #include "content/public/renderer/render_view_visitor.h"
9 #include "extensions/common/api/messaging/message.h"
10 #include "extensions/common/constants.h" 9 #include "extensions/common/constants.h"
11 #include "extensions/common/extension_messages.h" 10 #include "extensions/common/extension_messages.h"
12 #include "extensions/renderer/api/automation/automation_api_helper.h" 11 #include "extensions/renderer/api/automation/automation_api_helper.h"
13 #include "extensions/renderer/console.h" 12 #include "extensions/renderer/console.h"
14 #include "extensions/renderer/dispatcher.h" 13 #include "extensions/renderer/dispatcher.h"
15 #include "extensions/renderer/messaging_bindings.h"
16 #include "third_party/WebKit/public/platform/WebURLRequest.h" 14 #include "third_party/WebKit/public/platform/WebURLRequest.h"
17 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 15 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
18 #include "third_party/WebKit/public/web/WebDocument.h" 16 #include "third_party/WebKit/public/web/WebDocument.h"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" 17 #include "third_party/WebKit/public/web/WebLocalFrame.h"
20 #include "third_party/WebKit/public/web/WebView.h" 18 #include "third_party/WebKit/public/web/WebView.h"
21 19
22 using content::ConsoleMessageLevel; 20 using content::ConsoleMessageLevel;
23 using blink::WebConsoleMessage; 21 using blink::WebConsoleMessage;
24 using blink::WebDataSource; 22 using blink::WebDataSource;
25 using blink::WebFrame; 23 using blink::WebFrame;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 126 }
129 127
130 ExtensionHelper::~ExtensionHelper() { 128 ExtensionHelper::~ExtensionHelper() {
131 } 129 }
132 130
133 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { 131 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) {
134 bool handled = true; 132 bool handled = true;
135 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) 133 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message)
136 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) 134 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse)
137 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) 135 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke)
138 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect,
139 OnExtensionDispatchOnConnect)
140 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnExtensionDeliverMessage)
141 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect,
142 OnExtensionDispatchOnDisconnect)
143 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) 136 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName)
144 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) 137 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId)
145 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, 138 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId,
146 OnUpdateBrowserWindowId) 139 OnUpdateBrowserWindowId)
147 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, 140 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType,
148 OnNotifyRendererViewType) 141 OnNotifyRendererViewType)
149 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, 142 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole,
150 OnAddMessageToConsole) 143 OnAddMessageToConsole)
151 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, 144 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed,
152 OnAppWindowClosed) 145 OnAppWindowClosed)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id, 186 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id,
194 const std::string& module_name, 187 const std::string& module_name,
195 const std::string& function_name, 188 const std::string& function_name,
196 const base::ListValue& args, 189 const base::ListValue& args,
197 bool user_gesture) { 190 bool user_gesture) {
198 dispatcher_->InvokeModuleSystemMethod( 191 dispatcher_->InvokeModuleSystemMethod(
199 render_view(), extension_id, module_name, function_name, args, 192 render_view(), extension_id, module_name, function_name, args,
200 user_gesture); 193 user_gesture);
201 } 194 }
202 195
203 void ExtensionHelper::OnExtensionDispatchOnConnect(
204 int target_port_id,
205 const std::string& channel_name,
206 const base::DictionaryValue& source_tab,
207 const ExtensionMsg_ExternalConnectionInfo& info,
208 const std::string& tls_channel_id) {
209 MessagingBindings::DispatchOnConnect(dispatcher_->script_context_set(),
210 target_port_id,
211 channel_name,
212 source_tab,
213 info,
214 tls_channel_id,
215 render_view());
216 }
217
218 void ExtensionHelper::OnExtensionDeliverMessage(int target_id,
219 const Message& message) {
220 MessagingBindings::DeliverMessage(
221 dispatcher_->script_context_set(), target_id, message, render_view());
222 }
223
224 void ExtensionHelper::OnExtensionDispatchOnDisconnect(
225 int port_id,
226 const std::string& error_message) {
227 MessagingBindings::DispatchOnDisconnect(
228 dispatcher_->script_context_set(), port_id, error_message, render_view());
229 }
230
231 void ExtensionHelper::OnNotifyRendererViewType(ViewType type) { 196 void ExtensionHelper::OnNotifyRendererViewType(ViewType type) {
232 view_type_ = type; 197 view_type_ = type;
233 } 198 }
234 199
235 void ExtensionHelper::OnSetFrameName(const std::string& name) { 200 void ExtensionHelper::OnSetFrameName(const std::string& name) {
236 blink::WebView* web_view = render_view()->GetWebView(); 201 blink::WebView* web_view = render_view()->GetWebView();
237 if (web_view) 202 if (web_view)
238 web_view->mainFrame()->setName(blink::WebString::fromUTF8(name)); 203 web_view->mainFrame()->setName(blink::WebString::fromUTF8(name));
239 } 204 }
240 205
(...skipping 18 matching lines...) Expand all
259 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); 224 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext();
260 ScriptContext* script_context = 225 ScriptContext* script_context =
261 dispatcher_->script_context_set().GetByV8Context(v8_context); 226 dispatcher_->script_context_set().GetByV8Context(v8_context);
262 if (!script_context) 227 if (!script_context)
263 return; 228 return;
264 script_context->module_system()->CallModuleMethod("app.window", 229 script_context->module_system()->CallModuleMethod("app.window",
265 "onAppWindowClosed"); 230 "onAppWindowClosed");
266 } 231 }
267 232
268 } // namespace extensions 233 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/extension_helper.h ('k') | extensions/renderer/messaging_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698