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

Side by Side Diff: ui/app_list/views/views_demo_app.cc

Issue 303543004: MacViews: views_examples_with_content_exe working! Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files Created 6 years, 6 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 | « ui/app_list/views/views_demo_app.h ('k') | ui/app_list/views/views_demo_app_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/app_list/views/views_demo_app.h"
6
7 #include "base/at_exit.h"
8 #include "base/command_line.h"
9 #include "base/i18n/icu_util.h"
10 #include "base/path_service.h"
11 #include "content/browser/browser_process_sub_thread.h"
12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
14 #include "content/public/app/content_main.h"
15 #include "content/public/app/content_main_delegate.h"
16 #include "content/public/app/content_main_runner.h"
17 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/notification_service.h"
19 #include "content/public/common/content_client.h"
20 #include "content/public/common/content_paths.h"
21 #include "content/test/test_content_client.h"
22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/ui_base_paths.h"
24 #include "ui/gfx/screen.h"
25 #include "ui/gl/gl_surface.h"
26 #include "ui/views/views_delegate.h"
27
28 class ViewsDemoApp::Impl {
29 public:
30 friend class ViewsDemoApp;
31
32 Impl();
33 ~Impl();
34
35 private:
36 void StartThreads();
37
38 base::AtExitManager exit_manager_;
39 content::ContentClient content_client_;
40 content::ContentBrowserClient browser_client_;
41 scoped_ptr<content::NotificationService> notification_service_;
42
43 scoped_ptr<content::BrowserThreadImpl> ui_thread_;
44 scoped_ptr<content::BrowserProcessSubThread> io_thread_;
45 scoped_ptr<content::BrowserProcessSubThread> process_launcher_thread_;
46
47 DISALLOW_COPY_AND_ASSIGN(Impl);
48 };
49
50 ViewsDemoAppDelegate::ViewsDemoAppDelegate() {
51 }
52
53 ViewsDemoAppDelegate::~ViewsDemoAppDelegate() {
54 }
55
56 void ViewsDemoAppDelegate::Init() {
57 }
58
59 void ViewsDemoAppDelegate::Run() {
60 run_loop_.reset(new base::RunLoop);
61 run_loop_->Run();
62 }
63
64 ViewsDemoApp::~ViewsDemoApp() {
65 }
66
67 void ViewsDemoApp::AddOption(const char* description,
68 const base::Callback<void(bool)>& callback,
69 bool initial_state) {
70 NOTIMPLEMENTED();
71 }
72
73 ViewsDemoApp::ViewsDemoApp() : impl_(new Impl) {
74 }
75
76 void ViewsDemoApp::InitOnMainThread() {
77 DCHECK(base::MessageLoopProxy::current());
78
79 impl_->ui_thread_.reset(new content::BrowserThreadImpl(
80 content::BrowserThread::UI, base::MessageLoop::current()));
81
82 content::BrowserGpuChannelHostFactory::Initialize(true);
83 content::ImageTransportFactory::Initialize();
84 }
85
86 ViewsDemoApp::Impl::Impl() {
87 base::i18n::InitializeICU();
88 gfx::GLSurface::InitializeOneOff();
89
90 ui::RegisterPathProvider();
91 content::RegisterPathProvider();
92
93 // Cache the child process path to avoid triggering an AssertIOAllowed.
94 {
95 base::FilePath child_process_exe;
96 PathService::Get(content::CHILD_PROCESS_EXE, &child_process_exe);
97 LOG(INFO) << "Child processes will lauch with: " << child_process_exe.value( );
98 }
99
100 {
101 base::FilePath pak_dir;
102 PathService::Get(base::DIR_MODULE, &pak_dir);
103 base::FilePath pak_file;
104 pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak"));
105 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
106 }
107
108 content::SetContentClient(&content_client_);
109 content::SetBrowserClientForTesting(&browser_client_);
110 notification_service_.reset(content::NotificationService::Create());
111
112 StartThreads();
113 }
114
115 void ViewsDemoApp::Impl::StartThreads() {
116 base::Thread::Options io_message_loop_options;
117 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO;
118 io_thread_.reset(
119 new content::BrowserProcessSubThread(content::BrowserThread::IO));
120 io_thread_->StartWithOptions(io_message_loop_options);
121
122 process_launcher_thread_.reset(new content::BrowserProcessSubThread(
123 content::BrowserThread::PROCESS_LAUNCHER));
124 process_launcher_thread_->StartWithOptions(base::Thread::Options());
125 }
126
127 ViewsDemoApp::Impl::~Impl() {
128 io_thread_.reset();
129
130 content::SetContentClient(&content_client_);
131 content::SetBrowserClientForTesting(&browser_client_);
132
133 ui::ResourceBundle::CleanupSharedInstance();
134 }
135
136 // static
137 int ViewsDemoApp::RunSubProcess(int argc, char** argv) {
138 base::CommandLine command_line = *base::CommandLine::ForCurrentProcess();
139 DLOG(INFO) << command_line.GetCommandLineString();
140
141 base::AtExitManager exit_manager_;
142 content::TestContentClient test_content_client;
143 content::SetContentClient(&test_content_client);
144
145 content::ContentMainDelegate delegate;
146 content::ContentMainParams params(&delegate);
147 params.argc = argc;
148 params.argv = (const char**)argv;
149
150 content::ContentMainRunner* runner = content::ContentMainRunner::Create();
151 runner->Initialize(params);
152 return runner->Run();
153 }
OLDNEW
« no previous file with comments | « ui/app_list/views/views_demo_app.h ('k') | ui/app_list/views/views_demo_app_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698