| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 BLIMP_CLIENT_PUBLIC_BLIMP_CLIENT_CONTEXT_H_ | |
| 6 #define BLIMP_CLIENT_PUBLIC_BLIMP_CLIENT_CONTEXT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/single_thread_task_runner.h" | |
| 13 #include "blimp/client/public/blimp_client_context_delegate.h" | |
| 14 #include "blimp/client/public/contents/blimp_contents.h" | |
| 15 #include "components/keyed_service/core/keyed_service.h" | |
| 16 #include "components/prefs/command_line_pref_store.h" | |
| 17 #include "components/prefs/pref_registry_simple.h" | |
| 18 #include "components/prefs/pref_service.h" | |
| 19 #include "ui/gfx/native_widget_types.h" | |
| 20 | |
| 21 #if defined(OS_ANDROID) | |
| 22 #include "base/android/jni_android.h" | |
| 23 #endif // defined(OS_ANDROID) | |
| 24 | |
| 25 namespace blimp { | |
| 26 namespace client { | |
| 27 class CompositorDependencies; | |
| 28 | |
| 29 // BlimpClientContext is the core class for the Blimp client. It provides hooks | |
| 30 // for creating BlimpContents and other features that are per | |
| 31 // BrowserContext/Profile. | |
| 32 class BlimpClientContext : public KeyedService { | |
| 33 public: | |
| 34 #if defined(OS_ANDROID) | |
| 35 // Returns a Java object of the type BlimpClientContext for the given | |
| 36 // BlimpClientContext. | |
| 37 static base::android::ScopedJavaLocalRef<jobject> GetJavaObject( | |
| 38 BlimpClientContext* blimp_client_context); | |
| 39 #endif // defined(OS_ANDROID) | |
| 40 | |
| 41 // Creates a BlimpClientContext. The implementation of this function | |
| 42 // depends on whether the core or dummy implementation of Blimp has been | |
| 43 // linked in. | |
| 44 // The |io_thread_task_runner| must be the task runner to use for IO | |
| 45 // operations. | |
| 46 // The |file_thread_task_runner| must be the task runner to use for file | |
| 47 // operations. | |
| 48 // |compositor_dependencies| is a support object that provides all embedder | |
| 49 // dependencies required by internal compositors. | |
| 50 static BlimpClientContext* Create( | |
| 51 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | |
| 52 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | |
| 53 std::unique_ptr<CompositorDependencies> compositor_dependencies, | |
| 54 PrefService* local_state); | |
| 55 | |
| 56 // Register Blimp prefs. The implementation of this function depends on | |
| 57 // whether the core or dummy implementation of Blimp has been linked in. | |
| 58 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 59 | |
| 60 // Apply blimp command-line switches to the corresponding preferences of the | |
| 61 // blimp's own switch map. | |
| 62 static void ApplyBlimpSwitches(CommandLinePrefStore* store); | |
| 63 | |
| 64 // The delegate provides all the required functionality from the embedder. | |
| 65 // The context must be initialized with a |delegate| before it can be used. | |
| 66 virtual void SetDelegate(BlimpClientContextDelegate* delegate) = 0; | |
| 67 | |
| 68 // Creates a new BlimpContents that will be shown in |window|. | |
| 69 // TODO(mlliu): Currently we want to have a single BlimpContents. If there is | |
| 70 // an existing contents, return nullptr (http://crbug.com/642558). | |
| 71 virtual std::unique_ptr<BlimpContents> CreateBlimpContents( | |
| 72 gfx::NativeWindow window) = 0; | |
| 73 | |
| 74 // Start authentication flow and connection to engine. | |
| 75 virtual void Connect() = 0; | |
| 76 virtual void ConnectWithAssignment(const Assignment& assignment) = 0; | |
| 77 | |
| 78 protected: | |
| 79 BlimpClientContext() = default; | |
| 80 | |
| 81 private: | |
| 82 DISALLOW_COPY_AND_ASSIGN(BlimpClientContext); | |
| 83 }; | |
| 84 | |
| 85 } // namespace client | |
| 86 } // namespace blimp | |
| 87 | |
| 88 #endif // BLIMP_CLIENT_PUBLIC_BLIMP_CLIENT_CONTEXT_H_ | |
| OLD | NEW |