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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 bool g_should_show_welcome_page = false; | 79 bool g_should_show_welcome_page = false; |
80 bool g_should_do_autofill_personal_data_manager_first_run = false; | 80 bool g_should_do_autofill_personal_data_manager_first_run = false; |
81 | 81 |
82 // This class acts as an observer for the ImporterProgressObserver::ImportEnded | 82 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
83 // callback. When the import process is started, certain errors may cause | 83 // callback. When the import process is started, certain errors may cause |
84 // ImportEnded() to be called synchronously, but the typical case is that | 84 // ImportEnded() to be called synchronously, but the typical case is that |
85 // ImportEnded() is called asynchronously. Thus we have to handle both cases. | 85 // ImportEnded() is called asynchronously. Thus we have to handle both cases. |
86 class ImportEndedObserver : public importer::ImporterProgressObserver { | 86 class ImportEndedObserver : public importer::ImporterProgressObserver { |
87 public: | 87 public: |
88 ImportEndedObserver() : ended_(false) {} | 88 ImportEndedObserver() : ended_(false) {} |
89 virtual ~ImportEndedObserver() {} | 89 ~ImportEndedObserver() override {} |
90 | 90 |
91 // importer::ImporterProgressObserver: | 91 // importer::ImporterProgressObserver: |
92 virtual void ImportStarted() override {} | 92 void ImportStarted() override {} |
93 virtual void ImportItemStarted(importer::ImportItem item) override {} | 93 void ImportItemStarted(importer::ImportItem item) override {} |
94 virtual void ImportItemEnded(importer::ImportItem item) override {} | 94 void ImportItemEnded(importer::ImportItem item) override {} |
95 virtual void ImportEnded() override { | 95 void ImportEnded() override { |
96 ended_ = true; | 96 ended_ = true; |
97 if (!callback_for_import_end_.is_null()) | 97 if (!callback_for_import_end_.is_null()) |
98 callback_for_import_end_.Run(); | 98 callback_for_import_end_.Run(); |
99 } | 99 } |
100 | 100 |
101 void set_callback_for_import_end(const base::Closure& callback) { | 101 void set_callback_for_import_end(const base::Closure& callback) { |
102 callback_for_import_end_ = callback; | 102 callback_for_import_end_ = callback; |
103 } | 103 } |
104 | 104 |
105 bool ended() const { | 105 bool ended() const { |
(...skipping 21 matching lines...) Expand all Loading... |
127 explicit FirstRunDelayedTasks(Tasks task) { | 127 explicit FirstRunDelayedTasks(Tasks task) { |
128 if (task == INSTALL_EXTENSIONS) { | 128 if (task == INSTALL_EXTENSIONS) { |
129 registrar_.Add(this, | 129 registrar_.Add(this, |
130 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, | 130 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, |
131 content::NotificationService::AllSources()); | 131 content::NotificationService::AllSources()); |
132 } | 132 } |
133 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 133 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
134 content::NotificationService::AllSources()); | 134 content::NotificationService::AllSources()); |
135 } | 135 } |
136 | 136 |
137 virtual void Observe(int type, | 137 void Observe(int type, |
138 const content::NotificationSource& source, | 138 const content::NotificationSource& source, |
139 const content::NotificationDetails& details) override { | 139 const content::NotificationDetails& details) override { |
140 // After processing the notification we always delete ourselves. | 140 // After processing the notification we always delete ourselves. |
141 if (type == extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED) { | 141 if (type == extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED) { |
142 Profile* profile = content::Source<Profile>(source).ptr(); | 142 Profile* profile = content::Source<Profile>(source).ptr(); |
143 ExtensionService* service = | 143 ExtensionService* service = |
144 extensions::ExtensionSystem::Get(profile)->extension_service(); | 144 extensions::ExtensionSystem::Get(profile)->extension_service(); |
145 DoExtensionWork(service); | 145 DoExtensionWork(service); |
146 } | 146 } |
147 delete this; | 147 delete this; |
148 } | 148 } |
149 | 149 |
150 private: | 150 private: |
151 // Private ctor forces it to be created only in the heap. | 151 // Private ctor forces it to be created only in the heap. |
152 virtual ~FirstRunDelayedTasks() {} | 152 ~FirstRunDelayedTasks() override {} |
153 | 153 |
154 // The extension work is to basically trigger an extension update check. | 154 // The extension work is to basically trigger an extension update check. |
155 // If the extension specified in the master pref is older than the live | 155 // If the extension specified in the master pref is older than the live |
156 // extension it will get updated which is the same as get it installed. | 156 // extension it will get updated which is the same as get it installed. |
157 void DoExtensionWork(ExtensionService* service) { | 157 void DoExtensionWork(ExtensionService* service) { |
158 if (service) | 158 if (service) |
159 service->updater()->CheckNow(extensions::ExtensionUpdater::CheckParams()); | 159 service->updater()->CheckNow(extensions::ExtensionUpdater::CheckParams()); |
160 } | 160 } |
161 | 161 |
162 content::NotificationRegistrar registrar_; | 162 content::NotificationRegistrar registrar_; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // Show the first run search engine bubble at the first appropriate opportunity. | 304 // Show the first run search engine bubble at the first appropriate opportunity. |
305 // This bubble may be delayed by other UI, like global errors and sync promos. | 305 // This bubble may be delayed by other UI, like global errors and sync promos. |
306 class FirstRunBubbleLauncher : public content::NotificationObserver { | 306 class FirstRunBubbleLauncher : public content::NotificationObserver { |
307 public: | 307 public: |
308 // Show the bubble at the first appropriate opportunity. This function | 308 // Show the bubble at the first appropriate opportunity. This function |
309 // instantiates a FirstRunBubbleLauncher, which manages its own lifetime. | 309 // instantiates a FirstRunBubbleLauncher, which manages its own lifetime. |
310 static void ShowFirstRunBubbleSoon(); | 310 static void ShowFirstRunBubbleSoon(); |
311 | 311 |
312 private: | 312 private: |
313 FirstRunBubbleLauncher(); | 313 FirstRunBubbleLauncher(); |
314 virtual ~FirstRunBubbleLauncher(); | 314 ~FirstRunBubbleLauncher() override; |
315 | 315 |
316 // content::NotificationObserver: | 316 // content::NotificationObserver: |
317 virtual void Observe(int type, | 317 void Observe(int type, |
318 const content::NotificationSource& source, | 318 const content::NotificationSource& source, |
319 const content::NotificationDetails& details) override; | 319 const content::NotificationDetails& details) override; |
320 | 320 |
321 content::NotificationRegistrar registrar_; | 321 content::NotificationRegistrar registrar_; |
322 | 322 |
323 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleLauncher); | 323 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleLauncher); |
324 }; | 324 }; |
325 | 325 |
326 // static | 326 // static |
327 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { | 327 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { |
328 SetShowFirstRunBubblePref(first_run::FIRST_RUN_BUBBLE_SHOW); | 328 SetShowFirstRunBubblePref(first_run::FIRST_RUN_BUBBLE_SHOW); |
329 // This FirstRunBubbleLauncher instance will manage its own lifetime. | 329 // This FirstRunBubbleLauncher instance will manage its own lifetime. |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 SetShouldDoPersonalDataManagerFirstRun(); | 804 SetShouldDoPersonalDataManagerFirstRun(); |
805 | 805 |
806 internal::DoPostImportPlatformSpecificTasks(profile); | 806 internal::DoPostImportPlatformSpecificTasks(profile); |
807 } | 807 } |
808 | 808 |
809 uint16 auto_import_state() { | 809 uint16 auto_import_state() { |
810 return g_auto_import_state; | 810 return g_auto_import_state; |
811 } | 811 } |
812 | 812 |
813 } // namespace first_run | 813 } // namespace first_run |
OLD | NEW |