summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 22:51:55 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 22:51:55 +0000
commit82b1f8e3008b8c9eea940f222612205a80249523 (patch)
treef9485bcf6ab407d961417df79f197d6628be1ac2
parentba2e465d364c573b530c3a14c99c2b377e5f626d (diff)
downloadchromium_src-82b1f8e3008b8c9eea940f222612205a80249523.zip
chromium_src-82b1f8e3008b8c9eea940f222612205a80249523.tar.gz
chromium_src-82b1f8e3008b8c9eea940f222612205a80249523.tar.bz2
WebUI Prefs: Fix editing of the default search engine
BUG=70799 TEST=Edit the default search engine; " (Default)" should not show up in the editable text field. Review URL: http://codereview.chromium.org/6591111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76639 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options/search_engine_manager_engine_list.js10
-rw-r--r--chrome/browser/ui/webui/options/search_engine_manager_handler.cc5
2 files changed, 11 insertions, 4 deletions
diff --git a/chrome/browser/resources/options/search_engine_manager_engine_list.js b/chrome/browser/resources/options/search_engine_manager_engine_list.js
index f536926..e414de4 100644
--- a/chrome/browser/resources/options/search_engine_manager_engine_list.js
+++ b/chrome/browser/resources/options/search_engine_manager_engine_list.js
@@ -107,7 +107,7 @@ cr.define('options.search_engines', function() {
faviconDivEl.appendChild(imgEl);
nameColEl.appendChild(faviconDivEl);
- var nameEl = this.createEditableTextCell(engine['name'],
+ var nameEl = this.createEditableTextCell(engine['displayName'],
this.isPlaceholder_);
nameColEl.appendChild(nameEl);
@@ -143,6 +143,8 @@ cr.define('options.search_engines', function() {
// Do final adjustment to the input fields.
this.nameField_ = nameEl.querySelector('input');
+ // The editable field uses the raw name, not the display name.
+ this.nameField_.value = engine['name'];
this.keywordField_ = keywordEl.querySelector('input');
this.urlField_ = urlEl.querySelector('input');
@@ -211,11 +213,15 @@ cr.define('options.search_engines', function() {
onEditCancelled_: function() {
chrome.send('searchEngineEditCancelled');
+ var engine = this.searchEngine_;
if (this.isPlaceholder_) {
- var engine = this.searchEngine_;
this.nameField_.value = '';
this.keywordField_.value = '';
this.urlField_.value = '';
+ } else {
+ // The name field has been automatically set to match the display name,
+ // but it should use the raw name instead.
+ this.nameField_.value = engine['name'];
}
this.currentlyValid_ = !this.isPlaceholder_;
},
diff --git a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
index 6d63de6..4a28e23 100644
--- a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
+++ b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc
@@ -144,13 +144,14 @@ void SearchEngineManagerHandler::OnItemsRemoved(int start, int length) {
DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine(
int index, bool is_default) {
TemplateURLTableModel* table_model = list_controller_->table_model();
+ const TemplateURL* template_url = list_controller_->GetTemplateURL(index);
DictionaryValue* dict = new DictionaryValue();
- dict->SetString("name", table_model->GetText(
+ dict->SetString("name", template_url->short_name());
+ dict->SetString("displayName", table_model->GetText(
index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN));
dict->SetString("keyword", table_model->GetText(
index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN));
- const TemplateURL* template_url = list_controller_->GetTemplateURL(index);
dict->SetString("url", template_url->url()->DisplayURL());
dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0);
GURL icon_url = template_url->GetFavIconURL();