Chromium Code Reviews| Index: ui/views/examples/content_client/examples_main.h |
| diff --git a/ui/views/examples/content_client/examples_main.h b/ui/views/examples/content_client/examples_main.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3604ff52f270e786752e7872a2e3b8f27b15bff0 |
| --- /dev/null |
| +++ b/ui/views/examples/content_client/examples_main.h |
| @@ -0,0 +1,85 @@ |
| +// 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_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_H_ |
| +#define UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "ui/gfx/native_widget_types.h" |
| +#include "ui/views/examples/views_examples_with_content_export.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace sandbox { |
| +struct SandboxInterfaceInfo; |
| +} |
| + |
| +namespace views { |
| +namespace examples { |
| + |
| +// 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}; |
|
tapted
2014/05/20 08:45:35
note: I think I can get rid of some of this boiler
|
| +// content::InitializeSandboxInfo(&sandbox_info); |
| +// views::examples::ExamplesMainParams params(instance, &sandbox_info); |
| +// #else |
| +// int main(int argc, const char** argv) { |
| +// views::examples::ExamplesMainParams params(argc, argv); |
| +// #endif |
| +// |
| +// params.set_task(base::Bind(&InitMyApp)); |
| +// return params.RunMain(); |
| +// } |
| +class VIEWS_EXAMPLES_WITH_CONTENT_EXPORT ExamplesMainParams { |
| + public: |
| + typedef base::Callback< |
| + void(content::BrowserContext* browser_context, |
| + gfx::NativeView window_context)> Task; |
| + |
| +#if defined(OS_WIN) |
| + ExamplesMainParams(HINSTANCE instance, |
| + sandbox::SandboxInterfaceInfo* sandbox_info); |
| +#else |
| + ExamplesMainParams(int argc, const char** argv); |
| +#endif |
| + |
| + ~ExamplesMainParams(); |
| + |
| + // 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(ExamplesMainParams); |
| +}; |
| + |
| +} // namespace examples |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_EXAMPLES_CONTENT_CLIENT_EXAMPLES_MAIN_H_ |