| 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/first_run_search_engine_view.h" | 5 #include "chrome/browser/views/first_run_search_engine_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/search_engines/search_engine_type.h" | 18 #include "chrome/browser/search_engines/search_engine_type.h" |
| 18 #include "chrome/browser/search_engines/template_url.h" | 19 #include "chrome/browser/search_engines/template_url.h" |
| 19 #include "chrome/browser/search_engines/template_url_model.h" | 20 #include "chrome/browser/search_engines/template_url_model.h" |
| 20 #include "chrome/browser/ui/options/options_window.h" | 21 #include "chrome/browser/ui/options/options_window.h" |
| 21 #include "gfx/canvas.h" | 22 #include "gfx/canvas.h" |
| 22 #include "gfx/font.h" | 23 #include "gfx/font.h" |
| 23 #include "grit/browser_resources.h" | 24 #include "grit/browser_resources.h" |
| 24 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
| 25 #include "grit/google_chrome_strings.h" | 26 #include "grit/google_chrome_strings.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 const int kSmallLogoHeight = 88; | 47 const int kSmallLogoHeight = 88; |
| 47 | 48 |
| 48 // Used to pad text label height so it fits nicely in view. | 49 // Used to pad text label height so it fits nicely in view. |
| 49 const int kLabelPadding = 25; | 50 const int kLabelPadding = 25; |
| 50 | 51 |
| 51 } // namespace | 52 } // namespace |
| 52 | 53 |
| 53 SearchEngineChoice::SearchEngineChoice(views::ButtonListener* listener, | 54 SearchEngineChoice::SearchEngineChoice(views::ButtonListener* listener, |
| 54 const TemplateURL* search_engine, | 55 const TemplateURL* search_engine, |
| 55 bool use_small_logos) | 56 bool use_small_logos) |
| 56 : NativeButton(listener, l10n_util::GetString(IDS_FR_SEARCH_CHOOSE)), | 57 : NativeButton( |
| 58 listener, |
| 59 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FR_SEARCH_CHOOSE))), |
| 57 is_image_label_(false), | 60 is_image_label_(false), |
| 58 search_engine_(search_engine), | 61 search_engine_(search_engine), |
| 59 slot_(0) { | 62 slot_(0) { |
| 60 bool use_images = false; | 63 bool use_images = false; |
| 61 #if defined(GOOGLE_CHROME_BUILD) | 64 #if defined(GOOGLE_CHROME_BUILD) |
| 62 use_images = true; | 65 use_images = true; |
| 63 #endif | 66 #endif |
| 64 int logo_id = search_engine_->logo_id(); | 67 int logo_id = search_engine_->logo_id(); |
| 65 if (use_images && logo_id != kNoSearchEngineLogo) { | 68 if (use_images && logo_id != kNoSearchEngineLogo) { |
| 66 is_image_label_ = true; | 69 is_image_label_ = true; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 background_image_->SetHorizontalAlignment(ImageView::LEADING); | 289 background_image_->SetHorizontalAlignment(ImageView::LEADING); |
| 287 } else { | 290 } else { |
| 288 background_image_->SetHorizontalAlignment(ImageView::TRAILING); | 291 background_image_->SetHorizontalAlignment(ImageView::TRAILING); |
| 289 } | 292 } |
| 290 | 293 |
| 291 AddChildView(background_image_); | 294 AddChildView(background_image_); |
| 292 | 295 |
| 293 int label_width = GetPreferredSize().width() - 2 * kPanelHorizMargin; | 296 int label_width = GetPreferredSize().width() - 2 * kPanelHorizMargin; |
| 294 | 297 |
| 295 // Add title and text asking the user to choose a search engine: | 298 // Add title and text asking the user to choose a search engine: |
| 296 title_label_ = new Label(l10n_util::GetString( | 299 title_label_ = new Label(UTF16ToWide(l10n_util::GetStringUTF16( |
| 297 IDS_FR_SEARCH_MAIN_LABEL)); | 300 IDS_FR_SEARCH_MAIN_LABEL))); |
| 298 title_label_->SetColor(SK_ColorBLACK); | 301 title_label_->SetColor(SK_ColorBLACK); |
| 299 title_label_->SetFont(title_label_->font().DeriveFont(3, gfx::Font::BOLD)); | 302 title_label_->SetFont(title_label_->font().DeriveFont(3, gfx::Font::BOLD)); |
| 300 title_label_->SetMultiLine(true); | 303 title_label_->SetMultiLine(true); |
| 301 title_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 304 title_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 302 title_label_->SizeToFit(label_width); | 305 title_label_->SizeToFit(label_width); |
| 303 AddChildView(title_label_); | 306 AddChildView(title_label_); |
| 304 | 307 |
| 305 text_label_ = new Label(l10n_util::GetStringF(IDS_FR_SEARCH_TEXT, | 308 text_label_ = new Label(UTF16ToWide(l10n_util::GetStringFUTF16( |
| 306 l10n_util::GetString(IDS_PRODUCT_NAME))); | 309 IDS_FR_SEARCH_TEXT, |
| 310 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); |
| 307 text_label_->SetColor(SK_ColorBLACK); | 311 text_label_->SetColor(SK_ColorBLACK); |
| 308 text_label_->SetFont(text_label_->font().DeriveFont(1, gfx::Font::NORMAL)); | 312 text_label_->SetFont(text_label_->font().DeriveFont(1, gfx::Font::NORMAL)); |
| 309 text_label_->SetMultiLine(true); | 313 text_label_->SetMultiLine(true); |
| 310 text_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 314 text_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 311 text_label_->SizeToFit(label_width); | 315 text_label_->SizeToFit(label_width); |
| 312 AddChildView(text_label_); | 316 AddChildView(text_label_); |
| 313 } | 317 } |
| 314 | 318 |
| 315 void FirstRunSearchEngineView::Layout() { | 319 void FirstRunSearchEngineView::Layout() { |
| 316 // Disable the close button. | 320 // Disable the close button. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 button_width, button_height); | 423 button_width, button_height); |
| 420 } | 424 } |
| 421 } // if (search_engine_choices.size() > 0) | 425 } // if (search_engine_choices.size() > 0) |
| 422 } | 426 } |
| 423 | 427 |
| 424 AccessibilityTypes::Role FirstRunSearchEngineView::GetAccessibleRole() { | 428 AccessibilityTypes::Role FirstRunSearchEngineView::GetAccessibleRole() { |
| 425 return AccessibilityTypes::ROLE_ALERT; | 429 return AccessibilityTypes::ROLE_ALERT; |
| 426 } | 430 } |
| 427 | 431 |
| 428 std::wstring FirstRunSearchEngineView::GetWindowTitle() const { | 432 std::wstring FirstRunSearchEngineView::GetWindowTitle() const { |
| 429 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); | 433 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_TITLE)); |
| 430 } | 434 } |
| OLD | NEW |