OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/external_extension.h" | 5 #include "chrome/renderer/external_extension.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
Sam McNally
2016/06/23 03:05:35
Remove.
tibell
2016/06/23 03:44:39
Done.
| |
11 #include "chrome/common/search_provider.h" | 11 #include "chrome/common/search_provider.h" |
Sam McNally
2016/06/23 03:05:36
Remove.
tibell
2016/06/23 03:44:39
Done.
| |
12 #include "chrome/common/search_provider.mojom.h" | |
13 #include "content/public/common/service_registry.h" | |
Sam McNally
2016/06/23 03:05:35
Remove.
tibell
2016/06/23 03:44:39
Done.
| |
14 #include "content/public/renderer/render_thread.h" | |
12 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
Sam McNally
2016/06/23 03:05:36
Remove.
tibell
2016/06/23 03:44:39
Done.
| |
16 #include "services/shell/public/cpp/interface_provider.h" | |
13 #include "third_party/WebKit/public/web/WebDocument.h" | 17 #include "third_party/WebKit/public/web/WebDocument.h" |
14 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
15 #include "third_party/WebKit/public/web/WebView.h" | 19 #include "third_party/WebKit/public/web/WebView.h" |
Sam McNally
2016/06/23 03:05:36
Remove.
tibell
2016/06/23 03:44:39
Done.
| |
16 #include "v8/include/v8.h" | 20 #include "v8/include/v8.h" |
17 | 21 |
18 using blink::WebLocalFrame; | 22 using blink::WebLocalFrame; |
19 using blink::WebView; | 23 using blink::WebView; |
20 using content::RenderView; | 24 using content::RenderView; |
21 | 25 |
22 namespace extensions_v8 { | 26 namespace extensions_v8 { |
23 | 27 |
24 namespace { | 28 namespace { |
25 | 29 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 void ExternalExtensionWrapper::IsSearchProviderInstalled( | 96 void ExternalExtensionWrapper::IsSearchProviderInstalled( |
93 const v8::FunctionCallbackInfo<v8::Value>& args) { | 97 const v8::FunctionCallbackInfo<v8::Value>& args) { |
94 if (!args.Length() || !args[0]->IsString()) | 98 if (!args.Length() || !args[0]->IsString()) |
95 return; | 99 return; |
96 | 100 |
97 v8::String::Utf8Value utf8name(args[0]); | 101 v8::String::Utf8Value utf8name(args[0]); |
98 if (!utf8name.length()) | 102 if (!utf8name.length()) |
99 return; | 103 return; |
100 | 104 |
101 std::string name(*utf8name); | 105 std::string name(*utf8name); |
102 RenderView* render_view = GetRenderView(); | 106 RenderView* render_view = GetRenderView(); |
Sam McNally
2016/06/23 03:05:36
Remove this and GetRenderView().
tibell
2016/06/23 03:44:39
Done.
| |
103 if (!render_view) | 107 if (!render_view) |
104 return; | 108 return; |
105 | 109 |
106 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); | 110 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); |
107 if (!webframe) | 111 if (!webframe) |
108 return; | 112 return; |
109 | 113 |
110 search_provider::InstallState install = search_provider::DENIED; | 114 chrome::mojom::InstallState install = chrome::mojom::InstallState::DENIED; |
111 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name); | 115 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name); |
112 if (!inquiry_url.is_empty()) { | 116 if (!inquiry_url.is_empty()) { |
113 webframe->didCallIsSearchProviderInstalled(); | 117 webframe->didCallIsSearchProviderInstalled(); |
114 render_view->Send(new ChromeViewHostMsg_GetSearchProviderInstallState( | 118 chrome::mojom::SearchProviderInstallStatePtr search_provider_service; |
115 render_view->GetRoutingID(), webframe->document().url(), inquiry_url, | 119 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( |
116 &install)); | 120 mojo::GetProxy(&search_provider_service)); |
121 if (!search_provider_service->GetInstallState(webframe->document().url(), | |
122 inquiry_url, &install)) { | |
123 DLOG(ERROR) << "Can't fetch search provider install state"; | |
124 } | |
117 } | 125 } |
118 | 126 |
119 if (install == search_provider::DENIED) { | 127 if (install == chrome::mojom::InstallState::DENIED) { |
120 // FIXME: throw access denied exception. | 128 // FIXME: throw access denied exception. |
121 v8::Isolate* isolate = args.GetIsolate(); | 129 v8::Isolate* isolate = args.GetIsolate(); |
122 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate))); | 130 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate))); |
123 return; | 131 return; |
124 } | 132 } |
125 args.GetReturnValue().Set(static_cast<int32_t>(install)); | 133 args.GetReturnValue().Set(static_cast<int32_t>(install)); |
126 } | 134 } |
127 | 135 |
128 v8::Extension* ExternalExtension::Get() { | 136 v8::Extension* ExternalExtension::Get() { |
129 return new ExternalExtensionWrapper(); | 137 return new ExternalExtensionWrapper(); |
130 } | 138 } |
131 | 139 |
132 } // namespace extensions_v8 | 140 } // namespace extensions_v8 |
OLD | NEW |