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 #include "chrome/browser/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/first_run/first_run_internal.h" | 9 #include "chrome/browser/first_run/first_run_internal.h" |
10 #include "chrome/browser/importer/importer_host.h" | 10 #include "chrome/browser/importer/importer_host.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 namespace first_run { | 121 namespace first_run { |
122 | 122 |
123 // TODO(port): Import switches need to be ported to both Mac and Linux. Not all | 123 // TODO(port): Import switches need to be ported to both Mac and Linux. Not all |
124 // import switches here are implemented for Linux. None are implemented for Mac | 124 // import switches here are implemented for Linux. None are implemented for Mac |
125 // (as this function will not be called on Mac). | 125 // (as this function will not be called on Mac). |
126 int ImportNow(Profile* profile, const CommandLine& cmdline) { | 126 int ImportNow(Profile* profile, const CommandLine& cmdline) { |
127 return internal::ImportBookmarkFromFileIfNeeded(profile, cmdline); | 127 return internal::ImportBookmarkFromFileIfNeeded(profile, cmdline); |
128 } | 128 } |
129 | 129 |
130 bool ProcessMasterPreferences(const FilePath& user_data_dir, | 130 ProcessMasterPreferencesResult ProcessMasterPreferences( |
131 MasterPrefs* out_prefs) { | 131 const FilePath& user_data_dir, |
| 132 MasterPrefs* out_prefs) { |
132 DCHECK(!user_data_dir.empty()); | 133 DCHECK(!user_data_dir.empty()); |
133 | 134 |
134 FilePath master_prefs_path; | 135 FilePath master_prefs_path; |
135 scoped_ptr<installer::MasterPreferences> | 136 scoped_ptr<installer::MasterPreferences> |
136 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); | 137 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); |
137 if (!install_prefs.get()) | 138 if (!install_prefs.get()) |
138 return true; | 139 return SHOW_FIRST_RUN; |
139 | 140 |
140 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); | 141 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); |
141 | 142 |
142 internal::SetRLZPref(out_prefs, install_prefs.get()); | 143 internal::SetRLZPref(out_prefs, install_prefs.get()); |
143 | 144 |
144 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 145 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
145 return true; | 146 return SHOW_FIRST_RUN; |
146 | 147 |
147 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, | 148 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, |
148 install_prefs.get()); | 149 install_prefs.get()); |
149 | 150 |
150 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run | 151 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run |
151 // import process. http://crbug.com/49647 | 152 // import process. http://crbug.com/49647 |
152 // Note we are skipping all other master preferences if skip-first-run-ui | 153 // Note we are skipping all other master preferences if skip-first-run-ui |
153 // is *not* specified. (That is, we continue only if skipping first run ui.) | 154 // is *not* specified. (That is, we continue only if skipping first run ui.) |
154 if (!internal::SkipFirstRunUI(install_prefs.get())) | 155 if (!internal::SkipFirstRunUI(install_prefs.get())) |
155 return true; | 156 return SHOW_FIRST_RUN; |
156 | 157 |
157 // From here on we won't show first run so we need to do the work to show the | 158 // From here on we won't show first run so we need to do the work to show the |
158 // bubble anyway, unless it's already been explicitly suppressed. | 159 // bubble anyway, unless it's already been explicitly suppressed. |
159 SetShowFirstRunBubblePref(true); | 160 SetShowFirstRunBubblePref(true); |
160 | 161 |
161 // We need to be able to create the first run sentinel or else we cannot | 162 // We need to be able to create the first run sentinel or else we cannot |
162 // proceed because ImportSettings will launch the importer process which | 163 // proceed because ImportSettings will launch the importer process which |
163 // would end up here if the sentinel is not present. | 164 // would end up here if the sentinel is not present. |
164 if (!CreateSentinel()) | 165 if (!CreateSentinel()) |
165 return false; | 166 return SKIP_FIRST_RUN; |
166 | 167 |
167 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); | 168 internal::SetShowWelcomePagePrefIfNeeded(install_prefs.get()); |
168 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 169 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
169 internal::SetDefaultBrowser(install_prefs.get()); | 170 internal::SetDefaultBrowser(install_prefs.get()); |
170 | 171 |
171 return false; | 172 return SKIP_FIRST_RUN; |
172 } | 173 } |
173 | 174 |
174 | 175 |
175 } // namespace first_run | 176 } // namespace first_run |
OLD | NEW |