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

Side by Side Diff: ui/app_list/demo/app_list_demo_views.cc

Issue 2588103004: Apply new WM shadows to app list. (Closed)
Patch Set: stop building app list on other platforms Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "ui/app_list/test/app_list_test_model.h" 17 #include "ui/app_list/test/app_list_test_model.h"
18 #include "ui/app_list/test/app_list_test_view_delegate.h" 18 #include "ui/app_list/test/app_list_test_view_delegate.h"
19 #include "ui/app_list/views/app_list_view.h" 19 #include "ui/app_list/views/app_list_view.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/resources/grit/ui_resources.h" 21 #include "ui/resources/grit/ui_resources.h"
22 #include "ui/views/controls/webview/webview.h" 22 #include "ui/views/controls/webview/webview.h"
23 #include "ui/views_content_client/views_content_client.h" 23 #include "ui/views_content_client/views_content_client.h"
24 24
25 #if defined(OS_WIN)
26 #include "content/public/app/sandbox_helper_win.h"
27 #include "sandbox/win/src/sandbox_types.h"
28 #endif
29
30 namespace { 25 namespace {
31 26
32 class AppListDemoService; 27 class AppListDemoService;
33 28
34 // Number of dummy apps to populate in the app list. 29 // Number of dummy apps to populate in the app list.
35 const int kInitialItems = 20; 30 const int kInitialItems = 20;
36 31
37 // Extends the test AppListViewDelegate to quit the run loop when the launcher 32 // Extends the test AppListViewDelegate to quit the run loop when the launcher
38 // window is closed, and to close the window if it is simply dismissed. 33 // window is closed, and to close the window if it is simply dismissed.
39 class DemoAppListViewDelegate : public app_list::test::AppListTestViewDelegate { 34 class DemoAppListViewDelegate : public app_list::test::AppListTestViewDelegate {
(...skipping 16 matching lines...) Expand all
56 51
57 DISALLOW_COPY_AND_ASSIGN(DemoAppListViewDelegate); 52 DISALLOW_COPY_AND_ASSIGN(DemoAppListViewDelegate);
58 }; 53 };
59 54
60 app_list::AppListView* DemoAppListViewDelegate::InitView( 55 app_list::AppListView* DemoAppListViewDelegate::InitView(
61 gfx::NativeWindow window_context) { 56 gfx::NativeWindow window_context) {
62 gfx::NativeView container = NULL; 57 gfx::NativeView container = NULL;
63 // On Ash, the app list is placed into an aura::Window container. For the demo 58 // On Ash, the app list is placed into an aura::Window container. For the demo
64 // use the root window context as the parent. This only works on Aura since an 59 // use the root window context as the parent. This only works on Aura since an
65 // aura::Window is also a NativeView. 60 // aura::Window is also a NativeView.
66 #if defined(USE_AURA)
67 container = window_context; 61 container = window_context;
msw 2016/12/20 19:16:10 nit: merge decl and init
Evan Stade 2016/12/29 17:23:12 Done.
68 #endif
69 62
70 view_ = new app_list::AppListView(this); 63 view_ = new app_list::AppListView(this);
71 view_->InitAsBubbleAtFixedLocation(container, 64 view_->InitAsBubble(container, 0);
72 0, 65 view_->SetAnchorPoint(gfx::Point(300, 300));
73 gfx::Point(300, 300),
74 views::BubbleBorder::FLOAT,
75 false /* border_accepts_events */);
76 66
77 // Populate some apps. 67 // Populate some apps.
78 GetTestModel()->PopulateApps(kInitialItems); 68 GetTestModel()->PopulateApps(kInitialItems);
79 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list(); 69 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list();
80 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 70 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
81 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32); 71 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32);
82 for (size_t i = 0; i < item_list->item_count(); ++i) { 72 for (size_t i = 0; i < item_list->item_count(); ++i) {
83 app_list::AppListItem* item = item_list->item_at(i); 73 app_list::AppListItem* item = item_list->item_at(i);
84 // Alternate images with shadows and images without. 74 // Alternate images with shadows and images without.
85 item->SetIcon(*test_image.ToImageSkia()); 75 item->SetIcon(*test_image.ToImageSkia());
(...skipping 30 matching lines...) Expand all
116 gfx::NativeWindow window_context) { 106 gfx::NativeWindow window_context) {
117 DemoAppListViewDelegate* delegate = 107 DemoAppListViewDelegate* delegate =
118 new DemoAppListViewDelegate(browser_context); 108 new DemoAppListViewDelegate(browser_context);
119 app_list::AppListView* view = delegate->InitView(window_context); 109 app_list::AppListView* view = delegate->InitView(window_context);
120 view->GetWidget()->Show(); 110 view->GetWidget()->Show();
121 view->GetWidget()->Activate(); 111 view->GetWidget()->Activate();
122 } 112 }
123 113
124 } // namespace 114 } // namespace
125 115
126 #if defined(OS_WIN)
127 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
128 sandbox::SandboxInterfaceInfo sandbox_info = {0};
129 content::InitializeSandboxInfo(&sandbox_info);
130 ui::ViewsContentClient views_content_client(instance, &sandbox_info);
131 #else
132 int main(int argc, const char** argv) { 116 int main(int argc, const char** argv) {
133 ui::ViewsContentClient views_content_client(argc, argv); 117 ui::ViewsContentClient views_content_client(argc, argv);
134 #endif
135 118
136 views_content_client.set_task(base::Bind(&ShowAppList)); 119 views_content_client.set_task(base::Bind(&ShowAppList));
137 return views_content_client.RunMain(); 120 return views_content_client.RunMain();
138 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698