| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 media_router_ui_->joinable_route_ids(), | 341 media_router_ui_->joinable_route_ids(), |
| 342 media_router_ui_->GetRouteProviderExtensionId())); | 342 media_router_ui_->GetRouteProviderExtensionId())); |
| 343 initial_data.Set("routes", routes.release()); | 343 initial_data.Set("routes", routes.release()); |
| 344 | 344 |
| 345 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); | 345 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); |
| 346 scoped_ptr<base::ListValue> cast_modes_list( | 346 scoped_ptr<base::ListValue> cast_modes_list( |
| 347 CastModesToValue(cast_modes, | 347 CastModesToValue(cast_modes, |
| 348 media_router_ui_->GetPresentationRequestSourceName())); | 348 media_router_ui_->GetPresentationRequestSourceName())); |
| 349 initial_data.Set("castModes", cast_modes_list.release()); | 349 initial_data.Set("castModes", cast_modes_list.release()); |
| 350 | 350 |
| 351 Profile* profile = Profile::FromWebUI(web_ui()); |
| 352 |
| 351 bool first_run_flow_acknowledged = | 353 bool first_run_flow_acknowledged = |
| 352 Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean( | 354 profile->GetPrefs()->GetBoolean( |
| 353 prefs::kMediaRouterFirstRunFlowAcknowledged); | 355 prefs::kMediaRouterFirstRunFlowAcknowledged); |
| 354 initial_data.SetBoolean("wasFirstRunFlowAcknowledged", | 356 initial_data.SetBoolean("wasFirstRunFlowAcknowledged", |
| 355 first_run_flow_acknowledged); | 357 first_run_flow_acknowledged); |
| 358 bool show_cloud_pref = false; |
| 359 #if defined(GOOGLE_CHROME_BUILD) |
| 360 // Cloud services preference is shown if user has sync enabled. |
| 361 // If the user enables sync after acknowledging the first run flow, this is |
| 362 // treated as the user opting into Google services, including cloud services, |
| 363 // if the browser is a Chrome branded build. |
| 364 show_cloud_pref = profile->IsSyncAllowed() && |
| 365 !profile->GetPrefs()->GetBoolean( |
| 366 prefs::kMediaRouterCloudServicesPrefSet); |
| 367 #endif // defined(GOOGLE_CHROME_BUILD) |
| 368 initial_data.SetBoolean("showFirstRunFlowCloudPref", show_cloud_pref); |
| 356 | 369 |
| 357 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data); | 370 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data); |
| 358 media_router_ui_->UIInitialized(); | 371 media_router_ui_->UIInitialized(); |
| 359 } | 372 } |
| 360 | 373 |
| 361 void MediaRouterWebUIMessageHandler::OnCreateRoute( | 374 void MediaRouterWebUIMessageHandler::OnCreateRoute( |
| 362 const base::ListValue* args) { | 375 const base::ListValue* args) { |
| 363 DVLOG(1) << "OnCreateRoute"; | 376 DVLOG(1) << "OnCreateRoute"; |
| 364 const base::DictionaryValue* args_dict = nullptr; | 377 const base::DictionaryValue* args_dict = nullptr; |
| 365 std::string sink_id; | 378 std::string sink_id; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // request. | 420 // request. |
| 408 DVLOG(1) << "Error initiating route request."; | 421 DVLOG(1) << "Error initiating route request."; |
| 409 } | 422 } |
| 410 } | 423 } |
| 411 | 424 |
| 412 void MediaRouterWebUIMessageHandler::OnAcknowledgeFirstRunFlow( | 425 void MediaRouterWebUIMessageHandler::OnAcknowledgeFirstRunFlow( |
| 413 const base::ListValue* args) { | 426 const base::ListValue* args) { |
| 414 DVLOG(1) << "OnAcknowledgeFirstRunFlow"; | 427 DVLOG(1) << "OnAcknowledgeFirstRunFlow"; |
| 415 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 428 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| 416 prefs::kMediaRouterFirstRunFlowAcknowledged, true); | 429 prefs::kMediaRouterFirstRunFlowAcknowledged, true); |
| 430 |
| 431 #if defined(GOOGLE_CHROME_BUILD) |
| 432 bool enabled_cloud_services = false; |
| 433 if (!args->GetBoolean(0, &enabled_cloud_services)) { |
| 434 DVLOG(1) << "Unable to extract args."; |
| 435 return; |
| 436 } |
| 437 |
| 438 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| 439 prefs::kMediaRouterEnableCloudServices, enabled_cloud_services); |
| 440 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| 441 prefs::kMediaRouterCloudServicesPrefSet, true); |
| 442 #endif // defined(GOOGLE_CHROME_BUILD) |
| 417 } | 443 } |
| 418 | 444 |
| 419 void MediaRouterWebUIMessageHandler::OnActOnIssue( | 445 void MediaRouterWebUIMessageHandler::OnActOnIssue( |
| 420 const base::ListValue* args) { | 446 const base::ListValue* args) { |
| 421 DVLOG(1) << "OnActOnIssue"; | 447 DVLOG(1) << "OnActOnIssue"; |
| 422 const base::DictionaryValue* args_dict = nullptr; | 448 const base::DictionaryValue* args_dict = nullptr; |
| 423 Issue::Id issue_id; | 449 Issue::Id issue_id; |
| 424 int action_type_num = -1; | 450 int action_type_num = -1; |
| 425 if (!args->GetDictionary(0, &args_dict) || | 451 if (!args->GetDictionary(0, &args_dict) || |
| 426 !args_dict->GetString("issueId", &issue_id) || | 452 !args_dict->GetString("issueId", &issue_id) || |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 open_args->AppendString(learn_more_url); | 669 open_args->AppendString(learn_more_url); |
| 644 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args); | 670 web_ui()->CallJavascriptFunction(kWindowOpen, *open_args); |
| 645 return true; | 671 return true; |
| 646 } else { | 672 } else { |
| 647 // Do nothing; no other issue action types require any other action. | 673 // Do nothing; no other issue action types require any other action. |
| 648 return true; | 674 return true; |
| 649 } | 675 } |
| 650 } | 676 } |
| 651 | 677 |
| 652 } // namespace media_router | 678 } // namespace media_router |
| OLD | NEW |