Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
| 10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
| 11 #include "extensions/common/extension_messages.h" | 11 #include "extensions/common/extension_messages.h" |
| 12 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 13 #include "extensions/common/url_pattern_set.h" | 13 #include "extensions/common/url_pattern_set.h" |
| 14 #include "extensions/renderer/api/automation/automation_api_helper.h" | 14 #include "extensions/renderer/api/automation/automation_api_helper.h" |
| 15 #include "extensions/renderer/dispatcher.h" | 15 #include "extensions/renderer/dispatcher.h" |
| 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 17 #include "third_party/WebKit/public/web/WebDocument.h" | 17 #include "third_party/WebKit/public/web/WebDocument.h" |
| 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
| 18 #include "third_party/WebKit/public/web/WebView.h" | 19 #include "third_party/WebKit/public/web/WebView.h" |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| 22 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, | 23 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, |
| 23 Dispatcher* dispatcher) | 24 Dispatcher* dispatcher) |
| 24 : content::RenderViewObserver(render_view), | 25 : content::RenderViewObserver(render_view), |
| 25 dispatcher_(dispatcher) { | 26 dispatcher_(dispatcher) { |
| 26 // Lifecycle managed by RenderViewObserver. | 27 // Lifecycle managed by RenderViewObserver. |
| 27 new AutomationApiHelper(render_view); | 28 new AutomationApiHelper(render_view); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ExtensionHelper::OnSetFrameName(const std::string& name) { | 63 void ExtensionHelper::OnSetFrameName(const std::string& name) { |
| 63 blink::WebView* web_view = render_view()->GetWebView(); | 64 blink::WebView* web_view = render_view()->GetWebView(); |
| 64 if (web_view) | 65 if (web_view) |
| 65 web_view->MainFrame()->SetName(blink::WebString::FromUTF8(name)); | 66 web_view->MainFrame()->SetName(blink::WebString::FromUTF8(name)); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void ExtensionHelper::OnAppWindowClosed() { | 69 void ExtensionHelper::OnAppWindowClosed() { |
| 69 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 70 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 70 v8::Local<v8::Context> v8_context = | 71 if (!render_view()->GetWebView()->MainFrame()->IsWebLocalFrame()) { |
|
dcheng
2017/06/06 19:57:17
Is this actually something we need to handle? I do
Łukasz Anforowicz
2017/06/07 20:35:07
Good point - ExtensionMsg_AppWindowClosed is sent
| |
| 71 render_view()->GetWebView()->MainFrame()->MainWorldScriptContext(); | 72 NOTREACHED(); |
| 73 return; | |
| 74 } | |
| 75 v8::Local<v8::Context> v8_context = render_view() | |
| 76 ->GetWebView() | |
| 77 ->MainFrame() | |
| 78 ->ToWebLocalFrame() | |
| 79 ->MainWorldScriptContext(); | |
| 72 ScriptContext* script_context = | 80 ScriptContext* script_context = |
| 73 dispatcher_->script_context_set().GetByV8Context(v8_context); | 81 dispatcher_->script_context_set().GetByV8Context(v8_context); |
| 74 if (!script_context) | 82 if (!script_context) |
| 75 return; | 83 return; |
| 76 script_context->module_system()->CallModuleMethodSafe("app.window", | 84 script_context->module_system()->CallModuleMethodSafe("app.window", |
| 77 "onAppWindowClosed"); | 85 "onAppWindowClosed"); |
| 78 } | 86 } |
| 79 | 87 |
| 80 } // namespace extensions | 88 } // namespace extensions |
| OLD | NEW |