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

Side by Side Diff: chrome/browser/ui/webui/options/search_engine_manager_handler.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 9 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/browser/ui/webui/options/search_engine_manager_handler.h" 5 #include "chrome/browser/ui/webui/options/search_engine_manager_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/user_metrics.h"
8 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/extensions/extension_util.h" 12 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 14 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
14 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 15 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
15 #include "chrome/browser/ui/search_engines/template_url_table_model.h" 16 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "components/search_engines/template_url.h" 19 #include "components/search_engines/template_url.h"
19 #include "components/search_engines/template_url_service.h" 20 #include "components/search_engines/template_url_service.h"
20 #include "content/public/browser/user_metrics.h"
21 #include "content/public/browser/web_ui.h" 21 #include "content/public/browser/web_ui.h"
22 #include "extensions/browser/extension_registry.h" 22 #include "extensions/browser/extension_registry.h"
23 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 25
26 namespace { 26 namespace {
27 27
28 enum EngineInfoIndexes { 28 enum EngineInfoIndexes {
29 ENGINE_NAME, 29 ENGINE_NAME,
30 ENGINE_KEYWORD, 30 ENGINE_KEYWORD,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 int index; 219 int index;
220 if (!ExtractIntegerValue(args, &index)) { 220 if (!ExtractIntegerValue(args, &index)) {
221 NOTREACHED(); 221 NOTREACHED();
222 return; 222 return;
223 } 223 }
224 if (index < 0 || index >= list_controller_->table_model()->RowCount()) 224 if (index < 0 || index >= list_controller_->table_model()->RowCount())
225 return; 225 return;
226 226
227 list_controller_->MakeDefaultTemplateURL(index); 227 list_controller_->MakeDefaultTemplateURL(index);
228 228
229 content::RecordAction( 229 base::RecordAction(base::UserMetricsAction("Options_SearchEngineSetDefault"));
230 base::UserMetricsAction("Options_SearchEngineSetDefault"));
231 } 230 }
232 231
233 void SearchEngineManagerHandler::RemoveSearchEngine( 232 void SearchEngineManagerHandler::RemoveSearchEngine(
234 const base::ListValue* args) { 233 const base::ListValue* args) {
235 int index; 234 int index;
236 if (!ExtractIntegerValue(args, &index)) { 235 if (!ExtractIntegerValue(args, &index)) {
237 NOTREACHED(); 236 NOTREACHED();
238 return; 237 return;
239 } 238 }
240 if (index < 0 || index >= list_controller_->table_model()->RowCount()) 239 if (index < 0 || index >= list_controller_->table_model()->RowCount())
241 return; 240 return;
242 241
243 if (list_controller_->CanRemove(list_controller_->GetTemplateURL(index))) { 242 if (list_controller_->CanRemove(list_controller_->GetTemplateURL(index))) {
244 list_controller_->RemoveTemplateURL(index); 243 list_controller_->RemoveTemplateURL(index);
245 content::RecordAction( 244 base::RecordAction(base::UserMetricsAction("Options_SearchEngineRemoved"));
246 base::UserMetricsAction("Options_SearchEngineRemoved"));
247 } 245 }
248 } 246 }
249 247
250 void SearchEngineManagerHandler::EditSearchEngine(const base::ListValue* args) { 248 void SearchEngineManagerHandler::EditSearchEngine(const base::ListValue* args) {
251 int index; 249 int index;
252 if (!ExtractIntegerValue(args, &index)) { 250 if (!ExtractIntegerValue(args, &index)) {
253 NOTREACHED(); 251 NOTREACHED();
254 return; 252 return;
255 } 253 }
256 254
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 321
324 // Recheck validity. It's possible to get here with invalid input if e.g. the 322 // Recheck validity. It's possible to get here with invalid input if e.g. the
325 // user calls the right JS functions directly from the web inspector. 323 // user calls the right JS functions directly from the web inspector.
326 if (edit_controller_->IsTitleValid(name) && 324 if (edit_controller_->IsTitleValid(name) &&
327 edit_controller_->IsKeywordValid(keyword) && 325 edit_controller_->IsKeywordValid(keyword) &&
328 edit_controller_->IsURLValid(url)) 326 edit_controller_->IsURLValid(url))
329 edit_controller_->AcceptAddOrEdit(name, keyword, url); 327 edit_controller_->AcceptAddOrEdit(name, keyword, url);
330 } 328 }
331 329
332 } // namespace options 330 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698