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 <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/environment.h" | 12 #include "base/environment.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 #include "base/win/metro.h" | 24 #include "base/win/metro.h" |
25 #include "base/win/object_watcher.h" | 25 #include "base/win/object_watcher.h" |
26 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/first_run/first_run_import_observer.h" | |
29 #include "chrome/browser/first_run/first_run_internal.h" | 28 #include "chrome/browser/first_run/first_run_internal.h" |
30 #include "chrome/browser/importer/importer_host.h" | 29 #include "chrome/browser/importer/importer_host.h" |
31 #include "chrome/browser/importer/importer_list.h" | 30 #include "chrome/browser/importer/importer_list.h" |
32 #include "chrome/browser/importer/importer_progress_dialog.h" | |
33 #include "chrome/browser/process_singleton.h" | 31 #include "chrome/browser/process_singleton.h" |
34 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/shell_integration.h" | 33 #include "chrome/browser/shell_integration.h" |
36 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
37 #include "chrome/common/chrome_paths.h" | 35 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/chrome_result_codes.h" | 36 #include "chrome/common/chrome_result_codes.h" |
39 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
40 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
41 #include "chrome/common/worker_thread_ticker.h" | 39 #include "chrome/common/worker_thread_ticker.h" |
42 #include "chrome/installer/util/browser_distribution.h" | 40 #include "chrome/installer/util/browser_distribution.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 290 } |
293 int importer_type = 0; | 291 int importer_type = 0; |
294 int items_to_import = 0; | 292 int items_to_import = 0; |
295 bool skip_first_run_ui = false; | 293 bool skip_first_run_ui = false; |
296 if (!DecodeImportParams(import_info, &importer_type, &items_to_import, | 294 if (!DecodeImportParams(import_info, &importer_type, &items_to_import, |
297 &skip_first_run_ui)) { | 295 &skip_first_run_ui)) { |
298 NOTREACHED(); | 296 NOTREACHED(); |
299 return false; | 297 return false; |
300 } | 298 } |
301 scoped_refptr<ImporterHost> importer_host(new ImporterHost); | 299 scoped_refptr<ImporterHost> importer_host(new ImporterHost); |
302 FirstRunImportObserver importer_observer; | |
303 | 300 |
304 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); | 301 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); |
305 importer_list->DetectSourceProfilesHack(); | 302 importer_list->DetectSourceProfilesHack(); |
306 | 303 |
307 // If |skip_first_run_ui|, we run in headless mode. This means that if | 304 // If |skip_first_run_ui|, we run in headless mode. This means that if |
308 // there is user action required the import is automatically canceled. | 305 // there is user action required the import is automatically canceled. |
309 if (skip_first_run_ui) | 306 if (skip_first_run_ui) |
310 importer_host->set_headless(); | 307 importer_host->set_headless(); |
311 | 308 |
312 importer::ShowImportProgressDialog(static_cast<uint16>(items_to_import), | 309 first_run::internal::ImportEndedObserver observer; |
313 importer_host, &importer_observer, | 310 importer_host->SetObserver(&observer); |
| 311 importer_host->StartImportSettings( |
314 importer_list->GetSourceProfileForImporterType(importer_type), profile, | 312 importer_list->GetSourceProfileForImporterType(importer_type), profile, |
315 true); | 313 static_cast<uint16>(items_to_import), new ProfileWriter(profile), true); |
316 importer_observer.RunLoop(); | 314 // If the import process has not errored out, block on it. |
317 return importer_observer.import_result(); | 315 if (!observer.ended()) { |
| 316 observer.set_should_quit_message_loop(); |
| 317 MessageLoop::current()->Run(); |
| 318 } |
| 319 // TODO(gab): This method will be go away as part of http://crbug.com/219419/, |
| 320 // so it is fine to hardcode |RESULT_CODE_NORMAL_EXIT| here for now. |
| 321 return content::RESULT_CODE_NORMAL_EXIT; |
318 } | 322 } |
319 #endif // !defined(USE_AURA) | 323 #endif // !defined(USE_AURA) |
320 | 324 |
321 bool ImportSettingsWin(Profile* profile, | 325 bool ImportSettingsWin(Profile* profile, |
322 int importer_type, | 326 int importer_type, |
323 int items_to_import, | 327 int items_to_import, |
324 const base::FilePath& import_bookmarks_path, | 328 const base::FilePath& import_bookmarks_path, |
325 bool skip_first_run_ui) { | 329 bool skip_first_run_ui) { |
326 if (!items_to_import && import_bookmarks_path.empty()) { | 330 if (!items_to_import && import_bookmarks_path.empty()) { |
327 return true; | 331 return true; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 514 |
511 base::FilePath MasterPrefsPath() { | 515 base::FilePath MasterPrefsPath() { |
512 // The standard location of the master prefs is next to the chrome binary. | 516 // The standard location of the master prefs is next to the chrome binary. |
513 base::FilePath master_prefs; | 517 base::FilePath master_prefs; |
514 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | 518 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
515 return base::FilePath(); | 519 return base::FilePath(); |
516 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); | 520 return master_prefs.AppendASCII(installer::kDefaultMasterPrefs); |
517 } | 521 } |
518 | 522 |
519 } // namespace first_run | 523 } // namespace first_run |
OLD | NEW |