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