OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 StatusAreaView::StatusAreaView(StatusAreaHost* host) | 35 StatusAreaView::StatusAreaView(StatusAreaHost* host) |
36 : host_(host), | 36 : host_(host), |
37 accessibility_view_(NULL), | 37 accessibility_view_(NULL), |
38 caps_lock_view_(NULL), | 38 caps_lock_view_(NULL), |
39 clock_view_(NULL), | 39 clock_view_(NULL), |
40 input_method_view_(NULL), | 40 input_method_view_(NULL), |
41 memory_view_(NULL), | 41 memory_view_(NULL), |
42 network_view_(NULL), | 42 network_view_(NULL), |
43 power_view_(NULL), | 43 power_view_(NULL), |
44 need_return_focus_(false), | 44 need_return_focus_(false) { |
45 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { | |
46 } | 45 } |
47 | 46 |
48 StatusAreaView::~StatusAreaView() { | 47 StatusAreaView::~StatusAreaView() { |
49 } | 48 } |
50 | 49 |
51 void StatusAreaView::Init() { | 50 void StatusAreaView::Init() { |
52 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) { | 51 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryWidget)) { |
53 memory_view_ = new MemoryMenuButton(host_); | 52 memory_view_ = new MemoryMenuButton(host_); |
54 AddChildView(memory_view_); | 53 AddChildView(memory_view_); |
55 } | 54 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 input_method_view()->set_active(active); | 130 input_method_view()->set_active(active); |
132 network_view()->set_active(active); | 131 network_view()->set_active(active); |
133 power_view()->set_active(active); | 132 power_view()->set_active(active); |
134 } | 133 } |
135 | 134 |
136 void StatusAreaView::ButtonVisibilityChanged(views::View* button_view) { | 135 void StatusAreaView::ButtonVisibilityChanged(views::View* button_view) { |
137 Layout(); | 136 Layout(); |
138 PreferredSizeChanged(); | 137 PreferredSizeChanged(); |
139 } | 138 } |
140 | 139 |
141 void StatusAreaView::TakeFocus( | 140 void StatusAreaView::TakeFocus(bool reverse, |
142 bool reverse, | 141 const ReturnFocusCallback& return_focus_cb) { |
satorux1
2011/10/25 01:08:16
nit: indentation for parameters should be vertical
achuithb
2011/10/25 08:49:09
Done.
| |
143 const base::Callback<void(bool)>& return_focus_cb) { | |
144 // Emulates focus receive by AccessiblePaneView::SetPaneFocus. | 142 // Emulates focus receive by AccessiblePaneView::SetPaneFocus. |
145 if (!focus_manager_) | 143 if (!focus_manager_) |
146 focus_manager_ = GetFocusManager(); | 144 focus_manager_ = GetFocusManager(); |
147 focus_manager_->SetFocusedView( | 145 focus_manager_->SetFocusedView( |
148 reverse ? GetLastFocusableChild() : GetFirstFocusableChild()); | 146 reverse ? GetLastFocusableChild() : GetFirstFocusableChild()); |
149 pane_has_focus_ = true; | 147 pane_has_focus_ = true; |
150 need_return_focus_ = true; | 148 need_return_focus_ = true; |
151 return_focus_cb_ = return_focus_cb; | 149 return_focus_cb_ = return_focus_cb; |
152 focus_manager_->AddFocusChangeListener(this); | 150 focus_manager_->AddFocusChangeListener(this); |
153 } | 151 } |
(...skipping 11 matching lines...) Expand all Loading... | |
165 | 163 |
166 void StatusAreaView::FocusWillChange(views::View* focused_before, | 164 void StatusAreaView::FocusWillChange(views::View* focused_before, |
167 views::View* focused_now) { | 165 views::View* focused_now) { |
168 // Call superclass. | 166 // Call superclass. |
169 AccessiblePaneView::FocusWillChange(focused_before, focused_now); | 167 AccessiblePaneView::FocusWillChange(focused_before, focused_now); |
170 | 168 |
171 // If focus has been wrapped, postpone focus return task. | 169 // If focus has been wrapped, postpone focus return task. |
172 if (need_return_focus_) { | 170 if (need_return_focus_) { |
173 const views::View* first = GetFirstFocusableChild(); | 171 const views::View* first = GetFirstFocusableChild(); |
174 const views::View* last = GetLastFocusableChild(); | 172 const views::View* last = GetLastFocusableChild(); |
173 const bool first_to_last = (focused_before == first && focused_now == last); | |
174 const bool last_to_first = (focused_now == first && focused_before == last); | |
175 | 175 |
176 if (focused_before == first && focused_now == last) { | 176 if (first_to_last || last_to_first) |
177 MessageLoop::current()->PostTask( | 177 MessageLoop::current()->PostTask(FROM_HERE, |
178 FROM_HERE, | 178 base::Bind(&StatusAreaView::ReturnFocus, AsWeakPtr(), first_to_last)); |
179 task_factory_.NewRunnableMethod(&StatusAreaView::ReturnFocus, true)); | |
180 } else if (focused_now == first && focused_before == last) { | |
181 MessageLoop::current()->PostTask( | |
182 FROM_HERE, | |
183 task_factory_.NewRunnableMethod(&StatusAreaView::ReturnFocus, false)); | |
184 } | |
185 } | 179 } |
186 } | 180 } |
187 | 181 |
188 } // namespace chromeos | 182 } // namespace chromeos |
OLD | NEW |