| 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_H_ | 5 #ifndef CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_ |
| 6 #define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_ | 6 #define CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // fully test the custom installer. It also contains the opposite actions to | 32 // fully test the custom installer. It also contains the opposite actions to |
| 33 // execute during uninstall. When the first run UI is ready we won't | 33 // execute during uninstall. When the first run UI is ready we won't |
| 34 // do the actions unconditionally. Currently the only action is to create a | 34 // do the actions unconditionally. Currently the only action is to create a |
| 35 // desktop shortcut. | 35 // desktop shortcut. |
| 36 // | 36 // |
| 37 // The way we detect first-run is by looking at a 'sentinel' file. | 37 // The way we detect first-run is by looking at a 'sentinel' file. |
| 38 // If it does not exist we understand that we need to do the first time | 38 // If it does not exist we understand that we need to do the first time |
| 39 // install work for this user. After that the sentinel file is created. | 39 // install work for this user. After that the sentinel file is created. |
| 40 namespace first_run { | 40 namespace first_run { |
| 41 | 41 |
| 42 enum AutoImportState { | |
| 43 AUTO_IMPORT_NONE = 0, | |
| 44 AUTO_IMPORT_CALLED = 1 << 0, | |
| 45 AUTO_IMPORT_PROFILE_IMPORTED = 1 << 1, | |
| 46 AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED = 1 << 2, | |
| 47 }; | |
| 48 | |
| 49 enum FirstRunBubbleMetric { | 42 enum FirstRunBubbleMetric { |
| 50 FIRST_RUN_BUBBLE_SHOWN = 0, // The search engine bubble was shown. | 43 FIRST_RUN_BUBBLE_SHOWN = 0, // The search engine bubble was shown. |
| 51 FIRST_RUN_BUBBLE_CHANGE_INVOKED, // The bubble's "Change" was invoked. | 44 FIRST_RUN_BUBBLE_CHANGE_INVOKED, // The bubble's "Change" was invoked. |
| 52 NUM_FIRST_RUN_BUBBLE_METRICS | 45 NUM_FIRST_RUN_BUBBLE_METRICS |
| 53 }; | 46 }; |
| 54 | 47 |
| 55 // Options for the first run bubble. The default is FIRST_RUN_BUBBLE_DONT_SHOW. | 48 // Options for the first run bubble. The default is FIRST_RUN_BUBBLE_DONT_SHOW. |
| 56 // FIRST_RUN_BUBBLE_SUPPRESS is stronger in that FIRST_RUN_BUBBLE_SHOW should | 49 // FIRST_RUN_BUBBLE_SUPPRESS is stronger in that FIRST_RUN_BUBBLE_SHOW should |
| 57 // never be set once FIRST_RUN_BUBBLE_SUPPRESS is set. | 50 // never be set once FIRST_RUN_BUBBLE_SUPPRESS is set. |
| 58 enum FirstRunBubbleOptions { | 51 enum FirstRunBubbleOptions { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 // dumped into local_state. Also see related TODO in chrome_browser_main.cc. | 70 // dumped into local_state. Also see related TODO in chrome_browser_main.cc. |
| 78 | 71 |
| 79 int ping_delay; | 72 int ping_delay; |
| 80 bool homepage_defined; | 73 bool homepage_defined; |
| 81 int do_import_items; | 74 int do_import_items; |
| 82 int dont_import_items; | 75 int dont_import_items; |
| 83 bool make_chrome_default; | 76 bool make_chrome_default; |
| 84 bool suppress_first_run_default_browser_prompt; | 77 bool suppress_first_run_default_browser_prompt; |
| 85 std::vector<GURL> new_tabs; | 78 std::vector<GURL> new_tabs; |
| 86 std::vector<GURL> bookmarks; | 79 std::vector<GURL> bookmarks; |
| 87 std::string import_bookmarks_path; | |
| 88 std::string variations_seed; | 80 std::string variations_seed; |
| 89 std::string suppress_default_browser_prompt_for_version; | 81 std::string suppress_default_browser_prompt_for_version; |
| 90 }; | 82 }; |
| 91 | 83 |
| 92 // Returns true if this is the first time chrome is run for this user. | 84 // Returns true if this is the first time chrome is run for this user. |
| 93 bool IsChromeFirstRun(); | 85 bool IsChromeFirstRun(); |
| 94 | 86 |
| 95 // Creates the sentinel file that signals that chrome has been configured. | 87 // Creates the sentinel file that signals that chrome has been configured. |
| 96 bool CreateSentinel(); | 88 bool CreateSentinel(); |
| 97 | 89 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Returns true if the autofill personal data manager first-run action | 123 // Returns true if the autofill personal data manager first-run action |
| 132 // should be taken. | 124 // should be taken. |
| 133 // | 125 // |
| 134 // This will return true only once, the first time it is called after | 126 // This will return true only once, the first time it is called after |
| 135 // SetShouldDoPersonalDataManagerFirstRun() is called. | 127 // SetShouldDoPersonalDataManagerFirstRun() is called. |
| 136 bool ShouldDoPersonalDataManagerFirstRun(); | 128 bool ShouldDoPersonalDataManagerFirstRun(); |
| 137 | 129 |
| 138 // Log a metric for the "FirstRun.SearchEngineBubble" histogram. | 130 // Log a metric for the "FirstRun.SearchEngineBubble" histogram. |
| 139 void LogFirstRunMetric(FirstRunBubbleMetric metric); | 131 void LogFirstRunMetric(FirstRunBubbleMetric metric); |
| 140 | 132 |
| 133 // Allow a test to specify additional arguments for the profile import process. |
| 134 void SetExtraArgumentsForImportProcess(const CommandLine& arguments); |
| 135 |
| 136 // Get any extra arguments set with SetExtraArgumentsForImportProcess. |
| 137 const CommandLine& GetExtraArgumentsForImportProcess(); |
| 138 |
| 139 // -- Platform-specific functions -- |
| 140 |
| 141 // Automatically import history and home page (and search engine, if | 141 // Automatically import history and home page (and search engine, if |
| 142 // ShouldShowSearchEngineDialog is true). Also imports bookmarks from file if | 142 // ShouldShowSearchEngineDialog is true). |
| 143 // |import_bookmarks_path| is not empty. | |
| 144 void AutoImport(Profile* profile, | 143 void AutoImport(Profile* profile, |
| 145 bool homepage_defined, | 144 bool homepage_defined, |
| 146 int import_items, | 145 int import_items, |
| 147 int dont_import_items, | 146 int dont_import_items); |
| 148 const std::string& import_bookmarks_path); | |
| 149 | 147 |
| 150 // Does remaining first run tasks for |profile| and makes Chrome default browser | 148 // Does remaining first run tasks for |profile| and makes Chrome default browser |
| 151 // if |make_chrome_default|. This can pop the first run consent dialog on linux. | 149 // if |make_chrome_default|. This can pop the first run consent dialog on linux. |
| 152 void DoPostImportTasks(Profile* profile, bool make_chrome_default); | 150 void DoPostImportTasks(Profile* profile, bool make_chrome_default); |
| 153 | 151 |
| 154 // Returns the current state of AutoImport as recorded in a bitfield formed from | 152 // Whether a first-run import was triggered before the browser mainloop began. |
| 155 // values in AutoImportState. | 153 // This is used in testing to verify import startup actions that occur before |
| 156 uint16 auto_import_state(); | 154 // an observer can be registered in the test. |
| 155 bool DidPerformProfileImport(bool* exited_successfully); |
| 156 |
| 157 // Imports bookmarks and/or browser items (depending on platform support) |
| 158 // in this process. This function is paired with first_run::ImportSettings(). |
| 159 // This function might or might not show a visible UI depending on the |
| 160 // cmdline parameters. |
| 161 int ImportNow(Profile* profile, const CommandLine& cmdline); |
| 157 | 162 |
| 158 // Set a master preferences file path that overrides platform defaults. | 163 // Set a master preferences file path that overrides platform defaults. |
| 159 void SetMasterPrefsPathForTesting(const base::FilePath& master_prefs); | 164 void SetMasterPrefsPathForTesting(const base::FilePath& master_prefs); |
| 160 | 165 |
| 161 // The master preferences is a JSON file with the same entries as the | 166 // The master preferences is a JSON file with the same entries as the |
| 162 // 'Default\Preferences' file. This function locates this file from a standard | 167 // 'Default\Preferences' file. This function locates this file from a standard |
| 163 // location and processes it so it becomes the default preferences in the | 168 // location and processes it so it becomes the default preferences in the |
| 164 // profile pointed to by |user_data_dir|. After processing the file, the | 169 // profile pointed to by |user_data_dir|. After processing the file, the |
| 165 // function returns a value from the ProcessMasterPreferencesResult enum, | 170 // function returns a value from the ProcessMasterPreferencesResult enum, |
| 166 // indicating whether the first run flow should be shown, skipped, or whether | 171 // indicating whether the first run flow should be shown, skipped, or whether |
| (...skipping 26 matching lines...) Expand all Loading... |
| 193 const content::NotificationDetails& details) OVERRIDE; | 198 const content::NotificationDetails& details) OVERRIDE; |
| 194 | 199 |
| 195 content::NotificationRegistrar registrar_; | 200 content::NotificationRegistrar registrar_; |
| 196 | 201 |
| 197 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleLauncher); | 202 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleLauncher); |
| 198 }; | 203 }; |
| 199 | 204 |
| 200 } // namespace first_run | 205 } // namespace first_run |
| 201 | 206 |
| 202 #endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_ | 207 #endif // CHROME_BROWSER_FIRST_RUN_FIRST_RUN_H_ |
| OLD | NEW |