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

Unified Diff: ash/system/chromeos/rotation/tray_rotation_lock.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/rotation/tray_rotation_lock.cc
diff --git a/ash/system/chromeos/rotation/tray_rotation_lock.cc b/ash/system/chromeos/rotation/tray_rotation_lock.cc
deleted file mode 100644
index 2a10c6ddbcc2f2100032c71097a0690235811018..0000000000000000000000000000000000000000
--- a/ash/system/chromeos/rotation/tray_rotation_lock.cc
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/system/chromeos/rotation/tray_rotation_lock.h"
-
-#include "ash/common/system/tray/actionable_view.h"
-#include "ash/common/system/tray/system_tray.h"
-#include "ash/common/system/tray/tray_constants.h"
-#include "ash/common/system/tray/tray_popup_item_style.h"
-#include "ash/common/system/tray/tray_popup_utils.h"
-#include "ash/common/system/tray/tri_view.h"
-#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
-#include "ash/common/wm_shell.h"
-#include "ash/display/screen_orientation_controller_chromeos.h"
-#include "ash/resources/vector_icons/vector_icons.h"
-#include "ash/shell.h"
-#include "ash/strings/grit/ash_strings.h"
-#include "ui/accessibility/ax_node_data.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/display/display.h"
-#include "ui/gfx/paint_vector_icon.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/layout/fill_layout.h"
-
-namespace ash {
-
-namespace {
-
-bool IsMaximizeModeWindowManagerEnabled() {
- return WmShell::Get()
- ->maximize_mode_controller()
- ->IsMaximizeModeWindowManagerEnabled();
-}
-
-bool IsRotationLocked() {
- return Shell::GetInstance()
- ->screen_orientation_controller()
- ->rotation_locked();
-}
-
-} // namespace
-
-namespace tray {
-
-class RotationLockDefaultView : public ActionableView,
- public ShellObserver,
- public ScreenOrientationController::Observer {
- public:
- explicit RotationLockDefaultView(SystemTrayItem* owner);
- ~RotationLockDefaultView() override;
-
- private:
- // Updates icon and label according to current rotation lock status.
- void Update();
-
- // Stop observing rotation lock status.
- void StopObservingRotation();
-
- // ActionableView:
- void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
- bool PerformAction(const ui::Event& event) override;
-
- // ShellObserver:
- void OnMaximizeModeStarted() override;
- void OnMaximizeModeEnded() override;
-
- // ScreenOrientationController::Obsever:
- void OnRotationLockChanged(bool rotation_locked) override;
-
- views::ImageView* icon_;
- views::Label* label_;
-
- DISALLOW_COPY_AND_ASSIGN(RotationLockDefaultView);
-};
-
-RotationLockDefaultView::RotationLockDefaultView(SystemTrayItem* owner)
- : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS),
- icon_(TrayPopupUtils::CreateMainImageView()),
- label_(TrayPopupUtils::CreateDefaultLabel()) {
- SetLayoutManager(new views::FillLayout);
-
- TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
- AddChildView(tri_view);
-
- tri_view->AddView(TriView::Container::START, icon_);
- tri_view->AddView(TriView::Container::CENTER, label_);
- tri_view->SetContainerVisible(TriView::Container::END, false);
-
- Update();
-
- SetInkDropMode(InkDropHostView::InkDropMode::ON);
-
- SetVisible(IsMaximizeModeWindowManagerEnabled());
- WmShell::Get()->AddShellObserver(this);
- if (IsMaximizeModeWindowManagerEnabled())
- Shell::GetInstance()->screen_orientation_controller()->AddObserver(this);
-}
-
-RotationLockDefaultView::~RotationLockDefaultView() {
- StopObservingRotation();
- WmShell::Get()->RemoveShellObserver(this);
-}
-
-void RotationLockDefaultView::Update() {
- TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
- icon_->SetImage(gfx::CreateVectorIcon(IsRotationLocked()
- ? kSystemMenuRotationLockLockedIcon
- : kSystemMenuRotationLockAutoIcon,
- kMenuIconSize, style.GetIconColor()));
-
- base::string16 label = l10n_util::GetStringUTF16(
- IsRotationLocked() ? IDS_ASH_STATUS_TRAY_ROTATION_LOCK_LOCKED
- : IDS_ASH_STATUS_TRAY_ROTATION_LOCK_AUTO);
- label_->SetText(label);
- style.SetupLabel(label_);
-
- Layout();
- SchedulePaint();
-}
-
-void RotationLockDefaultView::StopObservingRotation() {
- ScreenOrientationController* controller =
- Shell::GetInstance()->screen_orientation_controller();
- if (controller)
- controller->RemoveObserver(this);
-}
-
-void RotationLockDefaultView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
- ActionableView::GetAccessibleNodeData(node_data);
- if (!label_->text().empty())
- node_data->SetName(label_->text());
-}
-
-bool RotationLockDefaultView::PerformAction(const ui::Event& event) {
- Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
- !IsRotationLocked());
- return true;
-}
-
-void RotationLockDefaultView::OnMaximizeModeStarted() {
- Update();
- SetVisible(true);
- Shell::GetInstance()->screen_orientation_controller()->AddObserver(this);
-}
-
-void RotationLockDefaultView::OnMaximizeModeEnded() {
- SetVisible(false);
- StopObservingRotation();
-}
-
-void RotationLockDefaultView::OnRotationLockChanged(bool rotation_locked) {
- Update();
-}
-
-} // namespace tray
-
-TrayRotationLock::TrayRotationLock(SystemTray* system_tray)
- : TrayImageItem(system_tray,
- kSystemTrayRotationLockLockedIcon,
- UMA_ROTATION_LOCK) {
- WmShell::Get()->AddShellObserver(this);
-}
-
-TrayRotationLock::~TrayRotationLock() {
- WmShell::Get()->RemoveShellObserver(this);
-}
-
-void TrayRotationLock::OnRotationLockChanged(bool rotation_locked) {
- tray_view()->SetVisible(ShouldBeVisible());
-}
-
-views::View* TrayRotationLock::CreateDefaultView(LoginStatus status) {
- if (OnPrimaryDisplay())
- return new tray::RotationLockDefaultView(this);
- return nullptr;
-}
-
-void TrayRotationLock::OnMaximizeModeStarted() {
- tray_view()->SetVisible(IsRotationLocked());
- Shell::GetInstance()->screen_orientation_controller()->AddObserver(this);
-}
-
-void TrayRotationLock::OnMaximizeModeEnded() {
- tray_view()->SetVisible(false);
- StopObservingRotation();
-}
-
-void TrayRotationLock::DestroyTrayView() {
- StopObservingRotation();
- WmShell::Get()->RemoveShellObserver(this);
- TrayImageItem::DestroyTrayView();
-}
-
-bool TrayRotationLock::GetInitialVisibility() {
- return ShouldBeVisible();
-}
-
-bool TrayRotationLock::ShouldBeVisible() {
- return OnPrimaryDisplay() && IsMaximizeModeWindowManagerEnabled() &&
- IsRotationLocked();
-}
-
-bool TrayRotationLock::OnPrimaryDisplay() const {
- gfx::NativeView native_view = system_tray()->GetWidget()->GetNativeView();
- display::Display parent_display =
- display::Screen::GetScreen()->GetDisplayNearestWindow(native_view);
- return parent_display.IsInternal();
-}
-
-void TrayRotationLock::StopObservingRotation() {
- ScreenOrientationController* controller =
- Shell::GetInstance()->screen_orientation_controller();
- if (controller)
- controller->RemoveObserver(this);
-}
-
-} // namespace ash
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock.h ('k') | ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698