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

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

Issue 1403803003: Add metrics for window.external.AddSearchProvider and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
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_thread.h"
9 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebLocalFrame.h" 12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
12 #include "third_party/WebKit/public/web/WebView.h" 13 #include "third_party/WebKit/public/web/WebView.h"
13 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
14 15
15 using blink::WebLocalFrame; 16 using blink::WebLocalFrame;
16 using blink::WebView; 17 using blink::WebView;
17 using content::RenderView; 18 using content::RenderView;
18 19
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 RenderView* render_view = GetRenderView(); 110 RenderView* render_view = GetRenderView();
110 if (!render_view) 111 if (!render_view)
111 return; 112 return;
112 113
113 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); 114 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext();
114 if (!webframe) 115 if (!webframe)
115 return; 116 return;
116 117
117 GURL osdd_url = GURL(webframe->document().url()).Resolve(osdd_string); 118 GURL osdd_url = GURL(webframe->document().url()).Resolve(osdd_string);
118 if (!osdd_url.is_empty() && osdd_url.is_valid()) { 119 if (!osdd_url.is_empty() && osdd_url.is_valid()) {
120 content::RenderThread::Get()->RecordAction(
121 base::UserMetricsAction("window.external.AddSearchProvider"));
119 render_view->Send(new ChromeViewHostMsg_PageHasOSDD( 122 render_view->Send(new ChromeViewHostMsg_PageHasOSDD(
120 render_view->GetRoutingID(), webframe->document().url(), osdd_url, 123 render_view->GetRoutingID(), webframe->document().url(), osdd_url,
121 search_provider::EXPLICIT_PROVIDER)); 124 search_provider::EXPLICIT_PROVIDER));
122 } 125 }
123 } 126 }
124 127
125 // static 128 // static
126 void ExternalExtensionWrapper::IsSearchProviderInstalled( 129 void ExternalExtensionWrapper::IsSearchProviderInstalled(
127 const v8::FunctionCallbackInfo<v8::Value>& args) { 130 const v8::FunctionCallbackInfo<v8::Value>& args) {
128 if (!args.Length() || !args[0]->IsString()) 131 if (!args.Length() || !args[0]->IsString())
129 return; 132 return;
130 133
131 v8::String::Utf8Value utf8name(args[0]); 134 v8::String::Utf8Value utf8name(args[0]);
132 if (!utf8name.length()) 135 if (!utf8name.length())
133 return; 136 return;
134 137
135 std::string name(*utf8name); 138 std::string name(*utf8name);
136 RenderView* render_view = GetRenderView(); 139 RenderView* render_view = GetRenderView();
137 if (!render_view) 140 if (!render_view)
138 return; 141 return;
139 142
140 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext(); 143 WebLocalFrame* webframe = WebLocalFrame::frameForCurrentContext();
141 if (!webframe) 144 if (!webframe)
142 return; 145 return;
143 146
144 search_provider::InstallState install = search_provider::DENIED; 147 search_provider::InstallState install = search_provider::DENIED;
145 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name); 148 GURL inquiry_url = GURL(webframe->document().url()).Resolve(name);
146 if (!inquiry_url.is_empty()) { 149 if (!inquiry_url.is_empty()) {
147 render_view->Send(new ChromeViewHostMsg_GetSearchProviderInstallState( 150 content::RenderThread::Get()->RecordAction(
148 render_view->GetRoutingID(), 151 base::UserMetricsAction("window.external.IsSearchProviderInstalled"));
149 webframe->document().url(), 152 render_view->Send(new ChromeViewHostMsg_GetSearchProviderInstallState(
150 inquiry_url, 153 render_view->GetRoutingID(),
151 &install)); 154 webframe->document().url(),
155 inquiry_url,
156 &install));
152 } 157 }
153 158
154 if (install == search_provider::DENIED) { 159 if (install == search_provider::DENIED) {
155 // FIXME: throw access denied exception. 160 // FIXME: throw access denied exception.
156 v8::Isolate* isolate = args.GetIsolate(); 161 v8::Isolate* isolate = args.GetIsolate();
157 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate))); 162 isolate->ThrowException(v8::Exception::Error(v8::String::Empty(isolate)));
158 return; 163 return;
159 } 164 }
165
166 content::RenderThread::Get()->RecordAction(
167 base::UserMetricsAction("window.external.IsSearchProviderInstalled_success "));
Peter Kasting 2015/10/13 18:36:20 80 columns
Evan Stade 2015/10/13 18:40:57 I don't think I can because of this comment[1], un
Peter Kasting 2015/10/13 19:01:41 Based on extract_actions.py line 53, I think this
160 args.GetReturnValue().Set(static_cast<int32_t>(install)); 168 args.GetReturnValue().Set(static_cast<int32_t>(install));
161 } 169 }
162 170
163 v8::Extension* ExternalExtension::Get() { 171 v8::Extension* ExternalExtension::Get() {
164 return new ExternalExtensionWrapper(); 172 return new ExternalExtensionWrapper();
165 } 173 }
166 174
167 } // namespace extensions_v8 175 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698