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

Side by Side Diff: chrome/browser/importer/importer_host.h

Issue 10750018: Remove browser::FindLastActiveWithProfile call in importer code. There are many ways to create an I… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_ 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
6 #define CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_ 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
15 #include "chrome/browser/importer/importer_data_types.h" 15 #include "chrome/browser/importer/importer_data_types.h"
16 #include "chrome/browser/importer/profile_writer.h" 16 #include "chrome/browser/importer/profile_writer.h"
17 #include "chrome/browser/ui/browser_list.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
20 21
21 class FirefoxProfileLock; 22 class FirefoxProfileLock;
22 class Importer; 23 class Importer;
23 class Profile; 24 class Profile;
24 25
25 namespace importer { 26 namespace importer {
26 class ImporterProgressObserver; 27 class ImporterProgressObserver;
27 } 28 }
28 29
29 // This class hosts the importers. It enumerates profiles from other 30 // This class hosts the importers. It enumerates profiles from other
30 // browsers dynamically, and controls the process of importing. When 31 // browsers dynamically, and controls the process of importing. When
31 // the import process is done, ImporterHost deletes itself. 32 // the import process is done, ImporterHost deletes itself.
32 class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, 33 class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
33 public BaseBookmarkModelObserver, 34 public BaseBookmarkModelObserver,
34 public content::NotificationObserver { 35 public content::NotificationObserver,
36 public BrowserList::Observer {
35 public: 37 public:
36 ImporterHost(); 38 ImporterHost();
37 39
38 // ShowWarningDialog() asks user to close the application that is owning the 40 // ShowWarningDialog() asks user to close the application that is owning the
39 // lock. They can retry or skip the importing process. 41 // lock. They can retry or skip the importing process.
40 void ShowWarningDialog(); 42 void ShowWarningDialog();
41 43
42 // This is called when when user ends the lock dialog by clicking on either 44 // This is called when when user ends the lock dialog by clicking on either
43 // the "Skip" or "Continue" buttons. |is_continue| is true when user clicked 45 // the "Skip" or "Continue" buttons. |is_continue| is true when user clicked
44 // the "Continue" button. 46 // the "Continue" button.
(...skipping 11 matching lines...) Expand all
56 58
57 // When in headless mode, the importer will not show the warning dialog and 59 // When in headless mode, the importer will not show the warning dialog and
58 // the outcome is as if the user had canceled the import operation. 60 // the outcome is as if the user had canceled the import operation.
59 void set_headless() { headless_ = true; } 61 void set_headless() { headless_ = true; }
60 bool is_headless() const { return headless_; } 62 bool is_headless() const { return headless_; }
61 63
62 void set_parent_window(gfx::NativeWindow parent_window) { 64 void set_parent_window(gfx::NativeWindow parent_window) {
63 parent_window_ = parent_window; 65 parent_window_ = parent_window;
64 } 66 }
65 67
68 void set_browser(Browser* browser) { browser_ = browser; }
69
66 // Starts the process of importing the settings and data depending on what the 70 // Starts the process of importing the settings and data depending on what the
67 // user selected. 71 // user selected.
68 // |source_profile| - importer profile to import. 72 // |source_profile| - importer profile to import.
69 // |target_profile| - profile to import into. 73 // |target_profile| - profile to import into.
70 // |items| - specifies which data to import (bitmask of importer::ImportItem). 74 // |items| - specifies which data to import (bitmask of importer::ImportItem).
71 // |writer| - called to actually write data back to the profile. 75 // |writer| - called to actually write data back to the profile.
72 // |first_run| - true if this method is being called during first run. 76 // |first_run| - true if this method is being called during first run.
73 virtual void StartImportSettings( 77 virtual void StartImportSettings(
74 const importer::SourceProfile& source_profile, 78 const importer::SourceProfile& source_profile,
75 Profile* target_profile, 79 Profile* target_profile,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE; 136 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
133 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; 137 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
134 virtual void BookmarkModelChanged() OVERRIDE; 138 virtual void BookmarkModelChanged() OVERRIDE;
135 139
136 // content::NotificationObserver: 140 // content::NotificationObserver:
137 // Called when TemplateURLService has been loaded. 141 // Called when TemplateURLService has been loaded.
138 virtual void Observe(int type, 142 virtual void Observe(int type,
139 const content::NotificationSource& source, 143 const content::NotificationSource& source,
140 const content::NotificationDetails& details) OVERRIDE; 144 const content::NotificationDetails& details) OVERRIDE;
141 145
146 // BrowserList::Observer
147 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
148
142 // The task is the process of importing settings from other browsers. 149 // The task is the process of importing settings from other browsers.
143 base::Closure task_; 150 base::Closure task_;
144 151
145 // The importer used in the task. 152 // The importer used in the task.
146 Importer* importer_; 153 Importer* importer_;
147 154
148 // True if UI is not to be shown. 155 // True if UI is not to be shown.
149 bool headless_; 156 bool headless_;
150 157
151 // Parent window that we pass to the import lock dialog (i.e, the Firefox 158 // Parent window that we pass to the import lock dialog (i.e, the Firefox
152 // warning dialog). 159 // warning dialog).
153 gfx::NativeWindow parent_window_; 160 gfx::NativeWindow parent_window_;
154 161
162 // Used to add a new tab if we need the user to sign in.
163 Browser* browser_;
164
155 // The observer that we need to notify about changes in the import process. 165 // The observer that we need to notify about changes in the import process.
156 importer::ImporterProgressObserver* observer_; 166 importer::ImporterProgressObserver* observer_;
157 167
158 // Firefox profile lock. 168 // Firefox profile lock.
159 scoped_ptr<FirefoxProfileLock> firefox_lock_; 169 scoped_ptr<FirefoxProfileLock> firefox_lock_;
160 170
161 DISALLOW_COPY_AND_ASSIGN(ImporterHost); 171 DISALLOW_COPY_AND_ASSIGN(ImporterHost);
162 }; 172 };
163 173
164 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_ 174 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/importer/importer_host.cc » ('j') | chrome/browser/importer/importer_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698