OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <shlobj.h> | 7 #include <shlobj.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_updater.h" | 24 #include "chrome/browser/extensions/extension_updater.h" |
25 #include "chrome/browser/first_run/first_run_import_observer.h" | 25 #include "chrome/browser/first_run/first_run_import_observer.h" |
26 #include "chrome/browser/importer/importer_host.h" | 26 #include "chrome/browser/importer/importer_host.h" |
27 #include "chrome/browser/importer/importer_list.h" | 27 #include "chrome/browser/importer/importer_list.h" |
28 #include "chrome/browser/importer/importer_progress_dialog.h" | 28 #include "chrome/browser/importer/importer_progress_dialog.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 31 #include "chrome/common/chrome_result_codes.h" |
31 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/worker_thread_ticker.h" | 33 #include "chrome/common/worker_thread_ticker.h" |
33 #include "chrome/installer/util/browser_distribution.h" | 34 #include "chrome/installer/util/browser_distribution.h" |
34 #include "chrome/installer/util/google_update_constants.h" | 35 #include "chrome/installer/util/google_update_constants.h" |
35 #include "chrome/installer/util/google_update_settings.h" | 36 #include "chrome/installer/util/google_update_settings.h" |
36 #include "chrome/installer/util/install_util.h" | 37 #include "chrome/installer/util/install_util.h" |
37 #include "chrome/installer/util/shell_util.h" | 38 #include "chrome/installer/util/shell_util.h" |
38 #include "chrome/installer/util/util_constants.h" | 39 #include "chrome/installer/util/util_constants.h" |
39 #include "content/browser/user_metrics.h" | 40 #include "content/browser/user_metrics.h" |
40 #include "content/common/notification_service.h" | 41 #include "content/common/notification_service.h" |
41 #include "content/common/result_codes.h" | |
42 #include "google_update_idl.h" | 42 #include "google_update_idl.h" |
43 #include "grit/chromium_strings.h" | 43 #include "grit/chromium_strings.h" |
44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
45 #include "grit/locale_settings.h" | 45 #include "grit/locale_settings.h" |
46 #include "grit/theme_resources.h" | 46 #include "grit/theme_resources.h" |
47 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
48 #include "ui/base/ui_base_switches.h" | 48 #include "ui/base/ui_base_switches.h" |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // process has ended and what was the result of the operation as reported by | 176 // process has ended and what was the result of the operation as reported by |
177 // the process exit code. This class executes in the context of the main chrome | 177 // the process exit code. This class executes in the context of the main chrome |
178 // process. | 178 // process. |
179 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate { | 179 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate { |
180 public: | 180 public: |
181 // The constructor takes the importer process to watch and then it does a | 181 // The constructor takes the importer process to watch and then it does a |
182 // message loop blocking wait until the process ends. This object now owns | 182 // message loop blocking wait until the process ends. This object now owns |
183 // the import_process handle. | 183 // the import_process handle. |
184 explicit ImportProcessRunner(base::ProcessHandle import_process) | 184 explicit ImportProcessRunner(base::ProcessHandle import_process) |
185 : import_process_(import_process), | 185 : import_process_(import_process), |
186 exit_code_(ResultCodes::NORMAL_EXIT) { | 186 exit_code_(content::RESULT_CODE_NORMAL_EXIT) { |
187 watcher_.StartWatching(import_process, this); | 187 watcher_.StartWatching(import_process, this); |
188 MessageLoop::current()->Run(); | 188 MessageLoop::current()->Run(); |
189 } | 189 } |
190 virtual ~ImportProcessRunner() { | 190 virtual ~ImportProcessRunner() { |
191 ::CloseHandle(import_process_); | 191 ::CloseHandle(import_process_); |
192 } | 192 } |
193 // Returns the child process exit code. There are 2 expected values: | 193 // Returns the child process exit code. There are 2 expected values: |
194 // NORMAL_EXIT, or IMPORTER_HUNG. | 194 // NORMAL_EXIT, or IMPORTER_HUNG. |
195 int exit_code() const { return exit_code_; } | 195 int exit_code() const { return exit_code_; } |
196 | 196 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 virtual void OnTick() { | 238 virtual void OnTick() { |
239 if (!import_process_) | 239 if (!import_process_) |
240 return; | 240 return; |
241 // We find the top active popup that we own, this will be either the | 241 // We find the top active popup that we own, this will be either the |
242 // owner_window_ itself or the dialog window of the other process. In | 242 // owner_window_ itself or the dialog window of the other process. In |
243 // both cases it is worth hung testing because both windows share the | 243 // both cases it is worth hung testing because both windows share the |
244 // same message queue and at some point the other window could be gone | 244 // same message queue and at some point the other window could be gone |
245 // while the other process still not pumping messages. | 245 // while the other process still not pumping messages. |
246 HWND active_window = ::GetLastActivePopup(owner_window_); | 246 HWND active_window = ::GetLastActivePopup(owner_window_); |
247 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { | 247 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { |
248 ::TerminateProcess(import_process_, ResultCodes::IMPORTER_HUNG); | 248 ::TerminateProcess(import_process_, chrome::RESULT_CODE_IMPORTER_HUNG); |
249 import_process_ = NULL; | 249 import_process_ = NULL; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 HWND owner_window_; | 253 HWND owner_window_; |
254 base::ProcessHandle import_process_; | 254 base::ProcessHandle import_process_; |
255 WorkerThreadTicker ticker_; | 255 WorkerThreadTicker ticker_; |
256 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); | 256 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); |
257 }; | 257 }; |
258 | 258 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // We block inside the import_runner ctor, pumping messages until the | 348 // We block inside the import_runner ctor, pumping messages until the |
349 // importer process ends. This can happen either by completing the import | 349 // importer process ends. This can happen either by completing the import |
350 // or by hang_monitor killing it. | 350 // or by hang_monitor killing it. |
351 ImportProcessRunner import_runner(import_process); | 351 ImportProcessRunner import_runner(import_process); |
352 | 352 |
353 // Import process finished. Reload the prefs, because importer may set | 353 // Import process finished. Reload the prefs, because importer may set |
354 // the pref value. | 354 // the pref value. |
355 if (profile) | 355 if (profile) |
356 profile->GetPrefs()->ReloadPersistentPrefs(); | 356 profile->GetPrefs()->ReloadPersistentPrefs(); |
357 | 357 |
358 return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); | 358 return (import_runner.exit_code() == content::RESULT_CODE_NORMAL_EXIT); |
359 } | 359 } |
360 | 360 |
361 // static | 361 // static |
362 bool FirstRun::ImportSettings(Profile* profile, | 362 bool FirstRun::ImportSettings(Profile* profile, |
363 scoped_refptr<ImporterHost> importer_host, | 363 scoped_refptr<ImporterHost> importer_host, |
364 scoped_refptr<ImporterList> importer_list, | 364 scoped_refptr<ImporterList> importer_list, |
365 int items_to_import) { | 365 int items_to_import) { |
366 return ImportSettings( | 366 return ImportSettings( |
367 profile, | 367 profile, |
368 importer_list->GetSourceProfileAt(0).importer_type, | 368 importer_list->GetSourceProfileAt(0).importer_type, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 parent_window, | 403 parent_window, |
404 static_cast<uint16>(items_to_import), | 404 static_cast<uint16>(items_to_import), |
405 importer_host, | 405 importer_host, |
406 &importer_observer, | 406 &importer_observer, |
407 importer_list->GetSourceProfileForImporterType(importer_type), | 407 importer_list->GetSourceProfileForImporterType(importer_type), |
408 profile, | 408 profile, |
409 true); | 409 true); |
410 importer_observer.RunLoop(); | 410 importer_observer.RunLoop(); |
411 return importer_observer.import_result(); | 411 return importer_observer.import_result(); |
412 } | 412 } |
OLD | NEW |