| 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // Observer interface for listening to default MediaSource changes for the | 112 // Observer interface for listening to default MediaSource changes for the |
| 113 // WebContents. | 113 // WebContents. |
| 114 class DefaultMediaSourceObserver { | 114 class DefaultMediaSourceObserver { |
| 115 public: | 115 public: |
| 116 virtual ~DefaultMediaSourceObserver() {} | 116 virtual ~DefaultMediaSourceObserver() {} |
| 117 | 117 |
| 118 // Called when default media source for the corresponding WebContents has | 118 // Called when default media source for the corresponding WebContents has |
| 119 // changed. | 119 // changed. |
| 120 // |source|: New default MediaSource, or empty if default was removed. | 120 // |source|: New default MediaSource, or empty if default was removed. |
| 121 // |frame_url|: URL of the frame that contains the default | 121 // |frame_url|: URL of the frame that contains the default media |
| 122 // media source, or empty if there is no default media source. | 122 // source, or empty if there is no default media source. |
| 123 virtual void OnDefaultMediaSourceChanged( | 123 virtual void OnDefaultMediaSourceChanged(const MediaSource& source, |
| 124 const MediaSource& source, | 124 const GURL& frame_url) = 0; |
| 125 const GURL& frame_url) = 0; | |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 // Adds / removes an observer for listening to default MediaSource changes. | 127 // Adds / removes an observer for listening to default MediaSource changes. |
| 129 void AddDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer); | 128 void AddDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer); |
| 130 void RemoveDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer); | 129 void RemoveDefaultMediaSourceObserver(DefaultMediaSourceObserver* observer); |
| 131 | 130 |
| 132 void SetMediaRouterForTest(MediaRouter* router); | 131 void SetMediaRouterForTest(MediaRouter* router); |
| 133 bool HasScreenAvailabilityListenerForTest( | 132 bool HasScreenAvailabilityListenerForTest( |
| 134 int render_process_id, | 133 int render_process_id, |
| 135 int render_frame_id, | 134 int render_frame_id, |
| 136 const MediaSource::Id& source_id) const; | 135 const MediaSource::Id& source_id) const; |
| 137 | 136 |
| 138 base::WeakPtr<PresentationServiceDelegateImpl> GetWeakPtr(); | 137 base::WeakPtr<PresentationServiceDelegateImpl> GetWeakPtr(); |
| 139 | 138 |
| 140 private: | 139 private: |
| 141 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents); | 140 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents); |
| 142 friend class content::WebContentsUserData<PresentationServiceDelegateImpl>; | 141 friend class content::WebContentsUserData<PresentationServiceDelegateImpl>; |
| 143 | 142 |
| 144 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, | 143 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, |
| 145 DelegateObservers); | 144 DelegateObservers); |
| 146 | 145 |
| 147 // Returns |listener|'s presentation URL as a MediaSource. If |listener| does | 146 // Returns |listener|'s presentation URL as a MediaSource. If |listener| does |
| 148 // not have a persentation URL, returns the tab mirroring MediaSource. | 147 // not have a persentation URL, returns the tab mirroring MediaSource. |
| 149 MediaSource GetMediaSourceFromListener( | 148 MediaSource GetMediaSourceFromListener( |
| 150 content::PresentationScreenAvailabilityListener* listener); | 149 content::PresentationScreenAvailabilityListener* listener); |
| 151 | 150 |
| 152 // Returns |true| if the frame is the main frame of |web_contents_|. | 151 // Returns |true| if the frame is the main frame of |web_contents_|. |
| 153 bool IsMainFrame(int render_process_id, int render_frame_id) const; | 152 bool IsMainFrame(int render_process_id, int render_frame_id) const; |
| 154 | 153 |
| 155 // Updates tab-level default MediaSource and source host name. If either | 154 // Updates tab-level default MediaSource and/or default frame URL. If either |
| 156 // changed, notify the observers. | 155 // changed, notify the observers. |
| 157 void UpdateDefaultMediaSourceAndNotifyObservers( | 156 void UpdateDefaultMediaSourceAndNotifyObservers( |
| 158 const MediaSource& new_default_source, | 157 const MediaSource& new_default_source, |
| 159 const GURL& new_default_frame_url); | 158 const GURL& new_default_frame_url); |
| 160 | 159 |
| 160 // Default MediaSource for the tab associated with this instance. |
| 161 MediaSource default_source_; | 161 MediaSource default_source_; |
| 162 // URL of the frame that contains the default MediaSource. |
| 162 GURL default_frame_url_; | 163 GURL default_frame_url_; |
| 163 | 164 |
| 164 // References to the observers listening for changes to default media source. | 165 // References to the observers listening for changes to default media source. |
| 165 base::ObserverList< | 166 base::ObserverList< |
| 166 DefaultMediaSourceObserver> default_media_source_observers_; | 167 DefaultMediaSourceObserver> default_media_source_observers_; |
| 167 | 168 |
| 168 // References to the WebContents that owns this instance, and associated | 169 // References to the WebContents that owns this instance, and associated |
| 169 // browser profile's MediaRouter instance. | 170 // browser profile's MediaRouter instance. |
| 170 content::WebContents* web_contents_; | 171 content::WebContents* web_contents_; |
| 171 MediaRouter* router_; | 172 MediaRouter* router_; |
| 172 | 173 |
| 173 scoped_ptr<PresentationFrameManager> frame_manager_; | 174 scoped_ptr<PresentationFrameManager> frame_manager_; |
| 174 | 175 |
| 175 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 176 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
| 176 | 177 |
| 177 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 178 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
| 178 }; | 179 }; |
| 179 | 180 |
| 180 } // namespace media_router | 181 } // namespace media_router |
| 181 | 182 |
| 182 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 183 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| OLD | NEW |