Index: chrome/browser/media/router/presentation_service_delegate_impl.cc |
diff --git a/chrome/browser/media/router/presentation_service_delegate_impl.cc b/chrome/browser/media/router/presentation_service_delegate_impl.cc |
index 634c219ee31e4e8449aa5a9826d65686f46c80f2..c9dc567eebdd8c6a319f0bc9f4c579154fc94375 100644 |
--- a/chrome/browser/media/router/presentation_service_delegate_impl.cc |
+++ b/chrome/browser/media/router/presentation_service_delegate_impl.cc |
@@ -24,7 +24,10 @@ |
#include "chrome/browser/media/router/route_message.h" |
#include "chrome/browser/media/router/route_message_observer.h" |
#include "chrome/browser/media/router/route_request_result.h" |
+#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/sessions/session_tab_helper.h" |
+#include "chrome/common/pref_names.h" |
+#include "components/prefs/pref_service.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/presentation_screen_availability_listener.h" |
#include "content/public/browser/presentation_session.h" |
@@ -821,6 +824,18 @@ void PresentationServiceDelegateImpl::JoinSession( |
error_cb.Run(content::PresentationError( |
content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND, |
"Invalid presentation arguments.")); |
+ return; |
+ } |
+ |
+ url::Origin origin = url::Origin(GetLastCommittedURLForFrame( |
mark a. foltz
2016/12/05 21:32:21
You'l need to rebase and pass |web_contents_| here
takumif
2016/12/06 02:21:57
Done.
|
+ RenderFrameHostId(render_process_id, render_frame_id))); |
+ |
+ if (IsAutoJoinPresentationId(presentation_id) && |
+ ShouldOverrideAutoJoinForOrigin(origin)) { |
+ error_cb.Run(content::PresentationError( |
+ content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
+ "Auto-join request overridden by user preferences.")); |
mark a. foltz
2016/12/05 21:32:22
s/overridden/cancelled/
takumif
2016/12/06 02:21:57
Done.
|
+ return; |
} |
// TODO(crbug.com/627655): Handle multiple URLs. |
@@ -831,12 +846,9 @@ void PresentationServiceDelegateImpl::JoinSession( |
base::Bind(&PresentationServiceDelegateImpl::OnJoinRouteResponse, |
weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, |
presentation_url, presentation_id, success_cb, error_cb)); |
- router_->JoinRoute( |
- MediaSourceForPresentationUrl(presentation_url).id(), presentation_id, |
- GetLastCommittedURLForFrame( |
- RenderFrameHostId(render_process_id, render_frame_id)) |
- .GetOrigin(), |
- web_contents_, route_response_callbacks, base::TimeDelta(), incognito); |
+ router_->JoinRoute(MediaSourceForPresentationUrl(presentation_url).id(), |
+ presentation_id, origin.GetURL(), web_contents_, |
+ route_response_callbacks, base::TimeDelta(), incognito); |
} |
void PresentationServiceDelegateImpl::CloseConnection( |
@@ -969,4 +981,18 @@ bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
render_frame_host_id, source_id); |
} |
+bool PresentationServiceDelegateImpl::ShouldOverrideAutoJoinForOrigin( |
+ const url::Origin& origin) const { |
+ Profile* profile = |
imcheng
2016/12/05 20:12:33
would it be sufficient to just check IsOffTheRecor
takumif
2016/12/06 02:21:57
I think so. Changing.
|
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
+ // If this is a guest or incognito profile, ignore the preferences. |
mark a. foltz
2016/12/05 21:32:21
Why are we ignoring the preference for incognito p
takumif
2016/12/06 02:21:57
I thought that not reading/writing user pref would
|
+ if (profile->GetProfileType() != Profile::ProfileType::REGULAR_PROFILE) |
+ return false; |
+ |
+ const base::ListValue* origins = |
+ profile->GetPrefs()->GetList(prefs::kMediaRouterTabMirroringSources); |
+ return origins && |
+ origins->Find(base::StringValue(origin.Serialize())) != origins->end(); |
+} |
+ |
} // namespace media_router |