Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/power_handler.cc

Issue 2341783005: mash: Fix Chrome crash accessing chrome://settings. (Closed)
Patch Set: Avoid PowerStatus access; not init in Chrome. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/resources/grit/ash_resources.h" 7 #include "ash/resources/grit/ash_resources.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/ui/ash/ash_util.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
15 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/l10n/time_format.h" 18 #include "ui/base/l10n/time_format.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/base/webui/web_ui_util.h" 20 #include "ui/base/webui/web_ui_util.h"
20 21
21 using ash::PowerStatus; 22 using ash::PowerStatus;
22 23
23 namespace chromeos { 24 namespace chromeos {
24 namespace options { 25 namespace options {
25 26
26 PowerHandler::PowerHandler() { 27 PowerHandler::PowerHandler() {
27 this->show_power_status_ = switches::PowerOverlayEnabled() || 28 // TODO(mash): Support Chrome power settings in Mash. crbug.com/644348
28 (PowerStatus::Get()->IsBatteryPresent() && 29 this->show_power_status_ = !chrome::IsRunningInMash() &&
29 PowerStatus::Get()->SupportsDualRoleDevices()); 30 (switches::PowerOverlayEnabled() ||
31 (PowerStatus::Get()->IsBatteryPresent() &&
32 PowerStatus::Get()->SupportsDualRoleDevices()));
30 } 33 }
31 34
32 PowerHandler::~PowerHandler() { 35 PowerHandler::~PowerHandler() {
33 if (this->show_power_status_) 36 if (this->show_power_status_)
34 PowerStatus::Get()->RemoveObserver(this); 37 PowerStatus::Get()->RemoveObserver(this);
35 } 38 }
36 39
37 void PowerHandler::GetLocalizedValues( 40 void PowerHandler::GetLocalizedValues(
38 base::DictionaryValue* localized_strings) { 41 base::DictionaryValue* localized_strings) {
39 DCHECK(localized_strings); 42 DCHECK(localized_strings);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 163
161 web_ui()->CallJavascriptFunctionUnsafe( 164 web_ui()->CallJavascriptFunctionUnsafe(
162 "options.PowerOverlay.setPowerSources", sources_list, 165 "options.PowerOverlay.setPowerSources", sources_list,
163 base::StringValue(status->GetCurrentPowerSourceID()), 166 base::StringValue(status->GetCurrentPowerSourceID()),
164 base::FundamentalValue(status->IsUsbChargerConnected()), 167 base::FundamentalValue(status->IsUsbChargerConnected()),
165 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); 168 base::FundamentalValue(status->IsBatteryTimeBeingCalculated()));
166 } 169 }
167 170
168 } // namespace options 171 } // namespace options
169 } // namespace chromeos 172 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698