| 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/importer_view.h" | 5 #include "chrome/browser/views/importer_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 initial_state_(initial_state) { | 46 initial_state_(initial_state) { |
| 47 DCHECK(profile); | 47 DCHECK(profile); |
| 48 SetupControl(); | 48 SetupControl(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ImporterView::~ImporterView() { | 51 ImporterView::~ImporterView() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ImporterView::SetupControl() { | 54 void ImporterView::SetupControl() { |
| 55 // Adds all controls. | 55 // Adds all controls. |
| 56 import_from_label_ = | 56 import_from_label_ = new views::Label(UTF16ToWide( |
| 57 new views::Label(l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); | 57 l10n_util::GetStringUTF16(IDS_IMPORT_FROM_LABEL))); |
| 58 | 58 |
| 59 profile_combobox_ = new views::Combobox(this); | 59 profile_combobox_ = new views::Combobox(this); |
| 60 profile_combobox_->set_listener(this); | 60 profile_combobox_->set_listener(this); |
| 61 profile_combobox_->SetAccessibleName(import_from_label_->GetText()); | 61 profile_combobox_->SetAccessibleName(import_from_label_->GetText()); |
| 62 | 62 |
| 63 import_items_label_ = | 63 import_items_label_ = new views::Label(UTF16ToWide( |
| 64 new views::Label(l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); | 64 l10n_util::GetStringUTF16(IDS_IMPORT_ITEMS_LABEL))); |
| 65 | 65 |
| 66 history_checkbox_ = | 66 history_checkbox_ = InitCheckbox( |
| 67 InitCheckbox(l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX), | 67 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX)), |
| 68 (initial_state_ & importer::HISTORY) != 0); | 68 (initial_state_ & importer::HISTORY) != 0); |
| 69 favorites_checkbox_ = | 69 favorites_checkbox_ = InitCheckbox( |
| 70 InitCheckbox(l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX), | 70 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_FAVORITES_CHKBOX)), |
| 71 (initial_state_ & importer::FAVORITES) != 0); | 71 (initial_state_ & importer::FAVORITES) != 0); |
| 72 passwords_checkbox_ = | 72 passwords_checkbox_ = InitCheckbox( |
| 73 InitCheckbox(l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX), | 73 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX)), |
| 74 (initial_state_ & importer::PASSWORDS) != 0); | 74 (initial_state_ & importer::PASSWORDS) != 0); |
| 75 search_engines_checkbox_ = | 75 search_engines_checkbox_ = InitCheckbox( |
| 76 InitCheckbox(l10n_util::GetString(IDS_IMPORT_SEARCH_ENGINES_CHKBOX), | 76 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_SEARCH_ENGINES_CHKBOX)), |
| 77 (initial_state_ & importer::SEARCH_ENGINES) != 0); | 77 (initial_state_ & importer::SEARCH_ENGINES) != 0); |
| 78 | 78 |
| 79 // Arranges controls by using GridLayout. | 79 // Arranges controls by using GridLayout. |
| 80 const int column_set_id = 0; | 80 const int column_set_id = 0; |
| 81 GridLayout* layout = CreatePanelGridLayout(this); | 81 GridLayout* layout = CreatePanelGridLayout(this); |
| 82 SetLayoutManager(layout); | 82 SetLayoutManager(layout); |
| 83 ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 83 ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
| 84 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 84 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
| 85 GridLayout::USE_PREF, 0, 0); | 85 GridLayout::USE_PREF, 0, 0); |
| 86 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 86 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 87 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, | 87 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 IDS_IMPORT_DIALOG_HEIGHT_LINES)); | 115 IDS_IMPORT_DIALOG_HEIGHT_LINES)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ImporterView::Layout() { | 118 void ImporterView::Layout() { |
| 119 GetLayoutManager()->Layout(this); | 119 GetLayoutManager()->Layout(this); |
| 120 } | 120 } |
| 121 | 121 |
| 122 std::wstring ImporterView::GetDialogButtonLabel( | 122 std::wstring ImporterView::GetDialogButtonLabel( |
| 123 MessageBoxFlags::DialogButton button) const { | 123 MessageBoxFlags::DialogButton button) const { |
| 124 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 124 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
| 125 return l10n_util::GetString(IDS_IMPORT_COMMIT); | 125 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_COMMIT)); |
| 126 } else { | 126 } else { |
| 127 return std::wstring(); | 127 return std::wstring(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool ImporterView::IsDialogButtonEnabled( | 131 bool ImporterView::IsDialogButtonEnabled( |
| 132 MessageBoxFlags::DialogButton button) const { | 132 MessageBoxFlags::DialogButton button) const { |
| 133 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 133 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
| 134 return history_checkbox_->checked() || | 134 return history_checkbox_->checked() || |
| 135 favorites_checkbox_->checked() || | 135 favorites_checkbox_->checked() || |
| 136 passwords_checkbox_->checked() || | 136 passwords_checkbox_->checked() || |
| 137 search_engines_checkbox_->checked(); | 137 search_engines_checkbox_->checked(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 return true; | 140 return true; |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool ImporterView::IsModal() const { | 143 bool ImporterView::IsModal() const { |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 std::wstring ImporterView::GetWindowTitle() const { | 147 std::wstring ImporterView::GetWindowTitle() const { |
| 148 return l10n_util::GetString(IDS_IMPORT_SETTINGS_TITLE); | 148 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_SETTINGS_TITLE)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool ImporterView::Accept() { | 151 bool ImporterView::Accept() { |
| 152 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) | 152 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) |
| 153 return false; | 153 return false; |
| 154 | 154 |
| 155 uint16 items = GetCheckedItems(); | 155 uint16 items = GetCheckedItems(); |
| 156 | 156 |
| 157 int selected_index = profile_combobox_->selected_item(); | 157 int selected_index = profile_combobox_->selected_item(); |
| 158 StartImportingWithUI(GetWidget()->GetNativeView(), items, | 158 StartImportingWithUI(GetWidget()->GetNativeView(), items, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 if (favorites_checkbox_->IsEnabled()) | 292 if (favorites_checkbox_->IsEnabled()) |
| 293 favorites_checkbox_->SetChecked(!!(items & importer::FAVORITES)); | 293 favorites_checkbox_->SetChecked(!!(items & importer::FAVORITES)); |
| 294 | 294 |
| 295 if (passwords_checkbox_->IsEnabled()) | 295 if (passwords_checkbox_->IsEnabled()) |
| 296 passwords_checkbox_->SetChecked(!!(items & importer::PASSWORDS)); | 296 passwords_checkbox_->SetChecked(!!(items & importer::PASSWORDS)); |
| 297 | 297 |
| 298 if (search_engines_checkbox_->IsEnabled()) | 298 if (search_engines_checkbox_->IsEnabled()) |
| 299 search_engines_checkbox_->SetChecked(!!(items & importer::SEARCH_ENGINES)); | 299 search_engines_checkbox_->SetChecked(!!(items & importer::SEARCH_ENGINES)); |
| 300 } | 300 } |
| OLD | NEW |