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 #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/constants.h" | 9 #include "extensions/common/constants.h" |
10 #include "extensions/common/extension_messages.h" | 10 #include "extensions/common/extension_messages.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 ExtensionHelper::~ExtensionHelper() { | 41 ExtensionHelper::~ExtensionHelper() { |
42 } | 42 } |
43 | 43 |
44 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { | 44 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { |
45 bool handled = true; | 45 bool handled = true; |
46 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) | 46 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) |
47 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) | 47 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) |
48 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) | 48 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFrameName, OnSetFrameName) |
49 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, | |
50 OnAddMessageToConsole) | |
51 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, | 49 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, |
52 OnAppWindowClosed) | 50 OnAppWindowClosed) |
53 IPC_MESSAGE_UNHANDLED(handled = false) | 51 IPC_MESSAGE_UNHANDLED(handled = false) |
54 IPC_END_MESSAGE_MAP() | 52 IPC_END_MESSAGE_MAP() |
55 return handled; | 53 return handled; |
56 } | 54 } |
57 | 55 |
58 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) { | 56 void ExtensionHelper::DidCreateDocumentElement(WebLocalFrame* frame) { |
59 dispatcher_->DidCreateDocumentElement(frame); | 57 dispatcher_->DidCreateDocumentElement(frame); |
60 } | 58 } |
(...skipping 28 matching lines...) Expand all Loading... |
89 render_view(), extension_id, module_name, function_name, args, | 87 render_view(), extension_id, module_name, function_name, args, |
90 user_gesture); | 88 user_gesture); |
91 } | 89 } |
92 | 90 |
93 void ExtensionHelper::OnSetFrameName(const std::string& name) { | 91 void ExtensionHelper::OnSetFrameName(const std::string& name) { |
94 blink::WebView* web_view = render_view()->GetWebView(); | 92 blink::WebView* web_view = render_view()->GetWebView(); |
95 if (web_view) | 93 if (web_view) |
96 web_view->mainFrame()->setName(blink::WebString::fromUTF8(name)); | 94 web_view->mainFrame()->setName(blink::WebString::fromUTF8(name)); |
97 } | 95 } |
98 | 96 |
99 void ExtensionHelper::OnAddMessageToConsole(ConsoleMessageLevel level, | |
100 const std::string& message) { | |
101 console::AddMessage(render_view(), level, message); | |
102 } | |
103 | |
104 void ExtensionHelper::OnAppWindowClosed() { | 97 void ExtensionHelper::OnAppWindowClosed() { |
105 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 98 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
106 v8::Local<v8::Context> v8_context = | 99 v8::Local<v8::Context> v8_context = |
107 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 100 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); |
108 ScriptContext* script_context = | 101 ScriptContext* script_context = |
109 dispatcher_->script_context_set().GetByV8Context(v8_context); | 102 dispatcher_->script_context_set().GetByV8Context(v8_context); |
110 if (!script_context) | 103 if (!script_context) |
111 return; | 104 return; |
112 script_context->module_system()->CallModuleMethod("app.window", | 105 script_context->module_system()->CallModuleMethod("app.window", |
113 "onAppWindowClosed"); | 106 "onAppWindowClosed"); |
114 } | 107 } |
115 | 108 |
116 } // namespace extensions | 109 } // namespace extensions |
OLD | NEW |