Chromium Code Reviews| 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_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_ANDRO ID_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_ANDRO ID_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_ANDRO ID_H_ | 6 #define CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_ANDRO ID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 13 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 14 #include "chrome/browser/media/router/media_routes_observer.h" | 14 #include "chrome/browser/media/router/media_routes_observer.h" |
| 15 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 16 | 16 |
| 17 namespace media_router { | 17 namespace media_router { |
| 18 | 18 |
| 19 // Android implementation of the MediaRouterDialogController. | 19 // Android implementation of the MediaRouterDialogController. |
| 20 class MediaRouterDialogControllerAndroid | 20 class MediaRouterDialogControllerAndroid |
| 21 : public content::WebContentsUserData<MediaRouterDialogControllerAndroid>, | 21 : public content::WebContentsUserData<MediaRouterDialogControllerAndroid>, |
| 22 public MediaRouterDialogController, | 22 public MediaRouterDialogController { |
| 23 public MediaRoutesObserver { | |
| 24 public: | 23 public: |
| 25 ~MediaRouterDialogControllerAndroid() override; | 24 ~MediaRouterDialogControllerAndroid() override; |
| 26 | 25 |
| 27 static bool Register(JNIEnv* env); | 26 static bool Register(JNIEnv* env); |
| 28 | 27 |
| 29 static MediaRouterDialogControllerAndroid* GetOrCreateForWebContents( | 28 static MediaRouterDialogControllerAndroid* GetOrCreateForWebContents( |
| 30 content::WebContents* web_contents); | 29 content::WebContents* web_contents); |
| 31 | 30 |
| 32 // The methods called by the Java counterpart. | 31 // The methods called by the Java counterpart. |
| 33 | 32 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 45 // Use MediaRouterDialogControllerAndroid::CreateForWebContents() to create an | 44 // Use MediaRouterDialogControllerAndroid::CreateForWebContents() to create an |
| 46 // instance. | 45 // instance. |
| 47 explicit MediaRouterDialogControllerAndroid( | 46 explicit MediaRouterDialogControllerAndroid( |
| 48 content::WebContents* web_contents); | 47 content::WebContents* web_contents); |
| 49 | 48 |
| 50 // MediaRouterDialogController: | 49 // MediaRouterDialogController: |
| 51 void CreateMediaRouterDialog() override; | 50 void CreateMediaRouterDialog() override; |
| 52 void CloseMediaRouterDialog() override; | 51 void CloseMediaRouterDialog() override; |
| 53 bool IsShowingMediaRouterDialog() const override; | 52 bool IsShowingMediaRouterDialog() const override; |
| 54 | 53 |
| 55 // MediaRoutesObserver: | 54 class UIMediaRoutesObserver : public MediaRoutesObserver { |
| 56 void OnRoutesUpdated(const std::vector<MediaRoute>& routes) override; | 55 public: |
| 56 using RoutesUpdatedCallback = | |
| 57 base::Callback<void(const std::vector<MediaRoute>&, | |
| 58 const std::vector<MediaRoute::Id>&)>; | |
| 59 UIMediaRoutesObserver(MediaRouter* router, const MediaSource::Id source_id, | |
| 60 const RoutesUpdatedCallback& callback); | |
| 61 ~UIMediaRoutesObserver() override; | |
| 62 | |
| 63 // MediaRoutesObserver | |
| 64 void OnRoutesUpdated( | |
| 65 const std::vector<MediaRoute>& routes, | |
| 66 const std::vector<MediaRoute::Id>& joinable_route_ids) override; | |
| 67 | |
| 68 private: | |
| 69 // Callback to the owning MediaRouterUI instance. | |
|
whywhat
2015/11/26 14:43:04
We don't have MediaRouterUI on Android.
matt.boetger
2015/12/01 01:26:55
Reverting.
| |
| 70 RoutesUpdatedCallback callback_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); | |
| 73 }; | |
| 57 | 74 |
| 58 void CancelPresentationRequest(); | 75 void CancelPresentationRequest(); |
| 59 | 76 |
| 77 void OnRoutesUpdated( | |
| 78 const std::vector<MediaRoute>& routes, | |
| 79 const std::vector<MediaRoute::Id>& joinable_route_ids); | |
| 80 | |
| 60 base::android::ScopedJavaGlobalRef<jobject> java_dialog_controller_; | 81 base::android::ScopedJavaGlobalRef<jobject> java_dialog_controller_; |
| 61 | 82 |
| 62 // Null if no routes or more than one route exist. If there's only one route, | 83 // Null if no routes or more than one route exist. If there's only one route, |
| 63 // keeps a copy to determine if the route controller dialog needs to be shown | 84 // keeps a copy to determine if the route controller dialog needs to be shown |
| 64 // vs. the route chooser one. | 85 // vs. the route chooser one. |
| 65 scoped_ptr<MediaRoute> single_existing_route_; | 86 scoped_ptr<MediaRoute> single_existing_route_; |
| 66 | 87 |
| 88 // The routes_observer_ only needs to be active when the dialog is open. | |
| 89 scoped_ptr<MediaRoutesObserver> routes_observer_; | |
| 90 | |
| 91 // Pointer to the MediaRouter for this instance's BrowserContext. | |
| 92 MediaRouter* router_; | |
|
imcheng
2015/11/26 00:49:45
MediaRouter* const router_;
matt.boetger
2015/12/01 01:26:55
Reverting.
| |
| 93 | |
| 67 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerAndroid); | 94 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerAndroid); |
| 68 }; | 95 }; |
| 69 | 96 |
| 70 } // namespace media_router | 97 } // namespace media_router |
| 71 | 98 |
| 72 #endif // CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_AN DROID_H_ | 99 #endif // CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_AN DROID_H_ |
| OLD | NEW |