Chromium Code Reviews| 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 "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 registry->RegisterDictionaryPref(prefs::kKeywordEditorWindowPlacement); | 32 registry->RegisterDictionaryPref(prefs::kKeywordEditorWindowPlacement); |
| 33 } | 33 } |
| 34 | 34 |
| 35 int KeywordEditorController::AddTemplateURL(const string16& title, | 35 int KeywordEditorController::AddTemplateURL(const string16& title, |
| 36 const string16& keyword, | 36 const string16& keyword, |
| 37 const std::string& url) { | 37 const std::string& url) { |
| 38 DCHECK(!url.empty()); | 38 DCHECK(!url.empty()); |
| 39 | 39 |
| 40 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword")); | 40 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword")); |
| 41 | 41 |
| 42 // There's a bug (1090726) in TableView with groups enabled such that newly | 42 const int new_index = table_model_->last_other_engine_index(); |
|
Aaron Jacobs
2013/05/31 03:07:24
I'm not sure if the mentioned bug was officially c
Peter Kasting
2013/06/01 01:38:03
This was an old internal Google bug that was cover
| |
| 43 // added items in groups ALWAYS appear at the end, regardless of the index | |
| 44 // passed in. Worse yet, the selected rows get messed up when this happens | |
| 45 // causing other problems. As a work around we always add the item to the end | |
| 46 // of the list. | |
| 47 const int new_index = table_model_->RowCount(); | |
| 48 table_model_->Add(new_index, title, keyword, url); | 43 table_model_->Add(new_index, title, keyword, url); |
| 49 | 44 |
| 50 return new_index; | 45 return new_index; |
| 51 } | 46 } |
| 52 | 47 |
| 53 void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url, | 48 void KeywordEditorController::ModifyTemplateURL(TemplateURL* template_url, |
| 54 const string16& title, | 49 const string16& title, |
| 55 const string16& keyword, | 50 const string16& keyword, |
| 56 const std::string& url) { | 51 const std::string& url) { |
| 57 DCHECK(!url.empty()); | 52 DCHECK(!url.empty()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 return url_model()->loaded(); | 93 return url_model()->loaded(); |
| 99 } | 94 } |
| 100 | 95 |
| 101 TemplateURL* KeywordEditorController::GetTemplateURL(int index) { | 96 TemplateURL* KeywordEditorController::GetTemplateURL(int index) { |
| 102 return table_model_->GetTemplateURL(index); | 97 return table_model_->GetTemplateURL(index); |
| 103 } | 98 } |
| 104 | 99 |
| 105 TemplateURLService* KeywordEditorController::url_model() const { | 100 TemplateURLService* KeywordEditorController::url_model() const { |
| 106 return table_model_->template_url_service(); | 101 return table_model_->template_url_service(); |
| 107 } | 102 } |
| OLD | NEW |