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

Side by Side Diff: chrome/browser/ui/search_engines/keyword_editor_controller.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 8 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/search_engines/keyword_editor_controller.h" 5 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
6 6
7 #include "base/metrics/user_metrics.h"
7 #include "chrome/browser/favicon/favicon_service_factory.h" 8 #include "chrome/browser/favicon/favicon_service_factory.h"
8 #include "chrome/browser/search_engines/template_url_service_factory.h" 9 #include "chrome/browser/search_engines/template_url_service_factory.h"
9 #include "chrome/browser/ui/search_engines/template_url_table_model.h" 10 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
10 #include "components/prefs/pref_registry_simple.h" 11 #include "components/prefs/pref_registry_simple.h"
11 #include "components/search_engines/template_url.h" 12 #include "components/search_engines/template_url.h"
12 #include "components/search_engines/template_url_service.h" 13 #include "components/search_engines/template_url_service.h"
13 #include "content/public/browser/user_metrics.h"
14 14
15 using base::UserMetricsAction; 15 using base::UserMetricsAction;
16 16
17 KeywordEditorController::KeywordEditorController(Profile* profile) 17 KeywordEditorController::KeywordEditorController(Profile* profile)
18 : url_model_(TemplateURLServiceFactory::GetForProfile(profile)) { 18 : url_model_(TemplateURLServiceFactory::GetForProfile(profile)) {
19 table_model_.reset(new TemplateURLTableModel( 19 table_model_.reset(new TemplateURLTableModel(
20 url_model_, FaviconServiceFactory::GetForProfile( 20 url_model_, FaviconServiceFactory::GetForProfile(
21 profile, ServiceAccessType::EXPLICIT_ACCESS))); 21 profile, ServiceAccessType::EXPLICIT_ACCESS)));
22 } 22 }
23 23
24 KeywordEditorController::~KeywordEditorController() { 24 KeywordEditorController::~KeywordEditorController() {
25 } 25 }
26 26
27 int KeywordEditorController::AddTemplateURL(const base::string16& title, 27 int KeywordEditorController::AddTemplateURL(const base::string16& title,
28 const base::string16& keyword, 28 const base::string16& keyword,
29 const std::string& url) { 29 const std::string& url) {
30 DCHECK(!url.empty()); 30 DCHECK(!url.empty());
31 31
32 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword")); 32 base::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword"));
33 33
34 const int new_index = table_model_->last_other_engine_index(); 34 const int new_index = table_model_->last_other_engine_index();
35 table_model_->Add(new_index, title, keyword, url); 35 table_model_->Add(new_index, title, keyword, url);
36 36
37 return new_index; 37 return new_index;
38 } 38 }
39 39
40 void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url, 40 void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url,
41 const base::string16& title, 41 const base::string16& title,
42 const base::string16& keyword, 42 const base::string16& keyword,
43 const std::string& url) { 43 const std::string& url) {
44 DCHECK(!url.empty()); 44 DCHECK(!url.empty());
45 const int index = table_model_->IndexOfTemplateURL(template_url); 45 const int index = table_model_->IndexOfTemplateURL(template_url);
46 if (index == -1) { 46 if (index == -1) {
47 // Will happen if url was deleted out from under us while the user was 47 // Will happen if url was deleted out from under us while the user was
48 // editing it. 48 // editing it.
49 return; 49 return;
50 } 50 }
51 51
52 // Don't do anything if the entry didn't change. 52 // Don't do anything if the entry didn't change.
53 if ((template_url->short_name() == title) && 53 if ((template_url->short_name() == title) &&
54 (template_url->keyword() == keyword) && (template_url->url() == url)) 54 (template_url->keyword() == keyword) && (template_url->url() == url))
55 return; 55 return;
56 56
57 table_model_->ModifyTemplateURL(index, title, keyword, url); 57 table_model_->ModifyTemplateURL(index, title, keyword, url);
58 58
59 content::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword")); 59 base::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword"));
60 } 60 }
61 61
62 bool KeywordEditorController::CanEdit(const TemplateURL* url) const { 62 bool KeywordEditorController::CanEdit(const TemplateURL* url) const {
63 return (url->type() == TemplateURL::NORMAL) && 63 return (url->type() == TemplateURL::NORMAL) &&
64 (url != url_model_->GetDefaultSearchProvider() || 64 (url != url_model_->GetDefaultSearchProvider() ||
65 !url_model_->is_default_search_managed()); 65 !url_model_->is_default_search_managed());
66 } 66 }
67 67
68 bool KeywordEditorController::CanMakeDefault(const TemplateURL* url) const { 68 bool KeywordEditorController::CanMakeDefault(const TemplateURL* url) const {
69 return url_model_->CanMakeDefault(url); 69 return url_model_->CanMakeDefault(url);
70 } 70 }
71 71
72 bool KeywordEditorController::CanRemove(const TemplateURL* url) const { 72 bool KeywordEditorController::CanRemove(const TemplateURL* url) const {
73 return (url->type() == TemplateURL::NORMAL) && 73 return (url->type() == TemplateURL::NORMAL) &&
74 (url != url_model_->GetDefaultSearchProvider()); 74 (url != url_model_->GetDefaultSearchProvider());
75 } 75 }
76 76
77 void KeywordEditorController::RemoveTemplateURL(int index) { 77 void KeywordEditorController::RemoveTemplateURL(int index) {
78 table_model_->Remove(index); 78 table_model_->Remove(index);
79 content::RecordAction(UserMetricsAction("KeywordEditor_RemoveKeyword")); 79 base::RecordAction(UserMetricsAction("KeywordEditor_RemoveKeyword"));
80 } 80 }
81 81
82 TemplateURL* KeywordEditorController::GetDefaultSearchProvider() { 82 TemplateURL* KeywordEditorController::GetDefaultSearchProvider() {
83 return url_model_->GetDefaultSearchProvider(); 83 return url_model_->GetDefaultSearchProvider();
84 } 84 }
85 85
86 int KeywordEditorController::MakeDefaultTemplateURL(int index) { 86 int KeywordEditorController::MakeDefaultTemplateURL(int index) {
87 return table_model_->MakeDefaultTemplateURL(index); 87 return table_model_->MakeDefaultTemplateURL(index);
88 } 88 }
89 89
90 bool KeywordEditorController::loaded() const { 90 bool KeywordEditorController::loaded() const {
91 return url_model_->loaded(); 91 return url_model_->loaded();
92 } 92 }
93 93
94 TemplateURL* KeywordEditorController::GetTemplateURL(int index) { 94 TemplateURL* KeywordEditorController::GetTemplateURL(int index) {
95 return table_model_->GetTemplateURL(index); 95 return table_model_->GetTemplateURL(index);
96 } 96 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search_engines/edit_search_engine_controller.cc ('k') | chrome/browser/ui/settings_window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698