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