| Index: ui/app_list/views/views_demo_app.cc
|
| diff --git a/ui/app_list/views/views_demo_app.cc b/ui/app_list/views/views_demo_app.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fb68f869b45a5fb7460b7417f5c08affaa630da4
|
| --- /dev/null
|
| +++ b/ui/app_list/views/views_demo_app.cc
|
| @@ -0,0 +1,153 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/app_list/views/views_demo_app.h"
|
| +
|
| +#include "base/at_exit.h"
|
| +#include "base/command_line.h"
|
| +#include "base/i18n/icu_util.h"
|
| +#include "base/path_service.h"
|
| +#include "content/browser/browser_process_sub_thread.h"
|
| +#include "content/browser/compositor/image_transport_factory.h"
|
| +#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
|
| +#include "content/public/app/content_main.h"
|
| +#include "content/public/app/content_main_delegate.h"
|
| +#include "content/public/app/content_main_runner.h"
|
| +#include "content/public/browser/content_browser_client.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +#include "content/public/common/content_client.h"
|
| +#include "content/public/common/content_paths.h"
|
| +#include "content/test/test_content_client.h"
|
| +#include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/base/ui_base_paths.h"
|
| +#include "ui/gfx/screen.h"
|
| +#include "ui/gl/gl_surface.h"
|
| +#include "ui/views/views_delegate.h"
|
| +
|
| +class ViewsDemoApp::Impl {
|
| + public:
|
| + friend class ViewsDemoApp;
|
| +
|
| + Impl();
|
| + ~Impl();
|
| +
|
| + private:
|
| + void StartThreads();
|
| +
|
| + base::AtExitManager exit_manager_;
|
| + content::ContentClient content_client_;
|
| + content::ContentBrowserClient browser_client_;
|
| + scoped_ptr<content::NotificationService> notification_service_;
|
| +
|
| + scoped_ptr<content::BrowserThreadImpl> ui_thread_;
|
| + scoped_ptr<content::BrowserProcessSubThread> io_thread_;
|
| + scoped_ptr<content::BrowserProcessSubThread> process_launcher_thread_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Impl);
|
| +};
|
| +
|
| +ViewsDemoAppDelegate::ViewsDemoAppDelegate() {
|
| +}
|
| +
|
| +ViewsDemoAppDelegate::~ViewsDemoAppDelegate() {
|
| +}
|
| +
|
| +void ViewsDemoAppDelegate::Init() {
|
| +}
|
| +
|
| +void ViewsDemoAppDelegate::Run() {
|
| + run_loop_.reset(new base::RunLoop);
|
| + run_loop_->Run();
|
| +}
|
| +
|
| +ViewsDemoApp::~ViewsDemoApp() {
|
| +}
|
| +
|
| +void ViewsDemoApp::AddOption(const char* description,
|
| + const base::Callback<void(bool)>& callback,
|
| + bool initial_state) {
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
| +ViewsDemoApp::ViewsDemoApp() : impl_(new Impl) {
|
| +}
|
| +
|
| +void ViewsDemoApp::InitOnMainThread() {
|
| + DCHECK(base::MessageLoopProxy::current());
|
| +
|
| + impl_->ui_thread_.reset(new content::BrowserThreadImpl(
|
| + content::BrowserThread::UI, base::MessageLoop::current()));
|
| +
|
| + content::BrowserGpuChannelHostFactory::Initialize(true);
|
| + content::ImageTransportFactory::Initialize();
|
| +}
|
| +
|
| +ViewsDemoApp::Impl::Impl() {
|
| + base::i18n::InitializeICU();
|
| + gfx::GLSurface::InitializeOneOff();
|
| +
|
| + ui::RegisterPathProvider();
|
| + content::RegisterPathProvider();
|
| +
|
| + // Cache the child process path to avoid triggering an AssertIOAllowed.
|
| + {
|
| + base::FilePath child_process_exe;
|
| + PathService::Get(content::CHILD_PROCESS_EXE, &child_process_exe);
|
| + LOG(INFO) << "Child processes will lauch with: " << child_process_exe.value();
|
| + }
|
| +
|
| + {
|
| + base::FilePath pak_dir;
|
| + PathService::Get(base::DIR_MODULE, &pak_dir);
|
| + base::FilePath pak_file;
|
| + pak_file = pak_dir.Append(FILE_PATH_LITERAL("ui_test.pak"));
|
| + ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
|
| + }
|
| +
|
| + content::SetContentClient(&content_client_);
|
| + content::SetBrowserClientForTesting(&browser_client_);
|
| + notification_service_.reset(content::NotificationService::Create());
|
| +
|
| + StartThreads();
|
| +}
|
| +
|
| +void ViewsDemoApp::Impl::StartThreads() {
|
| + base::Thread::Options io_message_loop_options;
|
| + io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO;
|
| + io_thread_.reset(
|
| + new content::BrowserProcessSubThread(content::BrowserThread::IO));
|
| + io_thread_->StartWithOptions(io_message_loop_options);
|
| +
|
| + process_launcher_thread_.reset(new content::BrowserProcessSubThread(
|
| + content::BrowserThread::PROCESS_LAUNCHER));
|
| + process_launcher_thread_->StartWithOptions(base::Thread::Options());
|
| +}
|
| +
|
| +ViewsDemoApp::Impl::~Impl() {
|
| + io_thread_.reset();
|
| +
|
| + content::SetContentClient(&content_client_);
|
| + content::SetBrowserClientForTesting(&browser_client_);
|
| +
|
| + ui::ResourceBundle::CleanupSharedInstance();
|
| +}
|
| +
|
| +// static
|
| +int ViewsDemoApp::RunSubProcess(int argc, char** argv) {
|
| + base::CommandLine command_line = *base::CommandLine::ForCurrentProcess();
|
| + DLOG(INFO) << command_line.GetCommandLineString();
|
| +
|
| + base::AtExitManager exit_manager_;
|
| + content::TestContentClient test_content_client;
|
| + content::SetContentClient(&test_content_client);
|
| +
|
| + content::ContentMainDelegate delegate;
|
| + content::ContentMainParams params(&delegate);
|
| + params.argc = argc;
|
| + params.argv = (const char**)argv;
|
| +
|
| + content::ContentMainRunner* runner = content::ContentMainRunner::Create();
|
| + runner->Initialize(params);
|
| + return runner->Run();
|
| +}
|
|
|