OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ |
| 6 #define EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "extensions/common/api/display_source.h" |
| 10 #include "extensions/renderer/api/display_source/display_source_session.h" |
| 11 #include "extensions/renderer/object_backed_native_handler.h" |
| 12 #include "v8/include/v8.h" |
| 13 |
| 14 namespace extensions { |
| 15 class ScriptContext; |
| 16 |
| 17 // Implements custom bindings for the displaySource API. |
| 18 class DisplaySourceCustomBindings : public ObjectBackedNativeHandler { |
| 19 public: |
| 20 explicit DisplaySourceCustomBindings(ScriptContext* context); |
| 21 |
| 22 ~DisplaySourceCustomBindings() override; |
| 23 |
| 24 private: |
| 25 // ObjectBackedNativeHandler override. |
| 26 void Invalidate() override; |
| 27 |
| 28 void StartSession( |
| 29 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 30 void TerminateSession( |
| 31 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 32 |
| 33 void DispatchSessionStarted(int sink_id) const; |
| 34 void DispatchSessionTerminated(int sink_id) const; |
| 35 void DispatchSessionError(int sink_id, |
| 36 DisplaySourceErrorType type, |
| 37 const std::string& message) const; |
| 38 |
| 39 // DisplaySession callbacks. |
| 40 void OnSessionStarted(int sink_id); |
| 41 void OnSessionTerminated(int sink_id); |
| 42 void OnSessionError(int sink_id, |
| 43 DisplaySourceErrorType type, |
| 44 const std::string& message); |
| 45 |
| 46 DisplaySourceSession* GetDisplaySession(int sink_id) const; |
| 47 |
| 48 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_; |
| 49 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); |
| 52 }; |
| 53 |
| 54 } // extensions |
| 55 |
| 56 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ |
OLD | NEW |