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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // process has ended and what was the result of the operation as reported by | 177 // process has ended and what was the result of the operation as reported by |
178 // the process exit code. This class executes in the context of the main chrome | 178 // the process exit code. This class executes in the context of the main chrome |
179 // process. | 179 // process. |
180 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate { | 180 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate { |
181 public: | 181 public: |
182 // The constructor takes the importer process to watch and then it does a | 182 // The constructor takes the importer process to watch and then it does a |
183 // message loop blocking wait until the process ends. This object now owns | 183 // message loop blocking wait until the process ends. This object now owns |
184 // the import_process handle. | 184 // the import_process handle. |
185 explicit ImportProcessRunner(base::ProcessHandle import_process) | 185 explicit ImportProcessRunner(base::ProcessHandle import_process) |
186 : import_process_(import_process), | 186 : import_process_(import_process), |
187 exit_code_(ResultCodes::NORMAL_EXIT) { | 187 exit_code_(content::RESULT_CODE_NORMAL_EXIT) { |
188 watcher_.StartWatching(import_process, this); | 188 watcher_.StartWatching(import_process, this); |
189 MessageLoop::current()->Run(); | 189 MessageLoop::current()->Run(); |
190 } | 190 } |
191 virtual ~ImportProcessRunner() { | 191 virtual ~ImportProcessRunner() { |
192 ::CloseHandle(import_process_); | 192 ::CloseHandle(import_process_); |
193 } | 193 } |
194 // Returns the child process exit code. There are 2 expected values: | 194 // Returns the child process exit code. There are 2 expected values: |
195 // NORMAL_EXIT, or IMPORTER_HUNG. | 195 // NORMAL_EXIT, or IMPORTER_HUNG. |
196 int exit_code() const { return exit_code_; } | 196 int exit_code() const { return exit_code_; } |
197 | 197 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 virtual void OnTick() { | 239 virtual void OnTick() { |
240 if (!import_process_) | 240 if (!import_process_) |
241 return; | 241 return; |
242 // We find the top active popup that we own, this will be either the | 242 // We find the top active popup that we own, this will be either the |
243 // owner_window_ itself or the dialog window of the other process. In | 243 // owner_window_ itself or the dialog window of the other process. In |
244 // both cases it is worth hung testing because both windows share the | 244 // both cases it is worth hung testing because both windows share the |
245 // same message queue and at some point the other window could be gone | 245 // same message queue and at some point the other window could be gone |
246 // while the other process still not pumping messages. | 246 // while the other process still not pumping messages. |
247 HWND active_window = ::GetLastActivePopup(owner_window_); | 247 HWND active_window = ::GetLastActivePopup(owner_window_); |
248 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { | 248 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { |
249 ::TerminateProcess(import_process_, ResultCodes::IMPORTER_HUNG); | 249 ::TerminateProcess(import_process_, chrome::RESULT_CODE_IMPORTER_HUNG); |
250 import_process_ = NULL; | 250 import_process_ = NULL; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 HWND owner_window_; | 254 HWND owner_window_; |
255 base::ProcessHandle import_process_; | 255 base::ProcessHandle import_process_; |
256 WorkerThreadTicker ticker_; | 256 WorkerThreadTicker ticker_; |
257 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); | 257 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); |
258 }; | 258 }; |
259 | 259 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // We block inside the import_runner ctor, pumping messages until the | 349 // We block inside the import_runner ctor, pumping messages until the |
350 // importer process ends. This can happen either by completing the import | 350 // importer process ends. This can happen either by completing the import |
351 // or by hang_monitor killing it. | 351 // or by hang_monitor killing it. |
352 ImportProcessRunner import_runner(import_process); | 352 ImportProcessRunner import_runner(import_process); |
353 | 353 |
354 // Import process finished. Reload the prefs, because importer may set | 354 // Import process finished. Reload the prefs, because importer may set |
355 // the pref value. | 355 // the pref value. |
356 if (profile) | 356 if (profile) |
357 profile->GetPrefs()->ReloadPersistentPrefs(); | 357 profile->GetPrefs()->ReloadPersistentPrefs(); |
358 | 358 |
359 return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); | 359 return (import_runner.exit_code() == content::RESULT_CODE_NORMAL_EXIT); |
360 } | 360 } |
361 | 361 |
362 // static | 362 // static |
363 bool FirstRun::ImportSettings(Profile* profile, | 363 bool FirstRun::ImportSettings(Profile* profile, |
364 scoped_refptr<ImporterHost> importer_host, | 364 scoped_refptr<ImporterHost> importer_host, |
365 scoped_refptr<ImporterList> importer_list, | 365 scoped_refptr<ImporterList> importer_list, |
366 int items_to_import) { | 366 int items_to_import) { |
367 return ImportSettings( | 367 return ImportSettings( |
368 profile, | 368 profile, |
369 importer_list->GetSourceProfileAt(0).importer_type, | 369 importer_list->GetSourceProfileAt(0).importer_type, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 parent_window, | 404 parent_window, |
405 static_cast<uint16>(items_to_import), | 405 static_cast<uint16>(items_to_import), |
406 importer_host, | 406 importer_host, |
407 &importer_observer, | 407 &importer_observer, |
408 importer_list->GetSourceProfileForImporterType(importer_type), | 408 importer_list->GetSourceProfileForImporterType(importer_type), |
409 profile, | 409 profile, |
410 true); | 410 true); |
411 importer_observer.RunLoop(); | 411 importer_observer.RunLoop(); |
412 return importer_observer.import_result(); | 412 return importer_observer.import_result(); |
413 } | 413 } |
OLD | NEW |