Commit d4d21546 authored by alph@chromium.org's avatar alph@chromium.org

Revert of Repurpose views+content example into a generic multiprocess views...

Revert of Repurpose views+content example into a generic multiprocess views runtime (https://codereview.chromium.org/284113011/)

Reason for revert:
Broke Blink runhooks step http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Win%20x64%20Builder%20%28dbg%29/builds/12039

Original issue's description:
> Repurpose views+content example into a generic multiprocess views runtime
> 
> This is to facilitate the addition of an app launcher example/demo app,
> separate from the browser, and to assist testing of the out-of-process
> compositor on mac.
> 
> The change splits out from the current views_examples_with_content_exe
> target a new views_content_client target placed in
> ui/views_content_client. views_examples_with_content_exe is updated to
> use it.
> 
> This will allow the app launcher to have its own example app, while
> reusing the logic to set up the multiprocess runtime environment for
> using views and content.
> 
> Follow-up patches for the views_content_client runtime will: isolate
> aura dependencies, introduce the gpu_process UI compositor, and
> implement the runtime environment for mac.
> 
> BUG=365977
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=272476

TBR=ben@chromium.org,tapted@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=365977

Review URL: https://codereview.chromium.org/288313012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272489 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e503205
......@@ -3,5 +3,4 @@ include_rules = [
"+content/shell",
"+sandbox",
"+ui/gl/gl_surface.h", # To initialize GL bindings.
"+ui/views_content_client",
]
include_rules = [
"+content/public",
"+content/shell",
"+ui/aura",
"+ui/base",
"+ui/gfx",
"+ui/views",
"+ui/wm",
]
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views_content_client/views_content_client_main_parts.h"
#include "ui/views/examples/content_client/examples_browser_main_parts.h"
#include "base/bind.h"
#include "base/command_line.h"
......@@ -17,10 +17,11 @@
#include "ui/aura/env.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/gfx/screen.h"
#include "ui/views/examples/examples_window_with_content.h"
#include "ui/views/test/desktop_test_views_delegate.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views_content_client/views_content_client.h"
#include "ui/wm/core/wm_state.h"
#include "url/gurl.h"
#if defined(OS_CHROMEOS)
#include "ui/aura/test/test_screen.h"
......@@ -31,22 +32,21 @@
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#endif
namespace ui {
namespace views {
namespace examples {
ViewsContentClientMainParts::ViewsContentClientMainParts(
const content::MainFunctionParams& content_params,
ViewsContentClient* views_content_client)
: views_content_client_(views_content_client) {
ExamplesBrowserMainParts::ExamplesBrowserMainParts(
const content::MainFunctionParams& parameters) {
}
ViewsContentClientMainParts::~ViewsContentClientMainParts() {
ExamplesBrowserMainParts::~ExamplesBrowserMainParts() {
}
void ViewsContentClientMainParts::ToolkitInitialized() {
wm_state_.reset(new ::wm::WMState);
void ExamplesBrowserMainParts::ToolkitInitialized() {
wm_state_.reset(new wm::WMState);
}
void ViewsContentClientMainParts::PreMainMessageLoopRun() {
void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
ui::InitializeInputMethodForTesting();
browser_context_.reset(new content::ShellBrowserContext(false, NULL));
......@@ -55,8 +55,8 @@ void ViewsContentClientMainParts::PreMainMessageLoopRun() {
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create());
// Set up basic pieces of views::corewm.
wm_test_helper_.reset(new ::wm::WMTestHelper(gfx::Size(800, 600),
content::GetContextFactory()));
wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600),
content::GetContextFactory()));
// Ensure the X window gets mapped.
wm_test_helper_->host()->Show();
// Ensure Aura knows where to open new windows.
......@@ -64,14 +64,15 @@ void ViewsContentClientMainParts::PreMainMessageLoopRun() {
#else
aura::Env::CreateInstance(true);
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen());
#endif
views_delegate_.reset(new views::DesktopTestViewsDelegate);
views_delegate_.reset(new DesktopTestViewsDelegate);
views_content_client_->task().Run(browser_context_.get(), window_context);
ShowExamplesWindowWithContent(
QUIT_ON_CLOSE, browser_context_.get(), window_context);
}
void ViewsContentClientMainParts::PostMainMessageLoopRun() {
void ExamplesBrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
#if defined(OS_CHROMEOS)
wm_test_helper_.reset();
......@@ -80,10 +81,11 @@ void ViewsContentClientMainParts::PostMainMessageLoopRun() {
aura::Env::DeleteInstance();
}
bool ViewsContentClientMainParts::MainMessageLoopRun(int* result_code) {
bool ExamplesBrowserMainParts::MainMessageLoopRun(int* result_code) {
base::RunLoop run_loop;
run_loop.Run();
return true;
}
} // namespace ui
} // namespace examples
} // namespace views
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_MAIN_PARTS_H_
#define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_MAIN_PARTS_H_
#ifndef UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
#define UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
......@@ -14,25 +14,21 @@ class ShellBrowserContext;
struct MainFunctionParams;
}
namespace views {
class ViewsDelegate;
}
namespace wm {
class WMState;
class WMTestHelper;
}
namespace ui {
namespace views {
class ViewsDelegate;
class ViewsContentClient;
namespace examples {
class ViewsContentClientMainParts : public content::BrowserMainParts {
class ExamplesBrowserMainParts : public content::BrowserMainParts {
public:
ViewsContentClientMainParts(
const content::MainFunctionParams& content_params,
ViewsContentClient* views_content_client);
virtual ~ViewsContentClientMainParts();
explicit ExamplesBrowserMainParts(
const content::MainFunctionParams& parameters);
virtual ~ExamplesBrowserMainParts();
// content::BrowserMainParts:
virtual void ToolkitInitialized() OVERRIDE;
......@@ -47,7 +43,7 @@ class ViewsContentClientMainParts : public content::BrowserMainParts {
private:
scoped_ptr<content::ShellBrowserContext> browser_context_;
scoped_ptr<views::ViewsDelegate> views_delegate_;
scoped_ptr<ViewsDelegate> views_delegate_;
#if defined(OS_CHROMEOS)
// Enable a minimal set of views::corewm to be initialized.
......@@ -56,11 +52,10 @@ class ViewsContentClientMainParts : public content::BrowserMainParts {
scoped_ptr<wm::WMState> wm_state_;
ViewsContentClient* views_content_client_;
DISALLOW_COPY_AND_ASSIGN(ViewsContentClientMainParts);
DISALLOW_COPY_AND_ASSIGN(ExamplesBrowserMainParts);
};
} // namespace ui
} // namespace examples
} // namespace views
#endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_MAIN_PARTS_H_
#endif // UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
......@@ -2,38 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views_content_client/views_content_browser_client.h"
#include "ui/views/examples/content_client/examples_content_browser_client.h"
#include "content/shell/browser/shell_browser_context.h"
#include "ui/views_content_client/views_content_client_main_parts.h"
#include "ui/views/examples/content_client/examples_browser_main_parts.h"
namespace ui {
namespace views {
namespace examples {
ViewsContentBrowserClient::ViewsContentBrowserClient(
ViewsContentClient* views_content_client)
: views_content_main_parts_(NULL),
views_content_client_(views_content_client) {
ExamplesContentBrowserClient::ExamplesContentBrowserClient()
: examples_browser_main_parts_(NULL) {
}
ViewsContentBrowserClient::~ViewsContentBrowserClient() {
ExamplesContentBrowserClient::~ExamplesContentBrowserClient() {
}
content::BrowserMainParts* ViewsContentBrowserClient::CreateBrowserMainParts(
content::BrowserMainParts* ExamplesContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
views_content_main_parts_ =
new ViewsContentClientMainParts(parameters, views_content_client_);
return views_content_main_parts_;
examples_browser_main_parts_ = new ExamplesBrowserMainParts(parameters);
return examples_browser_main_parts_;
}
net::URLRequestContextGetter*
ViewsContentBrowserClient::CreateRequestContext(
ExamplesContentBrowserClient::CreateRequestContext(
content::BrowserContext* content_browser_context,
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) {
content::ShellBrowserContext* shell_context =
views_content_main_parts_->browser_context();
examples_browser_main_parts_->browser_context();
return shell_context->CreateRequestContext(protocol_handlers,
protocol_interceptors.Pass());
}
} // namespace ui
} // namespace examples
} // namespace views
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_BROWSER_CLIENT_H_
#define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_BROWSER_CLIENT_H_
#ifndef UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_CONTENT_BROWSER_CLIENT_H_
#define UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_CONTENT_BROWSER_CLIENT_H_
#include "base/macros.h"
#include "content/public/browser/content_browser_client.h"
......@@ -12,16 +12,15 @@ namespace content {
class ShellBrowserContext;
}
namespace ui {
namespace views {
namespace examples {
class ViewsContentClient;
class ViewsContentClientMainParts;
class ExamplesBrowserMainParts;
class ViewsContentBrowserClient : public content::ContentBrowserClient {
class ExamplesContentBrowserClient : public content::ContentBrowserClient {
public:
explicit ViewsContentBrowserClient(
ViewsContentClient* views_content_client);
virtual ~ViewsContentBrowserClient();
ExamplesContentBrowserClient();
virtual ~ExamplesContentBrowserClient();
// content::ContentBrowserClient:
virtual content::BrowserMainParts* CreateBrowserMainParts(
......@@ -32,12 +31,12 @@ class ViewsContentBrowserClient : public content::ContentBrowserClient {
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
private:
ViewsContentClientMainParts* views_content_main_parts_;
ViewsContentClient* views_content_client_;
ExamplesBrowserMainParts* examples_browser_main_parts_;
DISALLOW_COPY_AND_ASSIGN(ViewsContentBrowserClient);
DISALLOW_COPY_AND_ASSIGN(ExamplesContentBrowserClient);
};
} // namespace ui
} // namespace examples
} // namespace views
#endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_BROWSER_CLIENT_H_
#endif // UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_CONTENT_BROWSER_CLIENT_H_
......@@ -2,40 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views_content_client/views_content_client.h"
#include "content/public/app/content_main.h"
#include "ui/views_content_client/views_content_main_delegate.h"
#include "ui/views/examples/content_client/examples_main_delegate.h"
namespace ui {
#if defined(OS_WIN)
#include "content/public/app/startup_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if defined(OS_WIN)
ViewsContentClient::ViewsContentClient(
HINSTANCE instance, sandbox::SandboxInterfaceInfo* sandbox_info)
: instance_(instance), sandbox_info_(sandbox_info) {
}
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
#else
ViewsContentClient::ViewsContentClient(int argc, const char** argv)
: argc_(argc), argv_(argv) {
}
int main(int argc, const char** argv) {
#endif
ViewsContentClient::~ViewsContentClient() {
}
int ViewsContentClient::RunMain() {
ViewsContentMainDelegate delegate(this);
views::examples::ExamplesMainDelegate delegate;
content::ContentMainParams params(&delegate);
#if defined(OS_WIN)
params.instance = instance_;
params.sandbox_info = sandbox_info_;
sandbox::SandboxInterfaceInfo sandbox_info = {0};
content::InitializeSandboxInfo(&sandbox_info);
params.instance = instance;
params.sandbox_info = &sandbox_info;
#else
params.argc = argc_;
params.argv = argv_;
params.argc = argc;
params.argv = argv;
#endif
return content::ContentMain(params);
}
} // namespace ui
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views_content_client/views_content_main_delegate.h"
#include "ui/views/examples/content_client/examples_main_delegate.h"
#include <string>
......@@ -13,33 +13,32 @@
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/views_content_client/views_content_browser_client.h"
#include "ui/views/examples/content_client/examples_content_browser_client.h"
#if defined(OS_WIN)
#include "base/logging_win.h"
#endif
namespace ui {
namespace views {
namespace examples {
namespace {
#if defined(OS_WIN)
// {83FAC8EE-7A0E-4dbb-A3F6-6F500D7CAB1A}
const GUID kViewsContentClientProviderName =
const GUID kViewsExamplesProviderName =
{ 0x83fac8ee, 0x7a0e, 0x4dbb,
{ 0xa3, 0xf6, 0x6f, 0x50, 0xd, 0x7c, 0xab, 0x1a } };
#endif
} // namespace
ViewsContentMainDelegate::ViewsContentMainDelegate(
ViewsContentClient* views_content_client)
: views_content_client_(views_content_client) {
ExamplesMainDelegate::ExamplesMainDelegate() {
}
ViewsContentMainDelegate::~ViewsContentMainDelegate() {
ExamplesMainDelegate::~ExamplesMainDelegate() {
}
bool ViewsContentMainDelegate::BasicStartupComplete(int* exit_code) {
bool ExamplesMainDelegate::BasicStartupComplete(int* exit_code) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
......@@ -51,22 +50,23 @@ bool ViewsContentMainDelegate::BasicStartupComplete(int* exit_code) {
bool success = logging::InitLogging(settings);
CHECK(success);
#if defined(OS_WIN)
logging::LogEventProvider::Initialize(kViewsContentClientProviderName);
logging::LogEventProvider::Initialize(kViewsExamplesProviderName);
#endif
return false;
}
void ViewsContentMainDelegate::PreSandboxStartup() {
void ExamplesMainDelegate::PreSandboxStartup() {
base::FilePath ui_test_pak_path;
DCHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
}
content::ContentBrowserClient*
ViewsContentMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new ViewsContentBrowserClient(views_content_client_));
ExamplesMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new ExamplesContentBrowserClient);
return browser_client_.get();
}
} // namespace ui
} // namespace examples
} // namespace views
......@@ -2,23 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_MAIN_DELEGATE_H_
#define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_MAIN_DELEGATE_H_
#ifndef UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_DELEGATE_H_
#define UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_DELEGATE_H_
#include <string>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/app/content_main_delegate.h"
#include "content/shell/common/shell_content_client.h"
namespace ui {
namespace views {
namespace examples {
class ViewsContentBrowserClient;
class ViewsContentClient;
class ExamplesContentBrowserClient;
class ViewsContentMainDelegate : public content::ContentMainDelegate {
class ExamplesMainDelegate : public content::ContentMainDelegate {
public:
explicit ViewsContentMainDelegate(ViewsContentClient* views_content_client);
virtual ~ViewsContentMainDelegate();
ExamplesMainDelegate();
virtual ~ExamplesMainDelegate();
// content::ContentMainDelegate implementation
virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
......@@ -26,13 +28,13 @@ class ViewsContentMainDelegate : public content::ContentMainDelegate {
virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
private:
scoped_ptr<ViewsContentBrowserClient> browser_client_;
scoped_ptr<ExamplesContentBrowserClient> browser_client_;
content::ShellContentClient content_client_;
ViewsContentClient* views_content_client_;
DISALLOW_COPY_AND_ASSIGN(ViewsContentMainDelegate);
DISALLOW_COPY_AND_ASSIGN(ExamplesMainDelegate);
};
} // namespace ui
} // namespace examples
} // namespace views
#endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_MAIN_DELEGATE_H_
#endif // UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_DELEGATE_H_
......@@ -117,14 +117,26 @@
'type': '<(component)',
'dependencies': [
'../../../base/base.gyp:base',
'../../../base/base.gyp:base_i18n',
'../../../content/content.gyp:content',
'../../../skia/skia.gyp:skia',
'../../../third_party/icu/icu.gyp:icui18n',
'../../../third_party/icu/icu.gyp:icuuc',
'../../../url/url.gyp:url_lib',
'../../aura/aura.gyp:aura',
'../../base/ui_base.gyp:ui_base',
'../../events/events.gyp:events',
'../../gfx/gfx.gyp:gfx',
'../../gfx/gfx.gyp:gfx_geometry',
'../../resources/ui_resources.gyp:ui_resources',
'../../resources/ui_resources.gyp:ui_test_pak',
'../controls/webview/webview.gyp:webview',
'../views.gyp:views',
'views_examples_lib',
],
'include_dirs': [
'../../..',
],
'defines': [
'VIEWS_EXAMPLES_WITH_CONTENT_IMPLEMENTATION',
],
......@@ -135,19 +147,53 @@
'webview_example.cc',
'webview_example.h',
],
'conditions': [
['OS=="win"', {
'include_dirs': [
'../../../third_party/wtl/include',
],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
}],
],
}, # target_name: views_examples_with_content_lib
{
'target_name': 'views_examples_with_content_exe',
'type': 'executable',
'dependencies': [
'../../../base/base.gyp:base',
'../../../base/base.gyp:base_i18n',
'../../../content/content.gyp:content',
'../../views_content_client/views_content_client.gyp:views_content_client',
'../../../content/content_shell_and_tests.gyp:content_shell_lib',
'../../../content/content_shell_and_tests.gyp:test_support_content',
'../../../skia/skia.gyp:skia',
'../../../third_party/icu/icu.gyp:icui18n',
'../../../third_party/icu/icu.gyp:icuuc',
'../../aura/aura.gyp:aura',
'../../base/ui_base.gyp:ui_base',
'../../compositor/compositor.gyp:compositor',
'../../events/events.gyp:events',
'../../gfx/gfx.gyp:gfx',
'../../gfx/gfx.gyp:gfx_geometry',
'../../resources/ui_resources.gyp:ui_resources',
'../../resources/ui_resources.gyp:ui_test_pak',
'../../wm/wm.gyp:wm_test_support',
'../views.gyp:views',
'../views.gyp:views_test_support',
'views_examples_with_content_lib',
],
'include_dirs': [
'../../..',
],
'sources': [
'../../../content/app/startup_helper_win.cc',
'examples_with_content_main_exe.cc',
'content_client/examples_browser_main_parts.cc',
'content_client/examples_browser_main_parts.h',
'content_client/examples_content_browser_client.cc',
'content_client/examples_content_browser_client.h',
'content_client/examples_main_delegate.cc',
'content_client/examples_main_delegate.h',
'content_client/examples_main.cc',
],
'conditions': [
['OS=="win"', {
......@@ -171,6 +217,13 @@
'../../../sandbox/sandbox.gyp:sandbox',
],
}],
['OS=="win"', {
'sources/': [
# This is needed because the aura rule strips it from the default
# sources list.
['include', '^../../../content/app/startup_helper_win.cc'],
],
}],
],
}, # target_name: views_examples_with_content_exe
],
......
// 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 "base/bind.h"
#include "content/public/browser/browser_context.h"
#include "ui/views/examples/examples_window_with_content.h"
#include "ui/views_content_client/views_content_client.h"
#if defined(OS_WIN)
#include "content/public/app/startup_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
namespace {
void ShowContentExampleWindow(content::BrowserContext* browser_context,
gfx::NativeView window_context) {
views::examples::ShowExamplesWindowWithContent(views::examples::QUIT_ON_CLOSE,
browser_context,
window_context);
// These lines serve no purpose other than to introduce an explicit content
// dependency. If the main executable doesn't have this dependency, the linker
// has more flexibility to reorder library dependencies in a shared component
// build. On linux, this can cause libc to appear before libcontent in the
// dlsym search path, which breaks (usually valid) assumptions made in
// sandbox::InitLibcUrandomOverrides(). See http://crbug.com/374712.
if (!browser_context) {
content::BrowserContext::SaveSessionState(NULL);
NOTREACHED();
}
}
} // namespace
#if defined(OS_WIN)
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
sandbox::SandboxInterfaceInfo sandbox_info = {0};
content::InitializeSandboxInfo(&sandbox_info);
ui::ViewsContentClient views_content_client(instance, &sandbox_info);
#else
int main(int argc, const char** argv) {
ui::ViewsContentClient views_content_client(argc, argv);
#endif
views_content_client.set_task(base::Bind(&ShowContentExampleWindow));
return views_content_client.RunMain();
}
This directory contains a content client for standalone views apps. It sets up
the multiprocess runtime environment for rendering web content, and establishes
the required environment for running a toolkit-views application.
# 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.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
'target_name': 'views_content_client',
'type': '<(component)',
'dependencies': [
'../../base/base.gyp:base',
'../../base/base.gyp:base_i18n',
'../../content/content.gyp:content',
'../../content/content_shell_and_tests.gyp:content_shell_lib',
'../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc',
'../aura/aura.gyp:aura',
'../base/ui_base.gyp:ui_base',
'../events/events.gyp:events',
'../gfx/gfx.gyp:gfx',
'../gfx/gfx.gyp:gfx_geometry',
'../resources/ui_resources.gyp:ui_resources',
'../resources/ui_resources.gyp:ui_test_pak',
'../views/views.gyp:views',
'../views/views.gyp:views_test_support',
],
'defines': [
'VIEWS_CONTENT_CLIENT_IMPLEMENTATION',
],
'sources': [
'views_content_browser_client.cc',
'views_content_browser_client.h',
'views_content_client.cc',
'views_content_client.h',
'views_content_client_export.h',
'views_content_client_main_parts.cc',
'views_content_client_main_parts.h',
'views_content_main_delegate.cc',
'views_main_delegate.h',
],
}, # target_name: views_content_client
],
}
// 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.
#ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_
#define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_
#include "base/callback.h"
#include "base/macros.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views_content_client/views_content_client_export.h"
namespace content {
class BrowserContext;
}
namespace sandbox {
struct SandboxInterfaceInfo;
}
namespace ui {
// Creates a multiprocess views runtime for running an example application.
//
// Sample usage:
//
// void InitMyApp(content::BrowserContext* browser_context,
// gfx::NativeView window_context) {
// // Create desired windows and views here. Runs on the UI thread.
// }
//
// #if defined(OS_WIN)
// int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
// sandbox::SandboxInterfaceInfo sandbox_info = {0};
// content::InitializeSandboxInfo(&sandbox_info);
// ui::ViewsContentClient params(instance, &sandbox_info);
// #else
// int main(int argc, const char** argv) {
// ui::ViewsContentClient params(argc, argv);
// #endif
//
// params.set_task(base::Bind(&InitMyApp));
// return params.RunMain();
// }
class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient {
public:
typedef base::Callback<
void(content::BrowserContext* browser_context,
gfx::NativeView window_context)> Task;
#if defined(OS_WIN)
ViewsContentClient(HINSTANCE instance,
sandbox::SandboxInterfaceInfo* sandbox_info);
#else
ViewsContentClient(int argc, const char** argv);
#endif
~ViewsContentClient();
// Runs content::ContentMain() using the ExamplesMainDelegate.
int RunMain();
// The task to run at the end of BrowserMainParts::PreMainMessageLoopRun().
// Ignored if this is not the main process.
void set_task(const Task& task) { task_ = task; }
const Task& task() const { return task_; }
private:
#if defined(OS_WIN)
HINSTANCE instance_;
sandbox::SandboxInterfaceInfo* sandbox_info_;
#else
int argc_;
const char** argv_;
#endif
Task task_;
DISALLOW_COPY_AND_ASSIGN(ViewsContentClient);
};
} // namespace ui
#endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_
// 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.
#ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_EXPORT_H_
#define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_EXPORT_H_
// Defines VIEWS_CONTENT_CLIENT_EXPORT so that functionality implemented by the
// views_content_client module can be exported to consumers.
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(VIEWS_CONTENT_CLIENT_IMPLEMENTATION)
#define VIEWS_CONTENT_CLIENT_EXPORT __declspec(dllexport)
#else
#define VIEWS_CONTENT_CLIENT_EXPORT __declspec(dllimport)
#endif // defined(VIEWS_CONTENT_CLIENT_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(VIEWS_CONTENT_CLIENT_IMPLEMENTATION)
#define VIEWS_CONTENT_CLIENT_EXPORT __attribute__((visibility("default")))
#else
#define VIEWS_CONTENT_CLIENT_EXPORT
#endif
#endif // defined(VIEWS_CONTENT_CLIENT_IMPLEMENTATION)
#else // defined(COMPONENT_BUILD)
#define VIEWS_CONTENT_CLIENT_EXPORT
#endif
#endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_EXPORT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment