OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "grit/locale_settings.h" | 10 #include "grit/locale_settings.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 ImporterView::~ImporterView() { | 46 ImporterView::~ImporterView() { |
47 } | 47 } |
48 | 48 |
49 void ImporterView::SetupControl() { | 49 void ImporterView::SetupControl() { |
50 // Adds all controls. | 50 // Adds all controls. |
51 import_from_label_ = | 51 import_from_label_ = |
52 new views::Label(l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); | 52 new views::Label(l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); |
53 | 53 |
54 profile_combobox_ = new views::ComboBox(this); | 54 profile_combobox_ = new views::Combobox(this); |
55 profile_combobox_->SetListener(this); | 55 profile_combobox_->set_listener(this); |
56 | 56 |
57 import_items_label_ = | 57 import_items_label_ = |
58 new views::Label(l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); | 58 new views::Label(l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); |
59 | 59 |
60 history_checkbox_ = | 60 history_checkbox_ = |
61 InitCheckbox(l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX), true); | 61 InitCheckbox(l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX), true); |
62 favorites_checkbox_ = | 62 favorites_checkbox_ = |
63 InitCheckbox(l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX), true); | 63 InitCheckbox(l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX), true); |
64 passwords_checkbox_ = | 64 passwords_checkbox_ = |
65 InitCheckbox(l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX), true); | 65 InitCheckbox(l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX), true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 bool ImporterView::Accept() { | 130 bool ImporterView::Accept() { |
131 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { | 131 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { |
132 return false; | 132 return false; |
133 } | 133 } |
134 | 134 |
135 uint16 items = GetCheckedItems(); | 135 uint16 items = GetCheckedItems(); |
136 | 136 |
137 Browser* browser = BrowserList::GetLastActive(); | 137 Browser* browser = BrowserList::GetLastActive(); |
138 int selected_index = profile_combobox_->GetSelectedItem(); | 138 int selected_index = profile_combobox_->selected_item(); |
139 HWND parent_hwnd = | 139 HWND parent_hwnd = |
140 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); | 140 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); |
141 StartImportingWithUI(parent_hwnd, items, importer_host_.get(), | 141 StartImportingWithUI(parent_hwnd, items, importer_host_.get(), |
142 importer_host_->GetSourceProfileInfoAt(selected_index), | 142 importer_host_->GetSourceProfileInfoAt(selected_index), |
143 profile_, this, false); | 143 profile_, this, false); |
144 // We return false here to prevent the window from being closed. We will be | 144 // We return false here to prevent the window from being closed. We will be |
145 // notified back by our implementation of ImportObserver when the import is | 145 // notified back by our implementation of ImportObserver when the import is |
146 // complete so that we can close ourselves. | 146 // complete so that we can close ourselves. |
147 return false; | 147 return false; |
148 } | 148 } |
149 | 149 |
150 views::View* ImporterView::GetContentsView() { | 150 views::View* ImporterView::GetContentsView() { |
151 return this; | 151 return this; |
152 } | 152 } |
153 | 153 |
154 int ImporterView::GetItemCount(views::ComboBox* source) { | 154 int ImporterView::GetItemCount(views::Combobox* source) { |
155 DCHECK(source == profile_combobox_); | 155 DCHECK(source == profile_combobox_); |
156 DCHECK(importer_host_.get()); | 156 DCHECK(importer_host_.get()); |
157 int item_count = importer_host_->GetAvailableProfileCount(); | 157 int item_count = importer_host_->GetAvailableProfileCount(); |
158 if (checkbox_items_.size() < static_cast<size_t>(item_count)) | 158 if (checkbox_items_.size() < static_cast<size_t>(item_count)) |
159 checkbox_items_.resize(item_count, ALL); | 159 checkbox_items_.resize(item_count, ALL); |
160 return item_count; | 160 return item_count; |
161 } | 161 } |
162 | 162 |
163 std::wstring ImporterView::GetItemAt(views::ComboBox* source, int index) { | 163 std::wstring ImporterView::GetItemAt(views::Combobox* source, int index) { |
164 DCHECK(source == profile_combobox_); | 164 DCHECK(source == profile_combobox_); |
165 DCHECK(importer_host_.get()); | 165 DCHECK(importer_host_.get()); |
166 return importer_host_->GetSourceProfileNameAt(index); | 166 return importer_host_->GetSourceProfileNameAt(index); |
167 } | 167 } |
168 | 168 |
169 void ImporterView::ItemChanged(views::ComboBox* combo_box, | 169 void ImporterView::ItemChanged(views::Combobox* combobox, |
170 int prev_index, int new_index) { | 170 int prev_index, int new_index) { |
171 DCHECK(combo_box); | 171 DCHECK(combobox); |
172 DCHECK(checkbox_items_.size() >= | 172 DCHECK(checkbox_items_.size() >= |
173 static_cast<size_t>(importer_host_->GetAvailableProfileCount())); | 173 static_cast<size_t>(importer_host_->GetAvailableProfileCount())); |
174 | 174 |
175 if (prev_index == new_index) | 175 if (prev_index == new_index) |
176 return; | 176 return; |
177 | 177 |
178 // Save the current state | 178 // Save the current state |
179 uint16 prev_items = GetCheckedItems(); | 179 uint16 prev_items = GetCheckedItems(); |
180 checkbox_items_[prev_index] = prev_items; | 180 checkbox_items_[prev_index] = prev_items; |
181 | 181 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 if (favorites_checkbox_->IsEnabled()) | 253 if (favorites_checkbox_->IsEnabled()) |
254 favorites_checkbox_->SetChecked(!!(items & FAVORITES)); | 254 favorites_checkbox_->SetChecked(!!(items & FAVORITES)); |
255 | 255 |
256 if (passwords_checkbox_->IsEnabled()) | 256 if (passwords_checkbox_->IsEnabled()) |
257 passwords_checkbox_->SetChecked(!!(items & PASSWORDS)); | 257 passwords_checkbox_->SetChecked(!!(items & PASSWORDS)); |
258 | 258 |
259 if (search_engines_checkbox_->IsEnabled()) | 259 if (search_engines_checkbox_->IsEnabled()) |
260 search_engines_checkbox_->SetChecked(!!(items & SEARCH_ENGINES)); | 260 search_engines_checkbox_->SetChecked(!!(items & SEARCH_ENGINES)); |
261 } | 261 } |
OLD | NEW |