| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ | 5 #ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ |
| 6 #define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ | 6 #define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/message_loop.h" | |
| 15 #include "chrome/browser/importer/importer_progress_observer.h" | |
| 16 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 17 | 15 |
| 18 class CommandLine; | 16 class CommandLine; |
| 19 class GURL; | 17 class GURL; |
| 20 class ImporterHost; | 18 class ImporterHost; |
| 21 class ImporterList; | 19 class ImporterList; |
| 22 class Profile; | 20 class Profile; |
| 23 class ProcessSingleton; | 21 class ProcessSingleton; |
| 24 class TemplateURLService; | 22 class TemplateURLService; |
| 25 | 23 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 | 35 |
| 38 enum FirstRunState { | 36 enum FirstRunState { |
| 39 FIRST_RUN_UNKNOWN, // The state is not tested or set yet. | 37 FIRST_RUN_UNKNOWN, // The state is not tested or set yet. |
| 40 FIRST_RUN_TRUE, | 38 FIRST_RUN_TRUE, |
| 41 FIRST_RUN_FALSE | 39 FIRST_RUN_FALSE |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 // This variable should only be accessed through IsChromeFirstRun(). | 42 // This variable should only be accessed through IsChromeFirstRun(). |
| 45 extern FirstRunState first_run_; | 43 extern FirstRunState first_run_; |
| 46 | 44 |
| 47 // This class acts as an observer for the ImporterProgressObserver::ImportEnded | |
| 48 // callback. When the import process is started, certain errors may cause | |
| 49 // ImportEnded() to be called synchronously, but the typical case is that | |
| 50 // ImportEnded() is called asynchronously. Thus we have to handle both cases. | |
| 51 // TODO(gab): Move this to the unnamed namespace of first_run.cc as part of the | |
| 52 // refactoring for OOP import (http://crbug.com/219419). | |
| 53 class ImportEndedObserver : public importer::ImporterProgressObserver { | |
| 54 public: | |
| 55 ImportEndedObserver() : ended_(false), | |
| 56 should_quit_message_loop_(false) {} | |
| 57 virtual ~ImportEndedObserver() {} | |
| 58 | |
| 59 // importer::ImporterProgressObserver: | |
| 60 virtual void ImportStarted() OVERRIDE {} | |
| 61 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | |
| 62 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | |
| 63 virtual void ImportEnded() OVERRIDE; | |
| 64 | |
| 65 void set_should_quit_message_loop() { | |
| 66 should_quit_message_loop_ = true; | |
| 67 } | |
| 68 | |
| 69 bool ended() const { | |
| 70 return ended_; | |
| 71 } | |
| 72 | |
| 73 private: | |
| 74 // Set if the import has ended. | |
| 75 bool ended_; | |
| 76 | |
| 77 // Set by the client (via set_should_quit_message_loop) if, when the import | |
| 78 // ends, this class should quit the message loop. | |
| 79 bool should_quit_message_loop_; | |
| 80 }; | |
| 81 | |
| 82 // Loads master preferences from the master preference file into the installer | 45 // Loads master preferences from the master preference file into the installer |
| 83 // master preferences. Passes the master preference file path out in | 46 // master preferences. Passes the master preference file path out in |
| 84 // master_prefs_path. Returns the pointer to installer::MasterPreferences object | 47 // master_prefs_path. Returns the pointer to installer::MasterPreferences object |
| 85 // if successful; otherwise, returns NULL. | 48 // if successful; otherwise, returns NULL. |
| 86 installer::MasterPreferences* LoadMasterPrefs( | 49 installer::MasterPreferences* LoadMasterPrefs( |
| 87 base::FilePath* master_prefs_path); | 50 base::FilePath* master_prefs_path); |
| 88 | 51 |
| 89 // Copies user preference file to master preference file. Returns true if | 52 // Copies user preference file to master preference file. Returns true if |
| 90 // successful. | 53 // successful. |
| 91 bool CopyPrefFile(const base::FilePath& user_data_dir, | 54 bool CopyPrefFile(const base::FilePath& user_data_dir, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 104 | 67 |
| 105 // Gives the full path to the sentinel file. The file might not exist. | 68 // Gives the full path to the sentinel file. The file might not exist. |
| 106 // This function has a common implementation on OS_POSIX and a windows specific | 69 // This function has a common implementation on OS_POSIX and a windows specific |
| 107 // implementation. | 70 // implementation. |
| 108 bool GetFirstRunSentinelFilePath(base::FilePath* path); | 71 bool GetFirstRunSentinelFilePath(base::FilePath* path); |
| 109 | 72 |
| 110 // This function has a common implementationin for all non-linux platforms, and | 73 // This function has a common implementationin for all non-linux platforms, and |
| 111 // a linux specific implementation. | 74 // a linux specific implementation. |
| 112 bool IsOrganicFirstRun(); | 75 bool IsOrganicFirstRun(); |
| 113 | 76 |
| 114 // Imports settings. This may be done in a separate process depending on the | |
| 115 // platform, but it will always block until done. The return value indicates | |
| 116 // success. | |
| 117 // This functions has a common implementation for OS_POSIX, and a | |
| 118 // windows specific implementation. | |
| 119 bool ImportSettings(Profile* profile, | |
| 120 ImporterHost* importer_host, | |
| 121 scoped_refptr<ImporterList> importer_list, | |
| 122 int items_to_import); | |
| 123 | |
| 124 // Sets import preferences and launch the import process. | |
| 125 void SetImportPreferencesAndLaunchImport( | |
| 126 MasterPrefs* out_prefs, | |
| 127 installer::MasterPreferences* install_prefs); | |
| 128 | |
| 129 int ImportBookmarkFromFileIfNeeded(Profile* profile, | |
| 130 const CommandLine& cmdline); | |
| 131 | |
| 132 #if !defined(OS_WIN) | |
| 133 bool ImportBookmarks(const base::FilePath& import_bookmarks_path); | |
| 134 #endif | |
| 135 | |
| 136 // Shows the EULA dialog if required. Returns true if the EULA is accepted, | 77 // Shows the EULA dialog if required. Returns true if the EULA is accepted, |
| 137 // returns false if the EULA has not been accepted, in which case the browser | 78 // returns false if the EULA has not been accepted, in which case the browser |
| 138 // should exit. | 79 // should exit. |
| 139 bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs); | 80 bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs); |
| 140 | 81 |
| 141 // Returns the path for the master preferences file. | 82 // Returns the path for the master preferences file. |
| 142 base::FilePath MasterPrefsPath(); | 83 base::FilePath MasterPrefsPath(); |
| 143 | 84 |
| 144 } // namespace internal | 85 } // namespace internal |
| 145 } // namespace first_run | 86 } // namespace first_run |
| 146 | 87 |
| 147 #endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ | 88 #endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_INTERNAL_H_ |
| OLD | NEW |