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, | 83 base::string16 GetOption(int string_id, const base::string16& default, |
84 const base::string16& default_option, | 84 bool secure) { |
85 bool secure) { | |
86 base::string16 prompt_format = cloud_print::LoadLocalString(string_id); | 85 base::string16 prompt_format = cloud_print::LoadLocalString(string_id); |
87 std::vector<base::string16> substitutions(1, default_option); | 86 std::vector<base::string16> substitutions(1, default); |
88 std::cout << ReplaceStringPlaceholders(prompt_format, substitutions, NULL); | 87 std::cout << ReplaceStringPlaceholders(prompt_format, substitutions, NULL); |
89 base::string16 tmp; | 88 base::string16 tmp; |
90 if (secure) { | 89 if (secure) { |
91 DWORD saved_mode = 0; | 90 DWORD saved_mode = 0; |
92 // Don't close. | 91 // Don't close. |
93 HANDLE stdin_handle = ::GetStdHandle(STD_INPUT_HANDLE); | 92 HANDLE stdin_handle = ::GetStdHandle(STD_INPUT_HANDLE); |
94 ::GetConsoleMode(stdin_handle, &saved_mode); | 93 ::GetConsoleMode(stdin_handle, &saved_mode); |
95 ::SetConsoleMode(stdin_handle, saved_mode & ~ENABLE_ECHO_INPUT); | 94 ::SetConsoleMode(stdin_handle, saved_mode & ~ENABLE_ECHO_INPUT); |
96 std::getline(std::wcin, tmp); | 95 std::getline(std::wcin, tmp); |
97 ::SetConsoleMode(stdin_handle, saved_mode); | 96 ::SetConsoleMode(stdin_handle, saved_mode); |
98 std::cout << "\n"; | 97 std::cout << "\n"; |
99 } else { | 98 } else { |
100 std::getline(std::wcin, tmp); | 99 std::getline(std::wcin, tmp); |
101 } | 100 } |
102 if (tmp.empty()) | 101 if (tmp.empty()) |
103 return default_option; | 102 return default; |
104 return tmp; | 103 return tmp; |
105 } | 104 } |
106 | 105 |
107 HRESULT ReportError(HRESULT hr, int string_id) { | 106 HRESULT ReportError(HRESULT hr, int string_id) { |
108 LOG(ERROR) << cloud_print::GetErrorMessage(hr); | 107 LOG(ERROR) << cloud_print::GetErrorMessage(hr); |
109 std::cerr << cloud_print::LoadLocalString(string_id); | 108 std::cerr << cloud_print::LoadLocalString(string_id); |
110 std::cerr << "\n"; | 109 std::cerr << "\n"; |
111 return hr; | 110 return hr; |
112 } | 111 } |
113 | 112 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 410 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
412 logging::InitLogging(settings); | 411 logging::InitLogging(settings); |
413 | 412 |
414 logging::SetMinLogLevel( | 413 logging::SetMinLogLevel( |
415 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging) ? | 414 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableLogging) ? |
416 logging::LOG_INFO : logging::LOG_FATAL); | 415 logging::LOG_INFO : logging::LOG_FATAL); |
417 | 416 |
418 return _AtlModule.WinMain(0); | 417 return _AtlModule.WinMain(0); |
419 } | 418 } |
420 | 419 |
OLD | NEW |