| 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 "chrome/browser/media/android/router/media_router_android.h" | 5 #include "chrome/browser/media/android/router/media_router_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 MediaRouterAndroid::~MediaRouterAndroid() { | 48 MediaRouterAndroid::~MediaRouterAndroid() { |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 bool MediaRouterAndroid::Register(JNIEnv* env) { | 52 bool MediaRouterAndroid::Register(JNIEnv* env) { |
| 53 bool ret = RegisterNativesImpl(env); | 53 bool ret = RegisterNativesImpl(env); |
| 54 DCHECK(g_ChromeMediaRouter_clazz); | 54 DCHECK(g_ChromeMediaRouter_clazz); |
| 55 return ret; | 55 return ret; |
| 56 } | 56 } |
| 57 | 57 |
| 58 const MediaRoute* MediaRouterAndroid::FindRouteBySource( |
| 59 const MediaSource::Id& source_id) const { |
| 60 for (const auto& route : active_routes_) { |
| 61 if (route.media_source().id() == source_id) |
| 62 return &route; |
| 63 } |
| 64 return nullptr; |
| 65 } |
| 66 |
| 58 void MediaRouterAndroid::CreateRoute( | 67 void MediaRouterAndroid::CreateRoute( |
| 59 const MediaSource::Id& source_id, | 68 const MediaSource::Id& source_id, |
| 60 const MediaSink::Id& sink_id, | 69 const MediaSink::Id& sink_id, |
| 61 const GURL& origin, | 70 const GURL& origin, |
| 62 content::WebContents* web_contents, | 71 content::WebContents* web_contents, |
| 63 const std::vector<MediaRouteResponseCallback>& callbacks) { | 72 const std::vector<MediaRouteResponseCallback>& callbacks) { |
| 64 if (!origin.is_valid()) { | 73 if (!origin.is_valid()) { |
| 65 for (const MediaRouteResponseCallback& callback : callbacks) | 74 for (const MediaRouteResponseCallback& callback : callbacks) |
| 66 callback.Run(nullptr, "", "Invalid origin"); | 75 callback.Run(nullptr, "", "Invalid origin"); |
| 67 return; | 76 return; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 scoped_ptr<content::PresentationSessionMessage> message( | 431 scoped_ptr<content::PresentationSessionMessage> message( |
| 423 new content::PresentationSessionMessage(content::TEXT)); | 432 new content::PresentationSessionMessage(content::TEXT)); |
| 424 message->message = ConvertJavaStringToUTF8(env, jmessage); | 433 message->message = ConvertJavaStringToUTF8(env, jmessage); |
| 425 session_messages.push_back(message.Pass()); | 434 session_messages.push_back(message.Pass()); |
| 426 | 435 |
| 427 FOR_EACH_OBSERVER(PresentationSessionMessagesObserver, *observer_list, | 436 FOR_EACH_OBSERVER(PresentationSessionMessagesObserver, *observer_list, |
| 428 OnMessagesReceived(session_messages, true)); | 437 OnMessagesReceived(session_messages, true)); |
| 429 } | 438 } |
| 430 | 439 |
| 431 } // namespace media_router | 440 } // namespace media_router |
| OLD | NEW |