Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: chrome/browser/ui/views/edit_search_engine_dialog.cc

Issue 138363004: Views Textfield fixes and cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and rebase. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/edit_search_engine_dialog.h ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..50a49aea318f19e40795e86650d5480bac918c96 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,14 @@ 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_ && !sender->HasCompositionText()) {
+ // TODO(msw): Prevent textfield scrolling with selection model changes here.
+ const gfx::SelectionModel selection_model = sender->GetSelectionModel();
+ sender->SetText(base::i18n::ToLower(new_contents));
+ sender->SelectSelectionModel(selection_model);
+ }
+
GetDialogClientView()->UpdateDialogButtons();
UpdateImageViews();
}
@@ -115,18 +124,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 +231,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;
}
« no previous file with comments | « chrome/browser/ui/views/edit_search_engine_dialog.h ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698