diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/ash/system/tray | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/ash/system/tray')
57 files changed, 0 insertions, 7460 deletions
diff --git a/chromium/ash/system/tray/actionable_view.cc b/chromium/ash/system/tray/actionable_view.cc deleted file mode 100644 index 261cefd30a1..00000000000 --- a/chromium/ash/system/tray/actionable_view.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2012 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/tray/actionable_view.h" - -#include "ash/ash_constants.h" -#include "ui/base/accessibility/accessible_view_state.h" -#include "ui/gfx/canvas.h" - -namespace ash { -namespace internal { - -// static -const char ActionableView::kViewClassName[] = "tray/ActionableView"; - -ActionableView::ActionableView() - : has_capture_(false) { - SetFocusable(true); -} - -ActionableView::~ActionableView() { -} - -void ActionableView::OnPaintFocus(gfx::Canvas* canvas) { - gfx::Rect rect(GetFocusBounds()); - rect.Inset(1, 1, 3, 2); - canvas->DrawSolidFocusRect(rect, kFocusBorderColor); -} - -gfx::Rect ActionableView::GetFocusBounds() { - return GetLocalBounds(); -} - -const char* ActionableView::GetClassName() const { - return kViewClassName; -} - -bool ActionableView::OnKeyPressed(const ui::KeyEvent& event) { - if (event.key_code() == ui::VKEY_SPACE || - event.key_code() == ui::VKEY_RETURN) { - return PerformAction(event); - } - return false; -} - -bool ActionableView::OnMousePressed(const ui::MouseEvent& event) { - // Return true so that this view starts capturing the events. - has_capture_ = true; - return true; -} - -void ActionableView::OnMouseReleased(const ui::MouseEvent& event) { - if (has_capture_ && GetLocalBounds().Contains(event.location())) - PerformAction(event); -} - -void ActionableView::OnMouseCaptureLost() { - has_capture_ = false; -} - -void ActionableView::SetAccessibleName(const base::string16& name) { - accessible_name_ = name; -} - -void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = accessible_name_; -} - -void ActionableView::OnPaint(gfx::Canvas* canvas) { - View::OnPaint(canvas); - if (HasFocus()) - OnPaintFocus(canvas); -} - -void ActionableView::OnFocus() { - View::OnFocus(); - // We render differently when focused. - SchedulePaint(); -} - -void ActionableView::OnBlur() { - View::OnBlur(); - // We render differently when focused. - SchedulePaint(); -} - -void ActionableView::OnGestureEvent(ui::GestureEvent* event) { - if (event->type() == ui::ET_GESTURE_TAP && PerformAction(*event)) - event->SetHandled(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/actionable_view.h b/chromium/ash/system/tray/actionable_view.h deleted file mode 100644 index f2b3ec1deba..00000000000 --- a/chromium/ash/system/tray/actionable_view.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ -#define ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/view.h" - -namespace ash { -namespace internal { - -// A focusable view that performs an action when user clicks on it, or presses -// enter or space when focused. Note that the action is triggered on mouse-up, -// instead of on mouse-down. So if user presses the mouse on the view, then -// moves the mouse out of the view and then releases, then the action will not -// be performed. -// Exported for SystemTray. -class ASH_EXPORT ActionableView : public views::View { - public: - static const char kViewClassName[]; - - ActionableView(); - - virtual ~ActionableView(); - - void SetAccessibleName(const base::string16& name); - const base::string16& accessible_name() const { return accessible_name_; } - - protected: - void OnPaintFocus(gfx::Canvas* canvas); - - // Returns the bounds to paint the focus rectangle in. - virtual gfx::Rect GetFocusBounds(); - - // Performs an action when user clicks on the view (on mouse-press event), or - // presses a key when this view is in focus. Returns true if the event has - // been handled and an action was performed. Returns false otherwise. - virtual bool PerformAction(const ui::Event& event) = 0; - - // Overridden from views::View. - virtual const char* GetClassName() const OVERRIDE; - virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; - virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseCaptureLost() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void OnFocus() OVERRIDE; - virtual void OnBlur() OVERRIDE; - - // Overridden from ui::EventHandler. - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - - private: - base::string16 accessible_name_; - bool has_capture_; - - DISALLOW_COPY_AND_ASSIGN(ActionableView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_ACTIONABLE_VIEW_H_ diff --git a/chromium/ash/system/tray/default_system_tray_delegate.cc b/chromium/ash/system/tray/default_system_tray_delegate.cc deleted file mode 100644 index 37836f0277f..00000000000 --- a/chromium/ash/system/tray/default_system_tray_delegate.cc +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright 2013 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/tray/default_system_tray_delegate.h" - -#include <string> - -#include "ash/session_state_delegate.h" -#include "ash/shell.h" -#include "ash/volume_control_delegate.h" -#include "base/message_loop/message_loop.h" -#include "base/time/time.h" - -namespace ash { - -namespace { - -class DefaultVolumnControlDelegate : public VolumeControlDelegate { - public: - DefaultVolumnControlDelegate() {} - virtual ~DefaultVolumnControlDelegate() {} - - virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE { - return true; - } - virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE { - return true; - } - virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE { - return true; - } - - private: - DISALLOW_COPY_AND_ASSIGN(DefaultVolumnControlDelegate); -}; - -} // namespace - -DefaultSystemTrayDelegate::DefaultSystemTrayDelegate() - : bluetooth_enabled_(true), - volume_control_delegate_(new DefaultVolumnControlDelegate) { -} - -DefaultSystemTrayDelegate::~DefaultSystemTrayDelegate() { -} - -void DefaultSystemTrayDelegate::Initialize() { -} - -void DefaultSystemTrayDelegate::Shutdown() { -} - -bool DefaultSystemTrayDelegate::GetTrayVisibilityOnStartup() { - return true; -} - -user::LoginStatus DefaultSystemTrayDelegate::GetUserLoginStatus() const { - return user::LOGGED_IN_USER; -} - -bool DefaultSystemTrayDelegate::IsOobeCompleted() const { - return true; -} - -void DefaultSystemTrayDelegate::ChangeProfilePicture() { -} - -const std::string DefaultSystemTrayDelegate::GetEnterpriseDomain() const { - return std::string(); -} - -const base::string16 DefaultSystemTrayDelegate::GetEnterpriseMessage() const { - return string16(); -} - -const std::string -DefaultSystemTrayDelegate::GetLocallyManagedUserManager() const { - return std::string(); -} - -const base::string16 -DefaultSystemTrayDelegate::GetLocallyManagedUserManagerName() - const { - return string16(); -} - -const base::string16 DefaultSystemTrayDelegate::GetLocallyManagedUserMessage() - const { - return string16(); -} - -bool DefaultSystemTrayDelegate::SystemShouldUpgrade() const { - return true; -} - -base::HourClockType DefaultSystemTrayDelegate::GetHourClockType() const { - return base::k24HourClock; -} - -void DefaultSystemTrayDelegate::ShowSettings() { -} - -bool DefaultSystemTrayDelegate::ShouldShowSettings() { - return true; -} - -void DefaultSystemTrayDelegate::ShowDateSettings() { -} - -void DefaultSystemTrayDelegate::ShowNetworkSettings( - const std::string& service_path) { -} - -void DefaultSystemTrayDelegate::ShowBluetoothSettings() { -} - -void DefaultSystemTrayDelegate::ShowDisplaySettings() { -} - -void DefaultSystemTrayDelegate::ShowChromeSlow() { -} - -bool DefaultSystemTrayDelegate::ShouldShowDisplayNotification() { - return false; -} - -void DefaultSystemTrayDelegate::ShowDriveSettings() { -} - -void DefaultSystemTrayDelegate::ShowIMESettings() { -} - -void DefaultSystemTrayDelegate::ShowHelp() { -} - -void DefaultSystemTrayDelegate::ShowAccessibilityHelp() { -} - -void DefaultSystemTrayDelegate::ShowAccessibilitySettings() { -} - -void DefaultSystemTrayDelegate::ShowPublicAccountInfo() { -} - -void DefaultSystemTrayDelegate::ShowEnterpriseInfo() { -} - -void DefaultSystemTrayDelegate::ShowLocallyManagedUserInfo() { -} - -void DefaultSystemTrayDelegate::ShowUserLogin() { -} - -void DefaultSystemTrayDelegate::ShowSpringChargerReplacementDialog() { -} - -bool DefaultSystemTrayDelegate::HasUserConfirmedSafeSpringCharger() { - return false; -} - -void DefaultSystemTrayDelegate::ShutDown() { -} - -void DefaultSystemTrayDelegate::SignOut() { -} - -void DefaultSystemTrayDelegate::RequestLockScreen() { -} - -void DefaultSystemTrayDelegate::RequestRestartForUpdate() { -} - -void DefaultSystemTrayDelegate::GetAvailableBluetoothDevices( - BluetoothDeviceList* list) { -} - -void DefaultSystemTrayDelegate::BluetoothStartDiscovering() { -} - -void DefaultSystemTrayDelegate::BluetoothStopDiscovering() { -} - -void DefaultSystemTrayDelegate::ConnectToBluetoothDevice( - const std::string& address) { -} - -void DefaultSystemTrayDelegate::GetCurrentIME(IMEInfo* info) { -} - -void DefaultSystemTrayDelegate::GetAvailableIMEList(IMEInfoList* list) { -} - -void DefaultSystemTrayDelegate::GetCurrentIMEProperties( - IMEPropertyInfoList* list) { -} - -void DefaultSystemTrayDelegate::SwitchIME(const std::string& ime_id) { -} - -void DefaultSystemTrayDelegate::ActivateIMEProperty(const std::string& key) { -} - -void DefaultSystemTrayDelegate::CancelDriveOperation(int32 operation_id) { -} - -void DefaultSystemTrayDelegate::GetDriveOperationStatusList( - ash::DriveOperationStatusList*) { -} - -void DefaultSystemTrayDelegate::ShowNetworkConfigure( - const std::string& network_id, - gfx::NativeWindow parent_window) { -} - -bool DefaultSystemTrayDelegate::EnrollNetwork(const std::string& network_id, - gfx::NativeWindow parent_window) { - return true; -} - -void DefaultSystemTrayDelegate::ManageBluetoothDevices() { -} - -void DefaultSystemTrayDelegate::ToggleBluetooth() { - bluetooth_enabled_ = !bluetooth_enabled_; -} - -bool DefaultSystemTrayDelegate::IsBluetoothDiscovering() { - return false; -} - -void DefaultSystemTrayDelegate::ShowMobileSimDialog() { -} - -void DefaultSystemTrayDelegate::ShowMobileSetupDialog( - const std::string& service_path) { -} - -void DefaultSystemTrayDelegate::ShowOtherNetworkDialog( - const std::string& type) { -} - -bool DefaultSystemTrayDelegate::GetBluetoothAvailable() { - return true; -} - -bool DefaultSystemTrayDelegate::GetBluetoothEnabled() { - return bluetooth_enabled_; -} - -void DefaultSystemTrayDelegate::ChangeProxySettings() { -} - -VolumeControlDelegate* DefaultSystemTrayDelegate::GetVolumeControlDelegate() - const { - return volume_control_delegate_.get(); -} - -void DefaultSystemTrayDelegate::SetVolumeControlDelegate( - scoped_ptr<VolumeControlDelegate> delegate) { - volume_control_delegate_ = delegate.Pass(); -} - -bool DefaultSystemTrayDelegate::GetSessionStartTime( - base::TimeTicks* session_start_time) { - return false; -} - -bool DefaultSystemTrayDelegate::GetSessionLengthLimit( - base::TimeDelta* session_length_limit) { - return false; -} - -int DefaultSystemTrayDelegate::GetSystemTrayMenuWidth() { - // This is the default width for English languages. - return 300; -} - -} // namespace ash diff --git a/chromium/ash/system/tray/default_system_tray_delegate.h b/chromium/ash/system/tray/default_system_tray_delegate.h deleted file mode 100644 index f85b6ca2cd4..00000000000 --- a/chromium/ash/system/tray/default_system_tray_delegate.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_DEFAULT_SYSTEM_TRAY_DELEGATE_H_ -#define ASH_SYSTEM_TRAY_DEFAULT_SYSTEM_TRAY_DELEGATE_H_ - -#include "ash/ash_export.h" -#include "ash/system/tray/system_tray_delegate.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" - -namespace ash { - -class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate { - public: - DefaultSystemTrayDelegate(); - virtual ~DefaultSystemTrayDelegate(); - - // Overridden from SystemTrayDelegate: - virtual void Initialize() OVERRIDE; - virtual void Shutdown() OVERRIDE; - virtual bool GetTrayVisibilityOnStartup() OVERRIDE; - virtual user::LoginStatus GetUserLoginStatus() const OVERRIDE; - virtual bool IsOobeCompleted() const OVERRIDE; - virtual void ChangeProfilePicture() OVERRIDE; - virtual const std::string GetEnterpriseDomain() const OVERRIDE; - virtual const base::string16 GetEnterpriseMessage() const OVERRIDE; - virtual const std::string GetLocallyManagedUserManager() const OVERRIDE; - virtual const base::string16 GetLocallyManagedUserManagerName() const - OVERRIDE; - virtual const base::string16 GetLocallyManagedUserMessage() const OVERRIDE; - virtual bool SystemShouldUpgrade() const OVERRIDE; - virtual base::HourClockType GetHourClockType() const OVERRIDE; - virtual void ShowSettings() OVERRIDE; - virtual bool ShouldShowSettings() OVERRIDE; - virtual void ShowDateSettings() OVERRIDE; - virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE; - virtual void ShowBluetoothSettings() OVERRIDE; - virtual void ShowDisplaySettings() OVERRIDE; - virtual void ShowChromeSlow() OVERRIDE; - virtual bool ShouldShowDisplayNotification() OVERRIDE; - virtual void ShowDriveSettings() OVERRIDE; - virtual void ShowIMESettings() OVERRIDE; - virtual void ShowHelp() OVERRIDE; - virtual void ShowAccessibilityHelp() OVERRIDE; - virtual void ShowAccessibilitySettings() OVERRIDE; - virtual void ShowPublicAccountInfo() OVERRIDE; - virtual void ShowEnterpriseInfo() OVERRIDE; - virtual void ShowLocallyManagedUserInfo() OVERRIDE; - virtual void ShowUserLogin() OVERRIDE; - virtual void ShowSpringChargerReplacementDialog() OVERRIDE; - virtual bool HasUserConfirmedSafeSpringCharger() OVERRIDE; - virtual void ShutDown() OVERRIDE; - virtual void SignOut() OVERRIDE; - virtual void RequestLockScreen() OVERRIDE; - virtual void RequestRestartForUpdate() OVERRIDE; - virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* list) OVERRIDE; - virtual void BluetoothStartDiscovering() OVERRIDE; - virtual void BluetoothStopDiscovering() OVERRIDE; - virtual void ConnectToBluetoothDevice(const std::string& address) OVERRIDE; - virtual void GetCurrentIME(IMEInfo* info) OVERRIDE; - virtual void GetAvailableIMEList(IMEInfoList* list) OVERRIDE; - virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) OVERRIDE; - virtual void SwitchIME(const std::string& ime_id) OVERRIDE; - virtual void ActivateIMEProperty(const std::string& key) OVERRIDE; - virtual void CancelDriveOperation(int32 operation_id) OVERRIDE; - virtual void GetDriveOperationStatusList( - ash::DriveOperationStatusList*) OVERRIDE; - virtual void ShowNetworkConfigure(const std::string& network_id, - gfx::NativeWindow parent_window) OVERRIDE; - virtual bool EnrollNetwork(const std::string& network_id, - gfx::NativeWindow parent_window) OVERRIDE; - virtual void ManageBluetoothDevices() OVERRIDE; - virtual void ToggleBluetooth() OVERRIDE; - virtual bool IsBluetoothDiscovering() OVERRIDE; - virtual void ShowMobileSimDialog() OVERRIDE; - virtual void ShowMobileSetupDialog(const std::string& service_path) OVERRIDE; - virtual void ShowOtherNetworkDialog(const std::string& type) OVERRIDE; - virtual bool GetBluetoothAvailable() OVERRIDE; - virtual bool GetBluetoothEnabled() OVERRIDE; - virtual void ChangeProxySettings() OVERRIDE; - virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE; - virtual void SetVolumeControlDelegate( - scoped_ptr<VolumeControlDelegate> delegate) OVERRIDE; - virtual bool GetSessionStartTime( - base::TimeTicks* session_start_time) OVERRIDE; - virtual bool GetSessionLengthLimit( - base::TimeDelta* session_length_limit) OVERRIDE; - virtual int GetSystemTrayMenuWidth() OVERRIDE; - - private: - bool bluetooth_enabled_; - scoped_ptr<VolumeControlDelegate> volume_control_delegate_; - - DISALLOW_COPY_AND_ASSIGN(DefaultSystemTrayDelegate); -}; - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_DEFAULT_SYSTEM_TRAY_DELEGATE_H_ diff --git a/chromium/ash/system/tray/fixed_sized_image_view.cc b/chromium/ash/system/tray/fixed_sized_image_view.cc deleted file mode 100644 index d0d49b92f21..00000000000 --- a/chromium/ash/system/tray/fixed_sized_image_view.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 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/tray/fixed_sized_image_view.h" - -namespace ash { -namespace internal { - -FixedSizedImageView::FixedSizedImageView(int width, int height) - : width_(width), - height_(height) { - SetHorizontalAlignment(views::ImageView::CENTER); - SetVerticalAlignment(views::ImageView::CENTER); -} - -FixedSizedImageView::~FixedSizedImageView() { -} - -gfx::Size FixedSizedImageView::GetPreferredSize() { - gfx::Size size = views::ImageView::GetPreferredSize(); - return gfx::Size(width_ ? width_ : size.width(), - height_ ? height_ : size.height()); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/fixed_sized_image_view.h b/chromium/ash/system/tray/fixed_sized_image_view.h deleted file mode 100644 index 1e5c7cda785..00000000000 --- a/chromium/ash/system/tray/fixed_sized_image_view.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_FIXED_SIZED_IMAGE_VIEW_H_ -#define ASH_SYSTEM_TRAY_FIXED_SIZED_IMAGE_VIEW_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/image_view.h" - -namespace ash { -namespace internal { - -// An image view with a specified width and height (kTrayPopupDetailsIconWidth). -// If the specified width or height is zero, then the image size is used for -// that dimension. -class FixedSizedImageView : public views::ImageView { - public: - FixedSizedImageView(int width, int height); - virtual ~FixedSizedImageView(); - - private: - virtual gfx::Size GetPreferredSize() OVERRIDE; - - int width_; - int height_; - - DISALLOW_COPY_AND_ASSIGN(FixedSizedImageView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_FIXED_SIZED_IMAGE_VIEW_H_ diff --git a/chromium/ash/system/tray/fixed_sized_scroll_view.cc b/chromium/ash/system/tray/fixed_sized_scroll_view.cc deleted file mode 100644 index d3fff9ad1ae..00000000000 --- a/chromium/ash/system/tray/fixed_sized_scroll_view.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 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/tray/fixed_sized_scroll_view.h" - -namespace ash { -namespace internal { - -FixedSizedScrollView::FixedSizedScrollView() { - set_notify_enter_exit_on_child(true); -} - -FixedSizedScrollView::~FixedSizedScrollView() { -} - -void FixedSizedScrollView::SetContentsView(views::View* view) { - SetContents(view); - view->SetBoundsRect(gfx::Rect(view->GetPreferredSize())); -} - -void FixedSizedScrollView::SetFixedSize(const gfx::Size& size) { - if (fixed_size_ == size) - return; - fixed_size_ = size; - PreferredSizeChanged(); -} - -gfx::Size FixedSizedScrollView::GetPreferredSize() { - gfx::Size size = fixed_size_.IsEmpty() ? - contents()->GetPreferredSize() : fixed_size_; - gfx::Insets insets = GetInsets(); - size.Enlarge(insets.width(), insets.height()); - return size; -} - -void FixedSizedScrollView::Layout() { - gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); - bounds.set_width(std::max(0, width() - GetScrollBarWidth())); - contents()->SetBoundsRect(bounds); - - views::ScrollView::Layout(); - if (!vertical_scroll_bar()->visible()) { - gfx::Rect bounds = contents()->bounds(); - bounds.set_width(bounds.width() + GetScrollBarWidth()); - contents()->SetBoundsRect(bounds); - } -} - -void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - gfx::Rect bounds = gfx::Rect(contents()->GetPreferredSize()); - bounds.set_width(std::max(0, width() - GetScrollBarWidth())); - contents()->SetBoundsRect(bounds); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/fixed_sized_scroll_view.h b/chromium/ash/system/tray/fixed_sized_scroll_view.h deleted file mode 100644 index aff53c217a6..00000000000 --- a/chromium/ash/system/tray/fixed_sized_scroll_view.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_ -#define ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/scroll_view.h" - -namespace ash { -namespace internal { - -// A custom scroll-view that has a specified dimension. -class FixedSizedScrollView : public views::ScrollView { - public: - FixedSizedScrollView(); - virtual ~FixedSizedScrollView(); - - void SetContentsView(views::View* view); - - // Change the fixed size of the view. Invalidates the layout (by calling - // PreferredSizeChanged()). - void SetFixedSize(const gfx::Size& size); - - void set_fixed_size(const gfx::Size& size) { fixed_size_ = size; } - - // Overridden from views::View: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - - protected: - // Overridden from views::View: - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; - - private: - gfx::Size fixed_size_; - - DISALLOW_COPY_AND_ASSIGN(FixedSizedScrollView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_ diff --git a/chromium/ash/system/tray/hover_highlight_view.cc b/chromium/ash/system/tray/hover_highlight_view.cc deleted file mode 100644 index 8afa2de4003..00000000000 --- a/chromium/ash/system/tray/hover_highlight_view.cc +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2012 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/tray/hover_highlight_view.h" - -#include "ash/system/tray/fixed_sized_image_view.h" -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray/view_click_listener.h" -#include "grit/ui_resources.h" -#include "ui/base/accessibility/accessible_view_state.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/views/border.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/layout/fill_layout.h" - -namespace { - -const int kCheckLabelPadding = 4; - -} // namespace - -namespace ash { -namespace internal { - -HoverHighlightView::HoverHighlightView(ViewClickListener* listener) - : listener_(listener), - text_label_(NULL), - highlight_color_(kHoverBackgroundColor), - default_color_(0), - text_highlight_color_(0), - text_default_color_(0), - hover_(false), - expandable_(false), - checkable_(false), - checked_(false) { - set_notify_enter_exit_on_child(true); -} - -HoverHighlightView::~HoverHighlightView() { -} - -void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, - const base::string16& text, - gfx::Font::FontStyle style) { - SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kHorizontal, 0, 3, kTrayPopupPaddingBetweenItems)); - views::ImageView* image_view = - new FixedSizedImageView(kTrayPopupDetailsIconWidth, 0); - image_view->SetImage(image); - AddChildView(image_view); - - text_label_ = new views::Label(text); - text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - text_label_->SetFont(text_label_->font().DeriveFont(0, style)); - if (text_default_color_) - text_label_->SetEnabledColor(text_default_color_); - AddChildView(text_label_); - - SetAccessibleName(text); -} - -views::Label* HoverHighlightView::AddLabel(const base::string16& text, - gfx::Font::FontStyle style) { - SetLayoutManager(new views::FillLayout()); - text_label_ = new views::Label(text); - int margin = kTrayPopupPaddingHorizontal + - kTrayPopupDetailsLabelExtraLeftMargin; - int left_margin = 0; - int right_margin = 0; - if (base::i18n::IsRTL()) - right_margin = margin; - else - left_margin = margin; - text_label_->set_border( - views::Border::CreateEmptyBorder(5, left_margin, 5, right_margin)); - text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - text_label_->SetFont(text_label_->font().DeriveFont(0, style)); - // Do not set alpha value in disable color. It will have issue with elide - // blending filter in disabled state for rendering label text color. - text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127)); - if (text_default_color_) - text_label_->SetEnabledColor(text_default_color_); - AddChildView(text_label_); - - SetAccessibleName(text); - return text_label_; -} - -views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text, - gfx::Font::FontStyle style, - bool checked) { - checkable_ = true; - checked_ = checked; - if (checked) { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const gfx::ImageSkia* check = - rb.GetImageNamed(IDR_MENU_CHECK).ToImageSkia(); - int margin = kTrayPopupPaddingHorizontal + - kTrayPopupDetailsLabelExtraLeftMargin - kCheckLabelPadding; - SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kHorizontal, 0, 3, kCheckLabelPadding)); - views::ImageView* image_view = new FixedSizedImageView(margin, 0); - image_view->SetImage(check); - image_view->SetHorizontalAlignment(views::ImageView::TRAILING); - AddChildView(image_view); - - text_label_ = new views::Label(text); - text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - text_label_->SetFont(text_label_->font().DeriveFont(0, style)); - text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); - if (text_default_color_) - text_label_->SetEnabledColor(text_default_color_); - AddChildView(text_label_); - - SetAccessibleName(text); - return text_label_; - } - return AddLabel(text, style); -} - -void HoverHighlightView::SetExpandable(bool expandable) { - if (expandable != expandable_) { - expandable_ = expandable; - InvalidateLayout(); - } -} - -bool HoverHighlightView::PerformAction(const ui::Event& event) { - if (!listener_) - return false; - listener_->OnViewClicked(this); - return true; -} - -void HoverHighlightView::GetAccessibleState(ui::AccessibleViewState* state) { - ActionableView::GetAccessibleState(state); - - if (checkable_) { - state->role = ui::AccessibilityTypes::ROLE_CHECKBUTTON; - state->state = checked_ ? ui::AccessibilityTypes::STATE_CHECKED : 0; - } -} - -gfx::Size HoverHighlightView::GetPreferredSize() { - gfx::Size size = ActionableView::GetPreferredSize(); - if (!expandable_ || size.height() < kTrayPopupItemHeight) - size.set_height(kTrayPopupItemHeight); - return size; -} - -int HoverHighlightView::GetHeightForWidth(int width) { - return GetPreferredSize().height(); -} - -void HoverHighlightView::OnMouseEntered(const ui::MouseEvent& event) { - hover_ = true; - if (text_highlight_color_ && text_label_) - text_label_->SetEnabledColor(text_highlight_color_); - SchedulePaint(); -} - -void HoverHighlightView::OnMouseExited(const ui::MouseEvent& event) { - hover_ = false; - if (text_default_color_ && text_label_) - text_label_->SetEnabledColor(text_default_color_); - SchedulePaint(); -} - -void HoverHighlightView::OnEnabledChanged() { - for (int i = 0; i < child_count(); ++i) - child_at(i)->SetEnabled(enabled()); -} - -void HoverHighlightView::OnPaintBackground(gfx::Canvas* canvas) { - canvas->DrawColor(hover_ ? highlight_color_ : default_color_); -} - -void HoverHighlightView::OnFocus() { - ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); - ActionableView::OnFocus(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/hover_highlight_view.h b/chromium/ash/system/tray/hover_highlight_view.h deleted file mode 100644 index e19c3ef77f1..00000000000 --- a/chromium/ash/system/tray/hover_highlight_view.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ -#define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ - -#include "ash/system/tray/actionable_view.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/gfx/font.h" - -namespace views { -class Label; -} - -namespace ash { -namespace internal { - -class ViewClickListener; - -// A view that changes background color on hover, and triggers a callback in the -// associated ViewClickListener on click. The view can also be forced to -// maintain a fixed height. -class HoverHighlightView : public ActionableView { - public: - explicit HoverHighlightView(ViewClickListener* listener); - virtual ~HoverHighlightView(); - - // Convenience function for adding an icon and a label. This also sets the - // accessible name. - void AddIconAndLabel(const gfx::ImageSkia& image, - const base::string16& text, - gfx::Font::FontStyle style); - - // Convenience function for adding a label with padding on the left for a - // blank icon. This also sets the accessible name. - // Returns label after parenting it. - views::Label* AddLabel(const base::string16& text, - gfx::Font::FontStyle style); - - // Convenience function for adding an optional check and a label. In the - // absence of a check, padding is added to align with checked items. - // Returns label after parenting it. - views::Label* AddCheckableLabel(const base::string16& text, - gfx::Font::FontStyle style, - bool checked); - - // Allows view to expand its height. - // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. - void SetExpandable(bool expandable); - - void set_highlight_color(SkColor color) { highlight_color_ = color; } - void set_default_color(SkColor color) { default_color_ = color; } - void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } - void set_text_default_color(SkColor color) { text_default_color_ = color; } - - views::Label* text_label() { return text_label_; } - - bool hover() const { return hover_; } - - private: - // Overridden from ActionableView: - virtual bool PerformAction(const ui::Event& event) OVERRIDE; - - // Overridden from views::View. - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual int GetHeightForWidth(int width) OVERRIDE; - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; - virtual void OnEnabledChanged() OVERRIDE; - virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; - virtual void OnFocus() OVERRIDE; - - ViewClickListener* listener_; - views::Label* text_label_; - SkColor highlight_color_; - SkColor default_color_; - SkColor text_highlight_color_; - SkColor text_default_color_; - bool hover_; - bool expandable_; - bool checkable_; - bool checked_; - - DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ diff --git a/chromium/ash/system/tray/special_popup_row.cc b/chromium/ash/system/tray/special_popup_row.cc deleted file mode 100644 index fd10f4721bd..00000000000 --- a/chromium/ash/system/tray/special_popup_row.cc +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2013 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/tray/special_popup_row.h" - -#include "ash/system/tray/hover_highlight_view.h" -#include "ash/system/tray/throbber_view.h" -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray/tray_popup_header_button.h" -#include "grit/ash_resources.h" -#include "grit/ash_strings.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/rect.h" -#include "ui/views/background.h" -#include "ui/views/border.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/painter.h" - -namespace ash { -namespace internal { - -namespace { - -const int kIconPaddingLeft = 5; -const int kSpecialPopupRowHeight = 55; -const int kBorderHeight = 1; -const SkColor kBorderColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); - -views::View* CreatePopupHeaderButtonsContainer() { - views::View* view = new views::View; - view->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, -1)); - view->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 5)); - return view; -} - -} // namespace - -SpecialPopupRow::SpecialPopupRow() - : content_(NULL), - button_container_(NULL) { - set_background(views::Background::CreateSolidBackground( - kHeaderBackgroundColor)); - set_border(views::Border::CreateSolidSidedBorder( - kBorderHeight, 0, 0, 0, kBorderColor)); - SetLayoutManager( - new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); -} - -SpecialPopupRow::~SpecialPopupRow() { -} - -void SpecialPopupRow::SetTextLabel(int string_id, ViewClickListener* listener) { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - HoverHighlightView* container = new HoverHighlightView(listener); - container->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 3, kIconPaddingLeft)); - - container->set_highlight_color(SkColorSetARGB(0, 0, 0, 0)); - container->set_default_color(SkColorSetARGB(0, 0, 0, 0)); - container->set_text_highlight_color(kHeaderTextColorHover); - container->set_text_default_color(kHeaderTextColorNormal); - - container->AddIconAndLabel( - *rb.GetImageNamed(IDR_AURA_UBER_TRAY_LESS).ToImageSkia(), - rb.GetLocalizedString(string_id), - gfx::Font::BOLD); - - container->set_border(views::Border::CreateEmptyBorder(0, - kTrayPopupPaddingHorizontal, 0, 0)); - - container->SetAccessibleName( - rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); - SetContent(container); -} - -void SpecialPopupRow::SetContent(views::View* view) { - CHECK(!content_); - content_ = view; - AddChildViewAt(content_, 0); -} - -void SpecialPopupRow::AddButton(TrayPopupHeaderButton* button) { - if (!button_container_) { - button_container_ = CreatePopupHeaderButtonsContainer(); - AddChildView(button_container_); - } - button_container_->AddChildView(button); -} - -void SpecialPopupRow::AddThrobber(ThrobberView* throbber) { - if (!button_container_) { - button_container_ = CreatePopupHeaderButtonsContainer(); - AddChildView(button_container_); - } - button_container_->AddChildView(throbber); -} - -gfx::Size SpecialPopupRow::GetPreferredSize() { - gfx::Size size = views::View::GetPreferredSize(); - size.set_height(kSpecialPopupRowHeight); - return size; -} - -int SpecialPopupRow::GetHeightForWidth(int width) { - return kSpecialPopupRowHeight; -} - -void SpecialPopupRow::Layout() { - views::View::Layout(); - gfx::Rect content_bounds = GetContentsBounds(); - if (content_bounds.IsEmpty()) - return; - if (!button_container_) { - content_->SetBoundsRect(GetContentsBounds()); - return; - } - - gfx::Rect bounds(button_container_->GetPreferredSize()); - bounds.set_height(content_bounds.height()); - gfx::Rect container_bounds = content_bounds; - container_bounds.ClampToCenteredSize(bounds.size()); - container_bounds.set_x(content_bounds.width() - container_bounds.width()); - button_container_->SetBoundsRect(container_bounds); - - bounds = content_->bounds(); - bounds.set_width(button_container_->x()); - content_->SetBoundsRect(bounds); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/special_popup_row.h b/chromium/ash/system/tray/special_popup_row.h deleted file mode 100644 index ee068e4eb8a..00000000000 --- a/chromium/ash/system/tray/special_popup_row.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2013 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. - -#ifndef ASH_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ -#define ASH_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ - -#include "ui/gfx/size.h" -#include "ui/views/view.h" - -namespace views { -class Label; -} - -namespace ash { -namespace internal { - -class ThrobberView; -class TrayItemView; -class TrayPopupHeaderButton; -class ViewClickListener; - -// The 'special' looking row in the uber-tray popups. This is usually the bottom -// row in the popups, and has a fixed height. -class SpecialPopupRow : public views::View { - public: - SpecialPopupRow(); - virtual ~SpecialPopupRow(); - - void SetTextLabel(int string_id, ViewClickListener* listener); - void SetContent(views::View* view); - - void AddButton(TrayPopupHeaderButton* button); - void AddThrobber(ThrobberView* throbber); - - views::View* content() const { return content_; } - - private: - // Overridden from views::View. - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual int GetHeightForWidth(int width) OVERRIDE; - virtual void Layout() OVERRIDE; - - views::View* content_; - views::View* button_container_; - views::Label* text_label_; - - DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ diff --git a/chromium/ash/system/tray/system_tray.cc b/chromium/ash/system/tray/system_tray.cc deleted file mode 100644 index cee88472837..00000000000 --- a/chromium/ash/system/tray/system_tray.cc +++ /dev/null @@ -1,732 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray.h" - -#include "ash/ash_switches.h" -#include "ash/metrics/user_metrics_recorder.h" -#include "ash/shelf/shelf_layout_manager.h" -#include "ash/shell.h" -#include "ash/shell/panel_window.h" -#include "ash/shell_window_ids.h" -#include "ash/system/bluetooth/tray_bluetooth.h" -#include "ash/system/date/tray_date.h" -#include "ash/system/drive/tray_drive.h" -#include "ash/system/ime/tray_ime.h" -#include "ash/system/monitor/tray_monitor.h" -#include "ash/system/session_length_limit/tray_session_length_limit.h" -#include "ash/system/status_area_widget.h" -#include "ash/system/tray/system_tray_delegate.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_bubble_wrapper.h" -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray_accessibility.h" -#include "ash/system/tray_caps_lock.h" -#include "ash/system/tray_update.h" -#include "ash/system/user/login_status.h" -#include "ash/system/user/tray_user.h" -#include "ash/system/user/tray_user_separator.h" -#include "ash/system/web_notification/web_notification_tray.h" -#include "base/command_line.h" -#include "base/logging.h" -#include "base/strings/utf_string_conversions.h" -#include "base/timer/timer.h" -#include "grit/ash_strings.h" -#include "ui/aura/root_window.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/compositor/layer.h" -#include "ui/events/event_constants.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/screen.h" -#include "ui/gfx/skia_util.h" -#include "ui/views/border.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/layout/fill_layout.h" -#include "ui/views/view.h" - -#if defined(OS_CHROMEOS) -#include "ash/system/chromeos/audio/tray_audio.h" -#include "ash/system/chromeos/brightness/tray_brightness.h" -#include "ash/system/chromeos/enterprise/tray_enterprise.h" -#include "ash/system/chromeos/managed/tray_locally_managed_user.h" -#include "ash/system/chromeos/network/tray_network.h" -#include "ash/system/chromeos/network/tray_sms.h" -#include "ash/system/chromeos/network/tray_vpn.h" -#include "ash/system/chromeos/power/tray_power.h" -#include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" -#include "ash/system/chromeos/screen_security/screen_share_tray_item.h" -#include "ash/system/chromeos/settings/tray_settings.h" -#include "ash/system/chromeos/tray_display.h" -#include "ash/system/chromeos/tray_tracing.h" -#include "ui/message_center/message_center.h" -#endif - -using views::TrayBubbleView; - -namespace ash { - -// The minimum width of the system tray menu width. -const int kMinimumSystemTrayMenuWidth = 300; - -namespace internal { - -// Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper -// instances for a bubble. - -class SystemBubbleWrapper { - public: - // Takes ownership of |bubble|. - explicit SystemBubbleWrapper(internal::SystemTrayBubble* bubble) - : bubble_(bubble), - is_persistent_(false) { - } - - // Initializes the bubble view and creates |bubble_wrapper_|. - void InitView(TrayBackgroundView* tray, - views::View* anchor, - TrayBubbleView::InitParams* init_params, - bool is_persistent) { - DCHECK(anchor); - user::LoginStatus login_status = - Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); - bubble_->InitView(anchor, login_status, init_params); - bubble_wrapper_.reset( - new internal::TrayBubbleWrapper(tray, bubble_->bubble_view())); - if (ash::switches::UseAlternateShelfLayout()) { - // The system bubble should not have an arrow. - bubble_->bubble_view()->SetArrowPaintType( - views::BubbleBorder::PAINT_NONE); - } - is_persistent_ = is_persistent; - - // If ChromeVox is enabled, focus the default item if no item is focused. - if (Shell::GetInstance()->accessibility_delegate()-> - IsSpokenFeedbackEnabled()) { - bubble_->FocusDefaultIfNeeded(); - } - } - - // Convenience accessors: - SystemTrayBubble* bubble() const { return bubble_.get(); } - SystemTrayBubble::BubbleType bubble_type() const { - return bubble_->bubble_type(); - } - TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } - bool is_persistent() const { return is_persistent_; } - - private: - scoped_ptr<internal::SystemTrayBubble> bubble_; - scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_; - bool is_persistent_; - - DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); -}; - -} // namespace internal - -// SystemTray - -using internal::SystemTrayBubble; - -SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget) - : internal::TrayBackgroundView(status_area_widget), - items_(), - default_bubble_height_(0), - hide_notifications_(false), - full_system_tray_menu_(false), - tray_accessibility_(NULL), - tray_date_(NULL) { - SetContentsBackground(); -} - -SystemTray::~SystemTray() { - // Destroy any child views that might have back pointers before ~View(). - system_bubble_.reset(); - notification_bubble_.reset(); - for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); - it != items_.end(); - ++it) { - (*it)->DestroyTrayView(); - } -} - -void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { - internal::TrayBackgroundView::Initialize(); - CreateItems(delegate); -} - -void SystemTray::CreateItems(SystemTrayDelegate* delegate) { -#if !defined(OS_WIN) - AddTrayItem(new internal::TraySessionLengthLimit(this)); - // Create user items for each possible user. - ash::Shell* shell = ash::Shell::GetInstance(); - int maximum_user_profiles = - shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers(); - for (int i = 0; i < maximum_user_profiles; i++) { - internal::TrayUser* tray_user = new internal::TrayUser(this, i); - AddTrayItem(tray_user); - user_items_.push_back(tray_user); - } - if (maximum_user_profiles > 1) { - // Add a special double line separator between users and the rest of the - // menu if more then one user is logged in. - AddTrayItem(new internal::TrayUserSeparator(this)); - } -#endif - - tray_accessibility_ = new internal::TrayAccessibility(this); - tray_date_ = new internal::TrayDate(this); - -#if defined(OS_CHROMEOS) - AddTrayItem(new internal::TrayEnterprise(this)); - AddTrayItem(new internal::TrayLocallyManagedUser(this)); - AddTrayItem(new internal::TrayIME(this)); - AddTrayItem(tray_accessibility_); - AddTrayItem(new internal::TrayTracing(this)); - AddTrayItem( - new internal::TrayPower(this, message_center::MessageCenter::Get())); - AddTrayItem(new internal::TrayNetwork(this)); - AddTrayItem(new internal::TrayVPN(this)); - AddTrayItem(new internal::TraySms(this)); - AddTrayItem(new internal::TrayBluetooth(this)); - AddTrayItem(new internal::TrayDrive(this)); - AddTrayItem(new internal::TrayDisplay(this)); - AddTrayItem(new internal::ScreenCaptureTrayItem(this)); - AddTrayItem(new internal::ScreenShareTrayItem(this)); - AddTrayItem(new internal::TrayAudio(this)); - AddTrayItem(new internal::TrayBrightness(this)); - AddTrayItem(new internal::TrayCapsLock(this)); - AddTrayItem(new internal::TraySettings(this)); - AddTrayItem(new internal::TrayUpdate(this)); - AddTrayItem(tray_date_); -#elif defined(OS_WIN) - AddTrayItem(tray_accessibility_); - AddTrayItem(new internal::TrayUpdate(this)); - AddTrayItem(tray_date_); -#elif defined(OS_LINUX) - AddTrayItem(new internal::TrayIME(this)); - AddTrayItem(tray_accessibility_); - AddTrayItem(new internal::TrayBluetooth(this)); - AddTrayItem(new internal::TrayDrive(this)); - AddTrayItem(new internal::TrayCapsLock(this)); - AddTrayItem(new internal::TrayUpdate(this)); - AddTrayItem(tray_date_); -#endif - -#if defined(OS_LINUX) - CommandLine* cmd = CommandLine::ForCurrentProcess(); - if (cmd->HasSwitch(ash::switches::kAshEnableMemoryMonitor)) - AddTrayItem(new internal::TrayMonitor(this)); -#endif - - SetVisible(ash::Shell::GetInstance()->system_tray_delegate()-> - GetTrayVisibilityOnStartup()); -} - -void SystemTray::AddTrayItem(SystemTrayItem* item) { - items_.push_back(item); - - SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); - views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); - item->UpdateAfterShelfAlignmentChange(shelf_alignment()); - - if (tray_item) { - tray_container()->AddChildViewAt(tray_item, 0); - PreferredSizeChanged(); - tray_item_map_[item] = tray_item; - } -} - -void SystemTray::RemoveTrayItem(SystemTrayItem* item) { - NOTIMPLEMENTED(); -} - -const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { - return items_.get(); -} - -const std::vector<internal::TrayUser*>& SystemTray::GetTrayUserItems() const { - return user_items_; -} - -void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { - ShowDefaultViewWithOffset( - creation_type, - TrayBubbleView::InitParams::kArrowDefaultOffset, - false); -} - -void SystemTray::ShowPersistentDefaultView() { - ShowItems(items_.get(), - false, - false, - BUBBLE_CREATE_NEW, - TrayBubbleView::InitParams::kArrowDefaultOffset, - true); -} - -void SystemTray::ShowDetailedView(SystemTrayItem* item, - int close_delay, - bool activate, - BubbleCreationType creation_type) { - std::vector<SystemTrayItem*> items; - items.push_back(item); - ShowItems(items, true, activate, creation_type, GetTrayXOffset(item), false); - if (system_bubble_) - system_bubble_->bubble()->StartAutoCloseTimer(close_delay); -} - -void SystemTray::SetDetailedViewCloseDelay(int close_delay) { - if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) - system_bubble_->bubble()->StartAutoCloseTimer(close_delay); -} - -void SystemTray::HideDetailedView(SystemTrayItem* item) { - if (item != detailed_item_) - return; - DestroySystemBubble(); - UpdateNotificationBubble(); -} - -void SystemTray::ShowNotificationView(SystemTrayItem* item) { - if (std::find(notification_items_.begin(), notification_items_.end(), item) - != notification_items_.end()) - return; - notification_items_.push_back(item); - UpdateNotificationBubble(); -} - -void SystemTray::HideNotificationView(SystemTrayItem* item) { - std::vector<SystemTrayItem*>::iterator found_iter = - std::find(notification_items_.begin(), notification_items_.end(), item); - if (found_iter == notification_items_.end()) - return; - notification_items_.erase(found_iter); - // Only update the notification bubble if visible (i.e. don't create one). - if (notification_bubble_) - UpdateNotificationBubble(); -} - -void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { - DestroySystemBubble(); - UpdateNotificationBubble(); - - for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); - it != items_.end(); - ++it) { - (*it)->UpdateAfterLoginStatusChange(login_status); - } - - // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial - // position of the shelf differs. - if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM) - UpdateAfterShelfAlignmentChange(shelf_alignment()); - - SetVisible(true); - PreferredSizeChanged(); -} - -void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { - for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); - it != items_.end(); - ++it) { - (*it)->UpdateAfterShelfAlignmentChange(alignment); - } -} - -void SystemTray::SetHideNotifications(bool hide_notifications) { - if (notification_bubble_) - notification_bubble_->bubble()->SetVisible(!hide_notifications); - hide_notifications_ = hide_notifications; -} - -bool SystemTray::ShouldShowLauncher() const { - return system_bubble_.get() && system_bubble_->bubble()->ShouldShowLauncher(); -} - -bool SystemTray::HasSystemBubble() const { - return system_bubble_.get() != NULL; -} - -bool SystemTray::HasNotificationBubble() const { - return notification_bubble_.get() != NULL; -} - -internal::SystemTrayBubble* SystemTray::GetSystemBubble() { - if (!system_bubble_) - return NULL; - return system_bubble_->bubble(); -} - -bool SystemTray::IsAnyBubbleVisible() const { - return ((system_bubble_.get() && - system_bubble_->bubble()->IsVisible()) || - (notification_bubble_.get() && - notification_bubble_->bubble()->IsVisible())); -} - -bool SystemTray::IsMouseInNotificationBubble() const { - if (!notification_bubble_) - return false; - return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains( - Shell::GetScreen()->GetCursorScreenPoint()); -} - -bool SystemTray::CloseSystemBubble() const { - if (!system_bubble_) - return false; - system_bubble_->bubble()->Close(); - return true; -} - -views::View* SystemTray::GetHelpButtonView() const { - return tray_date_->GetHelpButtonView(); -} - -bool SystemTray::CloseNotificationBubbleForTest() const { - if (!notification_bubble_) - return false; - notification_bubble_->bubble()->Close(); - return true; -} - -// Private methods. - -bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) { - DCHECK(type != SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); - return system_bubble_.get() && system_bubble_->bubble_type() == type; -} - -void SystemTray::DestroySystemBubble() { - CloseSystemBubbleAndDeactivateSystemTray(); - detailed_item_ = NULL; - UpdateWebNotifications(); -} - -void SystemTray::DestroyNotificationBubble() { - if (notification_bubble_) { - notification_bubble_.reset(); - UpdateWebNotifications(); - } -} - -int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { - // Don't attempt to align the arrow if the shelf is on the left or right. - if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && - shelf_alignment() != SHELF_ALIGNMENT_TOP) - return TrayBubbleView::InitParams::kArrowDefaultOffset; - - std::map<SystemTrayItem*, views::View*>::const_iterator it = - tray_item_map_.find(item); - if (it == tray_item_map_.end()) - return TrayBubbleView::InitParams::kArrowDefaultOffset; - - const views::View* item_view = it->second; - if (item_view->bounds().IsEmpty()) { - // The bounds of item could be still empty if it does not have a visible - // tray view. In that case, use the default (minimum) offset. - return TrayBubbleView::InitParams::kArrowDefaultOffset; - } - - gfx::Point point(item_view->width() / 2, 0); - ConvertPointToWidget(item_view, &point); - return point.x(); -} - -void SystemTray::ShowDefaultViewWithOffset(BubbleCreationType creation_type, - int arrow_offset, - bool persistent) { - if (creation_type != BUBBLE_USE_EXISTING) { - Shell::GetInstance()->metrics()->RecordUserMetricsAction( - ash::UMA_STATUS_AREA_MENU_OPENED); - } - ShowItems(items_.get(), false, true, creation_type, arrow_offset, persistent); -} - -void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, - bool detailed, - bool can_activate, - BubbleCreationType creation_type, - int arrow_offset, - bool persistent) { - // No system tray bubbles in kiosk mode. - if (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() == - ash::user::LOGGED_IN_KIOSK_APP) { - return; - } - - // Destroy any existing bubble and create a new one. - SystemTrayBubble::BubbleType bubble_type = detailed ? - SystemTrayBubble::BUBBLE_TYPE_DETAILED : - SystemTrayBubble::BUBBLE_TYPE_DEFAULT; - - // Destroy the notification bubble here so that it doesn't get rebuilt - // while we add items to the main bubble_ (e.g. in HideNotificationView). - notification_bubble_.reset(); - if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { - system_bubble_->bubble()->UpdateView(items, bubble_type); - // If ChromeVox is enabled, focus the default item if no item is focused. - if (Shell::GetInstance()->accessibility_delegate()-> - IsSpokenFeedbackEnabled()) { - system_bubble_->bubble()->FocusDefaultIfNeeded(); - } - } else { - // Remember if the menu is a single property (like e.g. volume) or the - // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case - // above, |full_system_tray_menu_| does not get changed since the fact that - // the menu is full (or not) doesn't change even if a "single property" - // (like network) replaces most of the menu. - full_system_tray_menu_ = items.size() > 1; - // The menu width is fixed, and it is a per language setting. - int menu_width = std::max(kMinimumSystemTrayMenuWidth, - Shell::GetInstance()->system_tray_delegate()->GetSystemTrayMenuWidth()); - - TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, - GetAnchorAlignment(), - menu_width, - kTrayPopupMaxWidth); - init_params.can_activate = can_activate; - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); - if (detailed) { - // This is the case where a volume control or brightness control bubble - // is created. - init_params.max_height = default_bubble_height_; - init_params.arrow_color = kBackgroundColor; - } else { - init_params.arrow_color = kHeaderBackgroundColor; - } - init_params.arrow_offset = arrow_offset; - if (bubble_type == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) - init_params.close_on_deactivate = !persistent; - // For Volume and Brightness we don't want to show an arrow when - // they are shown in a bubble by themselves. - init_params.arrow_paint_type = views::BubbleBorder::PAINT_NORMAL; - if (items.size() == 1 && items[0]->ShouldHideArrow()) - init_params.arrow_paint_type = views::BubbleBorder::PAINT_TRANSPARENT; - SystemTrayBubble* bubble = new SystemTrayBubble(this, items, bubble_type); - system_bubble_.reset(new internal::SystemBubbleWrapper(bubble)); - system_bubble_->InitView(this, tray_container(), &init_params, persistent); - } - // Save height of default view for creating detailed views directly. - if (!detailed) - default_bubble_height_ = system_bubble_->bubble_view()->height(); - - if (detailed && items.size() > 0) - detailed_item_ = items[0]; - else - detailed_item_ = NULL; - - UpdateNotificationBubble(); // State changed, re-create notifications. - if (!notification_bubble_) - UpdateWebNotifications(); - GetShelfLayoutManager()->UpdateAutoHideState(); - - // When we show the system menu in our alternate shelf layout, we need to - // tint the background. - if (full_system_tray_menu_) - SetDrawBackgroundAsActive(true); -} - -void SystemTray::UpdateNotificationBubble() { - // Only show the notification bubble if we have notifications. - if (notification_items_.empty()) { - DestroyNotificationBubble(); - return; - } - // Destroy the existing bubble before constructing a new one. - notification_bubble_.reset(); - SystemTrayBubble* notification_bubble; - notification_bubble = new SystemTrayBubble( - this, notification_items_, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); - views::View* anchor; - TrayBubbleView::AnchorType anchor_type; - // Tray items might want to show notifications while we are creating and - // initializing the |system_bubble_| - but it might not be fully initialized - // when coming here - this would produce a crashed like crbug.com/247416. - // As such we check the existence of the widget here. - if (system_bubble_.get() && - system_bubble_->bubble_view() && - system_bubble_->bubble_view()->GetWidget()) { - anchor = system_bubble_->bubble_view(); - anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE; - } else { - anchor = tray_container(); - anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY; - } - TrayBubbleView::InitParams init_params(anchor_type, - GetAnchorAlignment(), - kTrayPopupMinWidth, - kTrayPopupMaxWidth); - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); - init_params.arrow_color = kBackgroundColor; - init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); - notification_bubble_.reset( - new internal::SystemBubbleWrapper(notification_bubble)); - notification_bubble_->InitView(this, anchor, &init_params, false); - - if (notification_bubble->bubble_view()->child_count() == 0) { - // It is possible that none of the items generated actual notifications. - DestroyNotificationBubble(); - return; - } - if (hide_notifications_) - notification_bubble->SetVisible(false); - else - UpdateWebNotifications(); -} - -void SystemTray::UpdateWebNotifications() { - TrayBubbleView* bubble_view = NULL; - if (notification_bubble_) - bubble_view = notification_bubble_->bubble_view(); - else if (system_bubble_) - bubble_view = system_bubble_->bubble_view(); - - int height = 0; - if (bubble_view) { - gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( - bubble_view->GetWidget()->GetNativeView()).work_area(); - if (GetShelfLayoutManager()->GetAlignment() != SHELF_ALIGNMENT_TOP) { - height = std::max( - 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); - } else { - height = std::max( - 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); - } - } - status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); -} - -void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { - if (alignment == shelf_alignment()) - return; - internal::TrayBackgroundView::SetShelfAlignment(alignment); - UpdateAfterShelfAlignmentChange(alignment); - // Destroy any existing bubble so that it is rebuilt correctly. - CloseSystemBubbleAndDeactivateSystemTray(); - // Rebuild any notification bubble. - if (notification_bubble_) { - notification_bubble_.reset(); - UpdateNotificationBubble(); - } -} - -void SystemTray::AnchorUpdated() { - if (notification_bubble_) { - notification_bubble_->bubble_view()->UpdateBubble(); - // Ensure that the notification buble is above the launcher/status area. - notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); - UpdateBubbleViewArrow(notification_bubble_->bubble_view()); - } - if (system_bubble_) { - system_bubble_->bubble_view()->UpdateBubble(); - UpdateBubbleViewArrow(system_bubble_->bubble_view()); - } -} - -base::string16 SystemTray::GetAccessibleNameForTray() { - return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME); -} - -void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { - UpdateWebNotifications(); -} - -void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { - if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { - DestroySystemBubble(); - UpdateNotificationBubble(); // State changed, re-create notifications. - GetShelfLayoutManager()->UpdateAutoHideState(); - } else if (notification_bubble_.get() && - bubble_view == notification_bubble_->bubble_view()) { - DestroyNotificationBubble(); - } -} - -bool SystemTray::ClickedOutsideBubble() { - if (!system_bubble_ || system_bubble_->is_persistent()) - return false; - HideBubbleWithView(system_bubble_->bubble_view()); - return true; -} - -void SystemTray::BubbleViewDestroyed() { - if (system_bubble_) { - system_bubble_->bubble()->DestroyItemViews(); - system_bubble_->bubble()->BubbleViewDestroyed(); - } -} - -void SystemTray::OnMouseEnteredView() { - if (system_bubble_) - system_bubble_->bubble()->StopAutoCloseTimer(); -} - -void SystemTray::OnMouseExitedView() { - if (system_bubble_) - system_bubble_->bubble()->RestartAutoCloseTimer(); -} - -base::string16 SystemTray::GetAccessibleNameForBubble() { - return GetAccessibleNameForTray(); -} - -gfx::Rect SystemTray::GetAnchorRect( - views::Widget* anchor_widget, - TrayBubbleView::AnchorType anchor_type, - TrayBubbleView::AnchorAlignment anchor_alignment) { - return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); -} - -void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { - HideBubbleWithView(bubble_view); -} - -views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { - std::map<SystemTrayItem*, views::View*>::iterator it = - tray_item_map_.find(item); - return it == tray_item_map_.end() ? NULL : it->second; -} - -void SystemTray::AddTrayUserItemForTest(internal::TrayUser* tray_user) { - AddTrayItem(tray_user); - user_items_.push_back(tray_user); -} - -bool SystemTray::PerformAction(const ui::Event& event) { - // If we're already showing the default view, hide it; otherwise, show it - // (and hide any popup that's currently shown). - if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { - system_bubble_->bubble()->Close(); - } else { - int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset; - if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) { - const ui::LocatedEvent& located_event = - static_cast<const ui::LocatedEvent&>(event); - if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || - shelf_alignment() == SHELF_ALIGNMENT_TOP) { - gfx::Point point(located_event.x(), 0); - ConvertPointToWidget(this, &point); - arrow_offset = point.x(); - } - } - ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset, false); - } - return true; -} - -void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { - system_bubble_.reset(); - // When closing a system bubble with the alternate shelf layout, we need to - // turn off the active tinting of the shelf. - if (full_system_tray_menu_) { - SetDrawBackgroundAsActive(false); - full_system_tray_menu_ = false; - } -} - -} // namespace ash diff --git a/chromium/ash/system/tray/system_tray.h b/chromium/ash/system/tray/system_tray.h deleted file mode 100644 index 7b1681d1733..00000000000 --- a/chromium/ash/system/tray/system_tray.h +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ -#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ - -#include "ash/ash_export.h" -#include "ash/system/tray/system_tray_bubble.h" -#include "ash/system/tray/tray_background_view.h" -#include "ash/system/user/login_status.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" -#include "ui/views/bubble/tray_bubble_view.h" -#include "ui/views/view.h" - -#include <map> -#include <vector> - -namespace ash { - -class SystemTrayDelegate; -class SystemTrayItem; - -namespace internal { -class SystemBubbleWrapper; -class TrayAccessibility; -class TrayDate; -class TrayUser; -} - -// There are different methods for creating bubble views. -enum BubbleCreationType { - BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. - BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. -}; - -class ASH_EXPORT SystemTray : public internal::TrayBackgroundView, - public views::TrayBubbleView::Delegate { - public: - explicit SystemTray(internal::StatusAreaWidget* status_area_widget); - virtual ~SystemTray(); - - // Calls TrayBackgroundView::Initialize(), creates the tray items, and - // adds them to SystemTrayNotifier. - void InitializeTrayItems(SystemTrayDelegate* delegate); - - // Adds a new item in the tray. - void AddTrayItem(SystemTrayItem* item); - - // Removes an existing tray item. - void RemoveTrayItem(SystemTrayItem* item); - - // Returns all tray items that has been added to system tray. - const std::vector<SystemTrayItem*>& GetTrayItems() const; - - // Returns all tray user items that were added to the system tray. - const std::vector<internal::TrayUser*>& GetTrayUserItems() const; - - // Shows the default view of all items. - void ShowDefaultView(BubbleCreationType creation_type); - - // Shows default view that ingnores outside clicks and activation loss. - void ShowPersistentDefaultView(); - - // Shows details of a particular item. If |close_delay_in_seconds| is - // non-zero, then the view is automatically closed after the specified time. - void ShowDetailedView(SystemTrayItem* item, - int close_delay_in_seconds, - bool activate, - BubbleCreationType creation_type); - - // Continue showing the existing detailed view, if any, for |close_delay| - // seconds. - void SetDetailedViewCloseDelay(int close_delay); - - // Hides the detailed view for |item|. - void HideDetailedView(SystemTrayItem* item); - - // Shows the notification view for |item|. - void ShowNotificationView(SystemTrayItem* item); - - // Hides the notification view for |item|. - void HideNotificationView(SystemTrayItem* item); - - // Updates the items when the login status of the system changes. - void UpdateAfterLoginStatusChange(user::LoginStatus login_status); - - // Updates the items when the shelf alignment changes. - void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment); - - // Temporarily hides/unhides the notification bubble. - void SetHideNotifications(bool hidden); - - // Returns true if the launcher should be forced visible when auto-hidden. - bool ShouldShowLauncher() const; - - // Returns true if there is a system bubble (already visible or in the process - // of being created). - bool HasSystemBubble() const; - - // Returns true if there is a notification bubble. - bool HasNotificationBubble() const; - - // Returns true if the system_bubble_ exists and is of type |type|. - bool HasSystemBubbleType(internal::SystemTrayBubble::BubbleType type); - - // Returns a pointer to the system bubble or NULL if none. - internal::SystemTrayBubble* GetSystemBubble(); - - // Returns true if any bubble is visible. - bool IsAnyBubbleVisible() const; - - // Returns true if the mouse is inside the notification bubble. - bool IsMouseInNotificationBubble() const; - - // Closes system bubble and returns true if it did exist. - bool CloseSystemBubble() const; - - // Returns view for help button if default view is shown. Returns NULL - // otherwise. - views::View* GetHelpButtonView() const; - - // Accessors for testing. - - // Returns true if the bubble exists. - bool CloseNotificationBubbleForTest() const; - - // Overridden from TrayBackgroundView. - virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; - virtual void AnchorUpdated() OVERRIDE; - virtual base::string16 GetAccessibleNameForTray() OVERRIDE; - virtual void BubbleResized(const views::TrayBubbleView* bubble_view) OVERRIDE; - virtual void HideBubbleWithView( - const views::TrayBubbleView* bubble_view) OVERRIDE; - virtual bool ClickedOutsideBubble() OVERRIDE; - - // Overridden from message_center::TrayBubbleView::Delegate. - virtual void BubbleViewDestroyed() OVERRIDE; - virtual void OnMouseEnteredView() OVERRIDE; - virtual void OnMouseExitedView() OVERRIDE; - virtual base::string16 GetAccessibleNameForBubble() OVERRIDE; - virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, - AnchorType anchor_type, - AnchorAlignment anchor_alignment) OVERRIDE; - virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; - - internal::TrayAccessibility* GetTrayAccessibilityForTest() { - return tray_accessibility_; - } - - // Get the tray item view (or NULL) for a given |tray_item| in a unit test. - views::View* GetTrayItemViewForTest(SystemTrayItem* tray_item); - - // Add a tray user item for testing purposes. Note: The passed |tray_user| - // will be owned by the SystemTray after the call. - void AddTrayUserItemForTest(internal::TrayUser* tray_user); - - private: - // Creates the default set of items for the sytem tray. - void CreateItems(SystemTrayDelegate* delegate); - - // Resets |system_bubble_| and clears any related state. - void DestroySystemBubble(); - - // Resets |notification_bubble_| and clears any related state. - void DestroyNotificationBubble(); - - // Calculates the x-offset for the item in the tray. Returns -1 if its tray - // item view is not visible. - int GetTrayXOffset(SystemTrayItem* item) const; - - // Shows the default view and its arrow position is shifted by |x_offset|. - void ShowDefaultViewWithOffset(BubbleCreationType creation_type, - int x_offset, - bool persistent); - - // Constructs or re-constructs |system_bubble_| and populates it with |items|. - // Specify |change_tray_status| to true if want to change the tray background - // status. - void ShowItems(const std::vector<SystemTrayItem*>& items, - bool details, - bool activate, - BubbleCreationType creation_type, - int x_offset, - bool persistent); - - // Constructs or re-constructs |notification_bubble_| and populates it with - // |notification_items_|, or destroys it if there are no notification items. - void UpdateNotificationBubble(); - - // Checks the current status of the system tray and updates the web - // notification tray according to the current status. - void UpdateWebNotifications(); - - // Deactivate the system tray in the shelf if it was active before. - void CloseSystemBubbleAndDeactivateSystemTray(); - - const ScopedVector<SystemTrayItem>& items() const { return items_; } - - // Overridden from internal::ActionableView. - virtual bool PerformAction(const ui::Event& event) OVERRIDE; - - // Owned items. - ScopedVector<SystemTrayItem> items_; - - // User items - note, this is a subset of the |items_| list. Note that no - // item in this list needs to be deleted. - std::vector<internal::TrayUser*> user_items_; - - // Pointers to members of |items_|. - SystemTrayItem* detailed_item_; - std::vector<SystemTrayItem*> notification_items_; - - // Mappings of system tray item and it's view in the tray. - std::map<SystemTrayItem*, views::View*> tray_item_map_; - - // Bubble for default and detailed views. - scoped_ptr<internal::SystemBubbleWrapper> system_bubble_; - - // Bubble for notifications. - scoped_ptr<internal::SystemBubbleWrapper> notification_bubble_; - - // Keep track of the default view height so that when we create detailed - // views directly (e.g. from a notification) we know what height to use. - int default_bubble_height_; - - // Set to true when system notifications should be hidden (e.g. web - // notification bubble is visible). - bool hide_notifications_; - - // This is true when the displayed system tray menu is a full tray menu, - // otherwise a single line item menu like the volume slider is shown. - // Note that the value is only valid when |system_bubble_| is true. - bool full_system_tray_menu_; - - internal::TrayAccessibility* tray_accessibility_; // not owned - internal::TrayDate* tray_date_; - - DISALLOW_COPY_AND_ASSIGN(SystemTray); -}; - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ diff --git a/chromium/ash/system/tray/system_tray_bubble.cc b/chromium/ash/system/tray/system_tray_bubble.cc deleted file mode 100644 index 1aa60bc5541..00000000000 --- a/chromium/ash/system/tray/system_tray_bubble.cc +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray_bubble.h" - -#include "ash/shell.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/system_tray_delegate.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_bubble_wrapper.h" -#include "ash/system/tray/tray_constants.h" -#include "base/message_loop/message_loop.h" -#include "ui/aura/window.h" -#include "ui/compositor/layer.h" -#include "ui/compositor/layer_animation_observer.h" -#include "ui/compositor/scoped_layer_animation_settings.h" -#include "ui/gfx/canvas.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/view.h" -#include "ui/views/widget/widget.h" - -using views::TrayBubbleView; - -namespace ash { - -namespace { - -// Normally a detailed view is the same size as the default view. However, -// when showing a detailed view directly (e.g. clicking on a notification), -// we may not know the height of the default view, or the default view may -// be too short, so we use this as a default and minimum height for any -// detailed view. -const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5; - -// Duration of swipe animation used when transitioning from a default to -// detailed view or vice versa. -const int kSwipeDelayMS = 150; - -// A view with some special behaviour for tray items in the popup: -// - optionally changes background color on hover. -class TrayPopupItemContainer : public views::View { - public: - TrayPopupItemContainer(views::View* view, - bool change_background, - bool draw_border) - : hover_(false), - change_background_(change_background) { - set_notify_enter_exit_on_child(true); - if (draw_border) { - set_border( - views::Border::CreateSolidSidedBorder(0, 0, 1, 0, kBorderLightColor)); - } - views::BoxLayout* layout = new views::BoxLayout( - views::BoxLayout::kVertical, 0, 0, 0); - layout->set_spread_blank_space(true); - SetLayoutManager(layout); - SetPaintToLayer(view->layer() != NULL); - if (view->layer()) - SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); - AddChildView(view); - SetVisible(view->visible()); - } - - virtual ~TrayPopupItemContainer() {} - - private: - // Overridden from views::View. - virtual void ChildVisibilityChanged(View* child) OVERRIDE { - if (visible() == child->visible()) - return; - SetVisible(child->visible()); - PreferredSizeChanged(); - } - - virtual void ChildPreferredSizeChanged(View* child) OVERRIDE { - PreferredSizeChanged(); - } - - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE { - hover_ = true; - SchedulePaint(); - } - - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE { - hover_ = false; - SchedulePaint(); - } - - virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE { - if (child_count() == 0) - return; - - views::View* view = child_at(0); - if (!view->background()) { - canvas->FillRect(gfx::Rect(size()), (hover_ && change_background_) ? - kHoverBackgroundColor : kBackgroundColor); - } - } - - bool hover_; - bool change_background_; - - DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer); -}; - -// Implicit animation observer that deletes itself and the layer at the end of -// the animation. -class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver { - public: - explicit AnimationObserverDeleteLayer(ui::Layer* layer) - : layer_(layer) { - } - - virtual ~AnimationObserverDeleteLayer() { - } - - virtual void OnImplicitAnimationsCompleted() OVERRIDE { - base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, this); - } - - private: - scoped_ptr<ui::Layer> layer_; - - DISALLOW_COPY_AND_ASSIGN(AnimationObserverDeleteLayer); -}; - -} // namespace - -namespace internal { - -// SystemTrayBubble - -SystemTrayBubble::SystemTrayBubble( - ash::SystemTray* tray, - const std::vector<ash::SystemTrayItem*>& items, - BubbleType bubble_type) - : tray_(tray), - bubble_view_(NULL), - items_(items), - bubble_type_(bubble_type), - autoclose_delay_(0) { -} - -SystemTrayBubble::~SystemTrayBubble() { - DestroyItemViews(); - // Reset the host pointer in bubble_view_ in case its destruction is deferred. - if (bubble_view_) - bubble_view_->reset_delegate(); -} - -void SystemTrayBubble::UpdateView( - const std::vector<ash::SystemTrayItem*>& items, - BubbleType bubble_type) { - DCHECK(bubble_type != BUBBLE_TYPE_NOTIFICATION); - - scoped_ptr<ui::Layer> scoped_layer; - if (bubble_type != bubble_type_) { - base::TimeDelta swipe_duration = - base::TimeDelta::FromMilliseconds(kSwipeDelayMS); - scoped_layer.reset(bubble_view_->RecreateLayer()); - // Keep the reference to layer as we need it after releasing it. - ui::Layer* layer = scoped_layer.get(); - DCHECK(layer); - layer->SuppressPaint(); - - // When transitioning from detailed view to default view, animate the - // existing view (slide out towards the right). - if (bubble_type == BUBBLE_TYPE_DEFAULT) { - ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); - settings.AddObserver( - new AnimationObserverDeleteLayer(scoped_layer.release())); - settings.SetTransitionDuration(swipe_duration); - settings.SetTweenType(gfx::Tween::EASE_OUT); - gfx::Transform transform; - transform.Translate(layer->bounds().width(), 0.0); - layer->SetTransform(transform); - } - - { - // Add a shadow layer to make the old layer darker as the animation - // progresses. - ui::Layer* shadow = new ui::Layer(ui::LAYER_SOLID_COLOR); - shadow->SetColor(SK_ColorBLACK); - shadow->SetOpacity(0.01f); - shadow->SetBounds(layer->bounds()); - layer->Add(shadow); - layer->StackAtTop(shadow); - { - // Animate the darkening effect a little longer than the swipe-in. This - // is to make sure the darkening animation does not end up finishing - // early, because the dark layer goes away at the end of the animation, - // and there is a brief moment when the old view is still visible, but - // it does not have the shadow layer on top. - ui::ScopedLayerAnimationSettings settings(shadow->GetAnimator()); - settings.AddObserver(new AnimationObserverDeleteLayer(shadow)); - settings.SetTransitionDuration(swipe_duration + - base::TimeDelta::FromMilliseconds(150)); - settings.SetTweenType(gfx::Tween::LINEAR); - shadow->SetOpacity(0.15f); - } - } - } - - DestroyItemViews(); - bubble_view_->RemoveAllChildViews(true); - - items_ = items; - bubble_type_ = bubble_type; - CreateItemViews( - Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); - - // Close bubble view if we failed to create the item view. - if (!bubble_view_->has_children()) { - Close(); - return; - } - - bubble_view_->GetWidget()->GetContentsView()->Layout(); - // Make sure that the bubble is large enough for the default view. - if (bubble_type_ == BUBBLE_TYPE_DEFAULT) { - bubble_view_->SetMaxHeight(0); // Clear max height limit. - } - - if (scoped_layer) { - // When transitioning from default view to detailed view, animate the new - // view (slide in from the right). - if (bubble_type == BUBBLE_TYPE_DETAILED) { - ui::Layer* new_layer = bubble_view_->layer(); - - // Make sure the new layer is stacked above the old layer during the - // animation. - new_layer->parent()->StackAbove(new_layer, scoped_layer.get()); - - gfx::Rect bounds = new_layer->bounds(); - gfx::Transform transform; - transform.Translate(bounds.width(), 0.0); - new_layer->SetTransform(transform); - { - ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); - settings.AddObserver( - new AnimationObserverDeleteLayer(scoped_layer.release())); - settings.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kSwipeDelayMS)); - settings.SetTweenType(gfx::Tween::EASE_OUT); - new_layer->SetTransform(gfx::Transform()); - } - } - } -} - -void SystemTrayBubble::InitView(views::View* anchor, - user::LoginStatus login_status, - TrayBubbleView::InitParams* init_params) { - DCHECK(bubble_view_ == NULL); - - if (bubble_type_ == BUBBLE_TYPE_DETAILED && - init_params->max_height < kDetailedBubbleMaxHeight) { - init_params->max_height = kDetailedBubbleMaxHeight; - } else if (bubble_type_ == BUBBLE_TYPE_NOTIFICATION) { - init_params->close_on_deactivate = false; - } - bubble_view_ = TrayBubbleView::Create( - tray_->GetBubbleWindowContainer(), anchor, tray_, init_params); - bubble_view_->set_adjust_if_offscreen(false); - CreateItemViews(login_status); - - if (bubble_view_->CanActivate()) { - bubble_view_->NotifyAccessibilityEvent( - ui::AccessibilityTypes::EVENT_ALERT, true); - } -} - -void SystemTrayBubble::FocusDefaultIfNeeded() { - views::FocusManager* manager = bubble_view_->GetFocusManager(); - if (!manager || manager->GetFocusedView()) - return; - - views::View* view = manager->GetNextFocusableView(NULL, NULL, false, false); - if (view) - view->RequestFocus(); -} - -void SystemTrayBubble::DestroyItemViews() { - for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); - it != items_.end(); - ++it) { - switch (bubble_type_) { - case BUBBLE_TYPE_DEFAULT: - (*it)->DestroyDefaultView(); - break; - case BUBBLE_TYPE_DETAILED: - (*it)->DestroyDetailedView(); - break; - case BUBBLE_TYPE_NOTIFICATION: - (*it)->DestroyNotificationView(); - break; - } - } -} - -void SystemTrayBubble::BubbleViewDestroyed() { - bubble_view_ = NULL; -} - -void SystemTrayBubble::StartAutoCloseTimer(int seconds) { - autoclose_.Stop(); - autoclose_delay_ = seconds; - if (autoclose_delay_) { - autoclose_.Start(FROM_HERE, - base::TimeDelta::FromSeconds(autoclose_delay_), - this, &SystemTrayBubble::Close); - } -} - -void SystemTrayBubble::StopAutoCloseTimer() { - autoclose_.Stop(); -} - -void SystemTrayBubble::RestartAutoCloseTimer() { - if (autoclose_delay_) - StartAutoCloseTimer(autoclose_delay_); -} - -void SystemTrayBubble::Close() { - tray_->HideBubbleWithView(bubble_view()); -} - -void SystemTrayBubble::SetVisible(bool is_visible) { - if (!bubble_view_) - return; - views::Widget* bubble_widget = bubble_view_->GetWidget(); - if (is_visible) - bubble_widget->Show(); - else - bubble_widget->Hide(); -} - -bool SystemTrayBubble::IsVisible() { - return bubble_view() && bubble_view()->GetWidget()->IsVisible(); -} - -bool SystemTrayBubble::ShouldShowLauncher() const { - for (std::vector<ash::SystemTrayItem*>::const_iterator it = items_.begin(); - it != items_.end(); - ++it) { - if ((*it)->ShouldShowLauncher()) - return true; - } - return false; -} - -void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) { - std::vector<views::View*> item_views; - views::View* focus_view = NULL; - for (size_t i = 0; i < items_.size(); ++i) { - views::View* view = NULL; - switch (bubble_type_) { - case BUBBLE_TYPE_DEFAULT: - view = items_[i]->CreateDefaultView(login_status); - if (items_[i]->restore_focus()) - focus_view = view; - break; - case BUBBLE_TYPE_DETAILED: - view = items_[i]->CreateDetailedView(login_status); - break; - case BUBBLE_TYPE_NOTIFICATION: - view = items_[i]->CreateNotificationView(login_status); - break; - } - if (view) - item_views.push_back(view); - } - - bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT; - for (size_t i = 0; i < item_views.size(); ++i) { - // For default view, draw bottom border for each item, except the last - // 2 items, which are the bottom header row and the one just above it. - bubble_view_->AddChildView(new TrayPopupItemContainer( - item_views[i], is_default_bubble, - is_default_bubble && (i < item_views.size() - 2))); - } - if (focus_view) - focus_view->RequestFocus(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/system_tray_bubble.h b/chromium/ash/system/tray/system_tray_bubble.h deleted file mode 100644 index b84c3ea022e..00000000000 --- a/chromium/ash/system/tray/system_tray_bubble.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ -#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ - -#include "ash/system/user/login_status.h" -#include "base/base_export.h" -#include "base/memory/scoped_ptr.h" -#include "base/timer/timer.h" -#include "ui/views/bubble/tray_bubble_view.h" - -#include <vector> - -namespace ash { - -class SystemTray; -class SystemTrayItem; - -namespace internal { - -class SystemTrayBubble { - public: - enum BubbleType { - BUBBLE_TYPE_DEFAULT, - BUBBLE_TYPE_DETAILED, - BUBBLE_TYPE_NOTIFICATION - }; - - SystemTrayBubble(ash::SystemTray* tray, - const std::vector<ash::SystemTrayItem*>& items, - BubbleType bubble_type); - virtual ~SystemTrayBubble(); - - // Change the items displayed in the bubble. - void UpdateView(const std::vector<ash::SystemTrayItem*>& items, - BubbleType bubble_type); - - // Creates |bubble_view_| and a child views for each member of |items_|. - // Also creates |bubble_wrapper_|. |init_params| may be modified. - void InitView(views::View* anchor, - user::LoginStatus login_status, - views::TrayBubbleView::InitParams* init_params); - - // Focus the default item if no item is focused. Othewise, do nothing. - void FocusDefaultIfNeeded(); - - BubbleType bubble_type() const { return bubble_type_; } - views::TrayBubbleView* bubble_view() const { return bubble_view_; } - - void DestroyItemViews(); - void BubbleViewDestroyed(); - void StartAutoCloseTimer(int seconds); - void StopAutoCloseTimer(); - void RestartAutoCloseTimer(); - void Close(); - void SetVisible(bool is_visible); - bool IsVisible(); - - // Returns true if any of the SystemTrayItems return true from - // ShouldShowLauncher(). - bool ShouldShowLauncher() const; - - private: - void CreateItemViews(user::LoginStatus login_status); - - ash::SystemTray* tray_; - views::TrayBubbleView* bubble_view_; - std::vector<ash::SystemTrayItem*> items_; - BubbleType bubble_type_; - - int autoclose_delay_; - base::OneShotTimer<SystemTrayBubble> autoclose_; - - DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ diff --git a/chromium/ash/system/tray/system_tray_delegate.cc b/chromium/ash/system/tray/system_tray_delegate.cc deleted file mode 100644 index 084e1587661..00000000000 --- a/chromium/ash/system/tray/system_tray_delegate.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray_delegate.h" - -namespace ash { - -NetworkIconInfo::NetworkIconInfo() - : connecting(false), - connected(false), - tray_icon_visible(true), - is_cellular(false) { -} - -NetworkIconInfo::~NetworkIconInfo() { -} - -BluetoothDeviceInfo::BluetoothDeviceInfo() - : connected(false), - connecting(false), - paired(false) { -} - -BluetoothDeviceInfo::~BluetoothDeviceInfo() { -} - -DriveOperationStatus::DriveOperationStatus() - : id(-1), - progress(0.0), - type(OPERATION_DOWNLOAD), - state(OPERATION_NOT_STARTED) { -} - -DriveOperationStatus::~DriveOperationStatus() { -} - -IMEInfo::IMEInfo() - : selected(false), - third_party(false) { -} - -IMEInfo::~IMEInfo() { -} - -IMEPropertyInfo::IMEPropertyInfo() - : selected(false) { -} - -IMEPropertyInfo::~IMEPropertyInfo() { -} - -} // namespace ash diff --git a/chromium/ash/system/tray/system_tray_delegate.h b/chromium/ash/system/tray/system_tray_delegate.h deleted file mode 100644 index ee325dd95ba..00000000000 --- a/chromium/ash/system/tray/system_tray_delegate.h +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ -#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ - -#include <string> -#include <vector> - -#include "ash/ash_export.h" -#include "ash/system/user/login_status.h" -#include "base/files/file_path.h" -#include "base/i18n/time_formatting.h" -#include "base/memory/scoped_ptr.h" -#include "base/strings/string16.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/gfx/native_widget_types.h" - -namespace base { -class TimeDelta; -class TimeTicks; -} - -namespace ash { - -struct ASH_EXPORT NetworkIconInfo { - NetworkIconInfo(); - ~NetworkIconInfo(); - - bool highlight() const { return connected || connecting; } - - bool connecting; - bool connected; - bool tray_icon_visible; - gfx::ImageSkia image; - base::string16 name; - base::string16 description; - std::string service_path; - bool is_cellular; -}; - -struct ASH_EXPORT BluetoothDeviceInfo { - BluetoothDeviceInfo(); - ~BluetoothDeviceInfo(); - - std::string address; - base::string16 display_name; - bool connected; - bool connecting; - bool paired; -}; - -typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList; - -// Structure that packs progress information of each operation. -struct ASH_EXPORT DriveOperationStatus { - enum OperationType { - OPERATION_UPLOAD, - OPERATION_DOWNLOAD - }; - - enum OperationState { - OPERATION_NOT_STARTED, - OPERATION_IN_PROGRESS, - OPERATION_COMPLETED, - OPERATION_FAILED, - }; - - DriveOperationStatus(); - ~DriveOperationStatus(); - - // Unique ID for the operation. - int32 id; - - // File path. - base::FilePath file_path; - // Current operation completion progress [0.0 - 1.0]. - double progress; - OperationType type; - OperationState state; -}; - -typedef std::vector<DriveOperationStatus> DriveOperationStatusList; - - -struct ASH_EXPORT IMEPropertyInfo { - IMEPropertyInfo(); - ~IMEPropertyInfo(); - - bool selected; - std::string key; - base::string16 name; -}; - -typedef std::vector<IMEPropertyInfo> IMEPropertyInfoList; - -struct ASH_EXPORT IMEInfo { - IMEInfo(); - ~IMEInfo(); - - bool selected; - bool third_party; - std::string id; - base::string16 name; - base::string16 medium_name; - base::string16 short_name; -}; - -typedef std::vector<IMEInfo> IMEInfoList; - -class VolumeControlDelegate; - -class ASH_EXPORT SystemTrayDelegate { - public: - virtual ~SystemTrayDelegate() {} - - // Called after SystemTray has been instantiated. - virtual void Initialize() = 0; - - // Called before SystemTray is destroyed. - virtual void Shutdown() = 0; - - // Returns true if system tray should be visible on startup. - virtual bool GetTrayVisibilityOnStartup() = 0; - - // Gets information about the active user. - virtual user::LoginStatus GetUserLoginStatus() const = 0; - virtual bool IsOobeCompleted() const = 0; - - // Shows UI for changing user's profile picture. - virtual void ChangeProfilePicture() = 0; - - // Returns the domain that manages the device, if it is enterprise-enrolled. - virtual const std::string GetEnterpriseDomain() const = 0; - - // Returns notification for enterprise enrolled devices. - virtual const base::string16 GetEnterpriseMessage() const = 0; - - // Returns the display email of user that manages current - // locally managed user. - virtual const std::string GetLocallyManagedUserManager() const = 0; - - // Returns the name of user that manages current locally managed user. - virtual const base::string16 GetLocallyManagedUserManagerName() const = 0; - - // Returns notification for locally managed users. - virtual const base::string16 GetLocallyManagedUserMessage() const = 0; - - // Returns whether a system upgrade is available. - virtual bool SystemShouldUpgrade() const = 0; - - // Returns the desired hour clock type. - virtual base::HourClockType GetHourClockType() const = 0; - - // Shows settings. - virtual void ShowSettings() = 0; - - // Returns true if settings menu item should appear. - virtual bool ShouldShowSettings() = 0; - - // Shows the settings related to date, timezone etc. - virtual void ShowDateSettings() = 0; - - // Shows the settings related to network. If |service_path| is not empty, - // show the settings for that network. - virtual void ShowNetworkSettings(const std::string& service_path) = 0; - - // Shows the settings related to bluetooth. - virtual void ShowBluetoothSettings() = 0; - - // Shows settings related to multiple displays. - virtual void ShowDisplaySettings() = 0; - - // Shows the page that lets you disable performance tracing. - virtual void ShowChromeSlow() = 0; - - // Returns true if the notification for the display configuration change - // should appear. - virtual bool ShouldShowDisplayNotification() = 0; - - // Shows settings related to Google Drive. - virtual void ShowDriveSettings() = 0; - - // Shows settings related to input methods. - virtual void ShowIMESettings() = 0; - - // Shows help. - virtual void ShowHelp() = 0; - - // Show accessilibity help. - virtual void ShowAccessibilityHelp() = 0; - - // Show the settings related to accessilibity. - virtual void ShowAccessibilitySettings() = 0; - - // Shows more information about public account mode. - virtual void ShowPublicAccountInfo() = 0; - - // Shows information about enterprise enrolled devices. - virtual void ShowEnterpriseInfo() = 0; - - // Shows information about locally managed users. - virtual void ShowLocallyManagedUserInfo() = 0; - - // Shows login UI to add other users to this session. - virtual void ShowUserLogin() = 0; - - // Shows the spring charger replacement dialog if necessary. - virtual void ShowSpringChargerReplacementDialog() = 0; - - // True if user has confirmed using safe spring charger. - virtual bool HasUserConfirmedSafeSpringCharger() = 0; - - // Attempts to shut down the system. - virtual void ShutDown() = 0; - - // Attempts to sign out the user. - virtual void SignOut() = 0; - - // Attempts to lock the screen. - virtual void RequestLockScreen() = 0; - - // Attempts to restart the system for update. - virtual void RequestRestartForUpdate() = 0; - - // Returns a list of available bluetooth devices. - virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0; - - // Requests bluetooth start discovering devices. - virtual void BluetoothStartDiscovering() = 0; - - // Requests bluetooth stop discovering devices. - virtual void BluetoothStopDiscovering() = 0; - - // Connect to a specific bluetooth device. - virtual void ConnectToBluetoothDevice(const std::string& address) = 0; - - // Returns true if bluetooth adapter is discovering bluetooth devices. - virtual bool IsBluetoothDiscovering() = 0; - - // Returns the currently selected IME. - virtual void GetCurrentIME(IMEInfo* info) = 0; - - // Returns a list of availble IMEs. - virtual void GetAvailableIMEList(IMEInfoList* list) = 0; - - // Returns a list of properties for the currently selected IME. - virtual void GetCurrentIMEProperties(IMEPropertyInfoList* list) = 0; - - // Switches to the selected input method. - virtual void SwitchIME(const std::string& ime_id) = 0; - - // Activates an IME property. - virtual void ActivateIMEProperty(const std::string& key) = 0; - - // Cancels ongoing drive operation. - virtual void CancelDriveOperation(int32 operation_id) = 0; - - // Returns information about the ongoing drive operations. - virtual void GetDriveOperationStatusList( - DriveOperationStatusList* list) = 0; - - // Shows UI to configure or activate the network specified by |network_id|, - // which may include showing Payment or Portal UI when appropriate. - // |parent_window| is used to parent any configuration UI. If NULL a default - // window will be used. - virtual void ShowNetworkConfigure(const std::string& network_id, - gfx::NativeWindow parent_window) = 0; - - // Shows UI to enroll the network specified by |network_id| if appropriate - // and returns true, otherwise returns false. |parent_window| is used - // to parent any configuration UI. If NULL a default window will be used. - virtual bool EnrollNetwork(const std::string& network_id, - gfx::NativeWindow parent_window) = 0; - - // Shows UI to manage bluetooth devices. - virtual void ManageBluetoothDevices() = 0; - - // Toggles bluetooth. - virtual void ToggleBluetooth() = 0; - - // Shows UI to unlock a mobile sim. - virtual void ShowMobileSimDialog() = 0; - - // Shows UI to setup a mobile network. - virtual void ShowMobileSetupDialog(const std::string& service_path) = 0; - - // Shows UI to connect to an unlisted network of type |type|. On Chrome OS - // |type| corresponds to a Shill network type. - virtual void ShowOtherNetworkDialog(const std::string& type) = 0; - - // Returns whether bluetooth capability is available. - virtual bool GetBluetoothAvailable() = 0; - - // Returns whether bluetooth is enabled. - virtual bool GetBluetoothEnabled() = 0; - - // Shows UI for changing proxy settings. - virtual void ChangeProxySettings() = 0; - - // Returns VolumeControlDelegate. - virtual VolumeControlDelegate* GetVolumeControlDelegate() const = 0; - - // Sets VolumeControlDelegate. - virtual void SetVolumeControlDelegate( - scoped_ptr<VolumeControlDelegate> delegate) = 0; - - // Retrieves the session start time. Returns |false| if the time is not set. - virtual bool GetSessionStartTime(base::TimeTicks* session_start_time) = 0; - - // Retrieves the session length limit. Returns |false| if no limit is set. - virtual bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) = 0; - - // Get the system tray menu size in pixels (dependent on the language). - virtual int GetSystemTrayMenuWidth() = 0; -}; - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_DELEGATE_H_ diff --git a/chromium/ash/system/tray/system_tray_item.cc b/chromium/ash/system/tray/system_tray_item.cc deleted file mode 100644 index f5d5b717c74..00000000000 --- a/chromium/ash/system/tray/system_tray_item.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray_item.h" - -#include "ash/shell.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/system_tray_delegate.h" -#include "ui/views/view.h" - -namespace ash { - -SystemTrayItem::SystemTrayItem(SystemTray* system_tray) - : system_tray_(system_tray), - restore_focus_(false) { -} - -SystemTrayItem::~SystemTrayItem() { -} - -views::View* SystemTrayItem::CreateTrayView(user::LoginStatus status) { - return NULL; -} - -views::View* SystemTrayItem::CreateDefaultView(user::LoginStatus status) { - return NULL; -} - -views::View* SystemTrayItem::CreateDetailedView(user::LoginStatus status) { - return NULL; -} - -views::View* SystemTrayItem::CreateNotificationView(user::LoginStatus status) { - return NULL; -} - -void SystemTrayItem::DestroyTrayView() { -} - -void SystemTrayItem::DestroyDefaultView() { -} - -void SystemTrayItem::DestroyDetailedView() { -} - -void SystemTrayItem::DestroyNotificationView() { -} - -void SystemTrayItem::TransitionDetailedView() { - system_tray()->ShowDetailedView(this, 0, true, BUBBLE_USE_EXISTING); -} - -void SystemTrayItem::UpdateAfterLoginStatusChange(user::LoginStatus status) { -} - -void SystemTrayItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { -} - -void SystemTrayItem::PopupDetailedView(int for_seconds, bool activate) { - // Never show a detailed view during OOBE, e.g. from a notification. - if (!Shell::GetInstance()->system_tray_delegate()->IsOobeCompleted()) - return; - system_tray()->ShowDetailedView( - this, for_seconds, activate, BUBBLE_CREATE_NEW); -} - -void SystemTrayItem::SetDetailedViewCloseDelay(int for_seconds) { - system_tray()->SetDetailedViewCloseDelay(for_seconds); -} - -void SystemTrayItem::HideDetailedView() { - system_tray()->HideDetailedView(this); -} - -void SystemTrayItem::ShowNotificationView() { - system_tray()->ShowNotificationView(this); -} - -void SystemTrayItem::HideNotificationView() { - system_tray()->HideNotificationView(this); -} - -bool SystemTrayItem::ShouldHideArrow() const { - return false; -} - -bool SystemTrayItem::ShouldShowLauncher() const { - return true; -} - -} // namespace ash diff --git a/chromium/ash/system/tray/system_tray_item.h b/chromium/ash/system/tray/system_tray_item.h deleted file mode 100644 index b42f3f5b35f..00000000000 --- a/chromium/ash/system/tray/system_tray_item.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ -#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ - -#include "ash/ash_export.h" -#include "ash/shelf/shelf_types.h" -#include "ash/system/user/login_status.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -namespace views { -class View; -} - -namespace ash { - -class SystemTray; - -namespace internal { -class TrayItemView; -} - -class ASH_EXPORT SystemTrayItem { - public: - explicit SystemTrayItem(SystemTray* system_tray); - virtual ~SystemTrayItem(); - - // Create* functions may return NULL if nothing should be displayed for the - // type of view. The default implementations return NULL. - - // Returns a view to be displayed in the system tray. If this returns NULL, - // then this item is not displayed in the tray. - // NOTE: The returned view should almost always be a TrayItemView, which - // automatically resizes the widget when the size of the view changes, and - // adds animation when the visibility of the view changes. If a view wants to - // avoid this behavior, then it should not be a TrayItemView. - virtual views::View* CreateTrayView(user::LoginStatus status); - - // Returns a view for the item to be displayed in the list. This view can be - // displayed with a number of other tray items, so this should not be too - // big. - virtual views::View* CreateDefaultView(user::LoginStatus status); - - // Returns a detailed view for the item. This view is displayed standalone. - virtual views::View* CreateDetailedView(user::LoginStatus status); - - // Returns a notification view for the item. This view is displayed with - // other notifications and should be the same size as default views. - virtual views::View* CreateNotificationView(user::LoginStatus status); - - // These functions are called when the corresponding view item is about to be - // removed. An item should do appropriate cleanup in these functions. - // The default implementation does nothing. - virtual void DestroyTrayView(); - virtual void DestroyDefaultView(); - virtual void DestroyDetailedView(); - virtual void DestroyNotificationView(); - - // Updates the tray view (if applicable) when the user's login status changes. - // It is not necessary the update the default or detailed view, since the - // default/detailed popup is closed when login status changes. The default - // implementation does nothing. - virtual void UpdateAfterLoginStatusChange(user::LoginStatus status); - - // Updates the tray view (if applicable) when shelf's alignment changes. - // The default implementation does nothing. - virtual void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment); - - // Shows the detailed view for this item. If the main popup for the tray is - // currently visible, then making this call would use the existing window to - // display the detailed item. The detailed item will inherit the bounds of the - // existing window. - // If there is no existing view, then this is equivalent to calling - // PopupDetailedView(0, true). - void TransitionDetailedView(); - - // Pops up the detailed view for this item. An item can request to show its - // detailed view using this function (e.g. from an observer callback when - // something, e.g. volume, network availability etc. changes). If - // |for_seconds| is non-zero, then the popup is closed after the specified - // time. - void PopupDetailedView(int for_seconds, bool activate); - - // Continue showing the currently-shown detailed view, if any, for - // |for_seconds| seconds. The caller is responsible for checking that the - // currently-shown view is for this item. - void SetDetailedViewCloseDelay(int for_seconds); - - // Hides the detailed view for this item. - void HideDetailedView(); - - // Shows a notification for this item. - void ShowNotificationView(); - - // Hides the notification for this item. - void HideNotificationView(); - - // Returns true if item should hide the arrow. - virtual bool ShouldHideArrow() const; - - // Returns true if this item needs to force the launcher to be visible when - // the launcher is in the auto-hide state. Default is true. - virtual bool ShouldShowLauncher() const; - - // Returns the system tray that this item belongs to. - SystemTray* system_tray() const { return system_tray_; } - - bool restore_focus() const { return restore_focus_; } - void set_restore_focus(bool restore_focus) { - restore_focus_ = restore_focus; - } - - private: - SystemTray* system_tray_; - bool restore_focus_; - - DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); -}; - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_ diff --git a/chromium/ash/system/tray/system_tray_notifier.cc b/chromium/ash/system/tray/system_tray_notifier.cc deleted file mode 100644 index e2035ad357f..00000000000 --- a/chromium/ash/system/tray/system_tray_notifier.cc +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray_notifier.h" - -#if defined(OS_CHROMEOS) -#include "ash/system/chromeos/network/network_state_notifier.h" -#endif - -namespace ash { - -SystemTrayNotifier::SystemTrayNotifier() { -#if defined(OS_CHROMEOS) - network_state_notifier_.reset(new NetworkStateNotifier()); -#endif -} - -SystemTrayNotifier::~SystemTrayNotifier() { -} - -void SystemTrayNotifier::AddAccessibilityObserver( - AccessibilityObserver* observer) { - accessibility_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveAccessibilityObserver( - AccessibilityObserver* observer) { - accessibility_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddBluetoothObserver(BluetoothObserver* observer) { - bluetooth_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveBluetoothObserver(BluetoothObserver* observer) { - bluetooth_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddCapsLockObserver(CapsLockObserver* observer) { - caps_lock_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveCapsLockObserver(CapsLockObserver* observer) { - caps_lock_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddClockObserver(ClockObserver* observer) { - clock_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveClockObserver(ClockObserver* observer) { - clock_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddDriveObserver(DriveObserver* observer) { - drive_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveDriveObserver(DriveObserver* observer) { - drive_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddIMEObserver(IMEObserver* observer) { - ime_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveIMEObserver(IMEObserver* observer) { - ime_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) { - locale_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) { - locale_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddLogoutButtonObserver( - LogoutButtonObserver* observer) { - logout_button_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveLogoutButtonObserver( - LogoutButtonObserver* observer) { - logout_button_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddSessionLengthLimitObserver( - SessionLengthLimitObserver* observer) { - session_length_limit_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveSessionLengthLimitObserver( - SessionLengthLimitObserver* observer) { - session_length_limit_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) { - tracing_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) { - tracing_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) { - update_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveUpdateObserver(UpdateObserver* observer) { - update_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddUserObserver(UserObserver* observer) { - user_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveUserObserver(UserObserver* observer) { - user_observers_.RemoveObserver(observer); -} - -#if defined(OS_CHROMEOS) - -void SystemTrayNotifier::AddNetworkObserver(NetworkObserver* observer) { - network_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) { - network_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddEnterpriseDomainObserver( - EnterpriseDomainObserver* observer) { - enterprise_domain_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveEnterpriseDomainObserver( - EnterpriseDomainObserver* observer) { - enterprise_domain_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddScreenCaptureObserver( - ScreenCaptureObserver* observer) { - screen_capture_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveScreenCaptureObserver( - ScreenCaptureObserver* observer) { - screen_capture_observers_.RemoveObserver(observer); -} - -void SystemTrayNotifier::AddScreenShareObserver( - ScreenShareObserver* observer) { - screen_share_observers_.AddObserver(observer); -} - -void SystemTrayNotifier::RemoveScreenShareObserver( - ScreenShareObserver* observer) { - screen_share_observers_.RemoveObserver(observer); -} -#endif - -void SystemTrayNotifier::NotifyAccessibilityModeChanged( - AccessibilityNotificationVisibility notify) { - FOR_EACH_OBSERVER( - AccessibilityObserver, - accessibility_observers_, - OnAccessibilityModeChanged(notify)); -} - -void SystemTrayNotifier::NotifyTracingModeChanged(bool value) { - FOR_EACH_OBSERVER( - TracingObserver, - tracing_observers_, - OnTracingModeChanged(value)); -} - -void SystemTrayNotifier::NotifyRefreshBluetooth() { - FOR_EACH_OBSERVER(BluetoothObserver, - bluetooth_observers_, - OnBluetoothRefresh()); -} - -void SystemTrayNotifier::NotifyBluetoothDiscoveringChanged() { - FOR_EACH_OBSERVER(BluetoothObserver, - bluetooth_observers_, - OnBluetoothDiscoveringChanged()); -} - -void SystemTrayNotifier::NotifyCapsLockChanged( - bool enabled, - bool search_mapped_to_caps_lock) { - FOR_EACH_OBSERVER(CapsLockObserver, - caps_lock_observers_, - OnCapsLockChanged(enabled, search_mapped_to_caps_lock)); -} - -void SystemTrayNotifier::NotifyRefreshClock() { - FOR_EACH_OBSERVER(ClockObserver, clock_observers_, Refresh()); -} - -void SystemTrayNotifier::NotifyDateFormatChanged() { - FOR_EACH_OBSERVER(ClockObserver, - clock_observers_, - OnDateFormatChanged()); -} - -void SystemTrayNotifier::NotifySystemClockTimeUpdated() { - FOR_EACH_OBSERVER(ClockObserver, - clock_observers_, - OnSystemClockTimeUpdated()); -} - -void SystemTrayNotifier::NotifyDriveJobUpdated( - const DriveOperationStatus& status) { - FOR_EACH_OBSERVER(DriveObserver, - drive_observers_, - OnDriveJobUpdated(status)); -} - -void SystemTrayNotifier::NotifyRefreshIME(bool show_message) { - FOR_EACH_OBSERVER(IMEObserver, - ime_observers_, - OnIMERefresh(show_message)); -} - -void SystemTrayNotifier::NotifyShowLoginButtonChanged(bool show_login_button) { - FOR_EACH_OBSERVER(LogoutButtonObserver, - logout_button_observers_, - OnShowLogoutButtonInTrayChanged(show_login_button)); -} - -void SystemTrayNotifier::NotifyLocaleChanged( - LocaleObserver::Delegate* delegate, - const std::string& cur_locale, - const std::string& from_locale, - const std::string& to_locale) { - FOR_EACH_OBSERVER( - LocaleObserver, - locale_observers_, - OnLocaleChanged(delegate, cur_locale, from_locale, to_locale)); -} - -void SystemTrayNotifier::NotifySessionStartTimeChanged() { - FOR_EACH_OBSERVER(SessionLengthLimitObserver, - session_length_limit_observers_, - OnSessionStartTimeChanged()); -} - -void SystemTrayNotifier::NotifySessionLengthLimitChanged() { - FOR_EACH_OBSERVER(SessionLengthLimitObserver, - session_length_limit_observers_, - OnSessionLengthLimitChanged()); -} - -void SystemTrayNotifier::NotifyUpdateRecommended( - UpdateObserver::UpdateSeverity severity) { - FOR_EACH_OBSERVER(UpdateObserver, - update_observers_, - OnUpdateRecommended(severity)); -} - -void SystemTrayNotifier::NotifyUserUpdate() { - FOR_EACH_OBSERVER(UserObserver, - user_observers_, - OnUserUpdate()); -} - -void SystemTrayNotifier::NotifyUserAddedToSession() { - FOR_EACH_OBSERVER(UserObserver, - user_observers_, - OnUserAddedToSession()); -} - -#if defined(OS_CHROMEOS) - -void SystemTrayNotifier::NotifyRequestToggleWifi() { - FOR_EACH_OBSERVER(NetworkObserver, - network_observers_, - RequestToggleWifi()); -} - -void SystemTrayNotifier::NotifyEnterpriseDomainChanged() { - FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_, - OnEnterpriseDomainChanged()); -} - -void SystemTrayNotifier::NotifyScreenCaptureStart( - const base::Closure& stop_callback, - const base::string16& sharing_app_name) { - FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_, - OnScreenCaptureStart(stop_callback, sharing_app_name)); -} - -void SystemTrayNotifier::NotifyScreenCaptureStop() { - FOR_EACH_OBSERVER(ScreenCaptureObserver, screen_capture_observers_, - OnScreenCaptureStop()); -} - -void SystemTrayNotifier::NotifyScreenShareStart( - const base::Closure& stop_callback, - const base::string16& helper_name) { - FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_, - OnScreenShareStart(stop_callback, helper_name)); -} - -void SystemTrayNotifier::NotifyScreenShareStop() { - FOR_EACH_OBSERVER(ScreenShareObserver, screen_share_observers_, - OnScreenShareStop()); -} - -#endif // OS_CHROMEOS - -} // namespace ash diff --git a/chromium/ash/system/tray/system_tray_notifier.h b/chromium/ash/system/tray/system_tray_notifier.h deleted file mode 100644 index 3d7fb0e63e0..00000000000 --- a/chromium/ash/system/tray/system_tray_notifier.h +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_NOTIFIER_H_ -#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_NOTIFIER_H_ - -#include <string> -#include <vector> - -#include "ash/ash_export.h" -#include "ash/system/bluetooth/bluetooth_observer.h" -#include "ash/system/chromeos/tray_tracing.h" -#include "ash/system/date/clock_observer.h" -#include "ash/system/drive/drive_observer.h" -#include "ash/system/ime/ime_observer.h" -#include "ash/system/locale/locale_observer.h" -#include "ash/system/logout_button/logout_button_observer.h" -#include "ash/system/session_length_limit/session_length_limit_observer.h" -#include "ash/system/tray_accessibility.h" -#include "ash/system/tray_caps_lock.h" -#include "ash/system/user/update_observer.h" -#include "ash/system/user/user_observer.h" -#include "base/observer_list.h" - -#if defined(OS_CHROMEOS) -#include "ash/system/chromeos/enterprise/enterprise_domain_observer.h" -#include "ash/system/chromeos/network/network_observer.h" -#include "ash/system/chromeos/screen_security/screen_capture_observer.h" -#include "ash/system/chromeos/screen_security/screen_share_observer.h" -#endif - -namespace ash { - -#if defined(OS_CHROMEOS) -class NetworkStateNotifier; -#endif - -class ASH_EXPORT SystemTrayNotifier { -public: - SystemTrayNotifier(); - ~SystemTrayNotifier(); - - void AddAccessibilityObserver(AccessibilityObserver* observer); - void RemoveAccessibilityObserver(AccessibilityObserver* observer); - - void AddBluetoothObserver(BluetoothObserver* observer); - void RemoveBluetoothObserver(BluetoothObserver* observer); - - void AddCapsLockObserver(CapsLockObserver* observer); - void RemoveCapsLockObserver(CapsLockObserver* observer); - - void AddClockObserver(ClockObserver* observer); - void RemoveClockObserver(ClockObserver* observer); - - void AddDriveObserver(DriveObserver* observer); - void RemoveDriveObserver(DriveObserver* observer); - - void AddIMEObserver(IMEObserver* observer); - void RemoveIMEObserver(IMEObserver* observer); - - void AddLocaleObserver(LocaleObserver* observer); - void RemoveLocaleObserver(LocaleObserver* observer); - - void AddLogoutButtonObserver(LogoutButtonObserver* observer); - void RemoveLogoutButtonObserver(LogoutButtonObserver* observer); - - void AddSessionLengthLimitObserver(SessionLengthLimitObserver* observer); - void RemoveSessionLengthLimitObserver(SessionLengthLimitObserver* observer); - - void AddTracingObserver(TracingObserver* observer); - void RemoveTracingObserver(TracingObserver* observer); - - void AddUpdateObserver(UpdateObserver* observer); - void RemoveUpdateObserver(UpdateObserver* observer); - - void AddUserObserver(UserObserver* observer); - void RemoveUserObserver(UserObserver* observer); - -#if defined(OS_CHROMEOS) - void AddNetworkObserver(NetworkObserver* observer); - void RemoveNetworkObserver(NetworkObserver* observer); - - void AddEnterpriseDomainObserver(EnterpriseDomainObserver* observer); - void RemoveEnterpriseDomainObserver(EnterpriseDomainObserver* observer); - - void AddScreenCaptureObserver(ScreenCaptureObserver* observer); - void RemoveScreenCaptureObserver(ScreenCaptureObserver* observer); - - void AddScreenShareObserver(ScreenShareObserver* observer); - void RemoveScreenShareObserver(ScreenShareObserver* observer); -#endif - - void NotifyAccessibilityModeChanged( - AccessibilityNotificationVisibility notify); - void NotifyTracingModeChanged(bool value); - void NotifyRefreshBluetooth(); - void NotifyBluetoothDiscoveringChanged(); - void NotifyCapsLockChanged(bool enabled, bool search_mapped_to_caps_lock); - void NotifyRefreshClock(); - void NotifyDateFormatChanged(); - void NotifySystemClockTimeUpdated(); - void NotifyDriveJobUpdated(const DriveOperationStatus& status); - void NotifyRefreshIME(bool show_message); - void NotifyShowLoginButtonChanged(bool show_login_button); - void NotifyLocaleChanged(LocaleObserver::Delegate* delegate, - const std::string& cur_locale, - const std::string& from_locale, - const std::string& to_locale); - void NotifySessionStartTimeChanged(); - void NotifySessionLengthLimitChanged(); - void NotifyUpdateRecommended(UpdateObserver::UpdateSeverity severity); - void NotifyUserUpdate(); - void NotifyUserAddedToSession(); -#if defined(OS_CHROMEOS) - void NotifyRequestToggleWifi(); - void NotifyEnterpriseDomainChanged(); - void NotifyScreenCaptureStart(const base::Closure& stop_callback, - const base::string16& sharing_app_name); - void NotifyScreenCaptureStop(); - void NotifyScreenShareStart(const base::Closure& stop_callback, - const base::string16& helper_name); - void NotifyScreenShareStop(); - - NetworkStateNotifier* network_state_notifier() { - return network_state_notifier_.get(); - } -#endif - - private: - ObserverList<AccessibilityObserver> accessibility_observers_; - ObserverList<BluetoothObserver> bluetooth_observers_; - ObserverList<CapsLockObserver> caps_lock_observers_; - ObserverList<ClockObserver> clock_observers_; - ObserverList<DriveObserver> drive_observers_; - ObserverList<IMEObserver> ime_observers_; - ObserverList<LocaleObserver> locale_observers_; - ObserverList<LogoutButtonObserver> logout_button_observers_; - ObserverList<SessionLengthLimitObserver> session_length_limit_observers_; - ObserverList<TracingObserver> tracing_observers_; - ObserverList<UpdateObserver> update_observers_; - ObserverList<UserObserver> user_observers_; -#if defined(OS_CHROMEOS) - ObserverList<NetworkObserver> network_observers_; - ObserverList<EnterpriseDomainObserver> enterprise_domain_observers_; - ObserverList<ScreenCaptureObserver> screen_capture_observers_; - ObserverList<ScreenShareObserver> screen_share_observers_; - scoped_ptr<NetworkStateNotifier> network_state_notifier_; -#endif - - DISALLOW_COPY_AND_ASSIGN(SystemTrayNotifier); -}; - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_NOTIFIER_H_ diff --git a/chromium/ash/system/tray/system_tray_unittest.cc b/chromium/ash/system/tray/system_tray_unittest.cc deleted file mode 100644 index 779975ac621..00000000000 --- a/chromium/ash/system/tray/system_tray_unittest.cc +++ /dev/null @@ -1,421 +0,0 @@ -// Copyright (c) 2012 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/tray/system_tray.h" - -#include <vector> - -#include "ash/root_window_controller.h" -#include "ash/shelf/shelf_layout_manager.h" -#include "ash/shelf/shelf_widget.h" -#include "ash/shell.h" -#include "ash/system/status_area_widget.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/test/ash_test_base.h" -#include "ash/wm/window_util.h" -#include "base/run_loop.h" -#include "base/strings/utf_string_conversions.h" -#include "ui/aura/test/event_generator.h" -#include "ui/aura/window.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/fill_layout.h" -#include "ui/views/view.h" -#include "ui/views/widget/widget.h" - -#if defined(OS_WIN) -#include "base/win/windows_version.h" -#endif - -namespace ash { -namespace test { - -namespace { - -SystemTray* GetSystemTray() { - return Shell::GetPrimaryRootWindowController()->shelf()-> - status_area_widget()->system_tray(); -} - -// Trivial item implementation that tracks its views for testing. -class TestItem : public SystemTrayItem { - public: - TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} - - virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { - tray_view_ = new views::View; - // Add a label so it has non-zero width. - tray_view_->SetLayoutManager(new views::FillLayout); - tray_view_->AddChildView(new views::Label(UTF8ToUTF16("Tray"))); - return tray_view_; - } - - virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE { - default_view_ = new views::View; - default_view_->SetLayoutManager(new views::FillLayout); - default_view_->AddChildView(new views::Label(UTF8ToUTF16("Default"))); - return default_view_; - } - - virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE { - detailed_view_ = new views::View; - detailed_view_->SetLayoutManager(new views::FillLayout); - detailed_view_->AddChildView(new views::Label(UTF8ToUTF16("Detailed"))); - return detailed_view_; - } - - virtual views::View* CreateNotificationView( - user::LoginStatus status) OVERRIDE { - notification_view_ = new views::View; - return notification_view_; - } - - virtual void DestroyTrayView() OVERRIDE { - tray_view_ = NULL; - } - - virtual void DestroyDefaultView() OVERRIDE { - default_view_ = NULL; - } - - virtual void DestroyDetailedView() OVERRIDE { - detailed_view_ = NULL; - } - - virtual void DestroyNotificationView() OVERRIDE { - notification_view_ = NULL; - } - - virtual void UpdateAfterLoginStatusChange( - user::LoginStatus status) OVERRIDE { - } - - views::View* tray_view() const { return tray_view_; } - views::View* default_view() const { return default_view_; } - views::View* detailed_view() const { return detailed_view_; } - views::View* notification_view() const { return notification_view_; } - - private: - views::View* tray_view_; - views::View* default_view_; - views::View* detailed_view_; - views::View* notification_view_; -}; - -// Trivial item implementation that returns NULL from tray/default/detailed -// view creation methods. -class TestNoViewItem : public SystemTrayItem { - public: - TestNoViewItem() : SystemTrayItem(GetSystemTray()) {} - - virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { - return NULL; - } - - virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE { - return NULL; - } - - virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE { - return NULL; - } - - virtual views::View* CreateNotificationView( - user::LoginStatus status) OVERRIDE { - return NULL; - } - - virtual void DestroyTrayView() OVERRIDE {} - virtual void DestroyDefaultView() OVERRIDE {} - virtual void DestroyDetailedView() OVERRIDE {} - virtual void DestroyNotificationView() OVERRIDE {} - virtual void UpdateAfterLoginStatusChange( - user::LoginStatus status) OVERRIDE { - } -}; - -} // namespace - -typedef AshTestBase SystemTrayTest; - -TEST_F(SystemTrayTest, SystemTrayDefaultView) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - - // Ensure that closing the bubble destroys it. - ASSERT_TRUE(tray->CloseSystemBubble()); - RunAllPendingInMessageLoop(); - ASSERT_FALSE(tray->CloseSystemBubble()); -} - -// Opening and closing the bubble should change the coloring of the tray. -TEST_F(SystemTrayTest, SystemTrayColoring) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - // At the beginning the tray coloring is not active. - ASSERT_FALSE(tray->draw_background_as_active()); - - // Showing the system bubble should show the background as active. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - ASSERT_TRUE(tray->draw_background_as_active()); - - // Closing the system menu should change the coloring back to normal. - ASSERT_TRUE(tray->CloseSystemBubble()); - RunAllPendingInMessageLoop(); - ASSERT_FALSE(tray->draw_background_as_active()); -} - -// Closing the system bubble through an alignment change should change the -// system tray coloring back to normal. -TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - internal::ShelfLayoutManager* manager = - Shell::GetPrimaryRootWindowController()->shelf()->shelf_layout_manager(); - manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM); - // At the beginning the tray coloring is not active. - ASSERT_FALSE(tray->draw_background_as_active()); - - // Showing the system bubble should show the background as active. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - ASSERT_TRUE(tray->draw_background_as_active()); - - // Changing the alignment should close the system bubble and change the - // background color. - manager->SetAlignment(SHELF_ALIGNMENT_LEFT); - ASSERT_FALSE(tray->draw_background_as_active()); - RunAllPendingInMessageLoop(); - // The bubble should already be closed by now. - ASSERT_FALSE(tray->CloseSystemBubble()); -} - -TEST_F(SystemTrayTest, SystemTrayTestItems) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - TestItem* test_item = new TestItem; - TestItem* detailed_item = new TestItem; - tray->AddTrayItem(test_item); - tray->AddTrayItem(detailed_item); - - // Check items have been added - const std::vector<SystemTrayItem*>& items = tray->GetTrayItems(); - ASSERT_TRUE( - std::find(items.begin(), items.end(), test_item) != items.end()); - ASSERT_TRUE( - std::find(items.begin(), items.end(), detailed_item) != items.end()); - - // Ensure the tray views are created. - ASSERT_TRUE(test_item->tray_view() != NULL); - ASSERT_TRUE(detailed_item->tray_view() != NULL); - - // Ensure a default views are created. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - ASSERT_TRUE(test_item->default_view() != NULL); - ASSERT_TRUE(detailed_item->default_view() != NULL); - - // Show the detailed view, ensure it's created and the default view destroyed. - tray->ShowDetailedView(detailed_item, 0, false, BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - ASSERT_TRUE(test_item->default_view() == NULL); - ASSERT_TRUE(detailed_item->detailed_view() != NULL); - - // Show the default view, ensure it's created and the detailed view destroyed. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - ASSERT_TRUE(test_item->default_view() != NULL); - ASSERT_TRUE(detailed_item->detailed_view() == NULL); -} - -TEST_F(SystemTrayTest, SystemTrayNoViewItems) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - // Verify that no crashes occur on items lacking some views. - TestNoViewItem* no_view_item = new TestNoViewItem; - tray->AddTrayItem(no_view_item); - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING); - RunAllPendingInMessageLoop(); -} - -TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - // Add an initial tray item so that the tray gets laid out correctly. - TestItem* initial_item = new TestItem; - tray->AddTrayItem(initial_item); - - gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); - - TestItem* new_item = new TestItem; - tray->AddTrayItem(new_item); - - gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); - - // Adding the new item should change the size of the tray. - EXPECT_NE(initial_size.ToString(), new_size.ToString()); - - // Hiding the tray view of the new item should also change the size of the - // tray. - new_item->tray_view()->SetVisible(false); - EXPECT_EQ(initial_size.ToString(), - tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); - - new_item->tray_view()->SetVisible(true); - EXPECT_EQ(new_size.ToString(), - tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); -} - -TEST_F(SystemTrayTest, SystemTrayNotifications) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - TestItem* test_item = new TestItem; - TestItem* detailed_item = new TestItem; - tray->AddTrayItem(test_item); - tray->AddTrayItem(detailed_item); - - // Ensure the tray views are created. - ASSERT_TRUE(test_item->tray_view() != NULL); - ASSERT_TRUE(detailed_item->tray_view() != NULL); - - // Ensure a notification view is created. - tray->ShowNotificationView(test_item); - ASSERT_TRUE(test_item->notification_view() != NULL); - - // Show the default view, notification view should remain. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - ASSERT_TRUE(test_item->notification_view() != NULL); - - // Show the detailed view, ensure the notificaiton view remains. - tray->ShowDetailedView(detailed_item, 0, false, BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - ASSERT_TRUE(detailed_item->detailed_view() != NULL); - ASSERT_TRUE(test_item->notification_view() != NULL); - - // Hide the detailed view, ensure the notification view still exists. - ASSERT_TRUE(tray->CloseSystemBubble()); - RunAllPendingInMessageLoop(); - ASSERT_TRUE(detailed_item->detailed_view() == NULL); - ASSERT_TRUE(test_item->notification_view() != NULL); -} - -TEST_F(SystemTrayTest, BubbleCreationTypesTest) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - TestItem* test_item = new TestItem; - tray->AddTrayItem(test_item); - - // Ensure the tray views are created. - ASSERT_TRUE(test_item->tray_view() != NULL); - - // Show the default view, ensure the notification view is destroyed. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - - views::Widget* widget = test_item->default_view()->GetWidget(); - gfx::Rect bubble_bounds = widget->GetWindowBoundsInScreen(); - - tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); - RunAllPendingInMessageLoop(); - - EXPECT_FALSE(test_item->default_view()); - - EXPECT_EQ(bubble_bounds.ToString(), test_item->detailed_view()->GetWidget()-> - GetWindowBoundsInScreen().ToString()); - EXPECT_EQ(widget, test_item->detailed_view()->GetWidget()); - - tray->ShowDefaultView(BUBBLE_USE_EXISTING); - RunAllPendingInMessageLoop(); - - EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> - GetWindowBoundsInScreen().ToString()); - EXPECT_EQ(widget, test_item->default_view()->GetWidget()); -} - -// Tests that the tray is laid out properly and is fully contained within -// the shelf. -TEST_F(SystemTrayTest, TrayBoundsInWidget) { - internal::ShelfLayoutManager* manager = - Shell::GetPrimaryRootWindowController()->shelf()->shelf_layout_manager(); - internal::StatusAreaWidget* widget = - Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); - SystemTray* tray = widget->system_tray(); - - // Test in bottom alignment. - manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM); - gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); - gfx::Rect tray_bounds = tray->GetBoundsInScreen(); - EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); - EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); - EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); - EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); - - // Test in the left alignment. - manager->SetAlignment(SHELF_ALIGNMENT_LEFT); - window_bounds = widget->GetWindowBoundsInScreen(); - tray_bounds = tray->GetBoundsInScreen(); - EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); - EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); - EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); - EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); - - // Test in the right alignment. - manager->SetAlignment(SHELF_ALIGNMENT_LEFT); - window_bounds = widget->GetWindowBoundsInScreen(); - tray_bounds = tray->GetBoundsInScreen(); - EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); - EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); - EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); - EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); -} - -TEST_F(SystemTrayTest, PersistentBubble) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - TestItem* test_item = new TestItem; - tray->AddTrayItem(test_item); - - scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); - - // Tests for usual default view. - // Activating window. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - ASSERT_TRUE(tray->HasSystemBubble()); - wm::ActivateWindow(window.get()); - base::RunLoop().RunUntilIdle(); - ASSERT_FALSE(tray->HasSystemBubble()); - - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - ASSERT_TRUE(tray->HasSystemBubble()); - { - aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), - gfx::Point(5, 5)); - generator.ClickLeftButton(); - ASSERT_FALSE(tray->HasSystemBubble()); - } - - // Same tests for persistent default view. - tray->ShowPersistentDefaultView(); - ASSERT_TRUE(tray->HasSystemBubble()); - wm::ActivateWindow(window.get()); - base::RunLoop().RunUntilIdle(); - ASSERT_TRUE(tray->HasSystemBubble()); - - { - aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), - gfx::Point(5, 5)); - generator.ClickLeftButton(); - ASSERT_TRUE(tray->HasSystemBubble()); - } -} - -} // namespace test -} // namespace ash diff --git a/chromium/ash/system/tray/throbber_view.cc b/chromium/ash/system/tray/throbber_view.cc deleted file mode 100644 index 2c2cc206904..00000000000 --- a/chromium/ash/system/tray/throbber_view.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2013 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/tray/throbber_view.h" - -#include "ash/system/tray/tray_constants.h" -#include "grit/ash_resources.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/compositor/layer.h" -#include "ui/compositor/scoped_layer_animation_settings.h" - -namespace ash { -namespace internal { - -namespace { - -// Time in ms per throbber frame. -const int kThrobberFrameMs = 30; - -// Duration for showing/hiding animation in milliseconds. -const int kThrobberAnimationDurationMs = 200; - -} // namespace - -SystemTrayThrobber::SystemTrayThrobber(int frame_delay_ms) - : views::SmoothedThrobber(frame_delay_ms) { -} - -SystemTrayThrobber::~SystemTrayThrobber() { -} - -void SystemTrayThrobber::SetTooltipText(const base::string16& tooltip_text) { - tooltip_text_ = tooltip_text; -} - -bool SystemTrayThrobber::GetTooltipText(const gfx::Point& p, - base::string16* tooltip) const { - if (tooltip_text_.empty()) - return false; - - *tooltip = tooltip_text_; - return true; -} - -ThrobberView::ThrobberView() { - throbber_ = new SystemTrayThrobber(kThrobberFrameMs); - throbber_->SetFrames(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_AURA_CROS_DEFAULT_THROBBER).ToImageSkia()); - throbber_->set_stop_delay_ms(kThrobberAnimationDurationMs); - AddChildView(throbber_); - - SetPaintToLayer(true); - layer()->SetFillsBoundsOpaquely(false); - layer()->SetOpacity(0.0); -} - -ThrobberView::~ThrobberView() { -} - -gfx::Size ThrobberView::GetPreferredSize() { - return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight); -} - -void ThrobberView::Layout() { - View* child = child_at(0); - gfx::Size ps = child->GetPreferredSize(); - child->SetBounds((width() - ps.width()) / 2, - (height() - ps.height()) / 2, - ps.width(), ps.height()); - SizeToPreferredSize(); -} - -bool ThrobberView::GetTooltipText(const gfx::Point& p, - base::string16* tooltip) const { - if (tooltip_text_.empty()) - return false; - - *tooltip = tooltip_text_; - return true; -} - -void ThrobberView::Start() { - ScheduleAnimation(true); - throbber_->Start(); -} - -void ThrobberView::Stop() { - ScheduleAnimation(false); - throbber_->Stop(); -} - -void ThrobberView::SetTooltipText(const base::string16& tooltip_text) { - tooltip_text_ = tooltip_text; - throbber_->SetTooltipText(tooltip_text); -} - -void ThrobberView::ScheduleAnimation(bool start_throbber) { - // Stop any previous animation. - layer()->GetAnimator()->StopAnimating(); - - ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator()); - animation.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kThrobberAnimationDurationMs)); - - layer()->SetOpacity(start_throbber ? 1.0 : 0.0); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/throbber_view.h b/chromium/ash/system/tray/throbber_view.h deleted file mode 100644 index 0f2663280e2..00000000000 --- a/chromium/ash/system/tray/throbber_view.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2013 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. - -#ifndef ASH_SYSTEM_TRAY_THROBBER_VIEW_H_ -#define ASH_SYSTEM_TRAY_THROBBER_VIEW_H_ - -#include "ui/gfx/size.h" -#include "ui/views/controls/throbber.h" -#include "ui/views/view.h" - -namespace ash { -namespace internal { - -// A SmoothedThrobber with tooltip. -class SystemTrayThrobber : public views::SmoothedThrobber { - public: - SystemTrayThrobber(int frame_delay_ms); - virtual ~SystemTrayThrobber(); - - void SetTooltipText(const base::string16& tooltip_text); - - // Overriden from views::View. - virtual bool GetTooltipText( - const gfx::Point& p, base::string16* tooltip) const OVERRIDE; - - private: - // The current tooltip text. - base::string16 tooltip_text_; - - DISALLOW_COPY_AND_ASSIGN(SystemTrayThrobber); -}; - -// A View containing a SystemTrayThrobber with animation for starting/stopping. -class ThrobberView : public views::View { - public: - ThrobberView(); - virtual ~ThrobberView(); - - void Start(); - void Stop(); - void SetTooltipText(const base::string16& tooltip_text); - - // Overriden from views::View. - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual bool GetTooltipText( - const gfx::Point& p, base::string16* tooltip) const OVERRIDE; - - private: - // Schedules animation for starting/stopping throbber. - void ScheduleAnimation(bool start_throbber); - - SystemTrayThrobber* throbber_; - - // The current tooltip text. - base::string16 tooltip_text_; - - DISALLOW_COPY_AND_ASSIGN(ThrobberView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_THROBBER_VIEW_H_ diff --git a/chromium/ash/system/tray/tray_background_view.cc b/chromium/ash/system/tray/tray_background_view.cc deleted file mode 100644 index 80cac07e364..00000000000 --- a/chromium/ash/system/tray/tray_background_view.cc +++ /dev/null @@ -1,634 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_background_view.h" - -#include "ash/ash_switches.h" -#include "ash/root_window_controller.h" -#include "ash/screen_ash.h" -#include "ash/shelf/shelf_layout_manager.h" -#include "ash/shelf/shelf_widget.h" -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/system/status_area_widget.h" -#include "ash/system/status_area_widget_delegate.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray/tray_event_filter.h" -#include "ash/wm/window_animations.h" -#include "grit/ash_resources.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/base/accessibility/accessible_view_state.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/gfx/image/image_skia_operations.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/screen.h" -#include "ui/gfx/skia_util.h" -#include "ui/views/background.h" -#include "ui/views/layout/box_layout.h" - -namespace { - -const int kTrayBackgroundAlpha = 100; -const int kTrayBackgroundHoverAlpha = 150; -const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); - -// Adjust the size of TrayContainer with additional padding. -const int kTrayContainerVerticalPaddingBottomAlignment = 1; -const int kTrayContainerHorizontalPaddingBottomAlignment = 1; -const int kTrayContainerVerticalPaddingVerticalAlignment = 1; -const int kTrayContainerHorizontalPaddingVerticalAlignment = 1; - -const int kAnimationDurationForPopupMS = 200; - -} // namespace - -using views::TrayBubbleView; - -namespace ash { -namespace internal { - -// static -const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; - -// Used to track when the anchor widget changes position on screen so that the -// bubble position can be updated. -class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver { - public: - explicit TrayWidgetObserver(TrayBackgroundView* host) - : host_(host) { - } - - virtual void OnWidgetBoundsChanged(views::Widget* widget, - const gfx::Rect& new_bounds) OVERRIDE { - host_->AnchorUpdated(); - } - - virtual void OnWidgetVisibilityChanged(views::Widget* widget, - bool visible) OVERRIDE { - host_->AnchorUpdated(); - } - - private: - TrayBackgroundView* host_; - - DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); -}; - -class TrayBackground : public views::Background { - public: - const static int kImageTypeDefault = 0; - const static int kImageTypeOnBlack = 1; - const static int kImageTypePressed = 2; - const static int kNumStates = 3; - - const static int kImageHorizontal = 0; - const static int kImageVertical = 1; - const static int kNumOrientations = 2; - - explicit TrayBackground(TrayBackgroundView* tray_background_view) : - tray_background_view_(tray_background_view) { - set_alpha(kTrayBackgroundAlpha); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - leading_images_[kImageHorizontal][kImageTypeDefault] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT).ToImageSkia(); - middle_images_[kImageHorizontal][kImageTypeDefault] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER).ToImageSkia(); - trailing_images_[kImageHorizontal][kImageTypeDefault] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT).ToImageSkia(); - - leading_images_[kImageHorizontal][kImageTypeOnBlack] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT_ONBLACK).ToImageSkia(); - middle_images_[kImageHorizontal][kImageTypeOnBlack] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER_ONBLACK).ToImageSkia(); - trailing_images_[kImageHorizontal][kImageTypeOnBlack] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT_ONBLACK).ToImageSkia(); - - leading_images_[kImageHorizontal][kImageTypePressed] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT_PRESSED).ToImageSkia(); - middle_images_[kImageHorizontal][kImageTypePressed] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER_PRESSED).ToImageSkia(); - trailing_images_[kImageHorizontal][kImageTypePressed] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT_PRESSED).ToImageSkia(); - - leading_images_[kImageVertical][kImageTypeDefault] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP).ToImageSkia(); - middle_images_[kImageVertical][kImageTypeDefault] = - rb.GetImageNamed( - IDR_AURA_TRAY_BG_VERTICAL_CENTER).ToImageSkia(); - trailing_images_[kImageVertical][kImageTypeDefault] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_BOTTOM).ToImageSkia(); - - leading_images_[kImageVertical][kImageTypeOnBlack] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_ONBLACK).ToImageSkia(); - middle_images_[kImageVertical][kImageTypeOnBlack] = - rb.GetImageNamed( - IDR_AURA_TRAY_BG_VERTICAL_CENTER_ONBLACK).ToImageSkia(); - trailing_images_[kImageVertical][kImageTypeOnBlack] = - rb.GetImageNamed( - IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_ONBLACK).ToImageSkia(); - - leading_images_[kImageVertical][kImageTypePressed] = - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_PRESSED).ToImageSkia(); - middle_images_[kImageVertical][kImageTypePressed] = - rb.GetImageNamed( - IDR_AURA_TRAY_BG_VERTICAL_CENTER_PRESSED).ToImageSkia(); - trailing_images_[kImageVertical][kImageTypePressed] = - rb.GetImageNamed( - IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_PRESSED).ToImageSkia(); - } - - virtual ~TrayBackground() {} - - SkColor color() { return color_; } - void set_color(SkColor color) { color_ = color; } - void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); } - - private: - ShelfWidget* GetShelfWidget() const { - return RootWindowController::ForWindow(tray_background_view_-> - status_area_widget()->GetNativeWindow())->shelf(); - } - - void PaintForAlternateShelf(gfx::Canvas* canvas, views::View* view) const { - int orientation = kImageHorizontal; - ShelfWidget* shelf_widget = GetShelfWidget(); - if (shelf_widget && - !shelf_widget->shelf_layout_manager()->IsHorizontalAlignment()) - orientation = kImageVertical; - - int state = kImageTypeDefault; - if (tray_background_view_->draw_background_as_active()) - state = kImageTypePressed; - else if (shelf_widget && shelf_widget->GetDimsShelf()) - state = kImageTypeOnBlack; - else - state = kImageTypeDefault; - - const gfx::ImageSkia* leading = leading_images_[orientation][state]; - const gfx::ImageSkia* middle = middle_images_[orientation][state]; - const gfx::ImageSkia* trailing = trailing_images_[orientation][state]; - - gfx::Rect bounds(view->GetLocalBounds()); - gfx::Point leading_location, trailing_location; - gfx::Rect middle_bounds; - - if (orientation == kImageHorizontal) { - leading_location = gfx::Point(0, 0); - trailing_location = gfx::Point(bounds.width() - trailing->width(), 0); - middle_bounds = gfx::Rect( - leading->width(), - 0, - bounds.width() - (leading->width() + trailing->width()), - bounds.height()); - } else { - leading_location = gfx::Point(0, 0); - trailing_location = gfx::Point(0, bounds.height() - trailing->height()); - middle_bounds = gfx::Rect( - 0, - leading->height(), - bounds.width(), - bounds.height() - (leading->height() + trailing->height())); - } - - canvas->DrawImageInt(*leading, - leading_location.x(), - leading_location.y()); - - canvas->DrawImageInt(*trailing, - trailing_location.x(), - trailing_location.y()); - - canvas->TileImageInt(*middle, - middle_bounds.x(), - middle_bounds.y(), - middle_bounds.width(), - middle_bounds.height()); - } - - // Overridden from views::Background. - virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { - if (ash::switches::UseAlternateShelfLayout()) { - PaintForAlternateShelf(canvas, view); - } else { - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(color_); - SkPath path; - gfx::Rect bounds(view->GetLocalBounds()); - SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius); - path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); - canvas->DrawPath(path, paint); - } - } - - SkColor color_; - // Reference to the TrayBackgroundView for which this is a background. - TrayBackgroundView* tray_background_view_; - - // References to the images used as backgrounds, they are owned by the - // resource bundle class. - const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates]; - const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates]; - const gfx::ImageSkia* trailing_images_[kNumOrientations][kNumStates]; - - DISALLOW_COPY_AND_ASSIGN(TrayBackground); -}; - -TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) - : alignment_(alignment) { - UpdateLayout(); -} - -void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { - if (alignment_ == alignment) - return; - alignment_ = alignment; - UpdateLayout(); -} - -gfx::Size TrayBackgroundView::TrayContainer::GetPreferredSize() { - if (size_.IsEmpty()) - return views::View::GetPreferredSize(); - return size_; -} - -void TrayBackgroundView::TrayContainer::ChildPreferredSizeChanged( - views::View* child) { - PreferredSizeChanged(); -} - -void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { - PreferredSizeChanged(); -} - -void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( - const ViewHierarchyChangedDetails& details) { - if (details.parent == this) - PreferredSizeChanged(); -} - -void TrayBackgroundView::TrayContainer::UpdateLayout() { - // Adjust the size of status tray dark background by adding additional - // empty border. - if (alignment_ == SHELF_ALIGNMENT_BOTTOM || - alignment_ == SHELF_ALIGNMENT_TOP) { - int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; - int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; - if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding = kPaddingFromEdgeOfShelf; - horizontal_padding = kPaddingFromEdgeOfShelf; - } - set_border(views::Border::CreateEmptyBorder( - vertical_padding, - horizontal_padding, - vertical_padding, - horizontal_padding)); - - views::BoxLayout* layout = - new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); - layout->set_spread_blank_space(true); - views::View::SetLayoutManager(layout); - } else { - int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; - int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; - if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding = kPaddingFromEdgeOfShelf; - horizontal_padding = kPaddingFromEdgeOfShelf; - } - set_border(views::Border::CreateEmptyBorder( - vertical_padding, - horizontal_padding, - vertical_padding, - horizontal_padding)); - - views::BoxLayout* layout = - new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); - layout->set_spread_blank_space(true); - views::View::SetLayoutManager(layout); - } - PreferredSizeChanged(); -} - -//////////////////////////////////////////////////////////////////////////////// -// TrayBackgroundView - -TrayBackgroundView::TrayBackgroundView( - internal::StatusAreaWidget* status_area_widget) - : status_area_widget_(status_area_widget), - tray_container_(NULL), - shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), - background_(NULL), - hide_background_animator_(this, 0, kTrayBackgroundAlpha), - hover_background_animator_( - this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), - hovered_(false), - draw_background_as_active_(false), - widget_observer_(new TrayWidgetObserver(this)) { - set_notify_enter_exit_on_child(true); - - // Initially we want to paint the background, but without the hover effect. - hide_background_animator_.SetPaintsBackground( - true, BACKGROUND_CHANGE_IMMEDIATE); - hover_background_animator_.SetPaintsBackground( - false, BACKGROUND_CHANGE_IMMEDIATE); - - tray_container_ = new TrayContainer(shelf_alignment_); - SetContents(tray_container_); - tray_event_filter_.reset(new TrayEventFilter); -} - -TrayBackgroundView::~TrayBackgroundView() { - if (GetWidget()) - GetWidget()->RemoveObserver(widget_observer_.get()); -} - -void TrayBackgroundView::Initialize() { - GetWidget()->AddObserver(widget_observer_.get()); - SetBorder(); -} - -const char* TrayBackgroundView::GetClassName() const { - return kViewClassName; -} - -void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { - hovered_ = true; - if (!background_ || draw_background_as_active_ || - ash::switches::UseAlternateShelfLayout()) - return; - hover_background_animator_.SetPaintsBackground( - true, BACKGROUND_CHANGE_ANIMATE); -} - -void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { - hovered_ = false; - if (!background_ || draw_background_as_active_ || - ash::switches::UseAlternateShelfLayout()) - return; - hover_background_animator_.SetPaintsBackground( - false, BACKGROUND_CHANGE_ANIMATE); -} - -void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { - PreferredSizeChanged(); -} - -void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = GetAccessibleNameForTray(); -} - -void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { - // Return focus to the login view. See crbug.com/120500. - views::View* v = GetNextFocusableView(); - if (v) - v->AboutToRequestFocusFromTabTraversal(reverse); -} - -bool TrayBackgroundView::PerformAction(const ui::Event& event) { - return false; -} - -gfx::Rect TrayBackgroundView::GetFocusBounds() { - // The tray itself expands to the right and bottom edge of the screen to make - // sure clicking on the edges brings up the popup. However, the focus border - // should be only around the container. - return GetContentsBounds(); -} - -void TrayBackgroundView::UpdateBackground(int alpha) { - // The animator should never fire when the alternate shelf layout is used. - if (!background_ || draw_background_as_active_) - return; - DCHECK(!ash::switches::UseAlternateShelfLayout()); - background_->set_alpha(hide_background_animator_.alpha() + - hover_background_animator_.alpha()); - SchedulePaint(); -} - -void TrayBackgroundView::SetContents(views::View* contents) { - SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); - AddChildView(contents); -} - -void TrayBackgroundView::SetPaintsBackground( - bool value, BackgroundAnimatorChangeType change_type) { - DCHECK(!ash::switches::UseAlternateShelfLayout()); - hide_background_animator_.SetPaintsBackground(value, change_type); -} - -void TrayBackgroundView::SetContentsBackground() { - background_ = new internal::TrayBackground(this); - tray_container_->set_background(background_); -} - -ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { - return ShelfLayoutManager::ForLauncher(GetWidget()->GetNativeView()); -} - -void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { - shelf_alignment_ = alignment; - SetBorder(); - tray_container_->SetAlignment(alignment); -} - -void TrayBackgroundView::SetBorder() { - views::View* parent = status_area_widget_->status_area_widget_delegate(); - // Tray views are laid out right-to-left or bottom-to-top - bool on_edge = (this == parent->child_at(0)); - int left_edge, top_edge, right_edge, bottom_edge; - if (ash::switches::UseAlternateShelfLayout()) { - if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { - top_edge = ShelfLayoutManager::kShelfItemInset; - left_edge = 0; - bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { - top_edge = 0; - left_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - right_edge = ShelfLayoutManager::kShelfItemInset; - } else { // SHELF_ALIGNMENT_RIGHT - top_edge = 0; - left_edge = ShelfLayoutManager::kShelfItemInset; - bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - right_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - } - } else { - // Change the border padding for different shelf alignment. - if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { - top_edge = 0; - left_edge = 0; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : - kPaddingFromBottomOfScreenBottomAlignment - 1; - right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { - top_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : - kPaddingFromBottomOfScreenBottomAlignment - 1; - left_edge = 0; - bottom_edge = 0; - right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { - top_edge = 0; - left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; - right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - } else { - top_edge = 0; - left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; - right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; - } - } - set_border(views::Border::CreateEmptyBorder( - top_edge, left_edge, bottom_edge, right_edge)); -} - -void TrayBackgroundView::InitializeBubbleAnimations( - views::Widget* bubble_widget) { - views::corewm::SetWindowVisibilityAnimationType( - bubble_widget->GetNativeWindow(), - views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); - views::corewm::SetWindowVisibilityAnimationTransition( - bubble_widget->GetNativeWindow(), - views::corewm::ANIMATE_HIDE); - views::corewm::SetWindowVisibilityAnimationDuration( - bubble_widget->GetNativeWindow(), - base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); -} - -aura::Window* TrayBackgroundView::GetBubbleWindowContainer() const { - return ash::Shell::GetContainer( - tray_container()->GetWidget()->GetNativeWindow()->GetRootWindow(), - ash::internal::kShellWindowId_SettingBubbleContainer); -} - -gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( - views::Widget* anchor_widget, - TrayBubbleView::AnchorType anchor_type, - TrayBubbleView::AnchorAlignment anchor_alignment) const { - gfx::Rect rect; - if (anchor_widget && anchor_widget->IsVisible()) { - rect = anchor_widget->GetWindowBoundsInScreen(); - if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { - if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { - bool rtl = base::i18n::IsRTL(); - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset( - rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, - kTrayBubbleAnchorTopInsetBottomAnchor, - rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, - kPaddingFromBottomOfScreenBottomAlignment); - } else { - rect.Inset( - rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, - kAlternateLayoutBubblePaddingHorizontalBottom, - rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, - 0); - } - } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, - kPaddingFromBottomOfScreenVerticalAlignment); - } else { - rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, - kAlternateLayoutBubblePaddingVerticalBottom); - } - } else { - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, - 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); - } else { - rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, - kAlternateLayoutBubblePaddingVerticalBottom); - } - } - } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { - // Invert the offsets to align with the bubble below. - // Note that with the alternate shelf layout the tips are not shown and - // the offsets for left and right alignment do not need to be applied. - int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? - 0 : - kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ? - kAlternateLayoutBubblePaddingVerticalBottom : - kPaddingFromBottomOfScreenVerticalAlignment; - if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) - rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); - else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) - rect.Inset(0, 0, vertical_alignment, horizontal_alignment); - } - } - - // TODO(jennyz): May need to add left/right alignment in the following code. - if (rect.IsEmpty()) { - aura::Window* target_root = anchor_widget ? - anchor_widget->GetNativeView()->GetRootWindow() : - Shell::GetPrimaryRootWindow(); - rect = target_root->bounds(); - rect = gfx::Rect( - base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreenBottomAlignment : - rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, - rect.height() - kPaddingFromBottomOfScreenBottomAlignment, - 0, 0); - rect = ScreenAsh::ConvertRectToScreen(target_root, rect); - } - return rect; -} - -TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { - switch (shelf_alignment_) { - case SHELF_ALIGNMENT_BOTTOM: - return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; - case SHELF_ALIGNMENT_LEFT: - return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; - case SHELF_ALIGNMENT_RIGHT: - return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; - case SHELF_ALIGNMENT_TOP: - return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; - } - NOTREACHED(); - return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; -} - -void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { - draw_background_as_active_ = visible; - if (!background_ || !switches::UseAlternateShelfLayout()) - return; - - // Do not change gradually, changing color between grey and blue is weird. - if (draw_background_as_active_) - background_->set_color(kTrayBackgroundPressedColor); - else if (hovered_) - background_->set_alpha(kTrayBackgroundHoverAlpha); - else - background_->set_alpha(kTrayBackgroundAlpha); - SchedulePaint(); -} - -void TrayBackgroundView::UpdateBubbleViewArrow( - views::TrayBubbleView* bubble_view) { - if (switches::UseAlternateShelfLayout()) - return; - - aura::Window* root_window = - bubble_view->GetWidget()->GetNativeView()->GetRootWindow(); - ash::internal::ShelfLayoutManager* shelf = - ShelfLayoutManager::ForLauncher(root_window); - bubble_view->SetArrowPaintType( - (shelf && shelf->IsVisible()) ? - views::BubbleBorder::PAINT_NORMAL : - views::BubbleBorder::PAINT_TRANSPARENT); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_background_view.h b/chromium/ash/system/tray/tray_background_view.h deleted file mode 100644 index 5adaf4ec0c7..00000000000 --- a/chromium/ash/system/tray/tray_background_view.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ -#define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ - -#include "ash/ash_export.h" -#include "ash/shelf/background_animator.h" -#include "ash/shelf/shelf_types.h" -#include "ash/system/tray/actionable_view.h" -#include "ui/views/bubble/tray_bubble_view.h" - -namespace ash { -namespace internal { - -class ShelfLayoutManager; -class StatusAreaWidget; -class TrayEventFilter; -class TrayBackground; - -// Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, -// LogoutButtonTray. -// This class handles setting and animating the background when the Launcher -// his shown/hidden. It also inherits from ActionableView so that the tray -// items can override PerformAction when clicked on. -class ASH_EXPORT TrayBackgroundView : public ActionableView, - public BackgroundAnimatorDelegate { - public: - static const char kViewClassName[]; - - // Base class for tray containers. Sets the border and layout. The container - // auto-resizes the widget when necessary. - class TrayContainer : public views::View { - public: - explicit TrayContainer(ShelfAlignment alignment); - virtual ~TrayContainer() {} - - void SetAlignment(ShelfAlignment alignment); - - void set_size(const gfx::Size& size) { size_ = size; } - - // Overridden from views::View. - virtual gfx::Size GetPreferredSize() OVERRIDE; - - protected: - // Overridden from views::View. - virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; - virtual void ChildVisibilityChanged(View* child) OVERRIDE; - virtual void ViewHierarchyChanged( - const ViewHierarchyChangedDetails& details) OVERRIDE; - - private: - void UpdateLayout(); - - ShelfAlignment alignment_; - gfx::Size size_; - - DISALLOW_COPY_AND_ASSIGN(TrayContainer); - }; - - explicit TrayBackgroundView(internal::StatusAreaWidget* status_area_widget); - virtual ~TrayBackgroundView(); - - // Called after the tray has been added to the widget containing it. - virtual void Initialize(); - - // Overridden from views::View. - virtual const char* GetClassName() const OVERRIDE; - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; - virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; - - // Overridden from internal::ActionableView. - virtual bool PerformAction(const ui::Event& event) OVERRIDE; - virtual gfx::Rect GetFocusBounds() OVERRIDE; - - // Overridden from internal::BackgroundAnimatorDelegate. - virtual void UpdateBackground(int alpha) OVERRIDE; - - // Called whenever the shelf alignment changes. - virtual void SetShelfAlignment(ShelfAlignment alignment); - - // Called when the anchor (tray or bubble) may have moved or changed. - virtual void AnchorUpdated() {} - - // Called from GetAccessibleState, must return a valid accessible name. - virtual base::string16 GetAccessibleNameForTray() = 0; - - // Called when the bubble is resized. - virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {} - - // Hides the bubble associated with |bubble_view|. Called when the widget - // is closed. - virtual void HideBubbleWithView(const views::TrayBubbleView* bubble_view) = 0; - - // Called by the bubble wrapper when a click event occurs outside the bubble. - // May close the bubble. Returns true if the event is handled. - virtual bool ClickedOutsideBubble() = 0; - - // Sets |contents| as a child. - void SetContents(views::View* contents); - - // Creates and sets contents background to |background_|. - void SetContentsBackground(); - - // Sets whether the tray paints a background. Default is true, but is set to - // false if a window overlaps the shelf. - void SetPaintsBackground(bool value, - BackgroundAnimatorChangeType change_type); - - // Initializes animations for the bubble. - void InitializeBubbleAnimations(views::Widget* bubble_widget); - - // Returns the window hosting the bubble. - aura::Window* GetBubbleWindowContainer() const; - - // Returns the anchor rect for the bubble. - gfx::Rect GetBubbleAnchorRect( - views::Widget* anchor_widget, - views::TrayBubbleView::AnchorType anchor_type, - views::TrayBubbleView::AnchorAlignment anchor_alignment) const; - - // Returns the bubble anchor alignment based on |shelf_alignment_|. - views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; - - // Forces the background to be drawn active if set to true. - void SetDrawBackgroundAsActive(bool visible); - - // Returns true when the the background was overridden to be drawn as active. - bool draw_background_as_active() const {return draw_background_as_active_; } - - StatusAreaWidget* status_area_widget() { - return status_area_widget_; - } - const StatusAreaWidget* status_area_widget() const { - return status_area_widget_; - } - TrayContainer* tray_container() const { return tray_container_; } - ShelfAlignment shelf_alignment() const { return shelf_alignment_; } - TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } - - ShelfLayoutManager* GetShelfLayoutManager(); - - // Updates the arrow visibility based on the launcher visibility. - void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); - - private: - class TrayWidgetObserver; - - // Called from Initialize after all status area trays have been created. - // Sets the border based on the position of the view. - void SetBorder(); - - // Unowned pointer to parent widget. - StatusAreaWidget* status_area_widget_; - - // Convenience pointer to the contents view. - TrayContainer* tray_container_; - - // Shelf alignment. - ShelfAlignment shelf_alignment_; - - // Owned by the view passed to SetContents(). - internal::TrayBackground* background_; - - // Animators for the background. They are only used for the old shelf layout. - internal::BackgroundAnimator hide_background_animator_; - internal::BackgroundAnimator hover_background_animator_; - - // True if the background gets hovered. - bool hovered_; - - // This variable stores the activation override which will tint the background - // differently if set to true. - bool draw_background_as_active_; - - scoped_ptr<TrayWidgetObserver> widget_observer_; - scoped_ptr<TrayEventFilter> tray_event_filter_; - - DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ diff --git a/chromium/ash/system/tray/tray_bar_button_with_title.cc b/chromium/ash/system/tray/tray_bar_button_with_title.cc deleted file mode 100644 index 0fd94d84892..00000000000 --- a/chromium/ash/system/tray/tray_bar_button_with_title.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2013 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/tray/tray_bar_button_with_title.h" - -#include "ash/system/tray/tray_constants.h" -#include "base/memory/scoped_ptr.h" -#include "grit/ui_resources.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/views/controls/label.h" -#include "ui/views/painter.h" - -namespace ash { -namespace internal { - -namespace { - -const int kBarImagesActive[] = { - IDR_SLIDER_ACTIVE_LEFT, - IDR_SLIDER_ACTIVE_CENTER, - IDR_SLIDER_ACTIVE_RIGHT, -}; - -const int kBarImagesDisabled[] = { - IDR_SLIDER_DISABLED_LEFT, - IDR_SLIDER_DISABLED_CENTER, - IDR_SLIDER_DISABLED_RIGHT, -}; - -} // namespace - -class TrayBarButtonWithTitle::TrayBarButton : public views::View { - public: - TrayBarButton(const int bar_active_images[], const int bar_disabled_images[]) - : views::View(), - bar_active_images_(bar_active_images), - bar_disabled_images_(bar_disabled_images), - painter_(new views::HorizontalPainter(bar_active_images_)){ - } - virtual ~TrayBarButton() {} - - // Overriden from views::View: - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - painter_->Paint(canvas, size()); - } - - void Update(bool control_on) { - painter_.reset(new views::HorizontalPainter( - control_on ? bar_active_images_ : bar_disabled_images_)); - SchedulePaint(); - } - - private: - const int* bar_active_images_; - const int* bar_disabled_images_; - scoped_ptr<views::HorizontalPainter> painter_; - - DISALLOW_COPY_AND_ASSIGN(TrayBarButton); -}; - -TrayBarButtonWithTitle::TrayBarButtonWithTitle(views::ButtonListener* listener, - int title_id, - int width) - : views::CustomButton(listener), - image_(new TrayBarButton(kBarImagesActive, kBarImagesDisabled)), - title_(NULL), - width_(width) { - AddChildView(image_); - if (title_id != -1) { - title_ = new views::Label; - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - base::string16 text = rb.GetLocalizedString(title_id); - title_->SetText(text); - AddChildView(title_); - } - - image_height_ = ui::ResourceBundle::GetSharedInstance().GetImageNamed( - kBarImagesActive[0]).ToImageSkia()->height(); -} - -TrayBarButtonWithTitle::~TrayBarButtonWithTitle() {} - -void TrayBarButtonWithTitle::UpdateButton(bool control_on) { - image_->Update(control_on); -} - -gfx::Size TrayBarButtonWithTitle::GetPreferredSize() { - return gfx::Size(width_, kTrayPopupItemHeight); -} - -void TrayBarButtonWithTitle::Layout() { - gfx::Rect rect(GetContentsBounds()); - int bar_image_y = rect.height() / 2 - image_height_ / 2; - gfx::Rect bar_image_rect(rect.x(), - bar_image_y, - rect.width(), - image_height_); - image_->SetBoundsRect(bar_image_rect); - if (title_) { - // The image_ has some empty space below the bar image, move the title - // a little bit up to look closer to the bar. - gfx::Size title_size = title_->GetPreferredSize(); - title_->SetBounds(rect.x(), - bar_image_y + image_height_ - 3, - rect.width(), - title_size.height()); - } -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_bar_button_with_title.h b/chromium/ash/system/tray/tray_bar_button_with_title.h deleted file mode 100644 index 8b63d4f8fa7..00000000000 --- a/chromium/ash/system/tray/tray_bar_button_with_title.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_BAR_BUTTON_WITH_TITLE_H_ -#define ASH_SYSTEM_TRAY_TRAY_BAR_BUTTON_WITH_TITLE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/button/custom_button.h" - -namespace views { -class Label; -} - -namespace ash { -namespace internal { - -// A button with a bar image and title text below the bar image. These buttons -// will be used in audio and brightness control UI, which can be toggled with -// on/off states. -class TrayBarButtonWithTitle : public views::CustomButton { - public: - TrayBarButtonWithTitle(views::ButtonListener* listener, - int title_id, - int width); - virtual ~TrayBarButtonWithTitle(); - - void UpdateButton(bool control_on); - - private: - class TrayBarButton; - - // Overridden from views::CustomButton: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - - TrayBarButton* image_; - views::Label* title_; - int width_; - int image_height_; - - DISALLOW_COPY_AND_ASSIGN(TrayBarButtonWithTitle); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_BAR_BUTTON_WITH_TITLE_H_ diff --git a/chromium/ash/system/tray/tray_bubble_wrapper.cc b/chromium/ash/system/tray/tray_bubble_wrapper.cc deleted file mode 100644 index 2bcb07bb3de..00000000000 --- a/chromium/ash/system/tray/tray_bubble_wrapper.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_bubble_wrapper.h" - -#include "ash/system/tray/tray_background_view.h" -#include "ash/system/tray/tray_event_filter.h" -#include "ash/wm/window_properties.h" -#include "ui/aura/client/capture_client.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/views/bubble/tray_bubble_view.h" -#include "ui/views/widget/widget.h" - -namespace ash { -namespace internal { - -TrayBubbleWrapper::TrayBubbleWrapper(TrayBackgroundView* tray, - views::TrayBubbleView* bubble_view) - : tray_(tray), - bubble_view_(bubble_view) { - bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); - bubble_widget_->AddObserver(this); - - tray_->InitializeBubbleAnimations(bubble_widget_); - tray_->UpdateBubbleViewArrow(bubble_view_); - bubble_view_->InitializeAndShowBubble(); - - tray->tray_event_filter()->AddWrapper(this); -} - -TrayBubbleWrapper::~TrayBubbleWrapper() { - tray_->tray_event_filter()->RemoveWrapper(this); - if (bubble_widget_) { - bubble_widget_->RemoveObserver(this); - bubble_widget_->Close(); - } -} - -void TrayBubbleWrapper::OnWidgetDestroying(views::Widget* widget) { - CHECK_EQ(bubble_widget_, widget); - bubble_widget_->RemoveObserver(this); - bubble_widget_ = NULL; - - // Although the bubble is already closed, the next mouse release event - // will invoke PerformAction which reopens the bubble again. To prevent the - // reopen, the mouse capture of |tray_| has to be released. - // See crbug.com/177075 - aura::client::CaptureClient* capture_client = aura::client::GetCaptureClient( - tray_->GetWidget()->GetNativeView()->GetRootWindow()); - if (capture_client) - capture_client->ReleaseCapture(tray_->GetWidget()->GetNativeView()); - tray_->HideBubbleWithView(bubble_view_); // May destroy |bubble_view_| -} - -void TrayBubbleWrapper::OnWidgetBoundsChanged(views::Widget* widget, - const gfx::Rect& new_bounds) { - DCHECK_EQ(bubble_widget_, widget); - tray_->BubbleResized(bubble_view_); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_bubble_wrapper.h b/chromium/ash/system/tray/tray_bubble_wrapper.h deleted file mode 100644 index 9ce443a8b30..00000000000 --- a/chromium/ash/system/tray/tray_bubble_wrapper.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ -#define ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "ui/views/widget/widget_observer.h" - -namespace views { -class TrayBubbleView; -} - -namespace ash { -namespace internal { - -class TrayBackgroundView; -class TrayEventFilter; - -// Creates and manages the Widget and EventFilter components of a bubble. - -class TrayBubbleWrapper : public views::WidgetObserver { - public: - TrayBubbleWrapper(TrayBackgroundView* tray, - views::TrayBubbleView* bubble_view); - virtual ~TrayBubbleWrapper(); - - // views::WidgetObserver overrides: - virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; - virtual void OnWidgetBoundsChanged(views::Widget* widget, - const gfx::Rect& new_bounds) OVERRIDE; - - const TrayBackgroundView* tray() const { return tray_; } - TrayBackgroundView* tray() { return tray_; } - const views::TrayBubbleView* bubble_view() const { return bubble_view_; } - const views::Widget* bubble_widget() const { return bubble_widget_; } - - private: - TrayBackgroundView* tray_; - views::TrayBubbleView* bubble_view_; // unowned - views::Widget* bubble_widget_; - - DISALLOW_COPY_AND_ASSIGN(TrayBubbleWrapper); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ diff --git a/chromium/ash/system/tray/tray_constants.cc b/chromium/ash/system/tray/tray_constants.cc deleted file mode 100644 index db769ef6678..00000000000 --- a/chromium/ash/system/tray/tray_constants.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_constants.h" - -#include "ash/ash_switches.h" -#include "third_party/skia/include/core/SkColor.h" - -namespace ash { - -const int kPaddingFromRightEdgeOfScreenBottomAlignment = 7; -const int kPaddingFromBottomOfScreenBottomAlignment = 7; -const int kPaddingFromOuterEdgeOfLauncherVerticalAlignment = 8; -const int kPaddingFromInnerEdgeOfLauncherVerticalAlignment = 9; -const int kPaddingFromBottomOfScreenVerticalAlignment = 10; - -// Padding used to position the system menu relative to the status area. -const int kAlternateLayoutBubblePaddingHorizontalBottom = 6; -const int kAlternateLayoutBubblePaddingHorizontalSide = 10; -const int kAlternateLayoutBubblePaddingVerticalBottom = 3; -const int kAlternateLayoutBubblePaddingVerticalSide = 15; - -const int kPaddingFromEdgeOfShelf = 3; - -// Top inset of system tray bubble for bottom anchor alignment. -const int kTrayBubbleAnchorTopInsetBottomAnchor = 3; - -const int kTrayImageItemHorizontalPaddingBottomAlignment = 1; -const int kTrayImageItemHorizontalPaddingVerticalAlignment = 1; -const int kTrayImageItemVerticalPaddingVerticalAlignment = 1; - -const int kTrayLabelItemHorizontalPaddingBottomAlignment = 7; - -// Vertical padding between status tray items when the shelf is vertical. -const int kTrayLabelItemVerticalPaddingVerticalAlignment = 4; - -const int kTrayMenuBottomRowPadding = 5; -const int kTrayMenuBottomRowPaddingBetweenItems = -1; - -const int kTrayPopupAutoCloseDelayInSeconds = 2; -const int kTrayPopupAutoCloseDelayForTextInSeconds = 5; -const int kTrayPopupPaddingHorizontal = 18; -const int kTrayPopupPaddingBetweenItems = 10; -const int kTrayPopupTextSpacingVertical = 4; - -const int kTrayPopupItemHeight = 48; -const int kTrayPopupDetailsIconWidth = 25; -const int kTrayPopupDetailsLabelExtraLeftMargin = 8; -const int kTrayPopupScrollSeparatorHeight = 15; -const int kTrayRoundedBorderRadius = 2; -const int kTrayBarButtonWidth = 39; - -const SkColor kBackgroundColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); -const SkColor kHoverBackgroundColor = SkColorSetRGB(0xf3, 0xf3, 0xf3); -const SkColor kPublicAccountBackgroundColor = SkColorSetRGB(0xf8, 0xe5, 0xb6); -const SkColor kPublicAccountUserCardTextColor = SkColorSetRGB(0x66, 0x66, 0x66); -const SkColor kPublicAccountUserCardNameColor = SK_ColorBLACK; - -const SkColor kHeaderBackgroundColor = SkColorSetRGB(0xf5, 0xf5, 0xf5); - -const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); -const SkColor kBorderLightColor = SkColorSetRGB(0xeb, 0xeb, 0xeb); -const SkColor kButtonStrokeColor = SkColorSetRGB(0xdd, 0xdd, 0xdd); - -const SkColor kHeaderTextColorNormal = SkColorSetARGB(0x7f, 0, 0, 0); -const SkColor kHeaderTextColorHover = SkColorSetARGB(0xd3, 0, 0, 0); - -const int kTrayPopupMinWidth = 300; -const int kTrayPopupMaxWidth = 500; -const int kNotificationIconWidth = 40; -const int kNotificationButtonWidth = 32; -const int kTrayNotificationContentsWidth = kTrayPopupMinWidth - - (kNotificationIconWidth + kNotificationButtonWidth + - (kTrayPopupPaddingHorizontal / 2) * 3); -const int kTraySpacing = 8; -const int kAlternateTraySpacing = 4; -const int kShelfItemHeight = 31; -const int kAlternateShelfItemHeight = 38; - -int GetTraySpacing() { - return ash::switches::UseAlternateShelfLayout() ? - kAlternateTraySpacing : kTraySpacing; -} - -int GetShelfItemHeight() { - return ash::switches::UseAlternateShelfLayout() ? - kAlternateShelfItemHeight : kShelfItemHeight; -} - -} // namespace ash diff --git a/chromium/ash/system/tray/tray_constants.h b/chromium/ash/system/tray/tray_constants.h deleted file mode 100644 index d5187f38fa5..00000000000 --- a/chromium/ash/system/tray/tray_constants.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_ -#define ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_ - -typedef unsigned int SkColor; - -namespace ash { - -extern const int kPaddingFromRightEdgeOfScreenBottomAlignment; -extern const int kPaddingFromBottomOfScreenBottomAlignment; -extern const int kPaddingFromOuterEdgeOfLauncherVerticalAlignment; -extern const int kPaddingFromInnerEdgeOfLauncherVerticalAlignment; -extern const int kPaddingFromBottomOfScreenVerticalAlignment; - -extern const int kAlternateLayoutBubblePaddingHorizontalBottom; -extern const int kAlternateLayoutBubblePaddingHorizontalSide; -extern const int kAlternateLayoutBubblePaddingVerticalBottom; -extern const int kAlternateLayoutBubblePaddingVerticalSide; - -extern const int kPaddingFromEdgeOfShelf; -extern const int kTrayBubbleAnchorTopInsetBottomAnchor; - -extern const int kTrayImageItemHorizontalPaddingBottomAlignment; -extern const int kTrayImageItemHorizontalPaddingVerticalAlignment; -extern const int kTrayImageItemVerticalPaddingVerticalAlignment; - -extern const int kTrayLabelItemHorizontalPaddingBottomAlignment; -extern const int kTrayLabelItemVerticalPaddingVerticalAlignment; - -extern const int kTrayMenuBottomRowPadding; -extern const int kTrayMenuBottomRowPaddingBetweenItems; - -extern const int kTrayPopupAutoCloseDelayInSeconds; -extern const int kTrayPopupAutoCloseDelayForTextInSeconds; -extern const int kTrayPopupPaddingHorizontal; -extern const int kTrayPopupPaddingBetweenItems; -extern const int kTrayPopupTextSpacingVertical; - -extern const int kTrayPopupItemHeight; -extern const int kTrayPopupDetailsIconWidth; -extern const int kTrayPopupDetailsLabelExtraLeftMargin; -extern const int kTrayPopupScrollSeparatorHeight; -extern const int kTrayRoundedBorderRadius; -extern const int kTrayBarButtonWidth; - -extern const SkColor kBackgroundColor; -extern const SkColor kHoverBackgroundColor; -extern const SkColor kPublicAccountBackgroundColor; -extern const SkColor kPublicAccountUserCardTextColor; -extern const SkColor kPublicAccountUserCardNameColor; - -extern const SkColor kHeaderBackgroundColor; - -extern const SkColor kBorderDarkColor; -extern const SkColor kBorderLightColor; -extern const SkColor kButtonStrokeColor; - -extern const SkColor kHeaderTextColorNormal; -extern const SkColor kHeaderTextColorHover; - -extern const int kTrayPopupMinWidth; -extern const int kTrayPopupMaxWidth; -extern const int kNotificationIconWidth; -extern const int kNotificationButtonWidth; -extern const int kTrayNotificationContentsWidth; - -// Returns kTraySpacing or kAlternateTraySpacing as applicable -// (Determined by ash::switches::UseAlternateShelfLayout). -int GetTraySpacing(); - -// Returns kShelfItemHeight or kAlternateShelfItemHeight as applicable -// (Determined by ash::switches::UseAlternateShelfLayout). -int GetShelfItemHeight(); - -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_ diff --git a/chromium/ash/system/tray/tray_details_view.cc b/chromium/ash/system/tray/tray_details_view.cc deleted file mode 100644 index 72efe4ffe0b..00000000000 --- a/chromium/ash/system/tray/tray_details_view.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_details_view.h" - -#include "ash/system/tray/fixed_sized_scroll_view.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_constants.h" -#include "ui/gfx/canvas.h" -#include "ui/views/background.h" -#include "ui/views/border.h" -#include "ui/views/controls/scroll_view.h" -#include "ui/views/layout/box_layout.h" - -namespace ash { -namespace internal { - -class ScrollSeparator : public views::View { - public: - ScrollSeparator() {} - - virtual ~ScrollSeparator() {} - - private: - // Overriden from views::View. - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRect(gfx::Rect(0, height() / 2, width(), 1), kBorderLightColor); - } - virtual gfx::Size GetPreferredSize() OVERRIDE { - return gfx::Size(1, kTrayPopupScrollSeparatorHeight); - } - - DISALLOW_COPY_AND_ASSIGN(ScrollSeparator); -}; - -class ScrollBorder : public views::Border { - public: - ScrollBorder() {} - virtual ~ScrollBorder() {} - - void set_visible(bool visible) { visible_ = visible; } - - private: - // Overridden from views::Border. - virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE { - if (!visible_) - return; - canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1), - kBorderLightColor); - } - - virtual gfx::Insets GetInsets() const OVERRIDE { - return gfx::Insets(0, 0, 1, 0); - } - - virtual gfx::Size GetMinimumSize() const OVERRIDE { - return gfx::Size(0, 1); - } - - bool visible_; - - DISALLOW_COPY_AND_ASSIGN(ScrollBorder); -}; - -TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) - : owner_(owner), - footer_(NULL), - scroller_(NULL), - scroll_content_(NULL), - scroll_border_(NULL) { - SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, - 0, 0, 0)); - set_background(views::Background::CreateSolidBackground(kBackgroundColor)); -} - -TrayDetailsView::~TrayDetailsView() { -} - -void TrayDetailsView::CreateSpecialRow(int string_id, - ViewClickListener* listener) { - DCHECK(!footer_); - footer_ = new SpecialPopupRow(); - footer_->SetTextLabel(string_id, listener); - AddChildViewAt(footer_, child_count()); -} - -void TrayDetailsView::CreateScrollableList() { - DCHECK(!scroller_); - scroll_content_ = new views::View; - scroll_content_->SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kVertical, 0, 0, 1)); - scroller_ = new FixedSizedScrollView; - scroller_->SetContentsView(scroll_content_); - - // Note: |scroller_| takes ownership of |scroll_border_|. - scroll_border_ = new ScrollBorder; - scroller_->set_border(scroll_border_); - - AddChildView(scroller_); -} - -void TrayDetailsView::AddScrollSeparator() { - DCHECK(scroll_content_); - // Do not draw the separator if it is the very first item - // in the scrollable list. - if (scroll_content_->has_children()) - scroll_content_->AddChildView(new ScrollSeparator); -} - -void TrayDetailsView::Reset() { - RemoveAllChildViews(true); - footer_ = NULL; - scroller_ = NULL; - scroll_content_ = NULL; -} - -void TrayDetailsView::TransitionToDefaultView() { - // Cache pointer to owner in this function scope. TrayDetailsView will be - // deleted after called ShowDefaultView. - SystemTrayItem* owner = owner_; - if (footer_ && footer_->content() && footer_->content()->HasFocus()) - owner->set_restore_focus(true); - owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); - owner->set_restore_focus(false); -} - -void TrayDetailsView::Layout() { - if (!scroller_ || !footer_ || bounds().IsEmpty()) { - views::View::Layout(); - return; - } - - scroller_->set_fixed_size(gfx::Size()); - gfx::Size size = GetPreferredSize(); - - // Set the scroller to fill the space above the bottom row, so that the - // bottom row of the detailed view will always stay just above the footer. - gfx::Size scroller_size = scroll_content_->GetPreferredSize(); - scroller_->set_fixed_size(gfx::Size( - width() + scroller_->GetScrollBarWidth(), - scroller_size.height() - (size.height() - height()))); - - views::View::Layout(); - // Always make sure the footer element is bottom aligned. - gfx::Rect fbounds = footer_->bounds(); - fbounds.set_y(height() - footer_->height()); - footer_->SetBoundsRect(fbounds); -} - -void TrayDetailsView::OnPaintBorder(gfx::Canvas* canvas) { - if (scroll_border_) { - int index = GetIndexOf(scroller_); - if (index < child_count() - 1 && child_at(index + 1) != footer_) - scroll_border_->set_visible(true); - else - scroll_border_->set_visible(false); - } - - views::View::OnPaintBorder(canvas); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_details_view.h b/chromium/ash/system/tray/tray_details_view.h deleted file mode 100644 index 28e9082c58f..00000000000 --- a/chromium/ash/system/tray/tray_details_view.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ -#define ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ - -#include "ash/ash_export.h" -#include "ash/system/tray/special_popup_row.h" -#include "ui/views/view.h" - -namespace views { -class ScrollView; -} - -namespace ash { - -class SystemTrayItem; - -namespace internal { - -class FixedSizedScrollView; -class ScrollBorder; -class ViewClickListener; - -class ASH_EXPORT TrayDetailsView : public views::View { - public: - explicit TrayDetailsView(SystemTrayItem* owner); - virtual ~TrayDetailsView(); - - // Creates a row with special highlighting etc. This is typically the - // bottom-most row in the popup. - void CreateSpecialRow(int string_id, ViewClickListener* listener); - - // Creates a scrollable list. The list has a border at the bottom if there is - // any other view between the list and the footer row at the bottom. - void CreateScrollableList(); - - // Adds a separator in scrollable list. - void AddScrollSeparator(); - - // Removes (and destroys) all child views. - void Reset(); - - // Transition to default view from details view. If |footer_| has focus before - // transition, the default view should focus on the owner of this details - // view. - void TransitionToDefaultView(); - - SystemTrayItem* owner() const { return owner_; } - SpecialPopupRow* footer() const { return footer_; } - FixedSizedScrollView* scroller() const { return scroller_; } - views::View* scroll_content() const { return scroll_content_; } - - protected: - // Overridden from views::View. - virtual void Layout() OVERRIDE; - virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; - - private: - SystemTrayItem* owner_; - SpecialPopupRow* footer_; - FixedSizedScrollView* scroller_; - views::View* scroll_content_; - ScrollBorder* scroll_border_; - - DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ diff --git a/chromium/ash/system/tray/tray_details_view_unittest.cc b/chromium/ash/system/tray/tray_details_view_unittest.cc deleted file mode 100644 index c608120411a..00000000000 --- a/chromium/ash/system/tray/tray_details_view_unittest.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2013 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/tray/tray_details_view.h" - -#include "ash/root_window_controller.h" -#include "ash/shelf/shelf_widget.h" -#include "ash/shell.h" -#include "ash/system/status_area_widget.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_details_view.h" -#include "ash/system/tray/view_click_listener.h" -#include "ash/test/ash_test_base.h" -#include "base/run_loop.h" -#include "grit/ash_strings.h" -#include "ui/aura/window.h" -#include "ui/views/view.h" -#include "ui/views/widget/widget.h" - -namespace ash { -namespace test { - -namespace { - -SystemTray* GetSystemTray() { - return Shell::GetPrimaryRootWindowController()->shelf()-> - status_area_widget()->system_tray(); -} - -class TestDetailsView : public internal::TrayDetailsView, - public internal::ViewClickListener { - public: - explicit TestDetailsView(SystemTrayItem* owner) - : internal::TrayDetailsView(owner) {} - - virtual ~TestDetailsView() {} - - void CreateFooterAndFocus() { - // Uses bluetooth label for testing purpose. It can be changed to any - // string_id. - CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); - footer()->content()->RequestFocus(); - } - - // Overridden from internal::ViewClickListener: - virtual void OnViewClicked(views::View* sender) OVERRIDE {} - - private: - DISALLOW_COPY_AND_ASSIGN(TestDetailsView); -}; - -// Trivial item implementation that tracks its views for testing. -class TestItem : public SystemTrayItem { - public: - TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} - - // Overridden from SystemTrayItem: - virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { - tray_view_ = new views::View; - return tray_view_; - } - virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE { - default_view_ = new views::View; - default_view_->SetFocusable(true); - return default_view_; - } - virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE { - detailed_view_ = new TestDetailsView(this); - return detailed_view_; - } - virtual void DestroyTrayView() OVERRIDE { - tray_view_ = NULL; - } - virtual void DestroyDefaultView() OVERRIDE { - default_view_ = NULL; - } - virtual void DestroyDetailedView() OVERRIDE { - detailed_view_ = NULL; - } - - views::View* tray_view() const { return tray_view_; } - views::View* default_view() const { return default_view_; } - TestDetailsView* detailed_view() const { return detailed_view_; } - - private: - views::View* tray_view_; - views::View* default_view_; - TestDetailsView* detailed_view_; - - DISALLOW_COPY_AND_ASSIGN(TestItem); -}; - -} // namespace - -typedef AshTestBase TrayDetailsViewTest; - -TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { - SystemTray* tray = GetSystemTray(); - ASSERT_TRUE(tray->GetWidget()); - - TestItem* test_item_1 = new TestItem; - TestItem* test_item_2 = new TestItem; - tray->AddTrayItem(test_item_1); - tray->AddTrayItem(test_item_2); - - // Ensure the tray views are created. - ASSERT_TRUE(test_item_1->tray_view() != NULL); - ASSERT_TRUE(test_item_2->tray_view() != NULL); - - // Show the default view. - tray->ShowDefaultView(BUBBLE_CREATE_NEW); - RunAllPendingInMessageLoop(); - - // Show the detailed view of item 2. - tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING); - EXPECT_TRUE(test_item_2->detailed_view()); - RunAllPendingInMessageLoop(); - EXPECT_FALSE(test_item_2->default_view()); - - // Transition back to default view, the default view of item 2 should have - // focus. - test_item_2->detailed_view()->CreateFooterAndFocus(); - test_item_2->detailed_view()->TransitionToDefaultView(); - RunAllPendingInMessageLoop(); - - EXPECT_TRUE(test_item_2->default_view()); - EXPECT_FALSE(test_item_2->detailed_view()); - EXPECT_TRUE(test_item_2->default_view()->HasFocus()); - - // Show the detailed view of item 2 again. - tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING); - EXPECT_TRUE(test_item_2->detailed_view()); - RunAllPendingInMessageLoop(); - EXPECT_FALSE(test_item_2->default_view()); - - // Transition back to default view, the default view of item 2 should NOT have - // focus. - test_item_2->detailed_view()->TransitionToDefaultView(); - RunAllPendingInMessageLoop(); - - EXPECT_TRUE(test_item_2->default_view()); - EXPECT_FALSE(test_item_2->detailed_view()); - EXPECT_FALSE(test_item_2->default_view()->HasFocus()); -} - -} // namespace test -} // namespace ash diff --git a/chromium/ash/system/tray/tray_empty.cc b/chromium/ash/system/tray/tray_empty.cc deleted file mode 100644 index f15f7b31e73..00000000000 --- a/chromium/ash/system/tray/tray_empty.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_empty.h" - -#include "ui/views/layout/box_layout.h" -#include "ui/views/background.h" -#include "ui/views/border.h" -#include "ui/views/view.h" - -namespace { - -class EmptyBackground : public views::Background { - public: - EmptyBackground() {} - virtual ~EmptyBackground() {} - - private: - virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { - } - - DISALLOW_COPY_AND_ASSIGN(EmptyBackground); -}; - -} - -namespace ash { -namespace internal { - -TrayEmpty::TrayEmpty(SystemTray* system_tray) - : SystemTrayItem(system_tray) { -} - -TrayEmpty::~TrayEmpty() {} - -views::View* TrayEmpty::CreateTrayView(user::LoginStatus status) { - return NULL; -} - -views::View* TrayEmpty::CreateDefaultView(user::LoginStatus status) { - if (status == user::LOGGED_IN_NONE) - return NULL; - - views::View* view = new views::View; - view->set_background(new EmptyBackground()); - view->set_border(views::Border::CreateEmptyBorder(10, 0, 0, 0)); - view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, - 0, 0, 0)); - view->SetPaintToLayer(true); - view->SetFillsBoundsOpaquely(false); - return view; -} - -views::View* TrayEmpty::CreateDetailedView(user::LoginStatus status) { - return NULL; -} - -void TrayEmpty::DestroyTrayView() {} - -void TrayEmpty::DestroyDefaultView() {} - -void TrayEmpty::DestroyDetailedView() {} - -void TrayEmpty::UpdateAfterLoginStatusChange(user::LoginStatus status) {} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_empty.h b/chromium/ash/system/tray/tray_empty.h deleted file mode 100644 index a7575cf46e3..00000000000 --- a/chromium/ash/system/tray/tray_empty.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_EMPTY_H_ -#define ASH_SYSTEM_TRAY_TRAY_EMPTY_H_ - -#include "ash/system/tray/system_tray_item.h" - -namespace ash { -namespace internal { - -class TrayEmpty : public SystemTrayItem { - public: - explicit TrayEmpty(SystemTray* system_tray); - virtual ~TrayEmpty(); - - private: - // Overridden from SystemTrayItem. - virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; - virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; - virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; - virtual void DestroyTrayView() OVERRIDE; - virtual void DestroyDefaultView() OVERRIDE; - virtual void DestroyDetailedView() OVERRIDE; - virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(TrayEmpty); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_EMPTY_H_ diff --git a/chromium/ash/system/tray/tray_event_filter.cc b/chromium/ash/system/tray/tray_event_filter.cc deleted file mode 100644 index 676c8b6346c..00000000000 --- a/chromium/ash/system/tray/tray_event_filter.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_event_filter.h" - -#include "ash/root_window_controller.h" -#include "ash/shelf/shelf_layout_manager.h" -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/system/tray/tray_background_view.h" -#include "ash/system/tray/tray_bubble_wrapper.h" -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray/tray_event_filter.h" -#include "ui/aura/client/screen_position_client.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/views/widget/widget.h" - -namespace ash { -namespace internal { - -TrayEventFilter::TrayEventFilter() { -} - -TrayEventFilter::~TrayEventFilter() { - DCHECK(wrappers_.empty()); -} - -void TrayEventFilter::AddWrapper(TrayBubbleWrapper* wrapper) { - bool was_empty = wrappers_.empty(); - wrappers_.insert(wrapper); - if (was_empty && !wrappers_.empty()) - ash::Shell::GetInstance()->AddPreTargetHandler(this); -} - -void TrayEventFilter::RemoveWrapper(TrayBubbleWrapper* wrapper) { - wrappers_.erase(wrapper); - if (wrappers_.empty()) - ash::Shell::GetInstance()->RemovePreTargetHandler(this); -} - -void TrayEventFilter::OnMouseEvent(ui::MouseEvent* event) { - if (event->type() == ui::ET_MOUSE_PRESSED && - ProcessLocatedEvent(event)) { - event->StopPropagation(); - } -} - -void TrayEventFilter::OnTouchEvent(ui::TouchEvent* event) { - if (event->type() == ui::ET_TOUCH_PRESSED && ProcessLocatedEvent(event)) - event->StopPropagation(); -} - -bool TrayEventFilter::ProcessLocatedEvent(ui::LocatedEvent* event) { - if (event->target()) { - aura::Window* target = static_cast<aura::Window*>(event->target()); - // Don't process events that occurred inside an embedded menu. - internal::RootWindowController* root_controller = - internal::GetRootWindowController(target->GetRootWindow()); - if (root_controller && root_controller->GetContainer( - internal::kShellWindowId_MenuContainer)->Contains(target)) { - return false; - } - } - - // Check the boundary for all wrappers, and do not handle the event if it - // happens inside of any of those wrappers. - for (std::set<TrayBubbleWrapper*>::const_iterator iter = wrappers_.begin(); - iter != wrappers_.end(); ++iter) { - const TrayBubbleWrapper* wrapper = *iter; - const views::Widget* bubble_widget = wrapper->bubble_widget(); - if (!bubble_widget) - continue; - - gfx::Rect bounds = bubble_widget->GetWindowBoundsInScreen(); - bounds.Inset(wrapper->bubble_view()->GetBorderInsets()); - aura::Window* root = bubble_widget->GetNativeView()->GetRootWindow(); - aura::client::ScreenPositionClient* screen_position_client = - aura::client::GetScreenPositionClient(root); - gfx::Point screen_point(event->root_location()); - screen_position_client->ConvertPointToScreen(root, &screen_point); - - if (bounds.Contains(screen_point)) - return false; - if (wrapper->tray()) { - // If the user clicks on the parent tray, don't process the event here, - // let the tray logic handle the event and determine show/hide behavior. - bounds = wrapper->tray()->GetBoundsInScreen(); - if (bounds.Contains(screen_point)) - return false; - } - } - - // Handle clicking outside the bubble and tray and return true if the - // event was handled. - // Cannot iterate |wrappers_| directly, because clicking outside will remove - // the wrapper, which shrinks |wrappers_| unsafely. - std::set<TrayBackgroundView*> trays; - for (std::set<TrayBubbleWrapper*>::iterator iter = wrappers_.begin(); - iter != wrappers_.end(); ++iter) { - trays.insert((*iter)->tray()); - } - bool handled = false; - for (std::set<TrayBackgroundView*>::iterator iter = trays.begin(); - iter != trays.end(); ++iter) { - handled |= (*iter)->ClickedOutsideBubble(); - } - return handled; -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_event_filter.h b/chromium/ash/system/tray/tray_event_filter.h deleted file mode 100644 index 40593155c2c..00000000000 --- a/chromium/ash/system/tray/tray_event_filter.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_EVENT_FILTER_H_ -#define ASH_SYSTEM_TRAY_TRAY_EVENT_FILTER_H_ - -#include <set> - -#include "base/basictypes.h" -#include "ui/events/event.h" -#include "ui/events/event_handler.h" - -namespace aura { -class Window; -} - -namespace ash { -namespace internal { - -class TrayBubbleWrapper; - -// Handles events for a tray bubble. - -class TrayEventFilter : public ui::EventHandler { - public: - explicit TrayEventFilter(); - virtual ~TrayEventFilter(); - - void AddWrapper(TrayBubbleWrapper* wrapper); - void RemoveWrapper(TrayBubbleWrapper* wrapper); - - // Overridden from ui::EventHandler. - virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; - - private: - // Returns true if the event is handled. - bool ProcessLocatedEvent(ui::LocatedEvent* event); - - std::set<TrayBubbleWrapper*> wrappers_; - - DISALLOW_COPY_AND_ASSIGN(TrayEventFilter); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_EVENT_FILTER_H_ diff --git a/chromium/ash/system/tray/tray_image_item.cc b/chromium/ash/system/tray/tray_image_item.cc deleted file mode 100644 index 7c5e216c942..00000000000 --- a/chromium/ash/system/tray/tray_image_item.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_image_item.h" - -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/tray_item_view.h" -#include "ash/system/tray/tray_utils.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/layout/box_layout.h" - -namespace ash { -namespace internal { - -TrayImageItem::TrayImageItem(SystemTray* system_tray, int resource_id) - : SystemTrayItem(system_tray), - resource_id_(resource_id), - tray_view_(NULL) { -} - -TrayImageItem::~TrayImageItem() {} - -views::View* TrayImageItem::tray_view() { - return tray_view_; -} - -void TrayImageItem::SetImageFromResourceId(int resource_id) { - resource_id_ = resource_id; - if (!tray_view_) - return; - tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). - GetImageNamed(resource_id_).ToImageSkia()); -} - -views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) { - CHECK(tray_view_ == NULL); - tray_view_ = new TrayItemView(this); - tray_view_->CreateImageView(); - tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance(). - GetImageNamed(resource_id_).ToImageSkia()); - tray_view_->SetVisible(GetInitialVisibility()); - SetItemAlignment(system_tray()->shelf_alignment()); - return tray_view_; -} - -views::View* TrayImageItem::CreateDefaultView(user::LoginStatus status) { - return NULL; -} - -views::View* TrayImageItem::CreateDetailedView(user::LoginStatus status) { - return NULL; -} - -void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) { -} - -void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { - SetTrayImageItemBorder(tray_view_, alignment); - SetItemAlignment(alignment); -} - -void TrayImageItem::DestroyTrayView() { - tray_view_ = NULL; -} - -void TrayImageItem::DestroyDefaultView() { -} - -void TrayImageItem::DestroyDetailedView() { -} - -void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) { - // Center the item dependent on the orientation of the shelf. - views::BoxLayout::Orientation layout = views::BoxLayout::kHorizontal; - switch (alignment) { - case ash::SHELF_ALIGNMENT_BOTTOM: - case ash::SHELF_ALIGNMENT_TOP: - layout = views::BoxLayout::kHorizontal; - break; - case ash::SHELF_ALIGNMENT_LEFT: - case ash::SHELF_ALIGNMENT_RIGHT: - layout = views::BoxLayout::kVertical; - break; - } - tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); - tray_view_->Layout(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_image_item.h b/chromium/ash/system/tray/tray_image_item.h deleted file mode 100644 index 6dea5c8372f..00000000000 --- a/chromium/ash/system/tray/tray_image_item.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_IMAGE_ITEM_H_ -#define ASH_SYSTEM_TRAY_TRAY_IMAGE_ITEM_H_ - -#include "ash/system/tray/system_tray_item.h" - -namespace views { -class ImageView; -} - -namespace ash { -namespace internal { - -class TrayItemView; - -class TrayImageItem : public SystemTrayItem { - public: - TrayImageItem(SystemTray* system_tray, int resource_id); - virtual ~TrayImageItem(); - - views::View* tray_view(); - - // Changes the icon of the tray-view to the specified resource. - void SetImageFromResourceId(int resource_id); - - protected: - virtual bool GetInitialVisibility() = 0; - - // Overridden from SystemTrayItem. - virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; - virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; - virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; - virtual void DestroyTrayView() OVERRIDE; - virtual void DestroyDefaultView() OVERRIDE; - virtual void DestroyDetailedView() OVERRIDE; - virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE; - virtual void UpdateAfterShelfAlignmentChange( - ShelfAlignment alignment) OVERRIDE; - - private: - // Set the alignment of the image depending on the shelf alignment. - void SetItemAlignment(ShelfAlignment alignment); - - int resource_id_; - TrayItemView* tray_view_; - - DISALLOW_COPY_AND_ASSIGN(TrayImageItem); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_IMAGE_ITEM_H_ diff --git a/chromium/ash/system/tray/tray_item_more.cc b/chromium/ash/system/tray/tray_item_more.cc deleted file mode 100644 index 9284b47d053..00000000000 --- a/chromium/ash/system/tray/tray_item_more.cc +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_item_more.h" - -#include "ash/system/tray/fixed_sized_image_view.h" -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_constants.h" -#include "grit/ash_resources.h" -#include "ui/base/accessibility/accessible_view_state.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/box_layout.h" - -namespace ash { -namespace internal { - -TrayItemMore::TrayItemMore(SystemTrayItem* owner, bool show_more) - : owner_(owner), - show_more_(show_more), - icon_(NULL), - label_(NULL), - more_(NULL) { - SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, - kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems)); - - icon_ = new FixedSizedImageView(0, kTrayPopupItemHeight); - AddChildView(icon_); - - label_ = new views::Label; - label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - AddChildView(label_); - - if (show_more) { - more_ = new views::ImageView; - more_->EnableCanvasFlippingForRTLUI(true); - more_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_AURA_UBER_TRAY_MORE).ToImageSkia()); - AddChildView(more_); - } -} - -TrayItemMore::~TrayItemMore() { -} - -void TrayItemMore::SetLabel(const base::string16& label) { - label_->SetText(label); - Layout(); - SchedulePaint(); -} - -void TrayItemMore::SetImage(const gfx::ImageSkia* image_skia) { - icon_->SetImage(image_skia); - SchedulePaint(); -} - -void TrayItemMore::SetAccessibleName(const base::string16& name) { - accessible_name_ = name; -} - -void TrayItemMore::ReplaceIcon(views::View* view) { - delete icon_; - icon_ = NULL; - AddChildViewAt(view, 0); -} - -bool TrayItemMore::PerformAction(const ui::Event& event) { - if (!show_more_) - return false; - - owner()->TransitionDetailedView(); - return true; -} - -void TrayItemMore::Layout() { - // Let the box-layout do the layout first. Then move the '>' arrow to right - // align. - views::View::Layout(); - - if (!show_more_) - return; - - // Make sure the chevron always has the full size. - gfx::Size size = more_->GetPreferredSize(); - gfx::Rect bounds(size); - bounds.set_x(width() - size.width() - kTrayPopupPaddingBetweenItems); - bounds.set_y((height() - size.height()) / 2); - more_->SetBoundsRect(bounds); - - // Adjust the label's bounds in case it got cut off by |more_|. - if (label_->bounds().Intersects(more_->bounds())) { - gfx::Rect bounds = label_->bounds(); - bounds.set_width(more_->x() - kTrayPopupPaddingBetweenItems - label_->x()); - label_->SetBoundsRect(bounds); - } -} - -void TrayItemMore::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = accessible_name_; -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_item_more.h b/chromium/ash/system/tray/tray_item_more.h deleted file mode 100644 index 49287240d40..00000000000 --- a/chromium/ash/system/tray/tray_item_more.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ -#define ASH_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ - -#include "ash/system/tray/actionable_view.h" -#include "ui/views/view.h" - -namespace views { -class ImageView; -class Label; -class View; -} - -namespace ash { - -class SystemTrayItem; - -namespace internal { - -// A view with a chevron ('>') on the right edge. Clicking on the view brings up -// the detailed view of the tray-item that owns it. -class TrayItemMore : public ActionableView { - public: - TrayItemMore(SystemTrayItem* owner, bool show_more); - virtual ~TrayItemMore(); - - SystemTrayItem* owner() const { return owner_; } - - void SetLabel(const base::string16& label); - void SetImage(const gfx::ImageSkia* image_skia); - void SetAccessibleName(const base::string16& name); - - protected: - // Replaces the default icon (on the left of the label), and allows a custom - // view to be placed there. Once the default icon is replaced, |SetImage| - // should never be called. - void ReplaceIcon(views::View* view); - - private: - // Overridden from ActionableView. - virtual bool PerformAction(const ui::Event& event) OVERRIDE; - - // Overridden from views::View. - virtual void Layout() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - - SystemTrayItem* owner_; - // True if |more_| should be shown. - bool show_more_; - views::ImageView* icon_; - views::Label* label_; - views::ImageView* more_; - base::string16 accessible_name_; - - DISALLOW_COPY_AND_ASSIGN(TrayItemMore); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_ITEM_MORE_H_ diff --git a/chromium/ash/system/tray/tray_item_view.cc b/chromium/ash/system/tray/tray_item_view.cc deleted file mode 100644 index 9a7a75c4378..00000000000 --- a/chromium/ash/system/tray/tray_item_view.cc +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_item_view.h" - -#include "ash/shelf/shelf_types.h" -#include "ash/system/tray/system_tray.h" -#include "ash/system/tray/system_tray_item.h" -#include "ui/compositor/layer.h" -#include "ui/gfx/animation/slide_animation.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/controls/label.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/widget/widget.h" - -namespace { -const int kTrayIconHeight = 29; -const int kTrayIconWidth = 29; -const int kTrayItemAnimationDurationMS = 200; - -// Animations can be disabled for testing. -bool animations_enabled = true; -} - -namespace ash { -namespace internal { - -TrayItemView::TrayItemView(SystemTrayItem* owner) - : owner_(owner), - label_(NULL), - image_view_(NULL) { - SetPaintToLayer(true); - SetFillsBoundsOpaquely(false); - SetLayoutManager( - new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); -} - -TrayItemView::~TrayItemView() {} - -// static -void TrayItemView::DisableAnimationsForTest() { - animations_enabled = false; -} - -void TrayItemView::CreateLabel() { - label_ = new views::Label; - AddChildView(label_); -} - -void TrayItemView::CreateImageView() { - image_view_ = new views::ImageView; - AddChildView(image_view_); -} - -void TrayItemView::SetVisible(bool set_visible) { - if (!GetWidget() || !animations_enabled) { - views::View::SetVisible(set_visible); - return; - } - - if (!animation_) { - animation_.reset(new gfx::SlideAnimation(this)); - animation_->SetSlideDuration(GetAnimationDurationMS()); - animation_->SetTweenType(gfx::Tween::LINEAR); - animation_->Reset(visible() ? 1.0 : 0.0); - } - - if (!set_visible) { - animation_->Hide(); - AnimationProgressed(animation_.get()); - } else { - animation_->Show(); - AnimationProgressed(animation_.get()); - views::View::SetVisible(true); - } -} - -gfx::Size TrayItemView::DesiredSize() { - return views::View::GetPreferredSize(); -} - -int TrayItemView::GetAnimationDurationMS() { - return kTrayItemAnimationDurationMS; -} - -gfx::Size TrayItemView::GetPreferredSize() { - gfx::Size size = DesiredSize(); - if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || - owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) - size.set_height(kTrayIconHeight); - else - size.set_width(kTrayIconWidth); - if (!animation_.get() || !animation_->is_animating()) - return size; - if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || - owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) { - size.set_width(std::max(1, - static_cast<int>(size.width() * animation_->GetCurrentValue()))); - } else { - size.set_height(std::max(1, - static_cast<int>(size.height() * animation_->GetCurrentValue()))); - } - return size; -} - -int TrayItemView::GetHeightForWidth(int width) { - return GetPreferredSize().height(); -} - -void TrayItemView::ChildPreferredSizeChanged(views::View* child) { - PreferredSizeChanged(); -} - -void TrayItemView::AnimationProgressed(const gfx::Animation* animation) { - gfx::Transform transform; - if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM || - owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) { - transform.Translate(0, animation->CurrentValueBetween( - static_cast<double>(height()) / 2, 0.)); - } else { - transform.Translate(animation->CurrentValueBetween( - static_cast<double>(width() / 2), 0.), 0); - } - transform.Scale(animation->GetCurrentValue(), - animation->GetCurrentValue()); - layer()->SetTransform(transform); - PreferredSizeChanged(); -} - -void TrayItemView::AnimationEnded(const gfx::Animation* animation) { - if (animation->GetCurrentValue() < 0.1) - views::View::SetVisible(false); -} - -void TrayItemView::AnimationCanceled(const gfx::Animation* animation) { - AnimationEnded(animation); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_item_view.h b/chromium/ash/system/tray/tray_item_view.h deleted file mode 100644 index 761e918791c..00000000000 --- a/chromium/ash/system/tray/tray_item_view.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ -#define ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ - -#include "ash/ash_export.h" -#include "ui/gfx/animation/animation_delegate.h" -#include "ui/views/view.h" - -namespace gfx { -class SlideAnimation; -} - -namespace views { -class ImageView; -class Label; -} - -namespace ash { - -class SystemTrayItem; - -namespace internal { - -// Base-class for items in the tray. It makes sure the widget is updated -// correctly when the visibility/size of the tray item changes. It also adds -// animation when showing/hiding the item in the tray. -class ASH_EXPORT TrayItemView : public views::View, - public gfx::AnimationDelegate { - public: - explicit TrayItemView(SystemTrayItem* owner); - virtual ~TrayItemView(); - - static void DisableAnimationsForTest(); - - // Convenience function for creating a child Label or ImageView. - void CreateLabel(); - void CreateImageView(); - - SystemTrayItem* owner() const { return owner_; } - views::Label* label() const { return label_; } - views::ImageView* image_view() const { return image_view_; } - - // Overridden from views::View. - virtual void SetVisible(bool visible) OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual int GetHeightForWidth(int width) OVERRIDE; - - protected: - // Makes sure the widget relayouts after the size/visibility of the view - // changes. - void ApplyChange(); - - // This should return the desired size of the view. For most views, this - // returns GetPreferredSize. But since this class overrides GetPreferredSize - // for animation purposes, we allow a different way to get this size, and do - // not allow GetPreferredSize to be overridden. - virtual gfx::Size DesiredSize(); - - // The default animation duration is 200ms. But each view can customize this. - virtual int GetAnimationDurationMS(); - - private: - // Overridden from views::View. - virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; - - // Overridden from gfx::AnimationDelegate. - virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; - virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; - virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; - - SystemTrayItem* owner_; - scoped_ptr<gfx::SlideAnimation> animation_; - views::Label* label_; - views::ImageView* image_view_; - - DISALLOW_COPY_AND_ASSIGN(TrayItemView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ diff --git a/chromium/ash/system/tray/tray_notification_view.cc b/chromium/ash/system/tray/tray_notification_view.cc deleted file mode 100644 index c09589285ea..00000000000 --- a/chromium/ash/system/tray/tray_notification_view.cc +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_notification_view.h" - -#include "ash/system/tray/system_tray_item.h" -#include "ash/system/tray/tray_constants.h" -#include "grit/ash_strings.h" -#include "grit/ui_resources.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/views/background.h" -#include "ui/views/controls/button/image_button.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/layout/grid_layout.h" - -namespace ash { -namespace internal { - -TrayNotificationView::TrayNotificationView(SystemTrayItem* owner, int icon_id) - : owner_(owner), - icon_id_(icon_id), - icon_(NULL) { -} - -TrayNotificationView::~TrayNotificationView() { -} - -void TrayNotificationView::InitView(views::View* contents) { - set_background(views::Background::CreateSolidBackground(kBackgroundColor)); - - views::GridLayout* layout = new views::GridLayout(this); - SetLayoutManager(layout); - - views::ImageButton* close_button = new views::ImageButton(this); - close_button->SetImage(views::CustomButton::STATE_NORMAL, - ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - IDR_MESSAGE_CLOSE)); - close_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_MIDDLE); - - icon_ = new views::ImageView; - if (icon_id_ != 0) { - icon_->SetImage( - ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_)); - } - - views::ColumnSet* columns = layout->AddColumnSet(0); - - columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); - - // Icon - columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, - 0, /* resize percent */ - views::GridLayout::FIXED, - kNotificationIconWidth, kNotificationIconWidth); - - columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); - - // Contents - columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, - 100, /* resize percent */ - views::GridLayout::FIXED, - kTrayNotificationContentsWidth, - kTrayNotificationContentsWidth); - - columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); - - // Close button - columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, - 0, /* resize percent */ - views::GridLayout::FIXED, - kNotificationButtonWidth, kNotificationButtonWidth); - - // Layout rows - layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); - layout->StartRow(0, 0); - layout->AddView(icon_); - layout->AddView(contents); - layout->AddView(close_button); - layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); -} - -void TrayNotificationView::SetIconImage(const gfx::ImageSkia& image) { - icon_->SetImage(image); - SchedulePaint(); -} - -const gfx::ImageSkia& TrayNotificationView::GetIconImage() const { - return icon_->GetImage(); -} - -void TrayNotificationView::UpdateView(views::View* new_contents) { - RemoveAllChildViews(true); - InitView(new_contents); - Layout(); - PreferredSizeChanged(); - SchedulePaint(); -} - -void TrayNotificationView::UpdateViewAndImage(views::View* new_contents, - const gfx::ImageSkia& image) { - RemoveAllChildViews(true); - InitView(new_contents); - icon_->SetImage(image); - Layout(); - PreferredSizeChanged(); - SchedulePaint(); -} - -void TrayNotificationView::StartAutoCloseTimer(int seconds) { - autoclose_.Stop(); - autoclose_delay_ = seconds; - if (autoclose_delay_) { - autoclose_.Start(FROM_HERE, - base::TimeDelta::FromSeconds(autoclose_delay_), - this, &TrayNotificationView::HandleClose); - } -} - -void TrayNotificationView::StopAutoCloseTimer() { - autoclose_.Stop(); -} - -void TrayNotificationView::RestartAutoCloseTimer() { - if (autoclose_delay_) - StartAutoCloseTimer(autoclose_delay_); -} - -void TrayNotificationView::ButtonPressed(views::Button* sender, - const ui::Event& event) { - HandleClose(); -} - -bool TrayNotificationView::OnMousePressed(const ui::MouseEvent& event) { - HandleClickAction(); - return true; -} - -void TrayNotificationView::OnGestureEvent(ui::GestureEvent* event) { - SlideOutView::OnGestureEvent(event); - if (event->handled()) - return; - if (event->type() != ui::ET_GESTURE_TAP) - return; - HandleClickAction(); - event->SetHandled(); -} - -void TrayNotificationView::OnClose() { -} - -void TrayNotificationView::OnClickAction() { -} - -void TrayNotificationView::OnSlideOut() { - owner_->HideNotificationView(); -} - -void TrayNotificationView::HandleClose() { - OnClose(); - owner_->HideNotificationView(); -} - -void TrayNotificationView::HandleClickAction() { - HandleClose(); - OnClickAction(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_notification_view.h b/chromium/ash/system/tray/tray_notification_view.h deleted file mode 100644 index 314b8aad7d2..00000000000 --- a/chromium/ash/system/tray/tray_notification_view.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_ -#define ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_ - -#include "base/timer/timer.h" -#include "ui/views/controls/button/image_button.h" -#include "ui/views/controls/slide_out_view.h" - -namespace gfx { -class ImageSkia; -} - -namespace views { -class ImageView; -} - -namespace ash { - -class SystemTrayItem; - -namespace internal { - -// A view for closable notification views, laid out like: -// ------------------- -// | icon contents x | -// ----------------v-- -// The close button will call OnClose() when clicked. -class TrayNotificationView : public views::SlideOutView, - public views::ButtonListener { - public: - // If icon_id is 0, no icon image will be set. SetIconImage can be called - // to later set the icon image. - TrayNotificationView(SystemTrayItem* owner, int icon_id); - virtual ~TrayNotificationView(); - - // InitView must be called once with the contents to be displayed. - void InitView(views::View* contents); - - // Sets/updates the icon image. - void SetIconImage(const gfx::ImageSkia& image); - - // Gets the icons image. - const gfx::ImageSkia& GetIconImage() const; - - // Replaces the contents view. - void UpdateView(views::View* new_contents); - - // Replaces the contents view and updates the icon image. - void UpdateViewAndImage(views::View* new_contents, - const gfx::ImageSkia& image); - - // Autoclose timer operations. - void StartAutoCloseTimer(int seconds); - void StopAutoCloseTimer(); - void RestartAutoCloseTimer(); - - // Overridden from ButtonListener. - virtual void ButtonPressed(views::Button* sender, - const ui::Event& event) OVERRIDE; - - // Overridden from views::View. - virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; - - // Overridden from ui::EventHandler. - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - - protected: - // Called when the close button is pressed. Does nothing by default. - virtual void OnClose(); - // Called when the notification is clicked on. Does nothing by default. - virtual void OnClickAction(); - - // Overridden from views::SlideOutView. - virtual void OnSlideOut() OVERRIDE; - - SystemTrayItem* owner() { return owner_; } - - private: - void HandleClose(); - void HandleClickAction(); - - SystemTrayItem* owner_; - int icon_id_; - views::ImageView* icon_; - - int autoclose_delay_; - base::OneShotTimer<TrayNotificationView> autoclose_; - - DISALLOW_COPY_AND_ASSIGN(TrayNotificationView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_ diff --git a/chromium/ash/system/tray/tray_popup_header_button.cc b/chromium/ash/system/tray/tray_popup_header_button.cc deleted file mode 100644 index d19cbc54823..00000000000 --- a/chromium/ash/system/tray/tray_popup_header_button.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 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/tray/tray_popup_header_button.h" - -#include "ash/ash_constants.h" -#include "ash/system/tray/tray_constants.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/views/painter.h" - -namespace ash { -namespace internal { - -// static -const char TrayPopupHeaderButton::kViewClassName[] = - "tray/TrayPopupHeaderButton"; - -TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener, - int enabled_resource_id, - int disabled_resource_id, - int enabled_resource_id_hover, - int disabled_resource_id_hover, - int accessible_name_id) - : views::ToggleImageButton(listener) { - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - SetImage(views::Button::STATE_NORMAL, - bundle.GetImageNamed(enabled_resource_id).ToImageSkia()); - SetToggledImage(views::Button::STATE_NORMAL, - bundle.GetImageNamed(disabled_resource_id).ToImageSkia()); - SetImage(views::Button::STATE_HOVERED, - bundle.GetImageNamed(enabled_resource_id_hover).ToImageSkia()); - SetToggledImage(views::Button::STATE_HOVERED, - bundle.GetImageNamed(disabled_resource_id_hover).ToImageSkia()); - SetImageAlignment(views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_MIDDLE); - SetAccessibleName(bundle.GetLocalizedString(accessible_name_id)); - SetFocusable(true); - set_request_focus_on_press(false); - - SetFocusPainter(views::Painter::CreateSolidFocusPainter( - kFocusBorderColor, - gfx::Insets(1, 2, 2, 3))); -} - -TrayPopupHeaderButton::~TrayPopupHeaderButton() {} - -const char* TrayPopupHeaderButton::GetClassName() const { - return kViewClassName; -} - -gfx::Size TrayPopupHeaderButton::GetPreferredSize() { - return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight); -} - -void TrayPopupHeaderButton::OnPaintBorder(gfx::Canvas* canvas) { - // Just the left border. - const int kBorderHeight = 25; - int padding = (height() - kBorderHeight) / 2; - canvas->FillRect(gfx::Rect(0, padding, 1, height() - padding * 2), - ash::kBorderDarkColor); -} - -void TrayPopupHeaderButton::StateChanged() { - SchedulePaint(); -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_popup_header_button.h b/chromium/ash/system/tray/tray_popup_header_button.h deleted file mode 100644 index 37849bc2e97..00000000000 --- a/chromium/ash/system/tray/tray_popup_header_button.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_POPUP_HEADER_BUTTON_H_ -#define ASH_SYSTEM_TRAY_TRAY_POPUP_HEADER_BUTTON_H_ - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/button/image_button.h" - -namespace ash { -namespace internal { - -// A ToggleImageButton with fixed size, paddings and hover effects. These -// buttons are used in the header. -class ASH_EXPORT TrayPopupHeaderButton : public views::ToggleImageButton { - public: - static const char kViewClassName[]; - - TrayPopupHeaderButton(views::ButtonListener* listener, - int enabled_resource_id, - int disabled_resource_id, - int enabled_resource_id_hover, - int disabled_resource_id_hover, - int accessible_name_id); - virtual ~TrayPopupHeaderButton(); - - private: - // Overridden from views::View: - virtual const char* GetClassName() const OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; - - // Overridden from views::CustomButton: - virtual void StateChanged() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(TrayPopupHeaderButton); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_POPUP_HEADER_BUTTON_H_ diff --git a/chromium/ash/system/tray/tray_popup_label_button.cc b/chromium/ash/system/tray/tray_popup_label_button.cc deleted file mode 100644 index 5b00c02a060..00000000000 --- a/chromium/ash/system/tray/tray_popup_label_button.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 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/tray/tray_popup_label_button.h" - -#include "ash/ash_constants.h" -#include "ash/system/tray/tray_popup_label_button_border.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/rect.h" -#include "ui/views/painter.h" - -namespace ash { -namespace internal { - -TrayPopupLabelButton::TrayPopupLabelButton(views::ButtonListener* listener, - const base::string16& text) - : views::LabelButton(listener, text) { - set_border(new TrayPopupLabelButtonBorder); - SetFocusable(true); - set_request_focus_on_press(false); - set_animate_on_state_change(false); - SetHorizontalAlignment(gfx::ALIGN_CENTER); - SetFocusPainter(views::Painter::CreateSolidFocusPainter( - kFocusBorderColor, - gfx::Insets(1, 1, 2, 2))); -} - -TrayPopupLabelButton::~TrayPopupLabelButton() {} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_popup_label_button.h b/chromium/ash/system/tray/tray_popup_label_button.h deleted file mode 100644 index a1f9db6b7b4..00000000000 --- a/chromium/ash/system/tray/tray_popup_label_button.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_H_ -#define ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/strings/string16.h" -#include "ui/views/controls/button/label_button.h" - -namespace ash { -namespace internal { - -// A label button with custom alignment, border and focus border. -class TrayPopupLabelButton : public views::LabelButton { - public: - TrayPopupLabelButton(views::ButtonListener* listener, - const base::string16& text); - virtual ~TrayPopupLabelButton(); - - private: - DISALLOW_COPY_AND_ASSIGN(TrayPopupLabelButton); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_H_ diff --git a/chromium/ash/system/tray/tray_popup_label_button_border.cc b/chromium/ash/system/tray/tray_popup_label_button_border.cc deleted file mode 100644 index d5be6bcc324..00000000000 --- a/chromium/ash/system/tray/tray_popup_label_button_border.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2013 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/tray/tray_popup_label_button_border.h" - -#include "base/i18n/rtl.h" -#include "grit/ash_resources.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/vector2d.h" -#include "ui/native_theme/native_theme.h" -#include "ui/views/controls/button/label_button.h" -#include "ui/views/native_theme_delegate.h" - -namespace ash { -namespace internal { - -TrayPopupLabelButtonBorder::TrayPopupLabelButtonBorder() - : LabelButtonBorder(views::Button::STYLE_TEXTBUTTON) { - const int kTrayPopupLabelButtonBorderImagesNormal[] = { - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, - }; - SetPainter(false, views::Button::STATE_NORMAL, - views::Painter::CreateImageGridPainter( - kTrayPopupLabelButtonBorderImagesNormal)); - SetPainter(false, views::Button::STATE_DISABLED, - views::Painter::CreateImageGridPainter( - kTrayPopupLabelButtonBorderImagesNormal)); - - const int kTrayPopupLabelButtonBorderImagesHovered[] = { - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_HOVER_BACKGROUND, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER, - }; - SetPainter(false, views::Button::STATE_HOVERED, - views::Painter::CreateImageGridPainter( - kTrayPopupLabelButtonBorderImagesHovered)); - SetPainter(false, views::Button::STATE_PRESSED, - views::Painter::CreateImageGridPainter( - kTrayPopupLabelButtonBorderImagesHovered)); - - const int kTrayPopupLabelButtonPaddingHorizontal = 16; - const int kTrayPopupLabelButtonPaddingVertical = 8; - set_insets(gfx::Insets(kTrayPopupLabelButtonPaddingVertical, - kTrayPopupLabelButtonPaddingHorizontal, - kTrayPopupLabelButtonPaddingVertical, - kTrayPopupLabelButtonPaddingHorizontal)); -} - -TrayPopupLabelButtonBorder::~TrayPopupLabelButtonBorder() {} - -void TrayPopupLabelButtonBorder::Paint(const views::View& view, - gfx::Canvas* canvas) { - const views::NativeThemeDelegate* native_theme_delegate = - static_cast<const views::LabelButton*>(&view); - ui::NativeTheme::ExtraParams extra; - const ui::NativeTheme::State state = - native_theme_delegate->GetThemeState(&extra); - if (state == ui::NativeTheme::kNormal || - state == ui::NativeTheme::kDisabled) { - // In normal and disabled state, the border is a vertical bar separating the - // button from the preceding sibling. If this button is its parent's first - // visible child, the separator bar should be omitted. - const views::View* first_visible_child = NULL; - for (int i = 0; i < view.parent()->child_count(); ++i) { - const views::View* child = view.parent()->child_at(i); - if (child->visible()) { - first_visible_child = child; - break; - } - } - if (first_visible_child == &view) - return; - } - if (base::i18n::IsRTL()) { - canvas->Save(); - canvas->Translate(gfx::Vector2d(view.width(), 0)); - canvas->Scale(-1, 1); - LabelButtonBorder::Paint(view, canvas); - canvas->Restore(); - } else { - LabelButtonBorder::Paint(view, canvas); - } -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_popup_label_button_border.h b/chromium/ash/system/tray/tray_popup_label_button_border.h deleted file mode 100644 index 04e5c7356d8..00000000000 --- a/chromium/ash/system/tray/tray_popup_label_button_border.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_BORDER_H_ -#define ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_BORDER_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/button/label_button_border.h" - -namespace ash { -namespace internal { - -// A border for label buttons that paints a vertical separator in normal state -// and a custom hover effect in hovered or pressed state. -class TrayPopupLabelButtonBorder : public views::LabelButtonBorder { - public: - TrayPopupLabelButtonBorder(); - virtual ~TrayPopupLabelButtonBorder(); - - // views::LabelButtonBorder: - virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(TrayPopupLabelButtonBorder); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_POPUP_LABEL_BUTTON_BORDER_H_ diff --git a/chromium/ash/system/tray/tray_utils.cc b/chromium/ash/system/tray/tray_utils.cc deleted file mode 100644 index 34582b6fb5e..00000000000 --- a/chromium/ash/system/tray/tray_utils.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 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/tray/tray_utils.h" - -#include "ash/system/tray/tray_constants.h" -#include "ash/system/tray/tray_item_view.h" -#include "ui/gfx/font.h" -#include "ui/views/border.h" -#include "ui/views/controls/label.h" - -namespace ash { -namespace internal { - -void SetupLabelForTray(views::Label* label) { - // Making label_font static to avoid the time penalty of DeriveFont for - // all but the first call. - static const gfx::Font label_font(gfx::Font().DeriveFont(1, gfx::Font::BOLD)); - label->SetFont(label_font); - label->SetAutoColorReadabilityEnabled(false); - label->SetEnabledColor(SK_ColorWHITE); - label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255)); - label->SetShadowColors(SkColorSetARGB(64, 0, 0, 0), - SkColorSetARGB(64, 0, 0, 0)); - label->SetShadowOffset(0, 1); -} - -void SetTrayImageItemBorder(views::View* tray_view, - ShelfAlignment alignment) { - if (alignment == SHELF_ALIGNMENT_BOTTOM || - alignment == SHELF_ALIGNMENT_TOP) { - tray_view->set_border(views::Border::CreateEmptyBorder( - 0, kTrayImageItemHorizontalPaddingBottomAlignment, - 0, kTrayImageItemHorizontalPaddingBottomAlignment)); - } else { - tray_view->set_border(views::Border::CreateEmptyBorder( - kTrayImageItemVerticalPaddingVerticalAlignment, - kTrayImageItemHorizontalPaddingVerticalAlignment, - kTrayImageItemVerticalPaddingVerticalAlignment, - kTrayImageItemHorizontalPaddingVerticalAlignment)); - } -} - -void SetTrayLabelItemBorder(TrayItemView* tray_view, - ShelfAlignment alignment) { - if (alignment == SHELF_ALIGNMENT_BOTTOM || - alignment == SHELF_ALIGNMENT_TOP) { - tray_view->set_border(views::Border::CreateEmptyBorder( - 0, kTrayLabelItemHorizontalPaddingBottomAlignment, - 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); - } else { - // Center the label for vertical launcher alignment. - int horizontal_padding = std::max(0, - (tray_view->GetPreferredSize().width() - - tray_view->label()->GetPreferredSize().width()) / 2); - tray_view->set_border(views::Border::CreateEmptyBorder( - kTrayLabelItemVerticalPaddingVerticalAlignment, - horizontal_padding, - kTrayLabelItemVerticalPaddingVerticalAlignment, - horizontal_padding)); - } -} - -} // namespace internal -} // namespace ash diff --git a/chromium/ash/system/tray/tray_utils.h b/chromium/ash/system/tray/tray_utils.h deleted file mode 100644 index 412fb97d8da..00000000000 --- a/chromium/ash/system/tray/tray_utils.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef ASH_SYSTEM_TRAY_TRAY_UTILS_H_ -#define ASH_SYSTEM_TRAY_TRAY_UTILS_H_ - -#include "ash/shelf/shelf_types.h" - -namespace views { -class Label; -class View; -} - -namespace ash { -namespace internal { - -class TrayItemView; - -// Sets up a Label properly for the tray (sets color, font etc.). -void SetupLabelForTray(views::Label* label); - -// TODO(jennyz): refactor these two functions to SystemTrayItem. -// Sets the empty border of an image tray item for adjusting the space -// around it. -void SetTrayImageItemBorder(views::View* tray_view, ShelfAlignment alignment); -// Sets the empty border around a label tray item for adjusting the space -// around it. -void SetTrayLabelItemBorder(TrayItemView* tray_view, - ShelfAlignment alignment); - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_TRAY_UTILS_H_ diff --git a/chromium/ash/system/tray/view_click_listener.h b/chromium/ash/system/tray/view_click_listener.h deleted file mode 100644 index b5f4bb886f0..00000000000 --- a/chromium/ash/system/tray/view_click_listener.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 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. - -#ifndef ASH_SYSTEM_TRAY_VIEW_CLICK_LISTENER_H_ -#define ASH_SYSTEM_TRAY_VIEW_CLICK_LISTENER_H_ - -namespace views { -class View; -} - -namespace ash { -namespace internal { - -class ViewClickListener { - public: - virtual void OnViewClicked(views::View* sender) = 0; - - protected: - virtual ~ViewClickListener() {} -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SYSTEM_TRAY_VIEW_CLICK_LISTENER_H_ |