| 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/views/edit_search_engine_dialog.h" | 5 #include "chrome/browser/ui/views/edit_search_engine_dialog.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 base::string16 EditSearchEngineDialog::GetWindowTitle() const { | 75 base::string16 EditSearchEngineDialog::GetWindowTitle() const { |
| 76 return l10n_util::GetStringUTF16(controller_->template_url() ? | 76 return l10n_util::GetStringUTF16(controller_->template_url() ? |
| 77 IDS_SEARCH_ENGINES_EDITOR_EDIT_WINDOW_TITLE : | 77 IDS_SEARCH_ENGINES_EDITOR_EDIT_WINDOW_TITLE : |
| 78 IDS_SEARCH_ENGINES_EDITOR_NEW_WINDOW_TITLE); | 78 IDS_SEARCH_ENGINES_EDITOR_NEW_WINDOW_TITLE); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool EditSearchEngineDialog::IsDialogButtonEnabled( | 81 bool EditSearchEngineDialog::IsDialogButtonEnabled( |
| 82 ui::DialogButton button) const { | 82 ui::DialogButton button) const { |
| 83 if (button == ui::DIALOG_BUTTON_OK) { | 83 if (button == ui::DIALOG_BUTTON_OK) { |
| 84 return (controller_->IsKeywordValid(keyword_tf_->text()) && | 84 return (controller_->IsKeywordValid(keyword_tf_->GetText()) && |
| 85 controller_->IsTitleValid(title_tf_->text()) && | 85 controller_->IsTitleValid(title_tf_->GetText()) && |
| 86 controller_->IsURLValid(base::UTF16ToUTF8(url_tf_->text()))); | 86 controller_->IsURLValid(base::UTF16ToUTF8(url_tf_->GetText()))); |
| 87 } | 87 } |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool EditSearchEngineDialog::Cancel() { | 91 bool EditSearchEngineDialog::Cancel() { |
| 92 controller_->CleanUpCancelledAdd(); | 92 controller_->CleanUpCancelledAdd(); |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool EditSearchEngineDialog::Accept() { | 96 bool EditSearchEngineDialog::Accept() { |
| 97 controller_->AcceptAddOrEdit(title_tf_->text(), keyword_tf_->text(), | 97 controller_->AcceptAddOrEdit(title_tf_->GetText(), keyword_tf_->GetText(), |
| 98 base::UTF16ToUTF8(url_tf_->text())); | 98 base::UTF16ToUTF8(url_tf_->GetText())); |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void EditSearchEngineDialog::ContentsChanged( | 102 void EditSearchEngineDialog::ContentsChanged( |
| 103 Textfield* sender, | 103 Textfield* sender, |
| 104 const base::string16& new_contents) { | 104 const base::string16& new_contents) { |
| 105 GetDialogClientView()->UpdateDialogButtons(); | 105 GetDialogClientView()->UpdateDialogButtons(); |
| 106 UpdateImageViews(); | 106 UpdateImageViews(); |
| 107 } | 107 } |
| 108 | 108 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 Textfield* EditSearchEngineDialog::CreateTextfield(const base::string16& text, | 226 Textfield* EditSearchEngineDialog::CreateTextfield(const base::string16& text, |
| 227 bool lowercase) { | 227 bool lowercase) { |
| 228 Textfield* text_field = new Textfield( | 228 Textfield* text_field = new Textfield( |
| 229 lowercase ? Textfield::STYLE_LOWERCASE : Textfield::STYLE_DEFAULT); | 229 lowercase ? Textfield::STYLE_LOWERCASE : Textfield::STYLE_DEFAULT); |
| 230 text_field->SetText(text); | 230 text_field->SetText(text); |
| 231 text_field->SetController(this); | 231 text_field->SetController(this); |
| 232 return text_field; | 232 return text_field; |
| 233 } | 233 } |
| 234 | 234 |
| 235 void EditSearchEngineDialog::UpdateImageViews() { | 235 void EditSearchEngineDialog::UpdateImageViews() { |
| 236 UpdateImageView(keyword_iv_, controller_->IsKeywordValid(keyword_tf_->text()), | 236 UpdateImageView(keyword_iv_, |
| 237 IDS_SEARCH_ENGINES_INVALID_KEYWORD_TT); | 237 controller_->IsKeywordValid(keyword_tf_->GetText()), |
| 238 IDS_SEARCH_ENGINES_INVALID_KEYWORD_TT); |
| 238 UpdateImageView(url_iv_, | 239 UpdateImageView(url_iv_, |
| 239 controller_->IsURLValid(base::UTF16ToUTF8(url_tf_->text())), | 240 controller_->IsURLValid(base::UTF16ToUTF8(url_tf_->GetText())), |
| 240 IDS_SEARCH_ENGINES_INVALID_URL_TT); | 241 IDS_SEARCH_ENGINES_INVALID_URL_TT); |
| 241 UpdateImageView(title_iv_, controller_->IsTitleValid(title_tf_->text()), | 242 UpdateImageView(title_iv_, controller_->IsTitleValid(title_tf_->GetText()), |
| 242 IDS_SEARCH_ENGINES_INVALID_TITLE_TT); | 243 IDS_SEARCH_ENGINES_INVALID_TITLE_TT); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void EditSearchEngineDialog::UpdateImageView(views::ImageView* image_view, | 246 void EditSearchEngineDialog::UpdateImageView(views::ImageView* image_view, |
| 246 bool is_valid, | 247 bool is_valid, |
| 247 int invalid_message_id) { | 248 int invalid_message_id) { |
| 248 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 249 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 249 if (is_valid) { | 250 if (is_valid) { |
| 250 image_view->SetTooltipText(base::string16()); | 251 image_view->SetTooltipText(base::string16()); |
| 251 image_view->SetImage(rb.GetImageSkiaNamed(IDR_INPUT_GOOD)); | 252 image_view->SetImage(rb.GetImageSkiaNamed(IDR_INPUT_GOOD)); |
| 252 } else { | 253 } else { |
| 253 image_view->SetTooltipText(l10n_util::GetStringUTF16(invalid_message_id)); | 254 image_view->SetTooltipText(l10n_util::GetStringUTF16(invalid_message_id)); |
| 254 image_view->SetImage(rb.GetImageSkiaNamed(IDR_INPUT_ALERT)); | 255 image_view->SetImage(rb.GetImageSkiaNamed(IDR_INPUT_ALERT)); |
| 255 } | 256 } |
| 256 } | 257 } |
| OLD | NEW |