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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const int new_index = table_model_->RowCount(); | 47 const int new_index = table_model_->RowCount(); |
48 table_model_->Add(new_index, title, keyword, url); | 48 table_model_->Add(new_index, title, keyword, url); |
49 | 49 |
50 return new_index; | 50 return new_index; |
51 } | 51 } |
52 | 52 |
53 void KeywordEditorController::ModifyTemplateURL(const TemplateURL* template_url, | 53 void KeywordEditorController::ModifyTemplateURL(const TemplateURL* template_url, |
54 const string16& title, | 54 const string16& title, |
55 const string16& keyword, | 55 const string16& keyword, |
56 const std::string& url) { | 56 const std::string& url) { |
| 57 DCHECK(!url.empty()); |
57 const int index = table_model_->IndexOfTemplateURL(template_url); | 58 const int index = table_model_->IndexOfTemplateURL(template_url); |
58 if (index == -1) { | 59 if (index == -1) { |
59 // Will happen if url was deleted out from under us while the user was | 60 // Will happen if url was deleted out from under us while the user was |
60 // editing it. | 61 // editing it. |
61 return; | 62 return; |
62 } | 63 } |
63 | 64 |
64 // Don't do anything if the entry didn't change. | 65 // Don't do anything if the entry didn't change. |
65 if ((template_url->short_name() == title) && | 66 if ((template_url->short_name() == title) && |
66 (template_url->keyword() == keyword) && (template_url->url() == url)) | 67 (template_url->keyword() == keyword) && (template_url->url() == url)) |
(...skipping 30 matching lines...) Expand all Loading... |
97 return url_model()->loaded(); | 98 return url_model()->loaded(); |
98 } | 99 } |
99 | 100 |
100 const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const { | 101 const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const { |
101 return table_model_->GetTemplateURL(index); | 102 return table_model_->GetTemplateURL(index); |
102 } | 103 } |
103 | 104 |
104 TemplateURLService* KeywordEditorController::url_model() const { | 105 TemplateURLService* KeywordEditorController::url_model() const { |
105 return table_model_->template_url_service(); | 106 return table_model_->template_url_service(); |
106 } | 107 } |
OLD | NEW |