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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc

Issue 2487673003: [Media Router] Make per-hostname cast mode selections persist (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handle r.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handle r.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 std::unique_ptr<base::ListValue> routes(RoutesToValue( 412 std::unique_ptr<base::ListValue> routes(RoutesToValue(
413 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), 413 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(),
414 media_router_ui_->current_cast_modes())); 414 media_router_ui_->current_cast_modes()));
415 initial_data.Set("routes", routes.release()); 415 initial_data.Set("routes", routes.release());
416 416
417 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); 417 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes();
418 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( 418 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue(
419 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); 419 cast_modes, media_router_ui_->GetPresentationRequestSourceName()));
420 initial_data.Set("castModes", cast_modes_list.release()); 420 initial_data.Set("castModes", cast_modes_list.release());
421 421
422 MediaCastMode initial_cast_mode =
imcheng 2016/11/14 19:56:59 What if |initial_cast_mode| is not in |cast_modes|
takumif 2016/11/16 01:34:27 Checking to make sure TAB_MIRROR is in |cast_modes
423 media_router_ui_->GetCastModeSelectionForCurrentHost();
424 if (initial_cast_mode != MediaCastMode::DEFAULT) {
takumif 2016/11/08 22:52:16 Right now, GetCastModeSelectionForCurrentHost() re
apacible 2016/11/11 22:40:23 This looks fine.
takumif 2016/11/12 00:08:31 Okay!
imcheng 2016/11/14 19:56:59 Saw this comment after I posted my own comments. N
takumif 2016/11/16 01:34:27 Changing the pref to only keep track of hostnames
425 initial_data.Set(
426 "initialCastMode",
427 new base::FundamentalValue(static_cast<int>(initial_cast_mode)));
428 }
429
422 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data); 430 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data);
423 media_router_ui_->UIInitialized(); 431 media_router_ui_->UIInitialized();
424 } 432 }
425 433
426 void MediaRouterWebUIMessageHandler::OnCreateRoute( 434 void MediaRouterWebUIMessageHandler::OnCreateRoute(
427 const base::ListValue* args) { 435 const base::ListValue* args) {
428 DVLOG(1) << "OnCreateRoute"; 436 DVLOG(1) << "OnCreateRoute";
429 const base::DictionaryValue* args_dict = nullptr; 437 const base::DictionaryValue* args_dict = nullptr;
430 std::string sink_id; 438 std::string sink_id;
431 int cast_mode_num = -1; 439 int cast_mode_num = -1;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 void MediaRouterWebUIMessageHandler::OnReportSelectedCastMode( 699 void MediaRouterWebUIMessageHandler::OnReportSelectedCastMode(
692 const base::ListValue* args) { 700 const base::ListValue* args) {
693 DVLOG(1) << "OnReportSelectedCastMode"; 701 DVLOG(1) << "OnReportSelectedCastMode";
694 int cast_mode_type; 702 int cast_mode_type;
695 if (!args->GetInteger(0, &cast_mode_type)) { 703 if (!args->GetInteger(0, &cast_mode_type)) {
696 DVLOG(1) << "Unable to extract args."; 704 DVLOG(1) << "Unable to extract args.";
697 return; 705 return;
698 } 706 }
699 UMA_HISTOGRAM_SPARSE_SLOWLY("MediaRouter.Ui.Navigate.SourceSelection", 707 UMA_HISTOGRAM_SPARSE_SLOWLY("MediaRouter.Ui.Navigate.SourceSelection",
700 cast_mode_type); 708 cast_mode_type);
709 media_router_ui_->RecordCastModeSelection(
710 static_cast<MediaCastMode>(cast_mode_type));
701 } 711 }
702 712
703 void MediaRouterWebUIMessageHandler::OnReportSinkCount( 713 void MediaRouterWebUIMessageHandler::OnReportSinkCount(
704 const base::ListValue* args) { 714 const base::ListValue* args) {
705 DVLOG(1) << "OnReportSinkCount"; 715 DVLOG(1) << "OnReportSinkCount";
706 int sink_count; 716 int sink_count;
707 if (!args->GetInteger(0, &sink_count)) { 717 if (!args->GetInteger(0, &sink_count)) {
708 DVLOG(1) << "Unable to extract args."; 718 DVLOG(1) << "Unable to extract args.";
709 return; 719 return;
710 } 720 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 890 }
881 891
882 return value; 892 return value;
883 } 893 }
884 894
885 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { 895 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) {
886 set_web_ui(web_ui); 896 set_web_ui(web_ui);
887 } 897 }
888 898
889 } // namespace media_router 899 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698