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 #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> |
jdoerrie
2017/04/13 09:08:52
#include <memory>
vabr (Chromium)
2017/04/13 12:03:14
Done.
| |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
13 #include "base/metrics/user_metrics.h" | 13 #include "base/metrics/user_metrics.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/media/router/issue.h" | 17 #include "chrome/browser/media/router/issue.h" |
18 #include "chrome/browser/media/router/media_router_metrics.h" | 18 #include "chrome/browser/media/router/media_router_metrics.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 | 124 |
125 int cast_mode_bits = 0; | 125 int cast_mode_bits = 0; |
126 for (MediaCastMode cast_mode : sink_with_cast_modes.cast_modes) | 126 for (MediaCastMode cast_mode : sink_with_cast_modes.cast_modes) |
127 cast_mode_bits |= cast_mode; | 127 cast_mode_bits |= cast_mode; |
128 | 128 |
129 sink_val->SetInteger("castModes", cast_mode_bits); | 129 sink_val->SetInteger("castModes", cast_mode_bits); |
130 sink_val->SetBoolean("isPseudoSink", is_pseudo_sink); | 130 sink_val->SetBoolean("isPseudoSink", is_pseudo_sink); |
131 sinks_val->Append(std::move(sink_val)); | 131 sinks_val->Append(std::move(sink_val)); |
132 } | 132 } |
133 | 133 |
134 sink_list_and_identity->Set("sinks", sinks_val.release()); | 134 sink_list_and_identity->Set("sinks", std::move(sinks_val)); |
135 sink_list_and_identity->SetBoolean("showEmail", show_email); | 135 sink_list_and_identity->SetBoolean("showEmail", show_email); |
136 sink_list_and_identity->SetBoolean("showDomain", show_domain); | 136 sink_list_and_identity->SetBoolean("showDomain", show_domain); |
137 return sink_list_and_identity; | 137 return sink_list_and_identity; |
138 } | 138 } |
139 | 139 |
140 std::unique_ptr<base::DictionaryValue> RouteToValue( | 140 std::unique_ptr<base::DictionaryValue> RouteToValue( |
141 const MediaRoute& route, | 141 const MediaRoute& route, |
142 bool can_join, | 142 bool can_join, |
143 const std::string& extension_id, | 143 const std::string& extension_id, |
144 bool incognito, | 144 bool incognito, |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 DVLOG(1) << "OnRequestInitialData"; | 407 DVLOG(1) << "OnRequestInitialData"; |
408 media_router_ui_->OnUIInitiallyLoaded(); | 408 media_router_ui_->OnUIInitiallyLoaded(); |
409 base::DictionaryValue initial_data; | 409 base::DictionaryValue initial_data; |
410 | 410 |
411 // "No Cast devices found?" Chromecast help center page. | 411 // "No Cast devices found?" Chromecast help center page. |
412 initial_data.SetString("deviceMissingUrl", | 412 initial_data.SetString("deviceMissingUrl", |
413 base::StringPrintf(kHelpPageUrlPrefix, 3249268)); | 413 base::StringPrintf(kHelpPageUrlPrefix, 3249268)); |
414 | 414 |
415 std::unique_ptr<base::DictionaryValue> sinks_and_identity( | 415 std::unique_ptr<base::DictionaryValue> sinks_and_identity( |
416 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); | 416 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); |
417 initial_data.Set("sinksAndIdentity", sinks_and_identity.release()); | 417 initial_data.Set("sinksAndIdentity", std::move(sinks_and_identity)); |
418 | 418 |
419 std::unique_ptr<base::ListValue> routes(RoutesToValue( | 419 std::unique_ptr<base::ListValue> routes(RoutesToValue( |
420 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), | 420 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), |
421 media_router_ui_->routes_and_cast_modes())); | 421 media_router_ui_->routes_and_cast_modes())); |
422 initial_data.Set("routes", routes.release()); | 422 initial_data.Set("routes", std::move(routes)); |
423 | 423 |
424 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); | 424 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); |
425 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( | 425 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( |
426 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); | 426 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); |
427 initial_data.Set("castModes", cast_modes_list.release()); | 427 initial_data.Set("castModes", std::move(cast_modes_list)); |
428 | 428 |
429 // If the cast mode last chosen for the current origin is tab mirroring, | 429 // If the cast mode last chosen for the current origin is tab mirroring, |
430 // that should be the cast mode initially selected in the dialog. Otherwise | 430 // that should be the cast mode initially selected in the dialog. Otherwise |
431 // the initial cast mode should be chosen automatically by the dialog. | 431 // the initial cast mode should be chosen automatically by the dialog. |
432 bool use_tab_mirroring = | 432 bool use_tab_mirroring = |
433 base::ContainsKey(cast_modes, MediaCastMode::TAB_MIRROR) && | 433 base::ContainsKey(cast_modes, MediaCastMode::TAB_MIRROR) && |
434 media_router_ui_->UserSelectedTabMirroringForCurrentOrigin(); | 434 media_router_ui_->UserSelectedTabMirroringForCurrentOrigin(); |
435 initial_data.SetBoolean("useTabMirroring", use_tab_mirroring); | 435 initial_data.SetBoolean("useTabMirroring", use_tab_mirroring); |
436 | 436 |
437 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data); | 437 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
894 } | 894 } |
895 | 895 |
896 return value; | 896 return value; |
897 } | 897 } |
898 | 898 |
899 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 899 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
900 set_web_ui(web_ui); | 900 set_web_ui(web_ui); |
901 } | 901 } |
902 | 902 |
903 } // namespace media_router | 903 } // namespace media_router |
OLD | NEW |