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

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

Issue 436513002: MacViews: Fix app list demo, for Widget InitParams "context" type change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix CrOS Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 18 matching lines...) Expand all
29 const int kInitialItems = 20; 29 const int kInitialItems = 20;
30 30
31 // Extends the test AppListViewDelegate to quit the run loop when the launcher 31 // Extends the test AppListViewDelegate to quit the run loop when the launcher
32 // window is closed, and to close the window if it is simply dismissed. 32 // window is closed, and to close the window if it is simply dismissed.
33 class DemoAppListViewDelegate : public app_list::test::AppListTestViewDelegate { 33 class DemoAppListViewDelegate : public app_list::test::AppListTestViewDelegate {
34 public: 34 public:
35 explicit DemoAppListViewDelegate(content::BrowserContext* browser_context) 35 explicit DemoAppListViewDelegate(content::BrowserContext* browser_context)
36 : view_(NULL), browser_context_(browser_context) {} 36 : view_(NULL), browser_context_(browser_context) {}
37 virtual ~DemoAppListViewDelegate() {} 37 virtual ~DemoAppListViewDelegate() {}
38 38
39 app_list::AppListView* InitView(gfx::NativeView window_context); 39 app_list::AppListView* InitView(gfx::NativeWindow window_context);
40 40
41 // Overridden from AppListViewDelegate: 41 // Overridden from AppListViewDelegate:
42 virtual void Dismiss() OVERRIDE; 42 virtual void Dismiss() OVERRIDE;
43 virtual void ViewClosing() OVERRIDE; 43 virtual void ViewClosing() OVERRIDE;
44 virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE; 44 virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;
45 45
46 private: 46 private:
47 app_list::AppListView* view_; // Weak. Owns this. 47 app_list::AppListView* view_; // Weak. Owns this.
48 content::BrowserContext* browser_context_; 48 content::BrowserContext* browser_context_;
49 scoped_ptr<content::WebContents> web_contents_; 49 scoped_ptr<content::WebContents> web_contents_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(DemoAppListViewDelegate); 51 DISALLOW_COPY_AND_ASSIGN(DemoAppListViewDelegate);
52 }; 52 };
53 53
54 app_list::AppListView* DemoAppListViewDelegate::InitView( 54 app_list::AppListView* DemoAppListViewDelegate::InitView(
55 gfx::NativeView window_context) { 55 gfx::NativeWindow window_context) {
56 gfx::NativeView container = NULL;
57 // On Ash, the app list is placed into an aura::Window container. For the demo
58 // use the root window context as the parent. This only works on Aura since an
59 // aura::Window is also a NativeView.
60 #if defined(USE_AURA)
61 container = window_context;
62 #endif
63
56 // Note AppListView takes ownership of |this| on the next line. 64 // Note AppListView takes ownership of |this| on the next line.
57 view_ = new app_list::AppListView(this); 65 view_ = new app_list::AppListView(this);
58 view_->InitAsBubbleAtFixedLocation(window_context, 66 view_->InitAsBubbleAtFixedLocation(container,
59 0, 67 0,
60 gfx::Point(300, 300), 68 gfx::Point(300, 300),
61 views::BubbleBorder::FLOAT, 69 views::BubbleBorder::FLOAT,
62 false /* border_accepts_events */); 70 false /* border_accepts_events */);
63 71
64 // Populate some apps. 72 // Populate some apps.
65 GetTestModel()->PopulateApps(kInitialItems); 73 GetTestModel()->PopulateApps(kInitialItems);
66 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list(); 74 app_list::AppListItemList* item_list = GetTestModel()->top_level_item_list();
67 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 75 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
68 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32); 76 gfx::Image test_image = rb.GetImageNamed(IDR_DEFAULT_FAVICON_32);
(...skipping 24 matching lines...) Expand all
93 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 101 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
94 std::string()); 102 std::string());
95 views::WebView* web_view = new views::WebView( 103 views::WebView* web_view = new views::WebView(
96 web_contents_->GetBrowserContext()); 104 web_contents_->GetBrowserContext());
97 web_view->SetPreferredSize(size); 105 web_view->SetPreferredSize(size);
98 web_view->SetWebContents(web_contents_.get()); 106 web_view->SetWebContents(web_contents_.get());
99 return web_view; 107 return web_view;
100 } 108 }
101 109
102 void ShowAppList(content::BrowserContext* browser_context, 110 void ShowAppList(content::BrowserContext* browser_context,
103 gfx::NativeView window_context) { 111 gfx::NativeWindow window_context) {
104 DemoAppListViewDelegate* delegate = 112 DemoAppListViewDelegate* delegate =
105 new DemoAppListViewDelegate(browser_context); 113 new DemoAppListViewDelegate(browser_context);
106 app_list::AppListView* view = delegate->InitView(window_context); 114 app_list::AppListView* view = delegate->InitView(window_context);
107 view->GetWidget()->Show(); 115 view->GetWidget()->Show();
108 view->GetWidget()->Activate(); 116 view->GetWidget()->Activate();
109 } 117 }
110 118
111 } // namespace 119 } // namespace
112 120
113 #if defined(OS_WIN) 121 #if defined(OS_WIN)
114 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { 122 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
115 sandbox::SandboxInterfaceInfo sandbox_info = {0}; 123 sandbox::SandboxInterfaceInfo sandbox_info = {0};
116 content::InitializeSandboxInfo(&sandbox_info); 124 content::InitializeSandboxInfo(&sandbox_info);
117 ui::ViewsContentClient views_content_client(instance, &sandbox_info); 125 ui::ViewsContentClient views_content_client(instance, &sandbox_info);
118 #else 126 #else
119 int main(int argc, const char** argv) { 127 int main(int argc, const char** argv) {
120 ui::ViewsContentClient views_content_client(argc, argv); 128 ui::ViewsContentClient views_content_client(argc, argv);
121 #endif 129 #endif
122 130
123 views_content_client.set_task(base::Bind(&ShowAppList)); 131 views_content_client.set_task(base::Bind(&ShowAppList));
124 return views_content_client.RunMain(); 132 return views_content_client.RunMain();
125 } 133 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698