| Index: chrome/browser/ui/webui/media_router/media_router_ui.cc
|
| diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chrome/browser/ui/webui/media_router/media_router_ui.cc
|
| index 3374fc27a4c5285c2972b246aa0fd5e50e5f571d..7f52e925c56595842ac30d326a3f108079f0d24b 100644
|
| --- a/chrome/browser/ui/webui/media_router/media_router_ui.cc
|
| +++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc
|
| @@ -36,8 +36,11 @@
|
| #include "chrome/browser/ui/webui/media_router/media_router_localized_strings_provider.h"
|
| #include "chrome/browser/ui/webui/media_router/media_router_resources_provider.h"
|
| #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h"
|
| +#include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/grit/generated_resources.h"
|
| +#include "components/prefs/pref_service.h"
|
| +#include "components/prefs/scoped_user_pref_update.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_ui.h"
|
| #include "content/public/browser/web_ui_data_source.h"
|
| @@ -507,6 +510,36 @@ void MediaRouterUI::SearchSinksAndCreateRoute(
|
| weak_factory_.GetWeakPtr(), cast_mode));
|
| }
|
|
|
| +bool MediaRouterUI::UserSelectedTabMirroringForCurrentHost() const {
|
| + const base::DictionaryValue* pref =
|
| + Profile::FromWebUI(web_ui())->GetPrefs()->GetDictionary(
|
| + prefs::kMediaRouterTabMirroringSelected);
|
| + bool tab_mirroring = false;
|
| + pref->GetBooleanWithoutPathExpansion(GetInitiatorHostname(), &tab_mirroring);
|
| + return tab_mirroring;
|
| +}
|
| +
|
| +void MediaRouterUI::RecordCastModeSelection(MediaCastMode cast_mode) {
|
| + DictionaryPrefUpdate update(Profile::FromWebUI(web_ui())->GetPrefs(),
|
| + prefs::kMediaRouterTabMirroringSelected);
|
| +
|
| + switch (cast_mode) {
|
| + case MediaCastMode::DEFAULT:
|
| + update->RemoveWithoutPathExpansion(GetInitiatorHostname(), nullptr);
|
| + break;
|
| + case MediaCastMode::TAB_MIRROR:
|
| + update->SetBooleanWithoutPathExpansion(GetInitiatorHostname(), true);
|
| + break;
|
| + case MediaCastMode::DESKTOP_MIRROR:
|
| + // Desktop mirroring isn't domain-specific, so we don't record the
|
| + // selection.
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| +}
|
| +
|
| void MediaRouterUI::OnResultsUpdated(
|
| const std::vector<MediaSinkWithCastModes>& sinks) {
|
| sinks_ = sinks;
|
| @@ -696,4 +729,8 @@ void MediaRouterUI::UpdateMaxDialogHeight(int height) {
|
| handler_->UpdateMaxDialogHeight(height);
|
| }
|
|
|
| +std::string MediaRouterUI::GetInitiatorHostname() const {
|
| + return initiator_ ? initiator_->GetLastCommittedURL().HostNoBrackets() : "";
|
| +}
|
| +
|
| } // namespace media_router
|
|
|