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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 media_router_ui_->joinable_route_ids(), | 342 media_router_ui_->joinable_route_ids(), |
343 media_router_ui_->GetRouteProviderExtensionId())); | 343 media_router_ui_->GetRouteProviderExtensionId())); |
344 initial_data.Set("routes", routes.release()); | 344 initial_data.Set("routes", routes.release()); |
345 | 345 |
346 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); | 346 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); |
347 scoped_ptr<base::ListValue> cast_modes_list( | 347 scoped_ptr<base::ListValue> cast_modes_list( |
348 CastModesToValue(cast_modes, | 348 CastModesToValue(cast_modes, |
349 media_router_ui_->GetPresentationRequestSourceName())); | 349 media_router_ui_->GetPresentationRequestSourceName())); |
350 initial_data.Set("castModes", cast_modes_list.release()); | 350 initial_data.Set("castModes", cast_modes_list.release()); |
351 | 351 |
352 Profile* profile = Profile::FromWebUI(web_ui()); | |
353 | |
352 bool first_run_flow_acknowledged = | 354 bool first_run_flow_acknowledged = |
353 Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean( | 355 profile->GetPrefs()->GetBoolean( |
354 prefs::kMediaRouterFirstRunFlowAcknowledged); | 356 prefs::kMediaRouterFirstRunFlowAcknowledged); |
355 initial_data.SetBoolean("wasFirstRunFlowAcknowledged", | 357 initial_data.SetBoolean("wasFirstRunFlowAcknowledged", |
356 first_run_flow_acknowledged); | 358 first_run_flow_acknowledged); |
359 #if defined(GOOGLE_CHROME_BUILD) | |
360 bool show_cloud_pref = profile->IsSyncAllowed() && | |
imcheng
2016/01/25 19:21:06
can this be replaced with whether the kMediaRouter
imcheng
2016/01/25 19:21:06
Why is IsSyncAllowed() checked here? Could you add
apacible
2016/01/26 01:12:56
Added comments.
Per discussion with product, we o
apacible
2016/01/26 01:12:56
I'm not sure I understand this comment. kMediaRout
| |
361 !profile->GetPrefs()->GetBoolean( | |
362 prefs::kMediaRouterCloudServicesPrefSet); | |
363 initial_data.SetBoolean("showFirstRunFlowCloudPref", show_cloud_pref); | |
364 #endif // defined(GOOGLE_CHROME_BUILD) | |
357 | 365 |
358 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data); | 366 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data); |
359 media_router_ui_->UIInitialized(); | 367 media_router_ui_->UIInitialized(); |
360 } | 368 } |
361 | 369 |
362 void MediaRouterWebUIMessageHandler::OnCreateRoute( | 370 void MediaRouterWebUIMessageHandler::OnCreateRoute( |
363 const base::ListValue* args) { | 371 const base::ListValue* args) { |
364 DVLOG(1) << "OnCreateRoute"; | 372 DVLOG(1) << "OnCreateRoute"; |
365 const base::DictionaryValue* args_dict = nullptr; | 373 const base::DictionaryValue* args_dict = nullptr; |
366 std::string sink_id; | 374 std::string sink_id; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 // request. | 416 // request. |
409 DVLOG(1) << "Error initiating route request."; | 417 DVLOG(1) << "Error initiating route request."; |
410 } | 418 } |
411 } | 419 } |
412 | 420 |
413 void MediaRouterWebUIMessageHandler::OnAcknowledgeFirstRunFlow( | 421 void MediaRouterWebUIMessageHandler::OnAcknowledgeFirstRunFlow( |
414 const base::ListValue* args) { | 422 const base::ListValue* args) { |
415 DVLOG(1) << "OnAcknowledgeFirstRunFlow"; | 423 DVLOG(1) << "OnAcknowledgeFirstRunFlow"; |
416 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 424 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
417 prefs::kMediaRouterFirstRunFlowAcknowledged, true); | 425 prefs::kMediaRouterFirstRunFlowAcknowledged, true); |
426 | |
427 #if defined(GOOGLE_CHROME_BUILD) | |
428 bool enabled_cloud_services = false; | |
429 if (!args->GetBoolean(0, &enabled_cloud_services)) { | |
430 DVLOG(1) << "Unable to extract args."; | |
431 return; | |
432 } | |
433 | |
434 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | |
435 prefs::kMediaRouterEnableCloudServices, enabled_cloud_services); | |
436 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | |
437 prefs::kMediaRouterCloudServicesPrefSet, true); | |
438 #endif // defined(GOOGLE_CHROME_BUILD) | |
418 } | 439 } |
419 | 440 |
420 void MediaRouterWebUIMessageHandler::OnActOnIssue( | 441 void MediaRouterWebUIMessageHandler::OnActOnIssue( |
421 const base::ListValue* args) { | 442 const base::ListValue* args) { |
422 DVLOG(1) << "OnActOnIssue"; | 443 DVLOG(1) << "OnActOnIssue"; |
423 const base::DictionaryValue* args_dict = nullptr; | 444 const base::DictionaryValue* args_dict = nullptr; |
424 Issue::Id issue_id; | 445 Issue::Id issue_id; |
425 int action_type_num = -1; | 446 int action_type_num = -1; |
426 if (!args->GetDictionary(0, &args_dict) || | 447 if (!args->GetDictionary(0, &args_dict) || |
427 !args_dict->GetString("issueId", &issue_id) || | 448 !args_dict->GetString("issueId", &issue_id) || |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 open_args->AppendString(learn_more_url); | 652 open_args->AppendString(learn_more_url); |
632 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args); | 653 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args); |
633 return true; | 654 return true; |
634 } else { | 655 } else { |
635 // Do nothing; no other issue action types require any other action. | 656 // Do nothing; no other issue action types require any other action. |
636 return true; | 657 return true; |
637 } | 658 } |
638 } | 659 } |
639 | 660 |
640 } // namespace media_router | 661 } // namespace media_router |
OLD | NEW |