| 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/app_list/app_list_view.h" |
| 12 #include "ui/aura_shell/examples/example_factory.h" |
| 11 #include "ui/aura_shell/examples/toplevel_window.h" | 13 #include "ui/aura_shell/examples/toplevel_window.h" |
| 12 #include "ui/aura_shell/launcher/launcher_types.h" | 14 #include "ui/aura_shell/launcher/launcher_types.h" |
| 13 #include "ui/aura_shell/shell.h" | 15 #include "ui/aura_shell/shell.h" |
| 14 #include "ui/aura_shell/shell_delegate.h" | 16 #include "ui/aura_shell/shell_delegate.h" |
| 15 #include "ui/aura_shell/shell_factory.h" | 17 #include "ui/aura_shell/shell_factory.h" |
| 16 #include "ui/aura_shell/window_util.h" | 18 #include "ui/aura_shell/window_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/base/ui_base_paths.h" | 20 #include "ui/base/ui_base_paths.h" |
| 19 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/compositor/test/compositor_test_support.h" | 22 #include "ui/gfx/compositor/test/compositor_test_support.h" |
| 21 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 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 { | 28 class ShellDelegateImpl : public aura_shell::ShellDelegate { |
| 55 public: | 29 public: |
| 56 ShellDelegateImpl() { | 30 ShellDelegateImpl() { |
| 57 } | 31 } |
| 58 | 32 |
| 59 virtual void CreateNewWindow() OVERRIDE { | 33 virtual void CreateNewWindow() OVERRIDE { |
| 60 aura_shell::examples::ToplevelWindow::CreateParams create_params; | 34 aura_shell::examples::ToplevelWindow::CreateParams create_params; |
| 61 create_params.can_resize = true; | 35 create_params.can_resize = true; |
| 62 create_params.can_maximize = true; | 36 create_params.can_maximize = true; |
| 63 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); | 37 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); |
| 64 } | 38 } |
| 65 | 39 |
| 66 virtual views::Widget* CreateStatusArea() OVERRIDE { | 40 virtual views::Widget* CreateStatusArea() OVERRIDE { |
| 67 return aura_shell::internal::CreateStatusArea(); | 41 return aura_shell::internal::CreateStatusArea(); |
| 68 } | 42 } |
| 69 | 43 |
| 70 virtual void RequestAppListWidget( | 44 virtual void RequestAppListWidget( |
| 71 const gfx::Rect& bounds, | 45 const gfx::Rect& bounds, |
| 72 const SetWidgetCallback& callback) OVERRIDE { | 46 const SetWidgetCallback& callback) OVERRIDE { |
| 73 callback.Run(AppListWindow::Create(bounds)); | 47 // AppListView deletes itself on close. |
| 48 new aura_shell::AppListView( |
| 49 aura_shell::examples::CreateAppListModel(), bounds, callback); |
| 74 } | 50 } |
| 75 | 51 |
| 76 virtual void LauncherItemClicked( | 52 virtual void LauncherItemClicked( |
| 77 const aura_shell::LauncherItem& item) OVERRIDE { | 53 const aura_shell::LauncherItem& item) OVERRIDE { |
| 78 aura_shell::ActivateWindow(item.window); | 54 aura_shell::ActivateWindow(item.window); |
| 79 } | 55 } |
| 80 | 56 |
| 81 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { | 57 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { |
| 82 static int image_count = 0; | 58 static int image_count = 0; |
| 83 item->tab_images.resize(image_count + 1); | 59 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(); | 101 aura::RootWindow::GetInstance()->Run(); |
| 126 | 102 |
| 127 aura_shell::Shell::DeleteInstance(); | 103 aura_shell::Shell::DeleteInstance(); |
| 128 | 104 |
| 129 aura::RootWindow::DeleteInstance(); | 105 aura::RootWindow::DeleteInstance(); |
| 130 | 106 |
| 131 ui::CompositorTestSupport::Terminate(); | 107 ui::CompositorTestSupport::Terminate(); |
| 132 | 108 |
| 133 return 0; | 109 return 0; |
| 134 } | 110 } |
| OLD | NEW |