| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/default_search_view.h" | 5 #include "chrome/browser/views/default_search_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 *short_name = built_in_data->short_name(); | 50 *short_name = built_in_data->short_name(); |
| 51 *logo_id = built_in_data->logo_id(); | 51 *logo_id = built_in_data->logo_id(); |
| 52 } else { | 52 } else { |
| 53 *short_name = UTF8ToWide(url.host()).c_str(); | 53 *short_name = UTF8ToWide(url.host()).c_str(); |
| 54 *logo_id = kNoSearchEngineLogo; | 54 *logo_id = kNoSearchEngineLogo; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 views::Label* CreateProviderLabel(int message_id) { | 58 views::Label* CreateProviderLabel(int message_id) { |
| 59 views::Label* choice_label = | 59 views::Label* choice_label = |
| 60 new views::Label(l10n_util::GetString(message_id)); | 60 new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(message_id))); |
| 61 choice_label->SetColor(SK_ColorBLACK); | 61 choice_label->SetColor(SK_ColorBLACK); |
| 62 choice_label->SetFont( | 62 choice_label->SetFont( |
| 63 choice_label->font().DeriveFont(1, gfx::Font::NORMAL)); | 63 choice_label->font().DeriveFont(1, gfx::Font::NORMAL)); |
| 64 return choice_label; | 64 return choice_label; |
| 65 } | 65 } |
| 66 | 66 |
| 67 views::View* CreateProviderLogo( | 67 views::View* CreateProviderLogo( |
| 68 int logo_id, | 68 int logo_id, |
| 69 const std::wstring& short_name) { | 69 const std::wstring& short_name) { |
| 70 views::View* logo_view = NULL; | 70 views::View* logo_view = NULL; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 94 logo_label->SetTooltipText(short_name); | 94 logo_label->SetTooltipText(short_name); |
| 95 logo_view = logo_label; | 95 logo_view = logo_label; |
| 96 } | 96 } |
| 97 | 97 |
| 98 return logo_view; | 98 return logo_view; |
| 99 } | 99 } |
| 100 views::NativeButton* CreateProviderChoiceButton( | 100 views::NativeButton* CreateProviderChoiceButton( |
| 101 views::ButtonListener* listener, | 101 views::ButtonListener* listener, |
| 102 int message_id, | 102 int message_id, |
| 103 const std::wstring& short_name) { | 103 const std::wstring& short_name) { |
| 104 return new views::NativeButton(listener, l10n_util::GetStringF( | 104 return new views::NativeButton(listener, UTF16ToWide( |
| 105 message_id, short_name)); | 105 l10n_util::GetStringFUTF16(message_id, WideToUTF16(short_name)))); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 // static | 110 // static |
| 111 void DefaultSearchView::Show(TabContents* tab_contents, | 111 void DefaultSearchView::Show(TabContents* tab_contents, |
| 112 TemplateURL* default_url, | 112 TemplateURL* default_url, |
| 113 TemplateURLModel* template_url_model) { | 113 TemplateURLModel* template_url_model) { |
| 114 scoped_ptr<TemplateURL> template_url(default_url); | 114 scoped_ptr<TemplateURL> template_url(default_url); |
| 115 if (!template_url_model->CanMakeDefault(default_url) || | 115 if (!template_url_model->CanMakeDefault(default_url) || |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 void DefaultSearchView::ButtonPressed(views::Button* sender, | 137 void DefaultSearchView::ButtonPressed(views::Button* sender, |
| 138 const views::Event& event) { | 138 const views::Event& event) { |
| 139 views::DialogClientView* client = GetDialogClientView(); | 139 views::DialogClientView* client = GetDialogClientView(); |
| 140 if (sender == proposed_provider_button_) | 140 if (sender == proposed_provider_button_) |
| 141 client->AcceptWindow(); | 141 client->AcceptWindow(); |
| 142 else | 142 else |
| 143 client->CancelWindow(); | 143 client->CancelWindow(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 std::wstring DefaultSearchView::GetWindowTitle() const { | 146 std::wstring DefaultSearchView::GetWindowTitle() const { |
| 147 return l10n_util::GetString(IDS_DEFAULT_SEARCH_TITLE); | 147 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_DEFAULT_SEARCH_TITLE)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 views::View* DefaultSearchView::GetInitiallyFocusedView() { | 150 views::View* DefaultSearchView::GetInitiallyFocusedView() { |
| 151 return default_provider_button_; | 151 return default_provider_button_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 views::View* DefaultSearchView::GetContentsView() { | 154 views::View* DefaultSearchView::GetContentsView() { |
| 155 return this; | 155 return this; |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 background_image_->SetImage(rb.GetBitmapNamed(IDR_SEARCH_ENGINE_DIALOG_TOP)); | 257 background_image_->SetImage(rb.GetBitmapNamed(IDR_SEARCH_ENGINE_DIALOG_TOP)); |
| 258 background_image_->EnableCanvasFlippingForRTLUI(true); | 258 background_image_->EnableCanvasFlippingForRTLUI(true); |
| 259 ImageView::Alignment horizontal_alignment = | 259 ImageView::Alignment horizontal_alignment = |
| 260 base::i18n::IsRTL() ? ImageView::LEADING : ImageView::TRAILING; | 260 base::i18n::IsRTL() ? ImageView::LEADING : ImageView::TRAILING; |
| 261 background_image_->SetHorizontalAlignment(horizontal_alignment); | 261 background_image_->SetHorizontalAlignment(horizontal_alignment); |
| 262 layout->AddView(background_image_); | 262 layout->AddView(background_image_); |
| 263 | 263 |
| 264 // Add text informing the user about the requested default change. | 264 // Add text informing the user about the requested default change. |
| 265 layout->StartRowWithPadding(0, kPaddedWholeDialogViewSetId, | 265 layout->StartRowWithPadding(0, kPaddedWholeDialogViewSetId, |
| 266 1, kLabelToControlVerticalSpacing); | 266 1, kLabelToControlVerticalSpacing); |
| 267 Label* summary_label = new Label(l10n_util::GetStringF( | 267 Label* summary_label = new Label(UTF16ToWide(l10n_util::GetStringFUTF16( |
| 268 IDS_DEFAULT_SEARCH_SUMMARY, | 268 IDS_DEFAULT_SEARCH_SUMMARY, |
| 269 proposed_short_name)); | 269 WideToUTF16(proposed_short_name)))); |
| 270 summary_label->SetColor(SK_ColorBLACK); | 270 summary_label->SetColor(SK_ColorBLACK); |
| 271 summary_label->SetFont( | 271 summary_label->SetFont( |
| 272 summary_label->font().DeriveFont(1, gfx::Font::NORMAL)); | 272 summary_label->font().DeriveFont(1, gfx::Font::NORMAL)); |
| 273 summary_label->SetHorizontalAlignment(Label::ALIGN_LEFT); | 273 summary_label->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 274 layout->AddView(summary_label); | 274 layout->AddView(summary_label); |
| 275 | 275 |
| 276 // Add the labels for the tops of the choices. | 276 // Add the labels for the tops of the choices. |
| 277 layout->StartRowWithPadding(0, kChoicesViewSetId, | 277 layout->StartRowWithPadding(0, kChoicesViewSetId, |
| 278 0, kRelatedControlVerticalSpacing); | 278 0, kRelatedControlVerticalSpacing); |
| 279 layout->AddView(CreateProviderLabel(IDS_DEFAULT_SEARCH_LABEL_CURRENT)); | 279 layout->AddView(CreateProviderLabel(IDS_DEFAULT_SEARCH_LABEL_CURRENT)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 292 this, | 292 this, |
| 293 IDS_DEFAULT_SEARCH_PROMPT_CURRENT, | 293 IDS_DEFAULT_SEARCH_PROMPT_CURRENT, |
| 294 default_short_name); | 294 default_short_name); |
| 295 layout->AddView(default_provider_button_); | 295 layout->AddView(default_provider_button_); |
| 296 proposed_provider_button_ = CreateProviderChoiceButton( | 296 proposed_provider_button_ = CreateProviderChoiceButton( |
| 297 this, | 297 this, |
| 298 IDS_DEFAULT_SEARCH_PROMPT_PROPOSED, | 298 IDS_DEFAULT_SEARCH_PROMPT_PROPOSED, |
| 299 proposed_short_name); | 299 proposed_short_name); |
| 300 layout->AddView(proposed_provider_button_); | 300 layout->AddView(proposed_provider_button_); |
| 301 } | 301 } |
| OLD | NEW |