OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/status/status_area_view.h" | 5 #include "chrome/browser/chromeos/status/status_area_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "chrome/browser/chromeos/view_ids.h" | 12 #include "chrome/browser/chromeos/view_ids.h" |
13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
15 | 15 |
16 #if defined(USE_AURA) | 16 #if defined(USE_ASH) |
17 #include "ui/views/widget/widget.h" | 17 #include "ash/focus_cycler.h" |
| 18 #include "ash/shell.h" |
18 #endif | 19 #endif |
19 | 20 |
20 // Number of pixels to separate each icon. | 21 // Number of pixels to separate each icon. |
21 const int kSeparation = 0; | 22 const int kSeparation = 0; |
22 | 23 |
23 StatusAreaView::StatusAreaView() | 24 StatusAreaView::StatusAreaView() |
24 : need_return_focus_(false), | 25 : need_return_focus_(false), |
25 skip_next_focus_return_(true) { | 26 skip_next_focus_return_(true) { |
26 set_id(VIEW_ID_STATUS_AREA); | 27 set_id(VIEW_ID_STATUS_AREA); |
27 } | 28 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 97 } |
97 | 98 |
98 void StatusAreaView::ChildPreferredSizeChanged(View* child) { | 99 void StatusAreaView::ChildPreferredSizeChanged(View* child) { |
99 // When something like the clock menu button's size changes, we need to | 100 // When something like the clock menu button's size changes, we need to |
100 // relayout. Also mark that this view's size has changed. This will let | 101 // relayout. Also mark that this view's size has changed. This will let |
101 // BrowserView know to relayout, which will reset the bounds of this view. | 102 // BrowserView know to relayout, which will reset the bounds of this view. |
102 Layout(); | 103 Layout(); |
103 PreferredSizeChanged(); | 104 PreferredSizeChanged(); |
104 } | 105 } |
105 | 106 |
| 107 bool StatusAreaView::CanActivate() const { |
| 108 #if defined(USE_ASH) |
| 109 // We don't want mouse clicks to activate us, but we need to allow |
| 110 // activation when the user is using the keyboard (FocusCycler). |
| 111 ash::internal::FocusCycler* focus_cycler = |
| 112 ash::Shell::GetInstance()->focus_cycler(); |
| 113 return focus_cycler->widget_activating() == GetWidget(); |
| 114 #else |
| 115 return false; |
| 116 #endif |
| 117 } |
| 118 |
| 119 views::Widget* StatusAreaView::GetWidget() { |
| 120 return View::GetWidget(); |
| 121 } |
| 122 |
| 123 const views::Widget* StatusAreaView::GetWidget() const { |
| 124 return View::GetWidget(); |
| 125 } |
| 126 |
106 void StatusAreaView::MakeButtonsActive(bool active) { | 127 void StatusAreaView::MakeButtonsActive(bool active) { |
107 for (std::list<StatusAreaButton*>::iterator iter = buttons_.begin(); | 128 for (std::list<StatusAreaButton*>::iterator iter = buttons_.begin(); |
108 iter != buttons_.end(); ++iter) { | 129 iter != buttons_.end(); ++iter) { |
109 (*iter)->SetMenuActive(active); | 130 (*iter)->SetMenuActive(active); |
110 } | 131 } |
111 } | 132 } |
112 | 133 |
113 void StatusAreaView::UpdateButtonVisibility() { | 134 void StatusAreaView::UpdateButtonVisibility() { |
114 Layout(); | 135 Layout(); |
115 PreferredSizeChanged(); | 136 PreferredSizeChanged(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Override Escape handling to return focus back. | 191 // Override Escape handling to return focus back. |
171 ReturnFocus(false); | 192 ReturnFocus(false); |
172 return true; | 193 return true; |
173 } else if (accelerator.key_code() == ui::VKEY_HOME || | 194 } else if (accelerator.key_code() == ui::VKEY_HOME || |
174 accelerator.key_code() == ui::VKEY_END) { | 195 accelerator.key_code() == ui::VKEY_END) { |
175 // Do not return focus if it wraps right after pressing Home/End. | 196 // Do not return focus if it wraps right after pressing Home/End. |
176 skip_next_focus_return_ = true; | 197 skip_next_focus_return_ = true; |
177 } | 198 } |
178 return AccessiblePaneView::AcceleratorPressed(accelerator); | 199 return AccessiblePaneView::AcceleratorPressed(accelerator); |
179 } | 200 } |
OLD | NEW |