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

Unified Diff: ash/common/system/tray/tray_background_view.cc

Issue 2099603002: Reland: mash: Convert TrayBackgroundView to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix conflict Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/tray_background_view.h ('k') | ash/common/system/tray/tray_bubble_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_background_view.cc
diff --git a/ash/system/tray/tray_background_view.cc b/ash/common/system/tray/tray_background_view.cc
similarity index 92%
rename from ash/system/tray/tray_background_view.cc
rename to ash/common/system/tray/tray_background_view.cc
index 94180852c8b3e895789f02185909682438bf40aa..06b2a76d9d5c07f0b72ac68f5133151c27bce613 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/common/system/tray/tray_background_view.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/system/tray/tray_background_view.h"
+#include "ash/common/system/tray/tray_background_view.h"
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shelf/shelf_constants.h"
@@ -10,18 +10,13 @@
#include "ash/common/shelf/wm_shelf_util.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/system/tray/tray_constants.h"
-#include "ash/screen_util.h"
-#include "ash/shell.h"
-#include "ash/system/status_area_widget.h"
-#include "ash/system/status_area_widget_delegate.h"
+#include "ash/common/system/tray/tray_event_filter.h"
+#include "ash/common/wm_lookup.h"
+#include "ash/common/wm_shell.h"
+#include "ash/common/wm_window.h"
#include "ash/system/tray/system_tray.h"
-#include "ash/system/tray/tray_event_filter.h"
-#include "ash/wm/window_animations.h"
-#include "base/command_line.h"
#include "grit/ash_resources.h"
#include "ui/accessibility/ax_view_state.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/nine_image_painter_factory.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/layer.h"
@@ -102,9 +97,7 @@ class TrayBackground : public views::Background {
~TrayBackground() override {}
private:
- WmShelf* GetShelf() const {
- return tray_background_view_->GetShelf();
- }
+ WmShelf* GetShelf() const { return tray_background_view_->shelf(); }
void PaintMaterial(gfx::Canvas* canvas, views::View* view) const {
SkColor background_color = SK_ColorTRANSPARENT;
@@ -233,14 +226,14 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() {
////////////////////////////////////////////////////////////////////////////////
// TrayBackgroundView
-TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget)
- : status_area_widget_(status_area_widget),
+TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
+ : wm_shelf_(wm_shelf),
tray_container_(NULL),
shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
background_(NULL),
draw_background_as_active_(false),
widget_observer_(new TrayWidgetObserver(this)) {
- DCHECK(status_area_widget->wm_shelf());
+ DCHECK(wm_shelf_);
set_notify_enter_exit_on_child(true);
tray_container_ = new TrayContainer(shelf_alignment_);
@@ -266,12 +259,12 @@ void TrayBackgroundView::Initialize() {
// static
void TrayBackgroundView::InitializeBubbleAnimations(
views::Widget* bubble_widget) {
- aura::Window* window = bubble_widget->GetNativeWindow();
- ::wm::SetWindowVisibilityAnimationType(
- window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
- ::wm::SetWindowVisibilityAnimationTransition(window, ::wm::ANIMATE_HIDE);
- ::wm::SetWindowVisibilityAnimationDuration(
- window, base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMs));
+ WmWindow* window = WmLookup::Get()->GetWindowForWidget(bubble_widget);
+ window->SetVisibilityAnimationType(
+ ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
+ window->SetVisibilityAnimationTransition(::wm::ANIMATE_HIDE);
+ window->SetVisibilityAnimationDuration(
+ base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMs));
}
void TrayBackgroundView::SetVisible(bool visible) {
@@ -383,10 +376,6 @@ void TrayBackgroundView::SetContentsBackground() {
tray_container_->set_background(background_);
}
-WmShelf* TrayBackgroundView::GetShelf() {
- return status_area_widget_->wm_shelf();
-}
-
void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
shelf_alignment_ = alignment;
tray_container_->SetAlignment(alignment);
@@ -463,10 +452,12 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
DCHECK(false) << "Unhandled anchor type.";
}
} else {
- aura::Window* target_root = anchor_widget ?
- anchor_widget->GetNativeView()->GetRootWindow() :
- Shell::GetPrimaryRootWindow();
- rect = target_root->bounds();
+ WmWindow* target_root = anchor_widget
+ ? WmLookup::Get()
+ ->GetWindowForWidget(anchor_widget)
+ ->GetRootWindow()
+ : WmShell::Get()->GetPrimaryRootWindow();
+ rect = target_root->GetBounds();
if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) {
if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
rect = gfx::Rect(
@@ -475,19 +466,19 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
0, 0);
- rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ rect = target_root->ConvertRectToScreen(rect);
} else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
rect = gfx::Rect(
kPaddingFromRightEdgeOfScreenBottomAlignment,
rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
1, 1);
- rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ rect = target_root->ConvertRectToScreen(rect);
} else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) {
rect = gfx::Rect(
rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
1, 1);
- rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ rect = target_root->ConvertRectToScreen(rect);
} else {
// TODO(bruthig) May need to handle other ANCHOR_ALIGNMENT_ values.
// ie. ANCHOR_ALIGNMENT_TOP
« no previous file with comments | « ash/common/system/tray/tray_background_view.h ('k') | ash/common/system/tray/tray_bubble_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698