| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/options/chromeos/power_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/power_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/resources/grit/ash_resources.h" | 9 #include "ash/resources/grit/ash_resources.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/base/webui/web_ui_util.h" | 22 #include "ui/base/webui/web_ui_util.h" |
| 23 | 23 |
| 24 using ash::PowerStatus; | 24 using ash::PowerStatus; |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 namespace options { | 27 namespace options { |
| 28 | 28 |
| 29 PowerHandler::PowerHandler() { | 29 PowerHandler::PowerHandler() { |
| 30 // TODO(mash): Support Chrome power settings in Mash. crbug.com/644348 | 30 // TODO(mash): Support Chrome power settings in Mash. crbug.com/644348 |
| 31 this->show_power_status_ = !ash_util::IsRunningInMash() && | 31 this->show_power_status_ = |
| 32 (switches::PowerOverlayEnabled() || | 32 !IsRunningInMash() && (switches::PowerOverlayEnabled() || |
| 33 (PowerStatus::Get()->IsBatteryPresent() && | 33 (PowerStatus::Get()->IsBatteryPresent() && |
| 34 PowerStatus::Get()->SupportsDualRoleDevices())); | 34 PowerStatus::Get()->SupportsDualRoleDevices())); |
| 35 } | 35 } |
| 36 | 36 |
| 37 PowerHandler::~PowerHandler() { | 37 PowerHandler::~PowerHandler() { |
| 38 if (this->show_power_status_) | 38 if (this->show_power_status_) |
| 39 PowerStatus::Get()->RemoveObserver(this); | 39 PowerStatus::Get()->RemoveObserver(this); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void PowerHandler::GetLocalizedValues( | 42 void PowerHandler::GetLocalizedValues( |
| 43 base::DictionaryValue* localized_strings) { | 43 base::DictionaryValue* localized_strings) { |
| 44 DCHECK(localized_strings); | 44 DCHECK(localized_strings); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 web_ui()->CallJavascriptFunctionUnsafe( | 166 web_ui()->CallJavascriptFunctionUnsafe( |
| 167 "options.PowerOverlay.setPowerSources", sources_list, | 167 "options.PowerOverlay.setPowerSources", sources_list, |
| 168 base::StringValue(status->GetCurrentPowerSourceID()), | 168 base::StringValue(status->GetCurrentPowerSourceID()), |
| 169 base::FundamentalValue(status->IsUsbChargerConnected()), | 169 base::FundamentalValue(status->IsUsbChargerConnected()), |
| 170 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); | 170 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace options | 173 } // namespace options |
| 174 } // namespace chromeos | 174 } // namespace chromeos |
| OLD | NEW |