| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/renderer/display_source_custom_bindings.h" | 5 #include "extensions/renderer/display_source_custom_bindings.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "content/public/child/v8_value_converter.h" | 10 #include "content/public/child/v8_value_converter.h" |
| 11 #include "extensions/renderer/extension_bindings_system.h" | 11 #include "extensions/renderer/extension_bindings_system.h" |
| 12 #include "extensions/renderer/script_context.h" | 12 #include "extensions/renderer/script_context.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 13 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 15 #include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h" | 15 #include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h" |
| 16 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 using content::V8ValueConverter; | |
| 21 | |
| 22 namespace { | 20 namespace { |
| 23 const char kErrorNotSupported[] = "Not supported"; | 21 const char kErrorNotSupported[] = "Not supported"; |
| 24 const char kInvalidStreamArgs[] = "Invalid stream arguments"; | 22 const char kInvalidStreamArgs[] = "Invalid stream arguments"; |
| 25 const char kSessionAlreadyStarted[] = "The session has been already started"; | 23 const char kSessionAlreadyStarted[] = "The session has been already started"; |
| 26 const char kSessionAlreadyTerminating[] = "The session is already terminating"; | 24 const char kSessionAlreadyTerminating[] = "The session is already terminating"; |
| 27 const char kSessionNotFound[] = "Session not found"; | 25 const char kSessionNotFound[] = "Session not found"; |
| 28 } // namespace | 26 } // namespace |
| 29 | 27 |
| 30 DisplaySourceCustomBindings::DisplaySourceCustomBindings( | 28 DisplaySourceCustomBindings::DisplaySourceCustomBindings( |
| 31 ScriptContext* context, | 29 ScriptContext* context, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 v8::String::NewFromUtf8(isolate, kInvalidStreamArgs))); | 127 v8::String::NewFromUtf8(isolate, kInvalidStreamArgs))); |
| 130 return; | 128 return; |
| 131 } | 129 } |
| 132 } | 130 } |
| 133 | 131 |
| 134 std::unique_ptr<DisplaySourceAuthInfo> auth_info; | 132 std::unique_ptr<DisplaySourceAuthInfo> auth_info; |
| 135 v8::Local<v8::Value> auth_info_v8_val = | 133 v8::Local<v8::Value> auth_info_v8_val = |
| 136 GetChildValue(start_info, "authenticationInfo", isolate); | 134 GetChildValue(start_info, "authenticationInfo", isolate); |
| 137 if (!auth_info_v8_val->IsNull()) { | 135 if (!auth_info_v8_val->IsNull()) { |
| 138 CHECK(auth_info_v8_val->IsObject()); | 136 CHECK(auth_info_v8_val->IsObject()); |
| 139 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 137 std::unique_ptr<base::Value> auth_info_val = |
| 140 std::unique_ptr<base::Value> auth_info_val( | 138 content::V8ValueConverter::Create()->FromV8Value( |
| 141 converter->FromV8Value(auth_info_v8_val, context()->v8_context())); | 139 auth_info_v8_val, context()->v8_context()); |
| 142 CHECK(auth_info_val); | 140 CHECK(auth_info_val); |
| 143 auth_info = DisplaySourceAuthInfo::FromValue(*auth_info_val); | 141 auth_info = DisplaySourceAuthInfo::FromValue(*auth_info_val); |
| 144 } | 142 } |
| 145 | 143 |
| 146 DisplaySourceSessionParams session_params; | 144 DisplaySourceSessionParams session_params; |
| 147 session_params.sink_id = sink_id; | 145 session_params.sink_id = sink_id; |
| 148 session_params.video_track = video_track; | 146 session_params.video_track = video_track; |
| 149 session_params.audio_track = audio_track; | 147 session_params.audio_track = audio_track; |
| 150 session_params.render_frame = context()->GetRenderFrame(); | 148 session_params.render_frame = context()->GetRenderFrame(); |
| 151 if (auth_info) { | 149 if (auth_info) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 287 } |
| 290 | 288 |
| 291 void DisplaySourceCustomBindings::OnSessionError(int sink_id, | 289 void DisplaySourceCustomBindings::OnSessionError(int sink_id, |
| 292 DisplaySourceErrorType type, | 290 DisplaySourceErrorType type, |
| 293 const std::string& message) { | 291 const std::string& message) { |
| 294 CHECK(GetDisplaySession(sink_id)); | 292 CHECK(GetDisplaySession(sink_id)); |
| 295 DispatchSessionError(sink_id, type, message); | 293 DispatchSessionError(sink_id, type, message); |
| 296 } | 294 } |
| 297 | 295 |
| 298 } // extensions | 296 } // extensions |
| OLD | NEW |