| 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_dialog_controller_and
roid.h" | 5 #include "chrome/browser/media/android/router/media_router_dialog_controller_and
roid.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_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "chrome/browser/media/android/router/media_router_android.h" | 10 #include "chrome/browser/media/android/router/media_router_android.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 void MediaRouterDialogControllerAndroid::OnSinkSelected( | 41 void MediaRouterDialogControllerAndroid::OnSinkSelected( |
| 42 JNIEnv* env, | 42 JNIEnv* env, |
| 43 const JavaParamRef<jobject>& obj, | 43 const JavaParamRef<jobject>& obj, |
| 44 const JavaParamRef<jstring>& jsink_id) { | 44 const JavaParamRef<jstring>& jsink_id) { |
| 45 std::unique_ptr<CreatePresentationConnectionRequest> | 45 std::unique_ptr<CreatePresentationConnectionRequest> |
| 46 create_connection_request = TakeCreateConnectionRequest(); | 46 create_connection_request = TakeCreateConnectionRequest(); |
| 47 const PresentationRequest& presentation_request = | 47 const PresentationRequest& presentation_request = |
| 48 create_connection_request->presentation_request(); | 48 create_connection_request->presentation_request(); |
| 49 const MediaSource::Id source_id = presentation_request.GetMediaSource().id(); | 49 |
| 50 // TODO(crbug.com/627655): Support multiple URLs. |
| 51 const MediaSource::Id source_id = |
| 52 presentation_request.GetMediaSources()[0].id(); |
| 50 const GURL origin = presentation_request.frame_url().GetOrigin(); | 53 const GURL origin = presentation_request.frame_url().GetOrigin(); |
| 51 | 54 |
| 52 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 55 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 53 route_response_callbacks.push_back( | 56 route_response_callbacks.push_back( |
| 54 base::Bind(&CreatePresentationConnectionRequest::HandleRouteResponse, | 57 base::Bind(&CreatePresentationConnectionRequest::HandleRouteResponse, |
| 55 base::Passed(&create_connection_request))); | 58 base::Passed(&create_connection_request))); |
| 56 | 59 |
| 57 content::BrowserContext* browser_context = initiator()->GetBrowserContext(); | 60 content::BrowserContext* browser_context = initiator()->GetBrowserContext(); |
| 58 MediaRouter* router = MediaRouterFactory::GetApiForBrowserContext( | 61 MediaRouter* router = MediaRouterFactory::GetApiForBrowserContext( |
| 59 browser_context); | 62 browser_context); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 bool MediaRouterDialogControllerAndroid::Register(JNIEnv* env) { | 109 bool MediaRouterDialogControllerAndroid::Register(JNIEnv* env) { |
| 107 return RegisterNativesImpl(env); | 110 return RegisterNativesImpl(env); |
| 108 } | 111 } |
| 109 | 112 |
| 110 MediaRouterDialogControllerAndroid::~MediaRouterDialogControllerAndroid() { | 113 MediaRouterDialogControllerAndroid::~MediaRouterDialogControllerAndroid() { |
| 111 } | 114 } |
| 112 | 115 |
| 113 void MediaRouterDialogControllerAndroid::CreateMediaRouterDialog() { | 116 void MediaRouterDialogControllerAndroid::CreateMediaRouterDialog() { |
| 114 JNIEnv* env = base::android::AttachCurrentThread(); | 117 JNIEnv* env = base::android::AttachCurrentThread(); |
| 115 | 118 |
| 116 const MediaSource::Id source_id = | 119 // TODO(crbug.com/627655): Support multiple URLs. |
| 117 create_connection_request()->presentation_request().GetMediaSource().id(); | 120 const MediaSource::Id source_id = create_connection_request() |
| 121 ->presentation_request() |
| 122 .GetMediaSources()[0] |
| 123 .id(); |
| 118 ScopedJavaLocalRef<jstring> jsource_urn = | 124 ScopedJavaLocalRef<jstring> jsource_urn = |
| 119 base::android::ConvertUTF8ToJavaString(env, source_id); | 125 base::android::ConvertUTF8ToJavaString(env, source_id); |
| 120 | 126 |
| 121 // If it's a single route with the same source, show the controller dialog | 127 // If it's a single route with the same source, show the controller dialog |
| 122 // instead of the device picker. | 128 // instead of the device picker. |
| 123 // TODO(avayvod): maybe this logic should be in | 129 // TODO(avayvod): maybe this logic should be in |
| 124 // PresentationServiceDelegateImpl: if the route exists for the same frame | 130 // PresentationServiceDelegateImpl: if the route exists for the same frame |
| 125 // and tab, show the route controller dialog, if not, show the device picker. | 131 // and tab, show the route controller dialog, if not, show the device picker. |
| 126 MediaRouterAndroid* router = static_cast<MediaRouterAndroid*>( | 132 MediaRouterAndroid* router = static_cast<MediaRouterAndroid*>( |
| 127 MediaRouterFactory::GetApiForBrowserContext( | 133 MediaRouterFactory::GetApiForBrowserContext( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 149 } | 155 } |
| 150 | 156 |
| 151 bool MediaRouterDialogControllerAndroid::IsShowingMediaRouterDialog() const { | 157 bool MediaRouterDialogControllerAndroid::IsShowingMediaRouterDialog() const { |
| 152 JNIEnv* env = base::android::AttachCurrentThread(); | 158 JNIEnv* env = base::android::AttachCurrentThread(); |
| 153 return Java_ChromeMediaRouterDialogController_isShowingDialog( | 159 return Java_ChromeMediaRouterDialogController_isShowingDialog( |
| 154 env, java_dialog_controller_); | 160 env, java_dialog_controller_); |
| 155 } | 161 } |
| 156 | 162 |
| 157 } // namespace media_router | 163 } // namespace media_router |
| 158 | 164 |
| OLD | NEW |