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

Side by Side Diff: chrome/browser/ui/gtk/edit_search_engine_dialog.cc

Issue 9965143: Revert 130431 - Move the URL string from TemplateURLRef onto the owning TemplateURL. This will mak… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtk/edit_search_engine_dialog.h" 5 #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/net/url_fixer_upper.h" 13 #include "chrome/browser/net/url_fixer_upper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/search_engines/template_url.h" 15 #include "chrome/browser/search_engines/template_url.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 16 #include "chrome/browser/search_engines/template_url_service.h"
17 #include "chrome/browser/ui/gtk/gtk_util.h" 17 #include "chrome/browser/ui/gtk/gtk_util.h"
18 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" 18 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "grit/ui_resources.h" 22 #include "grit/ui_resources.h"
23 #include "ui/base/gtk/gtk_hig_constants.h" 23 #include "ui/base/gtk/gtk_hig_constants.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
27 27
28 namespace { 28 namespace {
29 29
30 std::string GetDisplayURL(const TemplateURL& turl) {
31 return turl.url() ? UTF16ToUTF8(turl.url()->DisplayURL()) : std::string();
32 }
33
30 // Forces text to lowercase when connected to an editable's "insert-text" 34 // Forces text to lowercase when connected to an editable's "insert-text"
31 // signal. (Like views Textfield::STYLE_LOWERCASE.) 35 // signal. (Like views Textfield::STYLE_LOWERCASE.)
32 void LowercaseInsertTextHandler(GtkEditable *editable, const gchar *text, 36 void LowercaseInsertTextHandler(GtkEditable *editable, const gchar *text,
33 gint length, gint *position, gpointer data) { 37 gint length, gint *position, gpointer data) {
34 string16 original_text = UTF8ToUTF16(text); 38 string16 original_text = UTF8ToUTF16(text);
35 string16 lower_text = base::i18n::ToLower(original_text); 39 string16 lower_text = base::i18n::ToLower(original_text);
36 if (lower_text != original_text) { 40 if (lower_text != original_text) {
37 std::string result = UTF16ToUTF8(lower_text); 41 std::string result = UTF16ToUTF8(lower_text);
38 // Prevent ourselves getting called recursively about our own edit. 42 // Prevent ourselves getting called recursively about our own edit.
39 g_signal_handlers_block_by_func(G_OBJECT(editable), 43 g_signal_handlers_block_by_func(G_OBJECT(editable),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 146
143 if (controller_->template_url()) { 147 if (controller_->template_url()) {
144 gtk_entry_set_text( 148 gtk_entry_set_text(
145 GTK_ENTRY(title_entry_), 149 GTK_ENTRY(title_entry_),
146 UTF16ToUTF8(controller_->template_url()->short_name()).c_str()); 150 UTF16ToUTF8(controller_->template_url()->short_name()).c_str());
147 gtk_entry_set_text( 151 gtk_entry_set_text(
148 GTK_ENTRY(keyword_entry_), 152 GTK_ENTRY(keyword_entry_),
149 UTF16ToUTF8(controller_->template_url()->keyword()).c_str()); 153 UTF16ToUTF8(controller_->template_url()->keyword()).c_str());
150 gtk_entry_set_text( 154 gtk_entry_set_text(
151 GTK_ENTRY(url_entry_), 155 GTK_ENTRY(url_entry_),
152 UTF16ToUTF8(controller_->template_url()->url_ref().DisplayURL()). 156 GetDisplayURL(*controller_->template_url()).c_str());
153 c_str());
154 // We don't allow users to edit prepopulated URLs. 157 // We don't allow users to edit prepopulated URLs.
155 gtk_editable_set_editable( 158 gtk_editable_set_editable(
156 GTK_EDITABLE(url_entry_), 159 GTK_EDITABLE(url_entry_),
157 controller_->template_url()->prepopulate_id() == 0); 160 controller_->template_url()->prepopulate_id() == 0);
158 161
159 if (controller_->template_url()->prepopulate_id() != 0) { 162 if (controller_->template_url()->prepopulate_id() != 0) {
160 GtkWidget* fake_label = gtk_label_new("Fake label"); 163 GtkWidget* fake_label = gtk_label_new("Fake label");
161 gtk_widget_set_sensitive(fake_label, 164 gtk_widget_set_sensitive(fake_label,
162 controller_->template_url()->prepopulate_id() == 0); 165 controller_->template_url()->prepopulate_id() == 0);
163 GtkStyle* label_style = gtk_widget_get_style(fake_label); 166 GtkStyle* label_style = gtk_widget_get_style(fake_label);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 GetURLInput()); 270 GetURLInput());
268 } else { 271 } else {
269 controller_->CleanUpCancelledAdd(); 272 controller_->CleanUpCancelledAdd();
270 } 273 }
271 gtk_widget_destroy(dialog_); 274 gtk_widget_destroy(dialog_);
272 } 275 }
273 276
274 void EditSearchEngineDialog::OnWindowDestroy(GtkWidget* widget) { 277 void EditSearchEngineDialog::OnWindowDestroy(GtkWidget* widget) {
275 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 278 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
276 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698