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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 const std::string& url) { | 56 const std::string& url) { |
57 const int index = table_model_->IndexOfTemplateURL(template_url); | 57 const int index = table_model_->IndexOfTemplateURL(template_url); |
58 if (index == -1) { | 58 if (index == -1) { |
59 // Will happen if url was deleted out from under us while the user was | 59 // Will happen if url was deleted out from under us while the user was |
60 // editing it. | 60 // editing it. |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 // Don't do anything if the entry didn't change. | 64 // Don't do anything if the entry didn't change. |
65 if ((template_url->short_name() == title) && | 65 if ((template_url->short_name() == title) && |
66 (template_url->keyword() == keyword) && | 66 (template_url->keyword() == keyword) && (template_url->url() == url)) |
67 ((url.empty() && !template_url->url()) || | |
68 (!url.empty() && template_url->url() && | |
69 template_url->url()->url() == url))) | |
70 return; | 67 return; |
71 | 68 |
72 table_model_->ModifyTemplateURL(index, title, keyword, url); | 69 table_model_->ModifyTemplateURL(index, title, keyword, url); |
73 | 70 |
74 content::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword")); | 71 content::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword")); |
75 } | 72 } |
76 | 73 |
77 bool KeywordEditorController::CanEdit(const TemplateURL* url) const { | 74 bool KeywordEditorController::CanEdit(const TemplateURL* url) const { |
78 return !url_model()->is_default_search_managed() || | 75 return !url_model()->is_default_search_managed() || |
79 url != url_model()->GetDefaultSearchProvider(); | 76 url != url_model()->GetDefaultSearchProvider(); |
(...skipping 20 matching lines...) Expand all Loading... |
100 return url_model()->loaded(); | 97 return url_model()->loaded(); |
101 } | 98 } |
102 | 99 |
103 const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const { | 100 const TemplateURL* KeywordEditorController::GetTemplateURL(int index) const { |
104 return table_model_->GetTemplateURL(index); | 101 return table_model_->GetTemplateURL(index); |
105 } | 102 } |
106 | 103 |
107 TemplateURLService* KeywordEditorController::url_model() const { | 104 TemplateURLService* KeywordEditorController::url_model() const { |
108 return table_model_->template_url_service(); | 105 return table_model_->template_url_service(); |
109 } | 106 } |
OLD | NEW |