Chromium Code Reviews| Index: chrome/browser/ui/views/edit_search_engine_dialog.cc |
| diff --git a/chrome/browser/ui/views/edit_search_engine_dialog.cc b/chrome/browser/ui/views/edit_search_engine_dialog.cc |
| index 711422266c1827483262057fb947c0a77f29e6d1..906796767a5d25195f46af856942b7d1e512e61a 100644 |
| --- a/chrome/browser/ui/views/edit_search_engine_dialog.cc |
| +++ b/chrome/browser/ui/views/edit_search_engine_dialog.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/ui/views/edit_search_engine_dialog.h" |
| +#include "base/i18n/case_conversion.h" |
| #include "base/i18n/rtl.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -102,6 +103,13 @@ bool EditSearchEngineDialog::Accept() { |
| void EditSearchEngineDialog::ContentsChanged( |
| Textfield* sender, |
| const base::string16& new_contents) { |
| + // Force the keyword text to be lowercase, keep the caret or selection. |
| + if (sender == keyword_tf_) { |
| + const gfx::SelectionModel selection_model = sender->GetSelectionModel(); |
| + sender->SetText(base::i18n::ToLower(new_contents)); |
| + sender->SelectSelectionModel(selection_model); |
|
sky
2014/01/14 23:17:13
This seems really heavyweight and easy to lose sta
msw
2014/01/15 01:22:03
The ToT implementation is worse, it actually clamp
|
| + } |
| + |
| GetDialogClientView()->UpdateDialogButtons(); |
| UpdateImageViews(); |
| } |
| @@ -115,18 +123,17 @@ bool EditSearchEngineDialog::HandleKeyEvent( |
| void EditSearchEngineDialog::Init() { |
| // Create the views we'll need. |
| if (controller_->template_url()) { |
| - title_tf_ = CreateTextfield(controller_->template_url()->short_name(), |
| - false); |
| - keyword_tf_ = CreateTextfield(controller_->template_url()->keyword(), true); |
| + title_tf_ = CreateTextfield(controller_->template_url()->short_name()); |
| + keyword_tf_ = CreateTextfield(controller_->template_url()->keyword()); |
| url_tf_ = CreateTextfield( |
| - controller_->template_url()->url_ref().DisplayURL(), false); |
| + controller_->template_url()->url_ref().DisplayURL()); |
| // We don't allow users to edit prepopulate URLs. This is done as |
| // occasionally we need to update the URL of prepopulated TemplateURLs. |
| url_tf_->SetReadOnly(controller_->template_url()->prepopulate_id() != 0); |
| } else { |
| - title_tf_ = CreateTextfield(base::string16(), false); |
| - keyword_tf_ = CreateTextfield(base::string16(), true); |
| - url_tf_ = CreateTextfield(base::string16(), false); |
| + title_tf_ = CreateTextfield(base::string16()); |
| + keyword_tf_ = CreateTextfield(base::string16()); |
| + url_tf_ = CreateTextfield(base::string16()); |
| } |
| title_iv_ = new views::ImageView(); |
| keyword_iv_ = new views::ImageView(); |
| @@ -223,12 +230,10 @@ views::Label* EditSearchEngineDialog::CreateLabel(int message_id) { |
| return label; |
| } |
| -Textfield* EditSearchEngineDialog::CreateTextfield(const base::string16& text, |
| - bool lowercase) { |
| - Textfield* text_field = new Textfield( |
| - lowercase ? Textfield::STYLE_LOWERCASE : Textfield::STYLE_DEFAULT); |
| +Textfield* EditSearchEngineDialog::CreateTextfield(const base::string16& text) { |
| + Textfield* text_field = new Textfield(); |
| text_field->SetText(text); |
| - text_field->SetController(this); |
| + text_field->set_controller(this); |
| return text_field; |
| } |