Remove aura enum from DesktopMediaID to fix desktop mirroring audio (CrOS).
[chromium-blink-merge.git] / chrome / browser / importer / external_process_importer_host.h
blob3dc6d4c7d7da06e7333a6860a6c72e8afc453dd8
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_HOST_H_
6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_HOST_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/importer/importer_progress_observer.h"
14 #include "chrome/browser/importer/profile_writer.h"
15 #include "chrome/common/importer/importer_data_types.h"
16 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
17 #include "components/search_engines/template_url_service.h"
18 #include "ui/gfx/native_widget_types.h"
20 class ExternalProcessImporterClient;
21 class FirefoxProfileLock;
22 class Importer;
23 class Profile;
25 namespace importer {
26 struct SourceProfile;
29 // This class manages the import process. It creates the in-process half of the
30 // importer bridge and the external process importer client.
31 class ExternalProcessImporterHost
32 : public bookmarks::BaseBookmarkModelObserver {
33 public:
34 ExternalProcessImporterHost();
36 void Cancel();
38 // Starts the process of importing the settings and data depending on what the
39 // user selected.
40 // |source_profile| - importer profile to import.
41 // |target_profile| - profile to import into.
42 // |items| - specifies which data to import (bitmask of importer::ImportItem).
43 // |writer| - called to actually write data back to the profile.
44 virtual void StartImportSettings(
45 const importer::SourceProfile& source_profile,
46 Profile* target_profile,
47 uint16 items,
48 ProfileWriter* writer);
50 // When in headless mode, the importer will not show any warning dialog if
51 // a user action is required (e.g., Firefox profile is locked and user should
52 // close Firefox to continue) and the outcome is as if the user had canceled
53 // the import operation.
54 void set_headless() { headless_ = true; }
55 bool is_headless() const { return headless_; }
57 void set_parent_window(gfx::NativeWindow parent_window) {
58 parent_window_ = parent_window;
61 void set_observer(importer::ImporterProgressObserver* observer) {
62 observer_ = observer;
65 // A series of functions invoked at the start, during and end of the import
66 // process. The middle functions are notifications that the a harvesting of a
67 // particular source of data (specified by |item|) is under way.
68 void NotifyImportStarted();
69 void NotifyImportItemStarted(importer::ImportItem item);
70 void NotifyImportItemEnded(importer::ImportItem item);
71 void NotifyImportEnded();
73 private:
74 // ExternalProcessImporterHost deletes itself in OnImportEnded().
75 ~ExternalProcessImporterHost() override;
77 // Launches the utility process that starts the import task, unless bookmark
78 // or template model are not yet loaded. If load is not detected, this method
79 // will be called when the loading observer sees that model loading is
80 // complete.
81 virtual void LaunchImportIfReady();
83 // bookmarks::BaseBookmarkModelObserver:
84 void BookmarkModelLoaded(bookmarks::BookmarkModel* model,
85 bool ids_reassigned) override;
86 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override;
87 void BookmarkModelChanged() override;
89 // Called when TemplateURLService has been loaded.
90 void OnTemplateURLServiceLoaded();
92 // ShowWarningDialog() asks user to close the application that is owning the
93 // lock. They can retry or skip the importing process.
94 // This method should not be called if the importer is in headless mode.
95 void ShowWarningDialog();
97 // This is called when when user ends the lock dialog by clicking on either
98 // the "Skip" or "Continue" buttons. |is_continue| is true when user clicked
99 // the "Continue" button.
100 void OnImportLockDialogEnd(bool is_continue);
102 // Make sure that Firefox isn't running, if import browser is Firefox. Show
103 // to the user a dialog that notifies that is necessary to close Firefox
104 // prior to continue.
105 // |source_profile| - importer profile to import.
106 // Returns false iff import should be aborted.
107 bool CheckForFirefoxLock(const importer::SourceProfile& source_profile);
109 // Make sure BookmarkModel and TemplateURLService are loaded before import
110 // process starts, if bookmarks and/or search engines are among the items
111 // which are to be imported.
112 void CheckForLoadedModels(uint16 items);
114 // True if UI is not to be shown.
115 bool headless_;
117 // Parent window that we pass to the import lock dialog (i.e, the Firefox
118 // warning dialog).
119 gfx::NativeWindow parent_window_;
121 // The observer that we need to notify about changes in the import process.
122 importer::ImporterProgressObserver* observer_;
124 // Firefox profile lock.
125 scoped_ptr<FirefoxProfileLock> firefox_lock_;
127 // Profile we're importing from.
128 Profile* profile_;
130 // True if we're waiting for the model to finish loading.
131 bool waiting_for_bookmarkbar_model_;
133 // May contain a Subscription waiting for the TemplateURLService to finish
134 // loading.
135 scoped_ptr<TemplateURLService::Subscription> template_service_subscription_;
137 // Have we installed a listener on the bookmark model?
138 bool installed_bookmark_observer_;
140 // True if source profile is readable.
141 bool is_source_readable_;
143 // Writes data from the importer back to the profile.
144 scoped_refptr<ProfileWriter> writer_;
146 // Used to pass notifications from the browser side to the external process.
147 ExternalProcessImporterClient* client_;
149 // Information about a profile needed for importing.
150 importer::SourceProfile source_profile_;
152 // Bitmask of items to be imported (see importer::ImportItem enum).
153 uint16 items_;
155 // True if the import process has been cancelled.
156 bool cancelled_;
158 // Vends weak pointers for the importer to call us back.
159 base::WeakPtrFactory<ExternalProcessImporterHost> weak_ptr_factory_;
161 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterHost);
164 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_HOST_H_