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/message_loop.h" |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/first_run/first_run_internal.h" | 12 #include "chrome/browser/first_run/first_run_internal.h" |
12 #include "chrome/browser/importer/importer_host.h" | 13 #include "chrome/browser/importer/importer_host.h" |
13 #include "chrome/browser/importer/importer_list.h" | 14 #include "chrome/browser/importer/importer_list.h" |
14 #include "chrome/browser/importer/importer_progress_dialog.h" | |
15 #include "chrome/browser/importer/importer_progress_observer.h" | |
16 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
21 #include "chrome/installer/util/master_preferences.h" | 20 #include "chrome/installer/util/master_preferences.h" |
22 #include "chrome/installer/util/master_preferences_constants.h" | 21 #include "chrome/installer/util/master_preferences_constants.h" |
23 | 22 |
24 namespace { | |
25 | |
26 // This class acts as an observer for the ImporterProgressObserver::ImportEnded | |
27 // callback. When the import process is started, certain errors may cause | |
28 // ImportEnded() to be called synchronously, but the typical case is that | |
29 // ImportEnded() is called asynchronously. Thus we have to handle both cases. | |
30 class ImportEndedObserver : public importer::ImporterProgressObserver { | |
31 public: | |
32 ImportEndedObserver() : ended_(false), | |
33 should_quit_message_loop_(false) {} | |
34 virtual ~ImportEndedObserver() {} | |
35 | |
36 // importer::ImporterProgressObserver: | |
37 virtual void ImportStarted() OVERRIDE {} | |
38 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | |
39 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | |
40 virtual void ImportEnded() OVERRIDE { | |
41 ended_ = true; | |
42 if (should_quit_message_loop_) | |
43 MessageLoop::current()->Quit(); | |
44 } | |
45 | |
46 void set_should_quit_message_loop() { | |
47 should_quit_message_loop_ = true; | |
48 } | |
49 | |
50 bool ended() { | |
51 return ended_; | |
52 } | |
53 | |
54 private: | |
55 // Set if the import has ended. | |
56 bool ended_; | |
57 | |
58 // Set by the client (via set_should_quit_message_loop) if, when the import | |
59 // ends, this class should quit the message loop. | |
60 bool should_quit_message_loop_; | |
61 }; | |
62 | |
63 } // namespace | |
64 | |
65 namespace first_run { | 23 namespace first_run { |
66 namespace internal { | 24 namespace internal { |
67 | 25 |
68 void DoPostImportPlatformSpecificTasks() { | 26 void DoPostImportPlatformSpecificTasks() { |
69 #if !defined(OS_CHROMEOS) | 27 #if !defined(OS_CHROMEOS) |
70 // If stats reporting was turned on by the first run dialog then toggle | 28 // If stats reporting was turned on by the first run dialog then toggle |
71 // the pref (on Windows, the download is tagged with enable/disable stats so | 29 // the pref (on Windows, the download is tagged with enable/disable stats so |
72 // this is POSIX-specific). | 30 // this is POSIX-specific). |
73 if (GoogleUpdateSettings::GetCollectStatsConsent()) { | 31 if (GoogleUpdateSettings::GetCollectStatsConsent()) { |
74 g_browser_process->local_state()->SetBoolean( | 32 g_browser_process->local_state()->SetBoolean( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 namespace first_run { | 103 namespace first_run { |
146 | 104 |
147 // TODO(port): Import switches need to be ported to both Mac and Linux. Not all | 105 // TODO(port): Import switches need to be ported to both Mac and Linux. Not all |
148 // import switches here are implemented for Linux. None are implemented for Mac | 106 // import switches here are implemented for Linux. None are implemented for Mac |
149 // (as this function will not be called on Mac). | 107 // (as this function will not be called on Mac). |
150 int ImportNow(Profile* profile, const CommandLine& cmdline) { | 108 int ImportNow(Profile* profile, const CommandLine& cmdline) { |
151 return internal::ImportBookmarkFromFileIfNeeded(profile, cmdline); | 109 return internal::ImportBookmarkFromFileIfNeeded(profile, cmdline); |
152 } | 110 } |
153 | 111 |
154 } // namespace first_run | 112 } // namespace first_run |
OLD | NEW |