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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/views/controls/textfield/textfield.h" | 21 #include "ui/views/controls/textfield/textfield.h" |
22 #include "ui/views/layout/grid_layout.h" | 22 #include "ui/views/layout/grid_layout.h" |
23 #include "ui/views/layout/layout_constants.h" | 23 #include "ui/views/layout/layout_constants.h" |
24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
25 | 25 |
26 using views::GridLayout; | 26 using views::GridLayout; |
27 using views::ImageView; | 27 using views::ImageView; |
28 using views::Textfield; | 28 using views::Textfield; |
29 | 29 |
30 | 30 |
| 31 namespace { |
| 32 // Converts a URL as understood by TemplateURL to one appropriate for display |
| 33 // to the user. |
| 34 string16 GetDisplayURL(const TemplateURL& turl) { |
| 35 return turl.url() ? turl.url()->DisplayURL() : string16(); |
| 36 } |
| 37 } // namespace |
| 38 |
31 namespace browser { | 39 namespace browser { |
32 | 40 |
33 void EditSearchEngine(gfx::NativeWindow parent, | 41 void EditSearchEngine(gfx::NativeWindow parent, |
34 const TemplateURL* template_url, | 42 const TemplateURL* template_url, |
35 EditSearchEngineControllerDelegate* delegate, | 43 EditSearchEngineControllerDelegate* delegate, |
36 Profile* profile) { | 44 Profile* profile) { |
37 EditSearchEngineDialog::Show(parent, template_url, delegate, profile); | 45 EditSearchEngineDialog::Show(parent, template_url, delegate, profile); |
38 } | 46 } |
39 | 47 |
40 } // namespace browser | 48 } // namespace browser |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const views::KeyEvent& key_event) { | 122 const views::KeyEvent& key_event) { |
115 return false; | 123 return false; |
116 } | 124 } |
117 | 125 |
118 void EditSearchEngineDialog::Init() { | 126 void EditSearchEngineDialog::Init() { |
119 // Create the views we'll need. | 127 // Create the views we'll need. |
120 if (controller_->template_url()) { | 128 if (controller_->template_url()) { |
121 title_tf_ = CreateTextfield(controller_->template_url()->short_name(), | 129 title_tf_ = CreateTextfield(controller_->template_url()->short_name(), |
122 false); | 130 false); |
123 keyword_tf_ = CreateTextfield(controller_->template_url()->keyword(), true); | 131 keyword_tf_ = CreateTextfield(controller_->template_url()->keyword(), true); |
124 url_tf_ = CreateTextfield( | 132 url_tf_ = CreateTextfield(GetDisplayURL(*controller_->template_url()), |
125 controller_->template_url()->url_ref().DisplayURL(), false); | 133 false); |
126 // We don't allow users to edit prepopulate URLs. This is done as | 134 // We don't allow users to edit prepopulate URLs. This is done as |
127 // occasionally we need to update the URL of prepopulated TemplateURLs. | 135 // occasionally we need to update the URL of prepopulated TemplateURLs. |
128 url_tf_->SetReadOnly(controller_->template_url()->prepopulate_id() != 0); | 136 url_tf_->SetReadOnly(controller_->template_url()->prepopulate_id() != 0); |
129 } else { | 137 } else { |
130 title_tf_ = CreateTextfield(string16(), false); | 138 title_tf_ = CreateTextfield(string16(), false); |
131 keyword_tf_ = CreateTextfield(string16(), true); | 139 keyword_tf_ = CreateTextfield(string16(), true); |
132 url_tf_ = CreateTextfield(string16(), false); | 140 url_tf_ = CreateTextfield(string16(), false); |
133 } | 141 } |
134 title_iv_ = new ImageView(); | 142 title_iv_ = new ImageView(); |
135 keyword_iv_ = new ImageView(); | 143 keyword_iv_ = new ImageView(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 image_view->SetImage( | 268 image_view->SetImage( |
261 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 269 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
262 IDR_INPUT_GOOD)); | 270 IDR_INPUT_GOOD)); |
263 } else { | 271 } else { |
264 image_view->SetTooltipText(l10n_util::GetStringUTF16(invalid_message_id)); | 272 image_view->SetTooltipText(l10n_util::GetStringUTF16(invalid_message_id)); |
265 image_view->SetImage( | 273 image_view->SetImage( |
266 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 274 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
267 IDR_INPUT_ALERT)); | 275 IDR_INPUT_ALERT)); |
268 } | 276 } |
269 } | 277 } |
OLD | NEW |