Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/first_run/first_run_win.cc

Issue 3069014: Convert a bunch of easy AppendSwitchWithValue to *ASCII. (Closed)
Patch Set: fix Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 bool LaunchSetupWithParam(const std::string& param, const std::wstring& value, 129 bool LaunchSetupWithParam(const std::string& param, const std::wstring& value,
130 int* ret_code) { 130 int* ret_code) {
131 FilePath exe_path; 131 FilePath exe_path;
132 if (!PathService::Get(base::DIR_MODULE, &exe_path)) 132 if (!PathService::Get(base::DIR_MODULE, &exe_path))
133 return false; 133 return false;
134 exe_path = exe_path.Append(installer_util::kInstallerDir); 134 exe_path = exe_path.Append(installer_util::kInstallerDir);
135 exe_path = exe_path.Append(installer_util::kSetupExe); 135 exe_path = exe_path.Append(installer_util::kSetupExe);
136 base::ProcessHandle ph; 136 base::ProcessHandle ph;
137 CommandLine cl(exe_path); 137 CommandLine cl(exe_path);
138 cl.AppendSwitchWithValue(param, value); 138 cl.AppendSwitchNative(param, value);
139 139
140 CommandLine* browser_command_line = CommandLine::ForCurrentProcess(); 140 CommandLine* browser_command_line = CommandLine::ForCurrentProcess();
141 if (browser_command_line->HasSwitch(switches::kChromeFrame)) { 141 if (browser_command_line->HasSwitch(switches::kChromeFrame)) {
142 cl.AppendSwitch(switches::kChromeFrame); 142 cl.AppendSwitch(switches::kChromeFrame);
143 } 143 }
144 144
145 if (!base::LaunchApp(cl, false, false, &ph)) 145 if (!base::LaunchApp(cl, false, false, &ph))
146 return false; 146 return false;
147 DWORD wr = ::WaitForSingleObject(ph, INFINITE); 147 DWORD wr = ::WaitForSingleObject(ph, INFINITE);
148 if (wr != WAIT_OBJECT_0) 148 if (wr != WAIT_OBJECT_0)
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 import_process_ = NULL; 573 import_process_ = NULL;
574 } 574 }
575 } 575 }
576 576
577 HWND owner_window_; 577 HWND owner_window_;
578 base::ProcessHandle import_process_; 578 base::ProcessHandle import_process_;
579 WorkerThreadTicker ticker_; 579 WorkerThreadTicker ticker_;
580 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor); 580 DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor);
581 }; 581 };
582 582
583 std::wstring EncodeImportParams(int browser_type, int options, HWND window) { 583 std::string EncodeImportParams(int browser_type, int options, HWND window) {
584 return StringPrintf(L"%d@%d@%d", browser_type, options, window); 584 return StringPrintf("%d@%d@%d", browser_type, options, window);
585 } 585 }
586 586
587 bool DecodeImportParams(const std::wstring& encoded, 587 bool DecodeImportParams(const std::wstring& encoded,
588 int* browser_type, int* options, HWND* window) { 588 int* browser_type, int* options, HWND* window) {
589 std::vector<std::wstring> v; 589 std::vector<std::wstring> v;
590 SplitString(encoded, L'@', &v); 590 SplitString(encoded, L'@', &v);
591 if (v.size() != 3) 591 if (v.size() != 3)
592 return false; 592 return false;
593 593
594 if (!StringToInt(v[0], browser_type)) 594 if (!StringToInt(v[0], browser_type))
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 const char* kSwitchNames[] = { 686 const char* kSwitchNames[] = {
687 switches::kUserDataDir, 687 switches::kUserDataDir,
688 switches::kChromeFrame, 688 switches::kChromeFrame,
689 switches::kCountry, 689 switches::kCountry,
690 }; 690 };
691 import_cmd.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); 691 import_cmd.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames));
692 692
693 // Since ImportSettings is called before the local state is stored on disk 693 // Since ImportSettings is called before the local state is stored on disk
694 // we pass the language as an argument. GetApplicationLocale checks the 694 // we pass the language as an argument. GetApplicationLocale checks the
695 // current command line as fallback. 695 // current command line as fallback.
696 import_cmd.AppendSwitchWithValue( 696 import_cmd.AppendSwitchASCII(switches::kLang,
697 switches::kLang, 697 g_browser_process->GetApplicationLocale());
698 ASCIIToWide(g_browser_process->GetApplicationLocale()));
699 698
700 if (items_to_import) { 699 if (items_to_import) {
701 import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, 700 import_cmd.CommandLine::AppendSwitchASCII(switches::kImport,
702 EncodeImportParams(browser_type, items_to_import, parent_window)); 701 EncodeImportParams(browser_type, items_to_import, parent_window));
703 } 702 }
704 703
705 if (!import_bookmarks_path.empty()) { 704 if (!import_bookmarks_path.empty()) {
706 import_cmd.CommandLine::AppendSwitchWithValue( 705 import_cmd.CommandLine::AppendSwitchWithValue(
707 switches::kImportFromFile, import_bookmarks_path.c_str()); 706 switches::kImportFromFile, import_bookmarks_path.c_str());
708 } 707 }
709 708
710 // Time to launch the process that is going to do the import. 709 // Time to launch the process that is going to do the import.
711 base::ProcessHandle import_process; 710 base::ProcessHandle import_process;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1053
1055 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { 1054 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) {
1056 if (version > 10000) { 1055 if (version > 10000) {
1057 // This is a test value. We want to make sure we exercise 1056 // This is a test value. We want to make sure we exercise
1058 // returning this early. See EarlyReturnTest test harness. 1057 // returning this early. See EarlyReturnTest test harness.
1059 return Upgrade::TD_NOT_NOW; 1058 return Upgrade::TD_NOT_NOW;
1060 } 1059 }
1061 TryChromeDialog td; 1060 TryChromeDialog td;
1062 return td.ShowModal(); 1061 return td.ShowModal();
1063 } 1062 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698