OLD | NEW |
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/diagnostics/diagnostics_main.h" | 5 #include "chrome/browser/diagnostics/diagnostics_main.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #endif | 10 #endif |
11 | 11 |
| 12 #include <iostream> |
| 13 |
12 #include "app/app_paths.h" | 14 #include "app/app_paths.h" |
13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
15 #include "base/i18n/icu_util.h" | 17 #include "base/i18n/icu_util.h" |
16 #include "base/string_util.h" | 18 #include "base/string_util.h" |
17 #include "base/sys_string_conversions.h" | 19 #include "base/sys_string_conversions.h" |
18 #include "base/time.h" | 20 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/diagnostics/diagnostics_model.h" | 22 #include "chrome/browser/diagnostics/diagnostics_model.h" |
21 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 use_color_ = isatty(STDOUT_FILENO); | 147 use_color_ = isatty(STDOUT_FILENO); |
146 return true; | 148 return true; |
147 } | 149 } |
148 | 150 |
149 virtual bool Write(const std::wstring& text) { | 151 virtual bool Write(const std::wstring& text) { |
150 printf("%s", base::SysWideToNativeMB(text).c_str()); | 152 printf("%s", base::SysWideToNativeMB(text).c_str()); |
151 return true; | 153 return true; |
152 } | 154 } |
153 | 155 |
154 virtual bool Read(std::wstring* txt) { | 156 virtual bool Read(std::wstring* txt) { |
155 // TODO(mattm): implement this. | 157 std::string input; |
156 return false; | 158 if (!std::getline(std::cin, input)) { |
| 159 std::cin.clear(); |
| 160 return false; |
| 161 } |
| 162 *txt = UTF8ToWide(input); |
| 163 return true; |
157 } | 164 } |
158 | 165 |
159 virtual bool SetColor(Color color) { | 166 virtual bool SetColor(Color color) { |
160 if (!use_color_) | 167 if (!use_color_) |
161 return false; | 168 return false; |
162 | 169 |
163 const char* code = "\033[m"; | 170 const char* code = "\033[m"; |
164 switch (color) { | 171 switch (color) { |
165 case RED: | 172 case RED: |
166 code = "\033[1;31m"; | 173 code = "\033[1;31m"; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // Windows. | 345 // Windows. |
339 #if defined(OS_WIN) | 346 #if defined(OS_WIN) |
340 // Block here so the user can see the results. | 347 // Block here so the user can see the results. |
341 writer.WriteInfoText(L"Press [enter] to continue\n"); | 348 writer.WriteInfoText(L"Press [enter] to continue\n"); |
342 std::wstring txt; | 349 std::wstring txt; |
343 console->Read(&txt); | 350 console->Read(&txt); |
344 #endif | 351 #endif |
345 delete console; | 352 delete console; |
346 return 0; | 353 return 0; |
347 } | 354 } |
OLD | NEW |