| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_writer.h" | 5 #include "chrome/browser/diagnostics/diagnostics_writer.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 SimpleConsole* SimpleConsole::Create() { return new WinConsole(); } | 131 SimpleConsole* SimpleConsole::Create() { return new WinConsole(); } |
| 132 | 132 |
| 133 #elif defined(OS_POSIX) | 133 #elif defined(OS_POSIX) |
| 134 namespace { | 134 namespace { |
| 135 | 135 |
| 136 class PosixConsole : public SimpleConsole { | 136 class PosixConsole : public SimpleConsole { |
| 137 public: | 137 public: |
| 138 PosixConsole() : use_color_(false) {} | 138 PosixConsole() : use_color_(false) {} |
| 139 | 139 |
| 140 virtual bool Init() OVERRIDE { | 140 virtual bool Init() override { |
| 141 // Technically, we should also check the terminal capabilities before using | 141 // Technically, we should also check the terminal capabilities before using |
| 142 // color, but in practice this is unlikely to be an issue. | 142 // color, but in practice this is unlikely to be an issue. |
| 143 use_color_ = isatty(STDOUT_FILENO); | 143 use_color_ = isatty(STDOUT_FILENO); |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 virtual bool Write(const base::string16& text) OVERRIDE { | 147 virtual bool Write(const base::string16& text) override { |
| 148 // We're assuming that the terminal is using UTF-8 encoding. | 148 // We're assuming that the terminal is using UTF-8 encoding. |
| 149 printf("%s", base::UTF16ToUTF8(text).c_str()); | 149 printf("%s", base::UTF16ToUTF8(text).c_str()); |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 virtual void OnQuit() OVERRIDE { | 153 virtual void OnQuit() override { |
| 154 // The "press enter to continue" prompt isn't very unixy, so only do that on | 154 // The "press enter to continue" prompt isn't very unixy, so only do that on |
| 155 // Windows. | 155 // Windows. |
| 156 } | 156 } |
| 157 | 157 |
| 158 virtual bool SetColor(Color color) OVERRIDE { | 158 virtual bool SetColor(Color color) override { |
| 159 if (!use_color_) | 159 if (!use_color_) |
| 160 return false; | 160 return false; |
| 161 | 161 |
| 162 const char* code = "\033[m"; | 162 const char* code = "\033[m"; |
| 163 switch (color) { | 163 switch (color) { |
| 164 case RED: | 164 case RED: |
| 165 code = "\033[1;31m"; | 165 code = "\033[1;31m"; |
| 166 break; | 166 break; |
| 167 case GREEN: | 167 case GREEN: |
| 168 code = "\033[1;32m"; | 168 code = "\033[1;32m"; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 result.c_str(), | 279 result.c_str(), |
| 280 outcome_code, | 280 outcome_code, |
| 281 id.c_str(), | 281 id.c_str(), |
| 282 extra.c_str())); | 282 extra.c_str())); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 return true; | 285 return true; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace diagnostics | 288 } // namespace diagnostics |
| OLD | NEW |