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

Side by Side Diff: chrome/browser/chromeos/status/status_area_view.cc

Issue 8332016: Use Closure instead of ScopedRunnableFactory in StatusAreaView. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review feedback Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/status/status_area_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
142 bool reverse, 141 bool reverse,
143 const base::Callback<void(bool)>& return_focus_cb) { 142 const ReturnFocusCallback& return_focus_cb) {
144 // Emulates focus receive by AccessiblePaneView::SetPaneFocus. 143 // Emulates focus receive by AccessiblePaneView::SetPaneFocus.
145 if (!focus_manager_) 144 if (!focus_manager_)
146 focus_manager_ = GetFocusManager(); 145 focus_manager_ = GetFocusManager();
147 focus_manager_->SetFocusedView( 146 focus_manager_->SetFocusedView(
148 reverse ? GetLastFocusableChild() : GetFirstFocusableChild()); 147 reverse ? GetLastFocusableChild() : GetFirstFocusableChild());
149 pane_has_focus_ = true; 148 pane_has_focus_ = true;
150 need_return_focus_ = true; 149 need_return_focus_ = true;
151 return_focus_cb_ = return_focus_cb; 150 return_focus_cb_ = return_focus_cb;
152 focus_manager_->AddFocusChangeListener(this); 151 focus_manager_->AddFocusChangeListener(this);
153 } 152 }
(...skipping 11 matching lines...) Expand all
165 164
166 void StatusAreaView::FocusWillChange(views::View* focused_before, 165 void StatusAreaView::FocusWillChange(views::View* focused_before,
167 views::View* focused_now) { 166 views::View* focused_now) {
168 // Call superclass. 167 // Call superclass.
169 AccessiblePaneView::FocusWillChange(focused_before, focused_now); 168 AccessiblePaneView::FocusWillChange(focused_before, focused_now);
170 169
171 // If focus has been wrapped, postpone focus return task. 170 // If focus has been wrapped, postpone focus return task.
172 if (need_return_focus_) { 171 if (need_return_focus_) {
173 const views::View* first = GetFirstFocusableChild(); 172 const views::View* first = GetFirstFocusableChild();
174 const views::View* last = GetLastFocusableChild(); 173 const views::View* last = GetLastFocusableChild();
174 const bool first_to_last = (focused_before == first && focused_now == last);
175 const bool last_to_first = (focused_now == first && focused_before == last);
175 176
176 if (focused_before == first && focused_now == last) { 177 if (first_to_last || last_to_first)
177 MessageLoop::current()->PostTask( 178 MessageLoop::current()->PostTask(FROM_HERE,
178 FROM_HERE, 179 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 } 180 }
186 } 181 }
187 182
188 } // namespace chromeos 183 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/status_area_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698