OLD | NEW |
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/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
8 #include "chrome/browser/favicon/favicon_service_factory.h" | 8 #include "chrome/browser/favicon/favicon_service_factory.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/ui/search_engines/template_url_table_model.h" | 10 #include "chrome/browser/ui/search_engines/template_url_table_model.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "components/search_engines/template_url.h" | 12 #include "components/search_engines/template_url.h" |
13 #include "components/search_engines/template_url_service.h" | 13 #include "components/search_engines/template_url_service.h" |
14 #include "content/public/browser/user_metrics.h" | 14 #include "content/public/browser/user_metrics.h" |
15 | 15 |
16 using base::UserMetricsAction; | 16 using base::UserMetricsAction; |
17 | 17 |
18 KeywordEditorController::KeywordEditorController(Profile* profile) | 18 KeywordEditorController::KeywordEditorController(Profile* profile) |
19 : url_model_(TemplateURLServiceFactory::GetForProfile(profile)) { | 19 : url_model_(TemplateURLServiceFactory::GetForProfile(profile)) { |
20 table_model_.reset(new TemplateURLTableModel( | 20 table_model_.reset(new TemplateURLTableModel( |
21 url_model_, | 21 url_model_, |
22 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS))); | 22 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS))); |
23 } | 23 } |
24 | 24 |
25 KeywordEditorController::~KeywordEditorController() { | 25 KeywordEditorController::~KeywordEditorController() { |
26 } | 26 } |
27 | 27 |
28 // static | |
29 // TODO(rsesek): Other platforms besides Mac should remember window | |
30 // placement. http://crbug.com/22269 | |
31 void KeywordEditorController::RegisterPrefs(PrefRegistrySimple* registry) { | |
32 registry->RegisterDictionaryPref(prefs::kKeywordEditorWindowPlacement); | |
33 } | |
34 | |
35 int KeywordEditorController::AddTemplateURL(const base::string16& title, | 28 int KeywordEditorController::AddTemplateURL(const base::string16& title, |
36 const base::string16& keyword, | 29 const base::string16& keyword, |
37 const std::string& url) { | 30 const std::string& url) { |
38 DCHECK(!url.empty()); | 31 DCHECK(!url.empty()); |
39 | 32 |
40 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword")); | 33 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword")); |
41 | 34 |
42 const int new_index = table_model_->last_other_engine_index(); | 35 const int new_index = table_model_->last_other_engine_index(); |
43 table_model_->Add(new_index, title, keyword, url); | 36 table_model_->Add(new_index, title, keyword, url); |
44 | 37 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return table_model_->MakeDefaultTemplateURL(index); | 87 return table_model_->MakeDefaultTemplateURL(index); |
95 } | 88 } |
96 | 89 |
97 bool KeywordEditorController::loaded() const { | 90 bool KeywordEditorController::loaded() const { |
98 return url_model_->loaded(); | 91 return url_model_->loaded(); |
99 } | 92 } |
100 | 93 |
101 TemplateURL* KeywordEditorController::GetTemplateURL(int index) { | 94 TemplateURL* KeywordEditorController::GetTemplateURL(int index) { |
102 return table_model_->GetTemplateURL(index); | 95 return table_model_->GetTemplateURL(index); |
103 } | 96 } |
OLD | NEW |