Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: chrome/browser/ui/views/importer/import_progress_dialog_view.cc

Issue 9702103: Clean up first run: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/importer/import_progress_dialog_view.h" 5 #include "chrome/browser/ui/views/importer/import_progress_dialog_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/importer/importer_host.h" 8 #include "chrome/browser/importer/importer_host.h"
9 #include "chrome/browser/importer/importer_observer.h" 9 #include "chrome/browser/importer/importer_observer.h"
10 #include "chrome/browser/importer/importer_progress_dialog.h" 10 #include "chrome/browser/importer/importer_progress_dialog.h"
11 #include "grit/chromium_strings.h" 11 #include "grit/chromium_strings.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "grit/locale_settings.h" 13 #include "grit/locale_settings.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
16 #include "ui/views/controls/throbber.h" 16 #include "ui/views/controls/throbber.h"
17 #include "ui/views/layout/grid_layout.h" 17 #include "ui/views/layout/grid_layout.h"
18 #include "ui/views/layout/layout_constants.h" 18 #include "ui/views/layout/layout_constants.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 20
21 ImportProgressDialogView::ImportProgressDialogView( 21 ImportProgressDialogView::ImportProgressDialogView(
22 HWND parent_window,
23 uint16 items, 22 uint16 items,
24 ImporterHost* importer_host, 23 ImporterHost* importer_host,
25 ImporterObserver* importer_observer, 24 ImporterObserver* importer_observer,
26 const string16& importer_name, 25 const string16& importer_name,
27 bool bookmarks_import) 26 bool bookmarks_import)
28 : state_bookmarks_(new views::CheckmarkThrobber), 27 : state_bookmarks_(new views::CheckmarkThrobber),
29 state_searches_(new views::CheckmarkThrobber), 28 state_searches_(new views::CheckmarkThrobber),
30 state_passwords_(new views::CheckmarkThrobber), 29 state_passwords_(new views::CheckmarkThrobber),
31 state_history_(new views::CheckmarkThrobber), 30 state_history_(new views::CheckmarkThrobber),
32 state_cookies_(new views::CheckmarkThrobber), 31 state_cookies_(new views::CheckmarkThrobber),
33 label_bookmarks_(new views::Label( 32 label_bookmarks_(new views::Label(
34 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_BOOKMARKS))), 33 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_BOOKMARKS))),
35 label_searches_(new views::Label( 34 label_searches_(new views::Label(
36 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_SEARCH))), 35 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_SEARCH))),
37 label_passwords_(new views::Label( 36 label_passwords_(new views::Label(
38 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_PASSWORDS))), 37 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_PASSWORDS))),
39 label_history_(new views::Label( 38 label_history_(new views::Label(
40 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_HISTORY))), 39 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_HISTORY))),
41 label_cookies_(new views::Label( 40 label_cookies_(new views::Label(
42 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_COOKIES))), 41 l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_COOKIES))),
43 parent_window_(parent_window),
44 items_(items), 42 items_(items),
45 importer_host_(importer_host), 43 importer_host_(importer_host),
46 importer_observer_(importer_observer), 44 importer_observer_(importer_observer),
47 importing_(true), 45 importing_(true),
48 bookmarks_import_(bookmarks_import) { 46 bookmarks_import_(bookmarks_import) {
49 std::wstring info_text = bookmarks_import ? 47 std::wstring info_text = bookmarks_import ?
50 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_BOOKMARKS)) : 48 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_BOOKMARKS)) :
51 UTF16ToWide(l10n_util::GetStringFUTF16( 49 UTF16ToWide(l10n_util::GetStringFUTF16(
52 IDS_IMPORT_PROGRESS_INFO, importer_name)); 50 IDS_IMPORT_PROGRESS_INFO, importer_name));
53 label_info_ = new views::Label(info_text); 51 label_info_ = new views::Label(info_text);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 int ImportProgressDialogView::GetDialogButtons() const { 111 int ImportProgressDialogView::GetDialogButtons() const {
114 return ui::DIALOG_BUTTON_CANCEL; 112 return ui::DIALOG_BUTTON_CANCEL;
115 } 113 }
116 114
117 string16 ImportProgressDialogView::GetDialogButtonLabel( 115 string16 ImportProgressDialogView::GetDialogButtonLabel(
118 ui::DialogButton button) const { 116 ui::DialogButton button) const {
119 DCHECK_EQ(button, ui::DIALOG_BUTTON_CANCEL); 117 DCHECK_EQ(button, ui::DIALOG_BUTTON_CANCEL);
120 return l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_CANCEL); 118 return l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_STATUS_CANCEL);
121 } 119 }
122 120
123 ui::ModalType ImportProgressDialogView::GetModalType() const {
124 return parent_window_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE;
125 }
126
127 string16 ImportProgressDialogView::GetWindowTitle() const { 121 string16 ImportProgressDialogView::GetWindowTitle() const {
128 return l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_TITLE); 122 return l10n_util::GetStringUTF16(IDS_IMPORT_PROGRESS_TITLE);
129 } 123 }
130 124
131 bool ImportProgressDialogView::Cancel() { 125 bool ImportProgressDialogView::Cancel() {
132 // When the user cancels the import, we need to tell the importer_host to stop 126 // When the user cancels the import, we need to tell the importer_host to stop
133 // importing and return false so that the window lives long enough to receive 127 // importing and return false so that the window lives long enough to receive
134 // ImportEnded, which will close the window. Closing the window results in 128 // ImportEnded, which will close the window. Closing the window results in
135 // another call to this function and at that point we must return true to 129 // another call to this function and at that point we must return true to
136 // allow the window to close. 130 // allow the window to close.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // In every case, we need to close the UI now. 268 // In every case, we need to close the UI now.
275 importing_ = false; 269 importing_ = false;
276 importer_host_->SetObserver(NULL); 270 importer_host_->SetObserver(NULL);
277 GetWidget()->Close(); 271 GetWidget()->Close();
278 if (importer_observer_) 272 if (importer_observer_)
279 importer_observer_->ImportCompleted(); 273 importer_observer_->ImportCompleted();
280 } 274 }
281 275
282 namespace importer { 276 namespace importer {
283 277
284 void ShowImportProgressDialog(HWND parent_window, 278 void ShowImportProgressDialog(uint16 items,
285 uint16 items,
286 ImporterHost* importer_host, 279 ImporterHost* importer_host,
287 ImporterObserver* importer_observer, 280 ImporterObserver* importer_observer,
288 const SourceProfile& source_profile, 281 const SourceProfile& source_profile,
289 Profile* target_profile, 282 Profile* target_profile,
290 bool first_run) { 283 bool first_run) {
291 DCHECK_NE(items, 0u); 284 DCHECK_NE(items, 0u);
292 ImportProgressDialogView* progress_view = new ImportProgressDialogView( 285 ImportProgressDialogView* progress_view = new ImportProgressDialogView(
293 parent_window,
294 items, 286 items,
295 importer_host, 287 importer_host,
296 importer_observer, 288 importer_observer,
297 source_profile.importer_name, 289 source_profile.importer_name,
298 source_profile.importer_type == importer::TYPE_BOOKMARKS_FILE); 290 source_profile.importer_type == importer::TYPE_BOOKMARKS_FILE);
299 291
300 views::Widget* window = 292 views::Widget* window = views::Widget::CreateWindow(progress_view);
301 views::Widget::CreateWindowWithParent(progress_view, parent_window);
302 293
303 if (!importer_host->is_headless() && !first_run) 294 if (!importer_host->is_headless() && !first_run)
304 window->Show(); 295 window->Show();
305 296
306 importer_host->StartImportSettings( 297 importer_host->StartImportSettings(source_profile, target_profile, items,
307 source_profile, target_profile, items, new ProfileWriter(target_profile), 298 new ProfileWriter(target_profile), first_run);
308 first_run);
309 } 299 }
310 300
311 } // namespace importer 301 } // namespace importer
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/importer/import_progress_dialog_view.h ('k') | chrome/browser/ui/views/stubs_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698