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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 2117373002: Cleanup: Change LogMostVisitedImpression|Navigation APIs to take an enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntp_uma_cleanup
Patch Set: TODO Created 4 years, 5 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } 1053 }
1054 } 1054 }
1055 1055
1056 // static 1056 // static
1057 void SearchBoxExtensionWrapper::LogMostVisitedImpression( 1057 void SearchBoxExtensionWrapper::LogMostVisitedImpression(
1058 const v8::FunctionCallbackInfo<v8::Value>& args) { 1058 const v8::FunctionCallbackInfo<v8::Value>& args) {
1059 content::RenderView* render_view = GetRenderViewWithCheckedOrigin( 1059 content::RenderView* render_view = GetRenderViewWithCheckedOrigin(
1060 GURL(chrome::kChromeSearchMostVisitedUrl)); 1060 GURL(chrome::kChromeSearchMostVisitedUrl));
1061 if (!render_view) return; 1061 if (!render_view) return;
1062 1062
1063 if (args.Length() < 2 || !args[0]->IsNumber() || args[1]->IsUndefined()) { 1063 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) {
1064 ThrowInvalidParameters(args); 1064 ThrowInvalidParameters(args);
1065 return; 1065 return;
1066 } 1066 }
1067 1067
1068 DVLOG(1) << render_view << " LogMostVisitedImpression"; 1068 DVLOG(1) << render_view << " LogMostVisitedImpression";
1069 1069
1070 SearchBox::Get(render_view)->LogMostVisitedImpression( 1070 if (args[1]->Uint32Value() <= NTP_TILE_SOURCE_LAST) {
dcheng 2016/07/06 01:51:25 Nit: I have a weak preference for making this a DC
Marc Treib 2016/07/06 08:49:07 But the same would apply for all the other validit
Marc Treib 2016/07/06 08:55:56 Hm, then again, looking at the code around, nothin
dcheng 2016/07/06 09:01:28 Shrug, if it's copy and pasted, I guess that's fin
1071 args[0]->IntegerValue(), V8ValueToUTF16(args[1])); 1071 NTPLoggingTileSource tile_source =
1072 static_cast<NTPLoggingTileSource>(args[1]->Uint32Value());
1073 SearchBox::Get(render_view)->LogMostVisitedImpression(
1074 args[0]->IntegerValue(), tile_source);
1075 }
1072 } 1076 }
1073 1077
1074 // static 1078 // static
1075 void SearchBoxExtensionWrapper::LogMostVisitedNavigation( 1079 void SearchBoxExtensionWrapper::LogMostVisitedNavigation(
1076 const v8::FunctionCallbackInfo<v8::Value>& args) { 1080 const v8::FunctionCallbackInfo<v8::Value>& args) {
1077 content::RenderView* render_view = GetRenderViewWithCheckedOrigin( 1081 content::RenderView* render_view = GetRenderViewWithCheckedOrigin(
1078 GURL(chrome::kChromeSearchMostVisitedUrl)); 1082 GURL(chrome::kChromeSearchMostVisitedUrl));
1079 if (!render_view) return; 1083 if (!render_view) return;
1080 1084
1081 if (args.Length() < 2 || !args[0]->IsNumber() || args[1]->IsUndefined()) { 1085 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) {
1082 ThrowInvalidParameters(args); 1086 ThrowInvalidParameters(args);
1083 return; 1087 return;
1084 } 1088 }
1085 1089
1086 DVLOG(1) << render_view << " LogMostVisitedNavigation"; 1090 DVLOG(1) << render_view << " LogMostVisitedNavigation";
1087 1091
1088 SearchBox::Get(render_view)->LogMostVisitedNavigation( 1092 if (args[1]->Uint32Value() <= NTP_TILE_SOURCE_LAST) {
1089 args[0]->IntegerValue(), V8ValueToUTF16(args[1])); 1093 NTPLoggingTileSource tile_source =
1094 static_cast<NTPLoggingTileSource>(args[1]->Uint32Value());
1095 SearchBox::Get(render_view)->LogMostVisitedNavigation(
1096 args[0]->IntegerValue(), tile_source);
1097 }
1090 } 1098 }
1091 1099
1092 // static 1100 // static
1093 void SearchBoxExtensionWrapper::Paste( 1101 void SearchBoxExtensionWrapper::Paste(
1094 const v8::FunctionCallbackInfo<v8::Value>& args) { 1102 const v8::FunctionCallbackInfo<v8::Value>& args) {
1095 content::RenderView* render_view = GetRenderView(); 1103 content::RenderView* render_view = GetRenderView();
1096 if (!render_view) return; 1104 if (!render_view) return;
1097 1105
1098 base::string16 text; 1106 base::string16 text;
1099 if (!args[0]->IsUndefined()) 1107 if (!args[0]->IsUndefined())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 if (!render_view) return; 1165 if (!render_view) return;
1158 1166
1159 bool display_instant_results = 1167 bool display_instant_results =
1160 SearchBox::Get(render_view)->display_instant_results(); 1168 SearchBox::Get(render_view)->display_instant_results();
1161 DVLOG(1) << render_view << " GetDisplayInstantResults" << 1169 DVLOG(1) << render_view << " GetDisplayInstantResults" <<
1162 display_instant_results; 1170 display_instant_results;
1163 args.GetReturnValue().Set(display_instant_results); 1171 args.GetReturnValue().Set(display_instant_results);
1164 } 1172 }
1165 1173
1166 } // namespace extensions_v8 1174 } // namespace extensions_v8
OLDNEW
« chrome/common/ntp_logging_events.h ('K') | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698