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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/i18n/icu_util.h" | 7 #include "base/i18n/icu_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| 11 #include "ui/aura_shell/examples/example_factory.h" |
11 #include "ui/aura_shell/examples/toplevel_window.h" | 12 #include "ui/aura_shell/examples/toplevel_window.h" |
12 #include "ui/aura_shell/launcher/launcher_types.h" | 13 #include "ui/aura_shell/launcher/launcher_types.h" |
13 #include "ui/aura_shell/shell.h" | 14 #include "ui/aura_shell/shell.h" |
14 #include "ui/aura_shell/shell_delegate.h" | 15 #include "ui/aura_shell/shell_delegate.h" |
15 #include "ui/aura_shell/shell_factory.h" | 16 #include "ui/aura_shell/shell_factory.h" |
16 #include "ui/aura_shell/window_util.h" | 17 #include "ui/aura_shell/window_util.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/base/ui_base_paths.h" | 19 #include "ui/base/ui_base_paths.h" |
19 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/compositor/test/compositor_test_support.h" | 21 #include "ui/gfx/compositor/test/compositor_test_support.h" |
21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
22 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 class AppListWindow : public views::WidgetDelegateView { | |
27 public: | |
28 AppListWindow() { | |
29 } | |
30 | |
31 // static | |
32 static views::Widget* Create(const gfx::Rect& bounds) { | |
33 AppListWindow* app_list = new AppListWindow; | |
34 | |
35 views::Widget::InitParams widget_params( | |
36 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
37 widget_params.bounds = bounds; | |
38 widget_params.delegate = app_list; | |
39 widget_params.keep_on_top = true; | |
40 widget_params.transparent = true; | |
41 | |
42 views::Widget* widget = new views::Widget; | |
43 widget->Init(widget_params); | |
44 widget->SetContentsView(app_list); | |
45 return widget; | |
46 } | |
47 | |
48 // Overridden from views::View: | |
49 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | |
50 canvas->FillRect(SkColorSetARGB(0x4F, 0xFF, 0, 0), bounds()); | |
51 } | |
52 }; | |
53 | |
54 class ShellDelegateImpl : public aura_shell::ShellDelegate { | 27 class ShellDelegateImpl : public aura_shell::ShellDelegate { |
55 public: | 28 public: |
56 ShellDelegateImpl() { | 29 ShellDelegateImpl() { |
57 } | 30 } |
58 | 31 |
59 virtual void CreateNewWindow() OVERRIDE { | 32 virtual void CreateNewWindow() OVERRIDE { |
60 aura_shell::examples::ToplevelWindow::CreateParams create_params; | 33 aura_shell::examples::ToplevelWindow::CreateParams create_params; |
61 create_params.can_resize = true; | 34 create_params.can_resize = true; |
62 create_params.can_maximize = true; | 35 create_params.can_maximize = true; |
63 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); | 36 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); |
64 } | 37 } |
65 | 38 |
66 virtual views::Widget* CreateStatusArea() OVERRIDE { | 39 virtual views::Widget* CreateStatusArea() OVERRIDE { |
67 return aura_shell::internal::CreateStatusArea(); | 40 return aura_shell::internal::CreateStatusArea(); |
68 } | 41 } |
69 | 42 |
70 virtual void RequestAppListWidget( | 43 virtual void RequestAppListWidget( |
71 const gfx::Rect& bounds, | 44 const gfx::Rect& bounds, |
72 const SetWidgetCallback& callback) OVERRIDE { | 45 const SetWidgetCallback& callback) OVERRIDE { |
73 callback.Run(AppListWindow::Create(bounds)); | 46 // TODO(xiyuan): Clean this up. |
| 47 // The code below here is because we don't want to use |
| 48 // --aura-views-applist. This function is deprecated and all code |
| 49 // here will be removed when we clean it up. |
| 50 aura_shell::examples::CreateAppList(bounds, callback); |
| 51 } |
| 52 |
| 53 virtual void BuildAppListModel(aura_shell::AppListModel* model) { |
| 54 aura_shell::examples::BuildAppListModel(model); |
| 55 } |
| 56 |
| 57 virtual aura_shell::AppListViewDelegate* CreateAppListViewDelegate() { |
| 58 return aura_shell::examples::CreateAppListViewDelegate(); |
74 } | 59 } |
75 | 60 |
76 virtual void LauncherItemClicked( | 61 virtual void LauncherItemClicked( |
77 const aura_shell::LauncherItem& item) OVERRIDE { | 62 const aura_shell::LauncherItem& item) OVERRIDE { |
78 aura_shell::ActivateWindow(item.window); | 63 aura_shell::ActivateWindow(item.window); |
79 } | 64 } |
80 | 65 |
81 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { | 66 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { |
82 static int image_count = 0; | 67 static int image_count = 0; |
83 item->tab_images.resize(image_count + 1); | 68 item->tab_images.resize(image_count + 1); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 aura::RootWindow::GetInstance()->Run(); | 110 aura::RootWindow::GetInstance()->Run(); |
126 | 111 |
127 aura_shell::Shell::DeleteInstance(); | 112 aura_shell::Shell::DeleteInstance(); |
128 | 113 |
129 aura::RootWindow::DeleteInstance(); | 114 aura::RootWindow::DeleteInstance(); |
130 | 115 |
131 ui::CompositorTestSupport::Terminate(); | 116 ui::CompositorTestSupport::Terminate(); |
132 | 117 |
133 return 0; | 118 return 0; |
134 } | 119 } |
OLD | NEW |