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 "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/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 const views::Widget* StatusAreaView::GetWidget() const { | 36 const views::Widget* StatusAreaView::GetWidget() const { |
37 return View::GetWidget(); | 37 return View::GetWidget(); |
38 } | 38 } |
39 | 39 |
40 void StatusAreaView::OnPaint(gfx::Canvas* canvas) { | 40 void StatusAreaView::OnPaint(gfx::Canvas* canvas) { |
41 canvas->DrawBitmapInt(status_mock_, 0, 0); | 41 canvas->DrawBitmapInt(status_mock_, 0, 0); |
42 } | 42 } |
43 | 43 |
44 ASH_EXPORT views::Widget* CreateStatusArea() { | 44 ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) { |
45 StatusAreaView* status_area_view = new StatusAreaView; | 45 StatusAreaView* status_area_view = new StatusAreaView; |
| 46 if (!contents) |
| 47 contents = status_area_view; |
46 views::Widget* widget = new views::Widget; | 48 views::Widget* widget = new views::Widget; |
47 views::Widget::InitParams params( | 49 views::Widget::InitParams params( |
48 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 50 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
49 gfx::Size ps = status_area_view->GetPreferredSize(); | 51 gfx::Size ps = contents->GetPreferredSize(); |
50 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); | 52 params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); |
51 params.delegate = status_area_view; | 53 params.delegate = status_area_view; |
52 params.parent = Shell::GetInstance()->GetContainer( | 54 params.parent = Shell::GetInstance()->GetContainer( |
53 ash::internal::kShellWindowId_StatusContainer); | 55 ash::internal::kShellWindowId_StatusContainer); |
54 params.transparent = true; | 56 params.transparent = true; |
55 widget->Init(params); | 57 widget->Init(params); |
56 widget->set_focus_on_creation(false); | 58 widget->set_focus_on_creation(false); |
57 widget->SetContentsView(status_area_view); | 59 widget->SetContentsView(contents); |
58 widget->Show(); | 60 widget->Show(); |
59 widget->GetNativeView()->SetName("StatusAreaView"); | 61 widget->GetNativeView()->SetName("StatusAreaView"); |
60 return widget; | 62 return widget; |
61 } | 63 } |
62 | 64 |
63 } // namespace internal | 65 } // namespace internal |
64 } // namespace ash | 66 } // namespace ash |
OLD | NEW |