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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <security.h> | 6 #include <security.h> |
7 | 7 |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <iostream> | 9 #include <iostream> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 for (size_t i = 0; i < arraysize(kSwitchHelp); ++i) { | 74 for (size_t i = 0; i < arraysize(kSwitchHelp); ++i) { |
75 std::cout << std::setiosflags(std::ios::left); | 75 std::cout << std::setiosflags(std::ios::left); |
76 std::cout << " -" << std::setw(16) << kSwitchHelp[i].name; | 76 std::cout << " -" << std::setw(16) << kSwitchHelp[i].name; |
77 std::cout << cloud_print::LoadLocalString(kSwitchHelp[i].description); | 77 std::cout << cloud_print::LoadLocalString(kSwitchHelp[i].description); |
78 std::cout << "\n"; | 78 std::cout << "\n"; |
79 } | 79 } |
80 std::cout << "\n"; | 80 std::cout << "\n"; |
81 } | 81 } |
82 | 82 |
83 base::string16 GetOption(int string_id, const base::string16& default, | 83 base::string16 GetOption(int string_id, |
84 bool secure) { | 84 const base::string16& default_option, |
| 85 bool secure) { |
85 base::string16 prompt_format = cloud_print::LoadLocalString(string_id); | 86 base::string16 prompt_format = cloud_print::LoadLocalString(string_id); |
86 std::vector<base::string16> substitutions(1, default); | 87 std::vector<base::string16> substitutions(1, default_option); |
87 std::cout << ReplaceStringPlaceholders(prompt_format, substitutions, NULL); | 88 std::cout << ReplaceStringPlaceholders(prompt_format, substitutions, NULL); |
88 base::string16 tmp; | 89 base::string16 tmp; |
89 if (secure) { | 90 if (secure) { |
90 DWORD saved_mode = 0; | 91 DWORD saved_mode = 0; |
91 // Don't close. | 92 // Don't close. |
92 HANDLE stdin_handle = ::GetStdHandle(STD_INPUT_HANDLE); | 93 HANDLE stdin_handle = ::GetStdHandle(STD_INPUT_HANDLE); |
93 ::GetConsoleMode(stdin_handle, &saved_mode); | 94 ::GetConsoleMode(stdin_handle, &saved_mode); |
94 ::SetConsoleMode(stdin_handle, saved_mode & ~ENABLE_ECHO_INPUT); | 95 ::SetConsoleMode(stdin_handle, saved_mode & ~ENABLE_ECHO_INPUT); |
95 std::getline(std::wcin, tmp); | 96 std::getline(std::wcin, tmp); |
96 ::SetConsoleMode(stdin_handle, saved_mode); | 97 ::SetConsoleMode(stdin_handle, saved_mode); |
97 std::cout << "\n"; | 98 std::cout << "\n"; |
98 } else { | 99 } else { |
99 std::getline(std::wcin, tmp); | 100 std::getline(std::wcin, tmp); |
100 } | 101 } |
101 if (tmp.empty()) | 102 if (tmp.empty()) |
102 return default; | 103 return default_option; |
103 return tmp; | 104 return tmp; |
104 } | 105 } |
105 | 106 |
106 HRESULT ReportError(HRESULT hr, int string_id) { | 107 HRESULT ReportError(HRESULT hr, int string_id) { |
107 LOG(ERROR) << cloud_print::GetErrorMessage(hr); | 108 LOG(ERROR) << cloud_print::GetErrorMessage(hr); |
108 std::cerr << cloud_print::LoadLocalString(string_id); | 109 std::cerr << cloud_print::LoadLocalString(string_id); |
109 std::cerr << "\n"; | 110 std::cerr << "\n"; |
110 return hr; | 111 return hr; |
111 } | 112 } |
112 | 113 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 411 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
411 logging::InitLogging(settings); | 412 logging::InitLogging(settings); |
412 | 413 |
413 logging::SetMinLogLevel( | 414 logging::SetMinLogLevel( |
414 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging) ? | 415 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging) ? |
415 logging::LOG_INFO : logging::LOG_FATAL); | 416 logging::LOG_INFO : logging::LOG_FATAL); |
416 | 417 |
417 return _AtlModule.WinMain(0); | 418 return _AtlModule.WinMain(0); |
418 } | 419 } |
419 | 420 |
OLD | NEW |