// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_ #define CHROME_BROWSER_UI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_ #include <map> #include <memory> #include <set> #include <unordered_map> #include <vector> #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/observer_list.h" #include "chrome/browser/ui/media_router/cast_modes_with_media_sources.h" #include "chrome/browser/ui/media_router/media_cast_mode.h" #include "chrome/browser/ui/media_router/media_sink_with_cast_modes.h" #include "chrome/browser/ui/media_router/media_sink_with_cast_modes_observer.h" #include "components/media_router/browser/media_routes_observer.h" #include "components/media_router/common/media_sink.h" #include "components/media_router/common/media_source.h" namespace url { class Origin; } // namespace url namespace media_router { class MediaRouter; class MediaSinksObserver; // The Media Router dialog allows the user to initiate casting using one of // several actions (each represented by a cast mode). Each cast mode is // associated with a vector of media sources. This class allows the dialog to // receive lists of MediaSinks compatible with the cast modes available through // the dialog. // // Typical use: // // url::Origin origin{GURL("https://origin.com")}; // MediaSinkWithCastModesObserver* observer = ...; // QueryResultManager result_manager(router); // result_manager.AddObserver(observer); // result_manager.SetSourcesForCastMode(MediaCastMode::PRESENTATION, // {MediaSourceForPresentationUrl("http://google.com")}, origin); // result_manager.SetSourcesForCastMode(MediaCastMode::TAB_MIRROR, // {MediaSourceForTab(123)}, origin); // ... // [Updates will be received by observer via OnSinksUpdated()] // ... // [When info on MediaSource is needed, i.e. when requesting route for a mode] // CastModeSet cast_modes = result_manager.GetSupportedCastModes(); // [Logic to select a MediaCastMode from the set] // std::unique_ptr<MediaSource> source = // result_manager.GetSourceForCastModeAndSink( // MediaCastMode::TAB_MIRROR, sink_of_interest); // if (source) { // ... // } // // Not thread-safe. Must be used on the UI thread. class QueryResultManager { … }; } // namespace media_router #endif // CHROME_BROWSER_UI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_