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

Side by Side Diff: ash/system/palette/palette_tray.cc

Issue 2895843002: chromeos: Eliminate WmWindow from //ash/system (Closed)
Patch Set: comments Created 3 years, 7 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/system/palette/palette_tray.h ('k') | ash/system/palette/palette_utils.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 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/system/palette/palette_tray.h" 5 #include "ash/system/palette/palette_tray.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/resources/grit/ash_resources.h" 8 #include "ash/resources/grit/ash_resources.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 9 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/session/session_controller.h" 11 #include "ash/session/session_controller.h"
12 #include "ash/shelf/shelf_constants.h" 12 #include "ash/shelf/shelf_constants.h"
13 #include "ash/shelf/wm_shelf.h" 13 #include "ash/shelf/wm_shelf.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/strings/grit/ash_strings.h" 15 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/palette/palette_tool_manager.h" 16 #include "ash/system/palette/palette_tool_manager.h"
17 #include "ash/system/palette/palette_utils.h" 17 #include "ash/system/palette/palette_utils.h"
18 #include "ash/system/tray/system_menu_button.h" 18 #include "ash/system/tray/system_menu_button.h"
19 #include "ash/system/tray/system_tray_controller.h" 19 #include "ash/system/tray/system_tray_controller.h"
20 #include "ash/system/tray/tray_bubble_wrapper.h" 20 #include "ash/system/tray/tray_bubble_wrapper.h"
21 #include "ash/system/tray/tray_constants.h" 21 #include "ash/system/tray/tray_constants.h"
22 #include "ash/system/tray/tray_container.h" 22 #include "ash/system/tray/tray_container.h"
23 #include "ash/system/tray/tray_popup_header_button.h" 23 #include "ash/system/tray/tray_popup_header_button.h"
24 #include "ash/system/tray/tray_popup_item_style.h" 24 #include "ash/system/tray/tray_popup_item_style.h"
25 #include "ash/wm_window.h" 25 #include "ash/wm_window.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/display/display.h" 29 #include "ui/display/display.h"
30 #include "ui/display/screen.h"
30 #include "ui/events/devices/input_device_manager.h" 31 #include "ui/events/devices/input_device_manager.h"
31 #include "ui/events/devices/stylus_state.h" 32 #include "ui/events/devices/stylus_state.h"
32 #include "ui/gfx/color_palette.h" 33 #include "ui/gfx/color_palette.h"
33 #include "ui/gfx/paint_vector_icon.h" 34 #include "ui/gfx/paint_vector_icon.h"
34 #include "ui/views/controls/image_view.h" 35 #include "ui/views/controls/image_view.h"
35 #include "ui/views/controls/label.h" 36 #include "ui/views/controls/label.h"
36 #include "ui/views/controls/separator.h" 37 #include "ui/views/controls/separator.h"
37 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
38 #include "ui/views/layout/fill_layout.h" 39 #include "ui/views/layout/fill_layout.h"
39 40
(...skipping 25 matching lines...) Expand all
65 return !session_controller->IsUserSessionBlocked() && 66 return !session_controller->IsUserSessionBlocked() &&
66 session_controller->GetSessionState() == 67 session_controller->GetSessionState() ==
67 session_manager::SessionState::ACTIVE && 68 session_manager::SessionState::ACTIVE &&
68 !session_controller->IsKioskSession(); 69 !session_controller->IsKioskSession();
69 } 70 }
70 71
71 // Returns true if the |palette_tray| is on an internal display or on every 72 // Returns true if the |palette_tray| is on an internal display or on every
72 // display if requested from the command line. 73 // display if requested from the command line.
73 bool ShouldShowOnDisplay(PaletteTray* palette_tray) { 74 bool ShouldShowOnDisplay(PaletteTray* palette_tray) {
74 const display::Display& display = 75 const display::Display& display =
75 WmWindow::Get(palette_tray->GetWidget()->GetNativeWindow()) 76 display::Screen::GetScreen()->GetDisplayNearestWindow(
76 ->GetDisplayNearestWindow(); 77 palette_tray->GetWidget()->GetNativeWindow());
77 return display.IsInternal() || 78 return display.IsInternal() ||
78 palette_utils::IsPaletteEnabledOnEveryDisplay(); 79 palette_utils::IsPaletteEnabledOnEveryDisplay();
79 } 80 }
80 81
81 class TitleView : public views::View, public views::ButtonListener { 82 class TitleView : public views::View, public views::ButtonListener {
82 public: 83 public:
83 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { 84 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
84 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. 85 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title.
85 // See crbug.com/614453. 86 // See crbug.com/614453.
86 auto* box_layout = 87 auto* box_layout =
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 base::string16 PaletteTray::GetAccessibleNameForBubble() { 303 base::string16 PaletteTray::GetAccessibleNameForBubble() {
303 return GetAccessibleNameForTray(); 304 return GetAccessibleNameForTray();
304 } 305 }
305 306
306 void PaletteTray::OnBeforeBubbleWidgetInit( 307 void PaletteTray::OnBeforeBubbleWidgetInit(
307 views::Widget* anchor_widget, 308 views::Widget* anchor_widget,
308 views::Widget* bubble_widget, 309 views::Widget* bubble_widget,
309 views::Widget::InitParams* params) const { 310 views::Widget::InitParams* params) const {
310 // Place the bubble in the same root window as |anchor_widget|. 311 // Place the bubble in the same root window as |anchor_widget|.
311 WmWindow::Get(anchor_widget->GetNativeWindow()) 312 RootWindowController::ForWindow(anchor_widget->GetNativeWindow())
312 ->GetRootWindowController()
313 ->ConfigureWidgetInitParamsForContainer( 313 ->ConfigureWidgetInitParamsForContainer(
314 bubble_widget, kShellWindowId_SettingBubbleContainer, params); 314 bubble_widget, kShellWindowId_SettingBubbleContainer, params);
315 } 315 }
316 316
317 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { 317 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) {
318 HideBubbleWithView(bubble_view); 318 HideBubbleWithView(bubble_view);
319 } 319 }
320 320
321 void PaletteTray::HidePalette() { 321 void PaletteTray::HidePalette() {
322 is_bubble_auto_opened_ = false; 322 is_bubble_auto_opened_ = false;
(...skipping 28 matching lines...) Expand all
351 UMA_HISTOGRAM_ENUMERATION( 351 UMA_HISTOGRAM_ENUMERATION(
352 "Ash.Shelf.Palette.ModeCancellation", type, 352 "Ash.Shelf.Palette.ModeCancellation", type,
353 PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT); 353 PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT);
354 } 354 }
355 355
356 void PaletteTray::OnActiveToolChanged() { 356 void PaletteTray::OnActiveToolChanged() {
357 ++num_actions_in_bubble_; 357 ++num_actions_in_bubble_;
358 UpdateTrayIcon(); 358 UpdateTrayIcon();
359 } 359 }
360 360
361 WmWindow* PaletteTray::GetWindow() { 361 aura::Window* PaletteTray::GetWindow() {
362 return shelf()->GetWindow(); 362 return shelf()->GetWindow()->aura_window();
363 } 363 }
364 364
365 void PaletteTray::AnchorUpdated() { 365 void PaletteTray::AnchorUpdated() {
366 if (bubble_) 366 if (bubble_)
367 bubble_->bubble_view()->UpdateBubble(); 367 bubble_->bubble_view()->UpdateBubble();
368 } 368 }
369 369
370 void PaletteTray::Initialize() { 370 void PaletteTray::Initialize() {
371 PaletteDelegate* delegate = Shell::Get()->palette_delegate(); 371 PaletteDelegate* delegate = Shell::Get()->palette_delegate();
372 // |delegate| can be null in tests. 372 // |delegate| can be null in tests.
(...skipping 23 matching lines...) Expand all
396 UpdateIconVisibility(); 396 UpdateIconVisibility();
397 } 397 }
398 } 398 }
399 399
400 void PaletteTray::UpdateIconVisibility() { 400 void PaletteTray::UpdateIconVisibility() {
401 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && 401 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() &&
402 ShouldShowOnDisplay(this) && IsInUserSession()); 402 ShouldShowOnDisplay(this) && IsInUserSession());
403 } 403 }
404 404
405 } // namespace ash 405 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/palette/palette_tray.h ('k') | ash/system/palette/palette_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698