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

Side by Side Diff: ash/common/system/chromeos/brightness/tray_brightness.cc

Issue 2739763003: Moves maintaining ShellObservers back to Shell (Closed)
Patch Set: merge Created 3 years, 9 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 | « ash/common/shelf/wm_shelf.cc ('k') | ash/common/system/chromeos/cast/tray_cast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/common/system/chromeos/brightness/tray_brightness.h" 5 #include "ash/common/system/chromeos/brightness/tray_brightness.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/shell_observer.h" 10 #include "ash/common/shell_observer.h"
11 #include "ash/common/system/brightness_control_delegate.h" 11 #include "ash/common/system/brightness_control_delegate.h"
12 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_popup_utils.h" 13 #include "ash/common/system/tray/tray_popup_utils.h"
14 #include "ash/common/system/tray/tri_view.h" 14 #include "ash/common/system/tray/tri_view.h"
15 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 15 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
16 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "ash/resources/grit/ash_resources.h" 17 #include "ash/resources/grit/ash_resources.h"
18 #include "ash/resources/vector_icons/vector_icons.h" 18 #include "ash/resources/vector_icons/vector_icons.h"
19 #include "ash/shell.h"
19 #include "ash/strings/grit/ash_strings.h" 20 #include "ash/strings/grit/ash_strings.h"
20 #include "base/bind.h" 21 #include "base/bind.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
23 #include "chromeos/dbus/dbus_thread_manager.h" 24 #include "chromeos/dbus/dbus_thread_manager.h"
24 #include "chromeos/dbus/power_manager_client.h" 25 #include "chromeos/dbus/power_manager_client.h"
25 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/display/display.h" 27 #include "ui/display/display.h"
27 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
28 #include "ui/gfx/paint_vector_icon.h" 29 #include "ui/gfx/paint_vector_icon.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 112 }
112 tri_view->AddView(TriView::Container::START, icon); 113 tri_view->AddView(TriView::Container::START, icon);
113 114
114 slider_ = TrayPopupUtils::CreateSlider(this); 115 slider_ = TrayPopupUtils::CreateSlider(this);
115 slider_->SetValue(static_cast<float>(initial_percent / 100.0)); 116 slider_->SetValue(static_cast<float>(initial_percent / 100.0));
116 slider_->SetAccessibleName( 117 slider_->SetAccessibleName(
117 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS)); 118 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS));
118 tri_view->AddView(TriView::Container::CENTER, slider_); 119 tri_view->AddView(TriView::Container::CENTER, slider_);
119 120
120 if (is_default_view_) { 121 if (is_default_view_) {
121 WmShell::Get()->AddShellObserver(this); 122 Shell::GetInstance()->AddShellObserver(this);
122 SetVisible(WmShell::Get() 123 SetVisible(WmShell::Get()
123 ->maximize_mode_controller() 124 ->maximize_mode_controller()
124 ->IsMaximizeModeWindowManagerEnabled()); 125 ->IsMaximizeModeWindowManagerEnabled());
125 } else { 126 } else {
126 tri_view->SetContainerVisible(TriView::Container::END, false); 127 tri_view->SetContainerVisible(TriView::Container::END, false);
127 } 128 }
128 } 129 }
129 130
130 BrightnessView::~BrightnessView() { 131 BrightnessView::~BrightnessView() {
131 if (is_default_view_) 132 if (is_default_view_)
132 WmShell::Get()->RemoveShellObserver(this); 133 Shell::GetInstance()->RemoveShellObserver(this);
133 } 134 }
134 135
135 void BrightnessView::SetBrightnessPercent(double percent) { 136 void BrightnessView::SetBrightnessPercent(double percent) {
136 last_percent_ = percent; 137 last_percent_ = percent;
137 if (!dragging_) 138 if (!dragging_)
138 slider_->SetValue(static_cast<float>(percent / 100.0)); 139 slider_->SetValue(static_cast<float>(percent / 100.0));
139 } 140 }
140 141
141 void BrightnessView::OnMaximizeModeStarted() { 142 void BrightnessView::OnMaximizeModeStarted() {
142 SetVisible(true); 143 SetVisible(true);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 if (!display::Display::HasInternalDisplay()) 275 if (!display::Display::HasInternalDisplay())
275 return; 276 return;
276 277
277 if (brightness_view_ && brightness_view_->visible()) 278 if (brightness_view_ && brightness_view_->visible())
278 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); 279 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds);
279 else 280 else
280 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); 281 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
281 } 282 }
282 283
283 } // namespace ash 284 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/wm_shelf.cc ('k') | ash/common/system/chromeos/cast/tray_cast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698