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

Side by Side Diff: chrome/renderer/external_extension.cc

Issue 1407163002: Add feature use counting for window.external.AddSearchProvider (Blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: way too much contention on this enum Created 5 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 | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.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 (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 "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/common/search_provider.h" 8 #include "chrome/common/search_provider.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 10 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 RenderView* render_view = GetRenderView(); 109 RenderView* render_view = GetRenderView();
110 if (!render_view) 110 if (!render_view)
111 return; 111 return;
112 112
113 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); 113 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext();
114 if (!webframe) 114 if (!webframe)
115 return; 115 return;
116 116
117 GURL osdd_url = GURL(webframe->document().url()).Resolve(osdd_string); 117 GURL osdd_url = GURL(webframe->document().url()).Resolve(osdd_string);
118 if (!osdd_url.is_empty() && osdd_url.is_valid()) { 118 if (!osdd_url.is_empty() && osdd_url.is_valid()) {
119 webframe->didCallAddSearchProvider();
119 render_view->Send(new ChromeViewHostMsg_PageHasOSDD( 120 render_view->Send(new ChromeViewHostMsg_PageHasOSDD(
120 render_view->GetRoutingID(), webframe->document().url(), osdd_url, 121 render_view->GetRoutingID(), webframe->document().url(), osdd_url,
121 search_provider::EXPLICIT_PROVIDER)); 122 search_provider::EXPLICIT_PROVIDER));
122 } 123 }
123 } 124 }
124 125
125 // static 126 // static
126 void ExternalExtensionWrapper::IsSearchProviderInstalled( 127 void ExternalExtensionWrapper::IsSearchProviderInstalled(
127 const v8::FunctionCallbackInfo<v8::Value>& args) { 128 const v8::FunctionCallbackInfo<v8::Value>& args) {
128 if (!args.Length() || !args[0]->IsString()) 129 if (!args.Length() || !args[0]->IsString())
129 return; 130 return;
130 131
131 v8::String::Utf8Value utf8name(args[0]); 132 v8::String::Utf8Value utf8name(args[0]);
132 if (!utf8name.length()) 133 if (!utf8name.length())
133 return; 134 return;
134 135
135 std::string name(*utf8name); 136 std::string name(*utf8name);
136 RenderView* render_view = GetRenderView(); 137 RenderView* render_view = GetRenderView();
137 if (!render_view) 138 if (!render_view)
138 return; 139 return;
139 140
140 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); 141 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext();
141 if (!webframe) 142 if (!webframe)
142 return; 143 return;
143 144
144 search_provider::InstallState install = search_provider::DENIED; 145 search_provider::InstallState install = search_provider::DENIED;
145 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name); 146 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name);
146 if (!inquiry_url.is_empty()) { 147 if (!inquiry_url.is_empty()) {
147 render_view->Send(new ChromeViewHostMsg_GetSearchProviderInstallState( 148 webframe->didCallIsSearchProviderInstalled();
148 render_view->GetRoutingID(), 149 render_view->Send(new ChromeViewHostMsg_GetSearchProviderInstallState(
149 webframe->document().url(), 150 render_view->GetRoutingID(), webframe->document().url(), inquiry_url,
150 inquiry_url, 151 &install));
151 &install));
152 } 152 }
153 153
154 if (install == search_provider::DENIED) { 154 if (install == search_provider::DENIED) {
155 // FIXME: throw access denied exception. 155 // FIXME: throw access denied exception.
156 v8::Isolate* isolate = args.GetIsolate(); 156 v8::Isolate* isolate = args.GetIsolate();
157 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate))); 157 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate)));
158 return; 158 return;
159 } 159 }
160 args.GetReturnValue().Set(static_cast<int32_t>(install)); 160 args.GetReturnValue().Set(static_cast<int32_t>(install));
161 } 161 }
162 162
163 v8::Extension* ExternalExtension::Get() { 163 v8::Extension* ExternalExtension::Get() {
164 return new ExternalExtensionWrapper(); 164 return new ExternalExtensionWrapper();
165 } 165 }
166 166
167 } // namespace extensions_v8 167 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698