| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/hwid_checker.h" | 5 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 bool IsMachineHWIDCorrect() { | 112 bool IsMachineHWIDCorrect() { |
| 113 #if !defined(GOOGLE_CHROME_BUILD) | 113 #if !defined(GOOGLE_CHROME_BUILD) |
| 114 return true; | 114 return true; |
| 115 #endif | 115 #endif |
| 116 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 116 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 117 if (cmd_line->HasSwitch(::switches::kTestType)) | 117 if (cmd_line->HasSwitch(::switches::kTestType)) |
| 118 return true; | 118 return true; |
| 119 if (!base::SysInfo::IsRunningOnChromeOS()) | 119 if (!base::SysInfo::IsRunningOnChromeOS()) |
| 120 return true; | 120 return true; |
| 121 |
| 121 chromeos::system::StatisticsProvider* stats = | 122 chromeos::system::StatisticsProvider* stats = |
| 122 chromeos::system::StatisticsProvider::GetInstance(); | 123 chromeos::system::StatisticsProvider::GetInstance(); |
| 124 if (stats->IsRunningOnVm()) |
| 125 return true; |
| 123 | 126 |
| 124 std::string hwid; | 127 std::string hwid; |
| 125 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) { | 128 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) { |
| 126 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; | 129 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; |
| 127 return false; | 130 return false; |
| 128 } | 131 } |
| 129 if (!chromeos::IsHWIDCorrect(hwid)) { | 132 if (!chromeos::IsHWIDCorrect(hwid)) { |
| 130 // Log the system vendor info to see what the system vendor is on the GCE | 133 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'. "; |
| 131 // VMs. This info will be used to filter out error messages on VMs. See | 134 return false; |
| 132 // http://crbug.com/585514 and http://crbug.com/585515 for more info. | |
| 133 std::string system_vendor; | |
| 134 stats->GetMachineStatistic(chromeos::system::kSystemVendorKey, | |
| 135 &system_vendor); | |
| 136 std::string firmware_type; | |
| 137 const bool non_chrome_firmware = | |
| 138 stats->GetMachineStatistic(chromeos::system::kFirmwareTypeKey, | |
| 139 &firmware_type) && | |
| 140 firmware_type == system::kFirmwareTypeValueNonchrome; | |
| 141 if (non_chrome_firmware) { | |
| 142 LOG(WARNING) << "Detected non-Chrome firmware with malformed HWID '" | |
| 143 << hwid << "', assuming VM environment. " | |
| 144 << "The system vendor is '" << system_vendor << "'."; | |
| 145 } else { | |
| 146 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'. " | |
| 147 << "The system vendor is '" << system_vendor << "'."; | |
| 148 return false; | |
| 149 } | |
| 150 } | 135 } |
| 151 return true; | 136 return true; |
| 152 } | 137 } |
| 153 | 138 |
| 154 } // namespace chromeos | 139 } // namespace chromeos |
| OLD | NEW |