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