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

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: remove references on testing bots Created 3 years, 11 months 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
« no previous file with comments | « ui/app_list/BUILD.gn ('k') | ui/app_list/views/app_list_background.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
52 private: 47 private:
53 app_list::AppListView* view_; // Weak. Owns this. 48 app_list::AppListView* view_; // Weak. Owns this.
54 content::BrowserContext* browser_context_; 49 content::BrowserContext* browser_context_;
55 std::unique_ptr<content::WebContents> web_contents_; 50 std::unique_ptr<content::WebContents> web_contents_;
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;
63 // On Ash, the app list is placed into an aura::Window container. For the demo 57 // 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 58 // use the root window context as the parent. This only works on Aura since an
65 // aura::Window is also a NativeView. 59 // aura::Window is also a NativeView.
66 #if defined(USE_AURA) 60 gfx::NativeView container = window_context;
67 container = window_context;
68 #endif
69 61
70 view_ = new app_list::AppListView(this); 62 view_ = new app_list::AppListView(this);
71 view_->InitAsBubbleAtFixedLocation(container, 63 view_->InitAsBubble(container, 0);
72 0, 64 view_->SetAnchorPoint(gfx::Point(300, 300));
73 gfx::Point(300, 300),
74 views::BubbleBorder::FLOAT,
75 false /* border_accepts_events */);
76 65
77 // Populate some apps. 66 // Populate some apps.
78 GetTestModel()->PopulateApps(kInitialItems); 67 GetTestModel()->PopulateApps(kInitialItems);
79 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list(); 68 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list();
80 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
81 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32); 70 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32);
82 for (size_t i = 0; i < item_list->item_count(); ++i) { 71 for (size_t i = 0; i < item_list->item_count(); ++i) {
83 app_list::AppListItem* item = item_list->item_at(i); 72 app_list::AppListItem* item = item_list->item_at(i);
84 // Alternate images with shadows and images without. 73 // Alternate images with shadows and images without.
85 item->SetIcon(*test_image.ToImageSkia()); 74 item->SetIcon(*test_image.ToImageSkia());
(...skipping 30 matching lines...) Expand all
116 gfx::NativeWindow window_context) { 105 gfx::NativeWindow window_context) {
117 DemoAppListViewDelegate* delegate = 106 DemoAppListViewDelegate* delegate =
118 new DemoAppListViewDelegate(browser_context); 107 new DemoAppListViewDelegate(browser_context);
119 app_list::AppListView* view = delegate->InitView(window_context); 108 app_list::AppListView* view = delegate->InitView(window_context);
120 view->GetWidget()->Show(); 109 view->GetWidget()->Show();
121 view->GetWidget()->Activate(); 110 view->GetWidget()->Activate();
122 } 111 }
123 112
124 } // namespace 113 } // namespace
125 114
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) { 115 int main(int argc, const char** argv) {
133 ui::ViewsContentClient views_content_client(argc, argv); 116 ui::ViewsContentClient views_content_client(argc, argv);
134 #endif
135 117
136 views_content_client.set_task(base::Bind(&ShowAppList)); 118 views_content_client.set_task(base::Bind(&ShowAppList));
137 return views_content_client.RunMain(); 119 return views_content_client.RunMain();
138 } 120 }
OLDNEW
« no previous file with comments | « ui/app_list/BUILD.gn ('k') | ui/app_list/views/app_list_background.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698