OLD | NEW |
| (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 #ifndef UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_ | |
6 #define UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/macros.h" | |
10 #include "ui/gfx/native_widget_types.h" | |
11 #include "ui/views_content_client/views_content_client_export.h" | |
12 | |
13 namespace content { | |
14 class BrowserContext; | |
15 } | |
16 | |
17 namespace sandbox { | |
18 struct SandboxInterfaceInfo; | |
19 } | |
20 | |
21 namespace ui { | |
22 | |
23 // Creates a multiprocess views runtime for running an example application. | |
24 // | |
25 // Sample usage: | |
26 // | |
27 // void InitMyApp(content::BrowserContext* browser_context, | |
28 // gfx::NativeView window_context) { | |
29 // // Create desired windows and views here. Runs on the UI thread. | |
30 // } | |
31 // | |
32 // #if defined(OS_WIN) | |
33 // int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { | |
34 // sandbox::SandboxInterfaceInfo sandbox_info = {0}; | |
35 // content::InitializeSandboxInfo(&sandbox_info); | |
36 // ui::ViewsContentClient params(instance, &sandbox_info); | |
37 // #else | |
38 // int main(int argc, const char** argv) { | |
39 // ui::ViewsContentClient params(argc, argv); | |
40 // #endif | |
41 // | |
42 // params.set_task(base::Bind(&InitMyApp)); | |
43 // return params.RunMain(); | |
44 // } | |
45 class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient { | |
46 public: | |
47 typedef base::Callback< | |
48 void(content::BrowserContext* browser_context, | |
49 gfx::NativeView window_context)> Task; | |
50 | |
51 #if defined(OS_WIN) | |
52 ViewsContentClient(HINSTANCE instance, | |
53 sandbox::SandboxInterfaceInfo* sandbox_info); | |
54 #else | |
55 ViewsContentClient(int argc, const char** argv); | |
56 #endif | |
57 | |
58 ~ViewsContentClient(); | |
59 | |
60 // Runs content::ContentMain() using the ExamplesMainDelegate. | |
61 int RunMain(); | |
62 | |
63 // The task to run at the end of BrowserMainParts::PreMainMessageLoopRun(). | |
64 // Ignored if this is not the main process. | |
65 void set_task(const Task& task) { task_ = task; } | |
66 const Task& task() const { return task_; } | |
67 | |
68 private: | |
69 #if defined(OS_WIN) | |
70 HINSTANCE instance_; | |
71 sandbox::SandboxInterfaceInfo* sandbox_info_; | |
72 #else | |
73 int argc_; | |
74 const char** argv_; | |
75 #endif | |
76 Task task_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(ViewsContentClient); | |
79 }; | |
80 | |
81 } // namespace ui | |
82 | |
83 #endif // UI_VIEWS_CONTENT_CLIENT_VIEWS_CONTENT_CLIENT_H_ | |
OLD | NEW |