| 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" | |
| 12 #include "ui/aura_shell/examples/toplevel_window.h" | 11 #include "ui/aura_shell/examples/toplevel_window.h" |
| 13 #include "ui/aura_shell/launcher/launcher_types.h" | 12 #include "ui/aura_shell/launcher/launcher_types.h" |
| 14 #include "ui/aura_shell/shell.h" | 13 #include "ui/aura_shell/shell.h" |
| 15 #include "ui/aura_shell/shell_delegate.h" | 14 #include "ui/aura_shell/shell_delegate.h" |
| 16 #include "ui/aura_shell/shell_factory.h" | 15 #include "ui/aura_shell/shell_factory.h" |
| 17 #include "ui/aura_shell/window_util.h" | 16 #include "ui/aura_shell/window_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/base/ui_base_paths.h" | 18 #include "ui/base/ui_base_paths.h" |
| 20 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/compositor/test/compositor_test_support.h" | 20 #include "ui/gfx/compositor/test/compositor_test_support.h" |
| 22 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" | 22 #include "ui/views/widget/widget_delegate.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 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 |
| 27 class ShellDelegateImpl : public aura_shell::ShellDelegate { | 54 class ShellDelegateImpl : public aura_shell::ShellDelegate { |
| 28 public: | 55 public: |
| 29 ShellDelegateImpl() { | 56 ShellDelegateImpl() { |
| 30 } | 57 } |
| 31 | 58 |
| 32 virtual void CreateNewWindow() OVERRIDE { | 59 virtual void CreateNewWindow() OVERRIDE { |
| 33 aura_shell::examples::ToplevelWindow::CreateParams create_params; | 60 aura_shell::examples::ToplevelWindow::CreateParams create_params; |
| 34 create_params.can_resize = true; | 61 create_params.can_resize = true; |
| 35 create_params.can_maximize = true; | 62 create_params.can_maximize = true; |
| 36 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); | 63 aura_shell::examples::ToplevelWindow::CreateToplevelWindow(create_params); |
| 37 } | 64 } |
| 38 | 65 |
| 39 virtual views::Widget* CreateStatusArea() OVERRIDE { | 66 virtual views::Widget* CreateStatusArea() OVERRIDE { |
| 40 return aura_shell::internal::CreateStatusArea(); | 67 return aura_shell::internal::CreateStatusArea(); |
| 41 } | 68 } |
| 42 | 69 |
| 43 virtual void RequestAppListWidget( | 70 virtual void RequestAppListWidget( |
| 44 const gfx::Rect& bounds, | 71 const gfx::Rect& bounds, |
| 45 const SetWidgetCallback& callback) OVERRIDE { | 72 const SetWidgetCallback& callback) OVERRIDE { |
| 46 // TODO(xiyuan): Clean this up. | 73 callback.Run(AppListWindow::Create(bounds)); |
| 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(); | |
| 59 } | 74 } |
| 60 | 75 |
| 61 virtual void LauncherItemClicked( | 76 virtual void LauncherItemClicked( |
| 62 const aura_shell::LauncherItem& item) OVERRIDE { | 77 const aura_shell::LauncherItem& item) OVERRIDE { |
| 63 aura_shell::ActivateWindow(item.window); | 78 aura_shell::ActivateWindow(item.window); |
| 64 } | 79 } |
| 65 | 80 |
| 66 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { | 81 virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE { |
| 67 static int image_count = 0; | 82 static int image_count = 0; |
| 68 item->tab_images.resize(image_count + 1); | 83 item->tab_images.resize(image_count + 1); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 aura::RootWindow::GetInstance()->Run(); | 125 aura::RootWindow::GetInstance()->Run(); |
| 111 | 126 |
| 112 aura_shell::Shell::DeleteInstance(); | 127 aura_shell::Shell::DeleteInstance(); |
| 113 | 128 |
| 114 aura::RootWindow::DeleteInstance(); | 129 aura::RootWindow::DeleteInstance(); |
| 115 | 130 |
| 116 ui::CompositorTestSupport::Terminate(); | 131 ui::CompositorTestSupport::Terminate(); |
| 117 | 132 |
| 118 return 0; | 133 return 0; |
| 119 } | 134 } |
| OLD | NEW |