Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4453)

Unified Diff: chrome/browser/media/router/presentation_service_delegate_impl.h

Issue 1406013003: [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile again Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/presentation_service_delegate_impl.h
diff --git a/chrome/browser/media/router/presentation_service_delegate_impl.h b/chrome/browser/media/router/presentation_service_delegate_impl.h
index 03ad8c7a74ae47865cb040ff0acb6d97b85e1b14..5f790eb07d2f20dac0e351004dfe3389dd4267a3 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl.h
+++ b/chrome/browser/media/router/presentation_service_delegate_impl.h
@@ -16,6 +16,8 @@
#include "base/observer_list.h"
#include "chrome/browser/media/router/media_router.h"
#include "chrome/browser/media/router/media_source.h"
+#include "chrome/browser/media/router/presentation_request.h"
+#include "chrome/browser/media/router/render_frame_host_id.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
@@ -35,8 +37,6 @@ class MediaSinksObserver;
class PresentationFrameManager;
class PresentationSessionStateObserver;
-using RenderFrameHostId = std::pair<int, int>;
-
// Implementation of PresentationServiceDelegate that interfaces an
// instance of WebContents with the Chrome Media Router. It uses the Media
// Router to handle presentation API calls forwarded from
@@ -49,6 +49,20 @@ class PresentationServiceDelegateImpl
: public content::WebContentsUserData<PresentationServiceDelegateImpl>,
public content::PresentationServiceDelegate {
public:
+ // Observer interface for listening to default presentation request
+ // changes for the WebContents.
+ class DefaultPresentationRequestObserver {
+ public:
+ virtual ~DefaultPresentationRequestObserver() {}
+
+ // Called when default presentation for the corresponding WebContents has
+ // changed.
+ // |default_presentation_info|: New default presentation, or nullptr if
+ // there is no default presentation.
+ virtual void OnDefaultPresentationChanged(
+ const PresentationRequest* default_presentation_request) = 0;
+ };
+
// Retrieves the instance of PresentationServiceDelegateImpl that was attached
// to the specified WebContents. If no instance was attached, creates one,
// and attaches it to the specified WebContents.
@@ -75,18 +89,21 @@ class PresentationServiceDelegateImpl
void SetDefaultPresentationUrl(
int render_process_id,
int render_frame_id,
- const std::string& default_presentation_url) override;
- void StartSession(int render_process_id,
- int render_frame_id,
- const std::string& presentation_url,
- const PresentationSessionSuccessCallback& success_cb,
- const PresentationSessionErrorCallback& error_cb) override;
- void JoinSession(int render_process_id,
- int render_frame_id,
- const std::string& presentation_url,
- const std::string& presentation_id,
- const PresentationSessionSuccessCallback& success_cb,
- const PresentationSessionErrorCallback& error_cb) override;
+ const std::string& default_presentation_url,
+ const content::PresentationSessionStartedCallback& callback) override;
+ void StartSession(
+ int render_process_id,
+ int render_frame_id,
+ const std::string& presentation_url,
+ const content::PresentationSessionStartedCallback& success_cb,
+ const content::PresentationSessionErrorCallback& error_cb) override;
+ void JoinSession(
+ int render_process_id,
+ int render_frame_id,
+ const std::string& presentation_url,
+ const std::string& presentation_id,
+ const content::PresentationSessionStartedCallback& success_cb,
+ const content::PresentationSessionErrorCallback& error_cb) override;
void CloseSession(int render_process_id,
int render_frame_id,
const std::string& presentation_id) override;
@@ -105,39 +122,28 @@ class PresentationServiceDelegateImpl
int render_frame_id,
const content::SessionStateChangedCallback& state_changed_cb) override;
- // Callback invoked when there is a route response from CreateRoute/JoinRoute
- // outside of a Presentation API request. This could be due to
- // browser action (e.g., browser initiated media router dialog) or
- // a media route provider (e.g., autojoin).
- void OnRouteResponse(const MediaRoute* route,
+ // Callback invoked when there is a presentation route response from
+ // CreateRoute/JoinRoute outside of an explicit Presentation API
+ // start()/reconnect() call, such as due to browser action (e.g., browser
+ // initiated media router dialog).
mark a. foltz 2015/10/20 20:15:25 I found this comment a little confusing. Do you m
imcheng 2015/10/24 00:41:19 Well this method is only called on response to the
+ void OnRouteResponse(const PresentationRequest& request,
+ const MediaRoute* route,
const std::string& presentation_id,
const std::string& error);
- // Returns the default MediaSource for this tab if there is one.
- // Returns an empty MediaSource otherwise.
- MediaSource default_source() const { return default_source_; }
+ // Adds / removes an observer for listening to default presentation changes.
mark a. foltz 2015/10/20 20:15:25 Nit: default PresentationRequest changes
imcheng 2015/10/24 00:41:19 Done.
+ void AddDefaultPresentationRequestObserver(
+ DefaultPresentationRequestObserver* observer);
+ void RemoveDefaultPresentationRequestObserver(
+ DefaultPresentationRequestObserver* observer);
- content::WebContents* web_contents() const { return web_contents_; }
- const GURL& default_frame_url() const { return default_frame_url_; }
-
- // Observer interface for listening to default MediaSource changes for the
- // WebContents.
- class DefaultMediaSourceObserver {
- public:
- virtual ~DefaultMediaSourceObserver() {}
+ // Gets the default presentation request for the owning tab WebContents, or
+ // nullptr if it does not exist.
+ const PresentationRequest* GetDefaultPresentationRequest() const;
- // Called when default media source for the corresponding WebContents has
- // changed.
- // |source|: New default MediaSource, or empty if default was removed.
- // |frame_url|: URL of the frame that contains the default media
- // source, or empty if there is no default media source.
- virtual void OnDefaultMediaSourceChanged(const MediaSource& source,
- const GURL& frame_url) = 0;
- };
+ content::WebContents* web_contents() const { return web_contents_; }
- // Adds / removes an observer for listening to default MediaSource changes.
- void AddDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer);
- void RemoveDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer);
+ base::WeakPtr<PresentationServiceDelegateImpl> GetWeakPtr();
void SetMediaRouterForTest(MediaRouter* router);
bool HasScreenAvailabilityListenerForTest(
@@ -145,12 +151,16 @@ class PresentationServiceDelegateImpl
int render_frame_id,
const MediaSource::Id& source_id) const;
- base::WeakPtr<PresentationServiceDelegateImpl> GetWeakPtr();
-
private:
friend class content::WebContentsUserData<PresentationServiceDelegateImpl>;
FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
DelegateObservers);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
+ SetDefaultPresentationUrl);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
+ DefaultPresentationRequestObserver);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
+ DefaultPresentationUrlCallback);
explicit PresentationServiceDelegateImpl(content::WebContents* web_contents);
@@ -159,47 +169,26 @@ class PresentationServiceDelegateImpl
MediaSource GetMediaSourceFromListener(
content::PresentationScreenAvailabilityListener* listener);
- void OnJoinRouteResponse(int render_process_id,
- int render_frame_id,
- const content::PresentationSessionInfo& session,
- const PresentationSessionSuccessCallback& success_cb,
- const PresentationSessionErrorCallback& error_cb,
- const MediaRoute* route,
- const std::string& presentation_id,
- const std::string& error_text);
+ void OnJoinRouteResponse(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& session,
+ const content::PresentationSessionStartedCallback& success_cb,
+ const content::PresentationSessionErrorCallback& error_cb,
+ const MediaRoute* route,
+ const std::string& presentation_id,
+ const std::string& error_text);
void OnStartSessionSucceeded(
int render_process_id,
int render_frame_id,
- const PresentationSessionSuccessCallback& success_cb,
+ const content::PresentationSessionStartedCallback& success_cb,
const content::PresentationSessionInfo& new_session,
const MediaRoute::Id& route_id);
- // Returns |true| if the frame is the main frame of |web_contents_|.
- bool IsMainFrame(int render_process_id, int render_frame_id) const;
-
- // Updates tab-level default MediaSource, default frame URL, and the
- // originating frame. If the source or frame URL changed, notify the
- // observers.
- void UpdateDefaultMediaSourceAndNotifyObservers(
- const RenderFrameHostId& render_frame_host_id,
- const MediaSource& new_default_source,
- const GURL& new_default_frame_url);
-
- // ID of RenderFrameHost that contains the default presentation.
- RenderFrameHostId default_presentation_render_frame_host_id_;
- // Default MediaSource for the tab associated with this instance.
- MediaSource default_source_;
- // URL of the frame that contains the default MediaSource.
- GURL default_frame_url_;
-
- // References to the observers listening for changes to default media source.
- base::ObserverList<
- DefaultMediaSourceObserver> default_media_source_observers_;
-
// References to the WebContents that owns this instance, and associated
// browser profile's MediaRouter instance.
- content::WebContents* web_contents_;
+ content::WebContents* const web_contents_;
MediaRouter* router_;
scoped_ptr<PresentationFrameManager> frame_manager_;

Powered by Google App Engine
This is Rietveld 408576698