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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/palette/palette_tray.h" 5 #include "ash/common/system/chromeos/palette/palette_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h"
13 #include "ash/common/system/chromeos/palette/palette_utils.h" 13 #include "ash/common/system/chromeos/palette/palette_utils.h"
14 #include "ash/common/system/tray/system_menu_button.h" 14 #include "ash/common/system/tray/system_menu_button.h"
15 #include "ash/common/system/tray/system_tray_controller.h" 15 #include "ash/common/system/tray/system_tray_controller.h"
16 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
17 #include "ash/common/system/tray/tray_bubble_wrapper.h" 17 #include "ash/common/system/tray/tray_bubble_wrapper.h"
18 #include "ash/common/system/tray/tray_constants.h" 18 #include "ash/common/system/tray/tray_constants.h"
19 #include "ash/common/system/tray/tray_popup_header_button.h" 19 #include "ash/common/system/tray/tray_popup_header_button.h"
20 #include "ash/common/system/tray/tray_popup_item_style.h" 20 #include "ash/common/system/tray/tray_popup_item_style.h"
21 #include "ash/common/wm_shell.h" 21 #include "ash/common/wm_shell.h"
22 #include "ash/common/wm_window.h" 22 #include "ash/common/wm_window.h"
23 #include "ash/public/cpp/shell_window_ids.h" 23 #include "ash/public/cpp/shell_window_ids.h"
24 #include "ash/resources/grit/ash_resources.h" 24 #include "ash/resources/grit/ash_resources.h"
25 #include "ash/resources/vector_icons/vector_icons.h" 25 #include "ash/resources/vector_icons/vector_icons.h"
26 #include "ash/root_window_controller.h" 26 #include "ash/root_window_controller.h"
27 #include "ash/shell.h"
27 #include "ash/strings/grit/ash_strings.h" 28 #include "ash/strings/grit/ash_strings.h"
28 #include "base/metrics/histogram_macros.h" 29 #include "base/metrics/histogram_macros.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/events/devices/input_device_manager.h" 32 #include "ui/events/devices/input_device_manager.h"
32 #include "ui/events/devices/stylus_state.h" 33 #include "ui/events/devices/stylus_state.h"
33 #include "ui/gfx/color_palette.h" 34 #include "ui/gfx/color_palette.h"
34 #include "ui/gfx/paint_vector_icon.h" 35 #include "ui/gfx/paint_vector_icon.h"
35 #include "ui/gfx/vector_icons_public.h" 36 #include "ui/gfx/vector_icons_public.h"
36 #include "ui/views/controls/image_view.h" 37 #include "ui/views/controls/image_view.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 SetContentsBackground(true); 163 SetContentsBackground(true);
163 } 164 }
164 165
165 SetLayoutManager(new views::FillLayout()); 166 SetLayoutManager(new views::FillLayout());
166 icon_ = new views::ImageView(); 167 icon_ = new views::ImageView();
167 UpdateTrayIcon(); 168 UpdateTrayIcon();
168 169
169 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset); 170 tray_container()->SetMargin(kTrayIconMainAxisInset, kTrayIconCrossAxisInset);
170 tray_container()->AddChildView(icon_); 171 tray_container()->AddChildView(icon_);
171 172
172 WmShell::Get()->AddShellObserver(this); 173 Shell::GetInstance()->AddShellObserver(this);
173 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 174 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
174 ui::InputDeviceManager::GetInstance()->AddObserver(this); 175 ui::InputDeviceManager::GetInstance()->AddObserver(this);
175 } 176 }
176 177
177 PaletteTray::~PaletteTray() { 178 PaletteTray::~PaletteTray() {
178 if (bubble_) 179 if (bubble_)
179 bubble_->bubble_view()->reset_delegate(); 180 bubble_->bubble_view()->reset_delegate();
180 181
181 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); 182 ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
182 WmShell::Get()->RemoveShellObserver(this); 183 Shell::GetInstance()->RemoveShellObserver(this);
183 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); 184 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
184 } 185 }
185 186
186 bool PaletteTray::PerformAction(const ui::Event& event) { 187 bool PaletteTray::PerformAction(const ui::Event& event) {
187 if (bubble_) { 188 if (bubble_) {
188 if (num_actions_in_bubble_ == 0) 189 if (num_actions_in_bubble_ == 0)
189 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION); 190 RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION);
190 HidePalette(); 191 HidePalette();
191 return true; 192 return true;
192 } 193 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 UpdateIconVisibility(); 429 UpdateIconVisibility();
429 } 430 }
430 } 431 }
431 432
432 void PaletteTray::UpdateIconVisibility() { 433 void PaletteTray::UpdateIconVisibility() {
433 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && 434 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() &&
434 IsInUserSession()); 435 IsInUserSession());
435 } 436 }
436 437
437 } // namespace ash 438 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/cast/tray_cast.cc ('k') | ash/common/system/chromeos/screen_security/screen_capture_tray_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698