| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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.h" | 5 #include "chrome/browser/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 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 HWND active_window = ::GetLastActivePopup(owner_window_); | 497 HWND active_window = ::GetLastActivePopup(owner_window_); |
| 498 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { | 498 if (::IsHungAppWindow(active_window) || ::IsHungAppWindow(owner_window_)) { |
| 499 ::TerminateProcess(import_process_, ResultCodes::IMPORTER_HUNG); | 499 ::TerminateProcess(import_process_, ResultCodes::IMPORTER_HUNG); |
| 500 import_process_ = NULL; | 500 import_process_ = NULL; |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 HWND owner_window_; | 504 HWND owner_window_; |
| 505 base::ProcessHandle import_process_; | 505 base::ProcessHandle import_process_; |
| 506 WorkerThreadTicker ticker_; | 506 WorkerThreadTicker ticker_; |
| 507 DISALLOW_EVIL_CONSTRUCTORS(HungImporterMonitor); | 507 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); |
| 508 }; | 508 }; |
| 509 | 509 |
| 510 // This class is used by FirstRun::ImportNow to get notified of the outcome of | 510 // This class is used by FirstRun::ImportNow to get notified of the outcome of |
| 511 // the import operation. It differs from ImportProcessRunner in that this | 511 // the import operation. It differs from ImportProcessRunner in that this |
| 512 // class executes in the context of importing child process. | 512 // class executes in the context of importing child process. |
| 513 // The values that it handles are meant to be used as the process exit code. | 513 // The values that it handles are meant to be used as the process exit code. |
| 514 class FirstRunImportObserver : public ImportObserver { | 514 class FirstRunImportObserver : public ImportObserver { |
| 515 public: | 515 public: |
| 516 FirstRunImportObserver() | 516 FirstRunImportObserver() |
| 517 : loop_running_(false), import_result_(ResultCodes::NORMAL_EXIT) { | 517 : loop_running_(false), import_result_(ResultCodes::NORMAL_EXIT) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 534 } | 534 } |
| 535 | 535 |
| 536 private: | 536 private: |
| 537 void Finish() { | 537 void Finish() { |
| 538 if (loop_running_) | 538 if (loop_running_) |
| 539 MessageLoop::current()->Quit(); | 539 MessageLoop::current()->Quit(); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool loop_running_; | 542 bool loop_running_; |
| 543 int import_result_; | 543 int import_result_; |
| 544 DISALLOW_EVIL_CONSTRUCTORS(FirstRunImportObserver); | 544 DISALLOW_COPY_AND_ASSIGN(FirstRunImportObserver); |
| 545 }; | 545 }; |
| 546 | 546 |
| 547 std::wstring EncodeImportParams(int browser_type, int options, HWND window) { | 547 std::wstring EncodeImportParams(int browser_type, int options, HWND window) { |
| 548 return StringPrintf(L"%d@%d@%d", browser_type, options, window); | 548 return StringPrintf(L"%d@%d@%d", browser_type, options, window); |
| 549 } | 549 } |
| 550 | 550 |
| 551 bool DecodeImportParams(const std::wstring& encoded, | 551 bool DecodeImportParams(const std::wstring& encoded, |
| 552 int* browser_type, int* options, HWND* window) { | 552 int* browser_type, int* options, HWND* window) { |
| 553 std::vector<std::wstring> v; | 553 std::vector<std::wstring> v; |
| 554 SplitString(encoded, L'@', &v); | 554 SplitString(encoded, L'@', &v); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 568 } // namespace | 568 } // namespace |
| 569 | 569 |
| 570 bool FirstRun::ImportSettings(Profile* profile, int browser_type, | 570 bool FirstRun::ImportSettings(Profile* profile, int browser_type, |
| 571 int items_to_import, HWND parent_window) { | 571 int items_to_import, HWND parent_window) { |
| 572 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); | 572 const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); |
| 573 CommandLine import_cmd(cmdline.GetProgram()); | 573 CommandLine import_cmd(cmdline.GetProgram()); |
| 574 // Propagate user data directory switch. | 574 // Propagate user data directory switch. |
| 575 if (cmdline.HasSwitch(switches::kUserDataDir)) { | 575 if (cmdline.HasSwitch(switches::kUserDataDir)) { |
| 576 import_cmd.AppendSwitchWithValue( | 576 import_cmd.AppendSwitchWithValue( |
| 577 switches::kUserDataDir, | 577 switches::kUserDataDir, |
| 578 cmdline.GetSwitchValue(switches::kUserDataDir)); | 578 cmdline.GetSwitchValueASCII(switches::kUserDataDir)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 // Since ImportSettings is called before the local state is stored on disk | 581 // Since ImportSettings is called before the local state is stored on disk |
| 582 // we pass the language as an argument. GetApplicationLocale checks the | 582 // we pass the language as an argument. GetApplicationLocale checks the |
| 583 // current command line as fallback. | 583 // current command line as fallback. |
| 584 import_cmd.AppendSwitchWithValue( | 584 import_cmd.AppendSwitchWithValue( |
| 585 switches::kLang, | 585 switches::kLang, |
| 586 ASCIIToWide(g_browser_process->GetApplicationLocale())); | 586 ASCIIToWide(g_browser_process->GetApplicationLocale())); |
| 587 | 587 |
| 588 import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, | 588 import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 960 |
| 961 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog); | 961 DISALLOW_COPY_AND_ASSIGN(TryChromeDialog); |
| 962 }; | 962 }; |
| 963 | 963 |
| 964 } // namespace | 964 } // namespace |
| 965 | 965 |
| 966 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 966 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 967 TryChromeDialog td(version); | 967 TryChromeDialog td(version); |
| 968 return td.ShowModal(); | 968 return td.ShowModal(); |
| 969 } | 969 } |
| OLD | NEW |