Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/shelf/shelf_types.h" | 7 #include "ash/shelf/shelf_types.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | |
| 9 #include "ash/system/tray/tray_utils.h" | 10 #include "ash/system/tray/tray_utils.h" |
| 10 #include "ash/wm/overview/window_selector_controller.h" | 11 #include "ash/wm/overview/window_selector_controller.h" |
| 11 #include "grit/ash_resources.h" | 12 #include "grit/ash_resources.h" |
| 12 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
| 16 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 icon_(NULL) { | 35 icon_(NULL) { |
| 35 SetContentsBackground(); | 36 SetContentsBackground(); |
| 36 | 37 |
| 37 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 38 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 38 icon_ = new views::ImageView(); | 39 icon_ = new views::ImageView(); |
| 39 icon_->SetImage( | 40 icon_->SetImage( |
| 40 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_OVERVIEW_MODE).ToImageSkia()); | 41 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_OVERVIEW_MODE).ToImageSkia()); |
| 41 SetIconBorderForShelfAlignment(); | 42 SetIconBorderForShelfAlignment(); |
| 42 tray_container()->AddChildView(icon_); | 43 tray_container()->AddChildView(icon_); |
| 43 | 44 |
| 44 SetVisible(Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled()); | 45 SetIconVisibility(Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled()); |
| 45 | 46 |
| 46 Shell::GetInstance()->AddShellObserver(this); | 47 Shell::GetInstance()->AddShellObserver(this); |
| 47 } | 48 } |
| 48 | 49 |
| 49 OverviewButtonTray::~OverviewButtonTray() { | 50 OverviewButtonTray::~OverviewButtonTray() { |
| 50 Shell::GetInstance()->RemoveShellObserver(this); | 51 Shell::GetInstance()->RemoveShellObserver(this); |
| 51 } | 52 } |
| 52 | 53 |
| 53 bool OverviewButtonTray::PerformAction(const ui::Event& event) { | 54 bool OverviewButtonTray::PerformAction(const ui::Event& event) { |
| 54 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); | 55 Shell::GetInstance()->window_selector_controller()->ToggleOverview(); |
| 55 return true; | 56 return true; |
| 56 } | 57 } |
| 57 | 58 |
| 58 void OverviewButtonTray::OnMaximizeModeStarted() { | 59 void OverviewButtonTray::OnMaximizeModeStarted() { |
| 59 SetVisible(true); | 60 SetIconVisibility(true); |
|
flackr
2014/03/28 16:56:40
nit: Comment what argument is for clarity: i.e.
Se
jonross
2014/03/28 19:39:01
Done.
| |
| 60 } | 61 } |
| 61 | 62 |
| 62 void OverviewButtonTray::OnMaximizeModeEnded() { | 63 void OverviewButtonTray::OnMaximizeModeEnded() { |
| 63 SetVisible(false); | 64 SetIconVisibility(false); |
|
flackr
2014/03/28 16:56:40
And here.
jonross
2014/03/28 19:39:01
Done.
| |
| 64 } | 65 } |
| 65 | 66 |
| 66 bool OverviewButtonTray::ClickedOutsideBubble() { | 67 bool OverviewButtonTray::ClickedOutsideBubble() { |
| 67 // This class has no bubbles dismiss, but acknowledge that the message was | 68 // This class has no bubbles dismiss, but acknowledge that the message was |
| 68 // handled. | 69 // handled. |
| 69 return true; | 70 return true; |
| 70 } | 71 } |
| 71 | 72 |
| 72 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { | 73 base::string16 OverviewButtonTray::GetAccessibleNameForTray() { |
| 73 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); | 74 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 96 kHorizontalShelfHorizontalPadding)); | 97 kHorizontalShelfHorizontalPadding)); |
| 97 } else { | 98 } else { |
| 98 icon_->SetBorder(views::Border::CreateEmptyBorder( | 99 icon_->SetBorder(views::Border::CreateEmptyBorder( |
| 99 kVerticalShelfVerticalPadding, | 100 kVerticalShelfVerticalPadding, |
| 100 kVerticalShelfHorizontalPadding, | 101 kVerticalShelfHorizontalPadding, |
| 101 kVerticalShelfVerticalPadding, | 102 kVerticalShelfVerticalPadding, |
| 102 kVerticalShelfHorizontalPadding)); | 103 kVerticalShelfHorizontalPadding)); |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 107 void OverviewButtonTray::SetIconVisibility(bool maximize_mode_enabled) { | |
|
flackr
2014/03/28 16:56:40
nit: Since this doesn't just use maximize_mode_ena
jonross
2014/03/28 19:39:01
Done.
| |
| 108 SetVisible(maximize_mode_enabled && | |
| 109 Shell::GetInstance()->window_selector_controller()->CanSelect()); | |
| 110 } | |
| 111 | |
| 112 void OverviewButtonTray::UpdateAfterLoginStatusChange( | |
| 113 user::LoginStatus status) { | |
| 114 SetIconVisibility(Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled()); | |
| 115 } | |
| 116 | |
| 106 } // namespace ash | 117 } // namespace ash |
| OLD | NEW |