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

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

Issue 9295049: Allow focus to be sent between browser window and launcher/status window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
OLDNEW
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_AURA)
17 #include "ash/launcher/launcher.h"
18 #include "ash/shell.h"
17 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
18 #endif 20 #endif
19 21
20 // Number of pixels to separate each icon. 22 // Number of pixels to separate each icon.
21 const int kSeparation = 0; 23 const int kSeparation = 0;
22 24
23 StatusAreaView::StatusAreaView() 25 StatusAreaView::StatusAreaView()
24 : need_return_focus_(false) { 26 : need_return_focus_(false),
27 ctrl_forward_key_(ui::VKEY_F2, false, true, false),
28 ctrl_back_key_(ui::VKEY_F1, false, true, false) {
25 set_id(VIEW_ID_STATUS_AREA); 29 set_id(VIEW_ID_STATUS_AREA);
30 #if defined(USE_AURA)
31 AddAccelerator(ctrl_forward_key_);
32 AddAccelerator(ctrl_back_key_);
33 #endif
26 } 34 }
27 35
28 StatusAreaView::~StatusAreaView() { 36 StatusAreaView::~StatusAreaView() {
29 } 37 }
30 38
31 void StatusAreaView::AddButton(StatusAreaButton* button, bool bordered) { 39 void StatusAreaView::AddButton(StatusAreaButton* button, bool bordered) {
32 buttons_.push_back(button); 40 buttons_.push_back(button);
33 if (bordered) 41 if (bordered)
34 button->set_border(views::Border::CreateEmptyBorder(0, 1, 0, 0)); 42 button->set_border(views::Border::CreateEmptyBorder(0, 1, 0, 0));
35 AddChildView(button); 43 AddChildView(button);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 103 }
96 104
97 void StatusAreaView::ChildPreferredSizeChanged(View* child) { 105 void StatusAreaView::ChildPreferredSizeChanged(View* child) {
98 // When something like the clock menu button's size changes, we need to 106 // When something like the clock menu button's size changes, we need to
99 // relayout. Also mark that this view's size has changed. This will let 107 // relayout. Also mark that this view's size has changed. This will let
100 // BrowserView know to relayout, which will reset the bounds of this view. 108 // BrowserView know to relayout, which will reset the bounds of this view.
101 Layout(); 109 Layout();
102 PreferredSizeChanged(); 110 PreferredSizeChanged();
103 } 111 }
104 112
113 bool StatusAreaView::AcceleratorPressed(const ui::Accelerator& accelerator) {
114 #if defined(USE_AURA)
115 bool focus_launcher = false;
116 switch (accelerator.key_code()) {
117 case ui::VKEY_F1:
118 focus_launcher = !ash::Shell::GetInstance()->IsWindowModeCompact();
119 break;
120
121 case ui::VKEY_F2:
122 // Focus Browser.
123 break;
124
125 default:
126 return false;
127 }
128
129 if (focus_launcher) {
130 if (ash::Shell::GetInstance()->launcher()->Activate()) {
131 return true;
132 }
133 // If we couldn't focus the launcher, fall through and focus the browser.
134 }
135 // TODO: Focus Browser
136
137 return true;
138 #else
139 return false;
140 #endif
141 }
142
105 void StatusAreaView::MakeButtonsActive(bool active) { 143 void StatusAreaView::MakeButtonsActive(bool active) {
106 for (std::list<StatusAreaButton*>::iterator iter = buttons_.begin(); 144 for (std::list<StatusAreaButton*>::iterator iter = buttons_.begin();
107 iter != buttons_.end(); ++iter) { 145 iter != buttons_.end(); ++iter) {
108 (*iter)->SetMenuActive(active); 146 (*iter)->SetMenuActive(active);
109 } 147 }
110 } 148 }
111 149
112 void StatusAreaView::UpdateButtonVisibility() { 150 void StatusAreaView::UpdateButtonVisibility() {
113 Layout(); 151 Layout();
114 PreferredSizeChanged(); 152 PreferredSizeChanged();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (need_return_focus_) { 191 if (need_return_focus_) {
154 const views::View* first = GetFirstFocusableChild(); 192 const views::View* first = GetFirstFocusableChild();
155 const views::View* last = GetLastFocusableChild(); 193 const views::View* last = GetLastFocusableChild();
156 const bool first_to_last = (focused_before == first && focused_now == last); 194 const bool first_to_last = (focused_before == first && focused_now == last);
157 const bool last_to_first = (focused_now == first && focused_before == last); 195 const bool last_to_first = (focused_now == first && focused_before == last);
158 196
159 if (first_to_last || last_to_first) 197 if (first_to_last || last_to_first)
160 ReturnFocus(first_to_last); 198 ReturnFocus(first_to_last);
161 } 199 }
162 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698