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

Side by Side Diff: ash/status_area/status_area_view.cc

Issue 10056001: chromeos: Remove old status-area related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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 | « ash/status_area/status_area_view.h ('k') | ash/test/test_shell_delegate.h » ('j') | 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) 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 "ash/status_area/status_area_view.h" 5 #include "ash/status_area/status_area_view.h"
6 6
7 #include "ash/ash_export.h" 7 #include "ash/ash_export.h"
8 #include "ash/focus_cycler.h" 8 #include "ash/focus_cycler.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "grit/ui_resources.h" 12 #include "grit/ui_resources.h"
13 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
17 #include "ui/views/accessible_pane_view.h" 17 #include "ui/views/accessible_pane_view.h"
18 #include "ui/views/layout/fill_layout.h"
18 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
19 20
20 namespace ash { 21 namespace ash {
21 namespace internal { 22 namespace internal {
22 23
23 StatusAreaView::StatusAreaView() 24 StatusAreaView::StatusAreaView()
24 : status_mock_(*ui::ResourceBundle::GetSharedInstance().GetImageNamed( 25 : focus_cycler_for_testing_(NULL) {
25 IDR_AURA_STATUS_MOCK).ToSkBitmap()),
26 focus_cycler_for_testing_(NULL) {
27 } 26 }
27
28 StatusAreaView::~StatusAreaView() { 28 StatusAreaView::~StatusAreaView() {
29 } 29 }
30 30
31 void StatusAreaView::SetFocusCyclerForTesting(const FocusCycler* focus_cycler) { 31 void StatusAreaView::SetFocusCyclerForTesting(const FocusCycler* focus_cycler) {
32 focus_cycler_for_testing_ = focus_cycler; 32 focus_cycler_for_testing_ = focus_cycler;
33 } 33 }
34 34
35 gfx::Size StatusAreaView::GetPreferredSize() { 35 bool StatusAreaView::AcceleratorPressed(const ui::Accelerator& accelerator) {
36 return gfx::Size(status_mock_.width(), status_mock_.height()); 36 if (accelerator.key_code() == ui::VKEY_ESCAPE) {
37 RemovePaneFocus();
38 GetFocusManager()->ClearFocus();
39 return true;
40 }
41 return false;
37 } 42 }
38 43
39 views::Widget* StatusAreaView::GetWidget() { 44 views::Widget* StatusAreaView::GetWidget() {
40 return View::GetWidget(); 45 return View::GetWidget();
41 } 46 }
42 47
43 const views::Widget* StatusAreaView::GetWidget() const { 48 const views::Widget* StatusAreaView::GetWidget() const {
44 return View::GetWidget(); 49 return View::GetWidget();
45 } 50 }
46 51
47 bool StatusAreaView::CanActivate() const { 52 bool StatusAreaView::CanActivate() const {
48 // We don't want mouse clicks to activate us, but we need to allow 53 // We don't want mouse clicks to activate us, but we need to allow
49 // activation when the user is using the keyboard (FocusCycler). 54 // activation when the user is using the keyboard (FocusCycler).
50 const FocusCycler* focus_cycler = focus_cycler_for_testing_ ? 55 const FocusCycler* focus_cycler = focus_cycler_for_testing_ ?
51 focus_cycler_for_testing_ : Shell::GetInstance()->focus_cycler(); 56 focus_cycler_for_testing_ : Shell::GetInstance()->focus_cycler();
52 return focus_cycler->widget_activating() == GetWidget(); 57 return focus_cycler->widget_activating() == GetWidget();
53 } 58 }
54 59
55 void StatusAreaView::DeleteDelegate() { 60 void StatusAreaView::DeleteDelegate() {
56 // If this is used as the content-view of the widget, then do nothing, since
57 // deleting the widget will end up deleting this. But if this is used only as
58 // the widget-delegate, then delete this now.
59 if (!GetWidget())
60 delete this;
61 }
62
63 void StatusAreaView::OnPaint(gfx::Canvas* canvas) {
64 canvas->DrawBitmapInt(status_mock_, 0, 0);
65 } 61 }
66 62
67 ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) { 63 ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) {
68 StatusAreaView* status_area_view = new StatusAreaView; 64 StatusAreaView* status_area_view = new StatusAreaView;
69 if (!contents) 65 if (!contents)
70 contents = status_area_view; 66 contents = status_area_view;
71 views::Widget* widget = new views::Widget; 67 views::Widget* widget = new views::Widget;
72 views::Widget::InitParams params( 68 views::Widget::InitParams params(
73 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 69 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
74 gfx::Size ps = contents->GetPreferredSize(); 70 gfx::Size ps = contents ? contents->GetPreferredSize() : gfx::Size(200, 29);
75 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); 71 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
76 params.delegate = status_area_view; 72 params.delegate = status_area_view;
77 params.parent = Shell::GetInstance()->GetContainer( 73 params.parent = Shell::GetInstance()->GetContainer(
78 ash::internal::kShellWindowId_StatusContainer); 74 ash::internal::kShellWindowId_StatusContainer);
79 params.transparent = true; 75 params.transparent = true;
80 widget->Init(params); 76 widget->Init(params);
81 // TODO(sky): We need the contents to be an AccessiblePaneView for 77 // TODO(sky): We need the contents to be an AccessiblePaneView for
82 // FocusCycler. SystemTray isn't an AccessiblePaneView, so we wrap it in 78 // FocusCycler. SystemTray isn't an AccessiblePaneView, so we wrap it in
83 // one. This is a bit of a hack, but at this point this code path is only used 79 // one. This is a bit of a hack, but at this point this code path is only used
84 // for tests. Once the migration to SystemTray is done this method should no 80 // for tests. Once the migration to SystemTray is done this method should no
85 // longer be needed and we can nuke this. 81 // longer be needed and we can nuke this.
86 views::AccessiblePaneView* accessible_pane = 82 views::AccessiblePaneView* accessible_pane =
87 new views::AccessiblePaneView; 83 new views::AccessiblePaneView;
84 accessible_pane->SetLayoutManager(new views::FillLayout);
88 accessible_pane->AddChildView(contents); 85 accessible_pane->AddChildView(contents);
89 widget->set_focus_on_creation(false); 86 widget->set_focus_on_creation(false);
90 widget->SetContentsView(accessible_pane); 87 widget->SetContentsView(accessible_pane);
91 widget->Show(); 88 widget->Show();
92 widget->GetNativeView()->SetName("StatusAreaView"); 89 widget->GetNativeView()->SetName("StatusAreaView");
93 return widget; 90 return widget;
94 } 91 }
95 92
96 } // namespace internal 93 } // namespace internal
97 } // namespace ash 94 } // namespace ash
OLDNEW
« no previous file with comments | « ash/status_area/status_area_view.h ('k') | ash/test/test_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698