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

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

Issue 1680743006: [Media Router] Show user email in header if cloud sink is present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More adjustments to get dynamic height change working and updated domain handling. Created 4 years, 10 months 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 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 std::string help_url = base::StringPrintf(kHelpPageUrlPrefix, help_page_id); 187 std::string help_url = base::StringPrintf(kHelpPageUrlPrefix, help_page_id);
188 if (!GURL(help_url).is_valid()) { 188 if (!GURL(help_url).is_valid()) {
189 DVLOG(1) << "Error: URL is invalid and cannot be opened."; 189 DVLOG(1) << "Error: URL is invalid and cannot be opened.";
190 return std::string(); 190 return std::string();
191 } 191 }
192 return help_url; 192 return help_url;
193 } 193 }
194 194
195 bool SinksWithDomainInList(const std::vector<MediaSinkWithCastModes>& sinks) {
196 for (const MediaSinkWithCastModes& sink_with_cast_modes : sinks) {
197 const MediaSink& sink = sink_with_cast_modes.sink;
198 if (!sink.domain().empty())
199 return true;
200 }
201 return false;
202 }
203
195 } // namespace 204 } // namespace
196 205
197 MediaRouterWebUIMessageHandler::MediaRouterWebUIMessageHandler( 206 MediaRouterWebUIMessageHandler::MediaRouterWebUIMessageHandler(
198 MediaRouterUI* media_router_ui) 207 MediaRouterUI* media_router_ui)
199 : dialog_closing_(false), 208 : dialog_closing_(false),
200 media_router_ui_(media_router_ui) { 209 media_router_ui_(media_router_ui) {
201 DCHECK(media_router_ui_); 210 DCHECK(media_router_ui_);
202 } 211 }
203 212
204 MediaRouterWebUIMessageHandler::~MediaRouterWebUIMessageHandler() { 213 MediaRouterWebUIMessageHandler::~MediaRouterWebUIMessageHandler() {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 profile->GetPrefs()->GetBoolean( 378 profile->GetPrefs()->GetBoolean(
370 prefs::kMediaRouterFirstRunFlowAcknowledged); 379 prefs::kMediaRouterFirstRunFlowAcknowledged);
371 initial_data.SetBoolean("wasFirstRunFlowAcknowledged", 380 initial_data.SetBoolean("wasFirstRunFlowAcknowledged",
372 first_run_flow_acknowledged); 381 first_run_flow_acknowledged);
373 bool show_cloud_pref = false; 382 bool show_cloud_pref = false;
374 #if defined(GOOGLE_CHROME_BUILD) 383 #if defined(GOOGLE_CHROME_BUILD)
375 // Cloud services preference is shown if user is logged in and has sync 384 // Cloud services preference is shown if user is logged in and has sync
376 // enabled. If the user enables sync after acknowledging the first run flow, 385 // enabled. If the user enables sync after acknowledging the first run flow,
377 // this is treated as the user opting into Google services, including cloud 386 // this is treated as the user opting into Google services, including cloud
378 // services, if the browser is a Chrome branded build. 387 // services, if the browser is a Chrome branded build.
388 SigninManagerBase* signin_manager =
389 SigninManagerFactory::GetForProfile(profile);
379 if (!profile->GetPrefs()->GetBoolean( 390 if (!profile->GetPrefs()->GetBoolean(
380 prefs::kMediaRouterCloudServicesPrefSet) && 391 prefs::kMediaRouterCloudServicesPrefSet) &&
381 profile->IsSyncAllowed()) { 392 profile->IsSyncAllowed()) {
382 SigninManagerBase* signin_manager =
383 SigninManagerFactory::GetForProfile(profile);
384 show_cloud_pref = signin_manager && signin_manager->IsAuthenticated() && 393 show_cloud_pref = signin_manager && signin_manager->IsAuthenticated() &&
385 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive(); 394 ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive();
386 } 395 }
396 initial_data.SetString("userEmail",
apacible 2016/02/11 17:09:14 What would the behavior be like for scenarios wher
amp 2016/02/11 21:21:24 If the dialogue is still open and still shows sink
apacible 2016/02/12 21:26:15 Would the cloud mrp run discover when we do a sink
amp 2016/02/13 02:11:05 The CloudMRP will get the same queries, but it ign
apacible 2016/02/13 08:13:02 Acknowledged.
397 signin_manager->GetAuthenticatedAccountInfo().email);
398 initial_data.SetString("userDomain",
399 signin_manager->GetAuthenticatedAccountInfo().hosted_domain);
400 initial_data.SetBoolean("showEmail",
401 SinksWithDomainInList(media_router_ui_->sinks()));
387 #endif // defined(GOOGLE_CHROME_BUILD) 402 #endif // defined(GOOGLE_CHROME_BUILD)
388 initial_data.SetBoolean("showFirstRunFlowCloudPref", show_cloud_pref); 403 initial_data.SetBoolean("showFirstRunFlowCloudPref", show_cloud_pref);
389 404
390 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data); 405 web_ui()->CallJavascriptFunction(kSetInitialData, initial_data);
391 media_router_ui_->UIInitialized(); 406 media_router_ui_->UIInitialized();
392 } 407 }
393 408
394 void MediaRouterWebUIMessageHandler::OnCreateRoute( 409 void MediaRouterWebUIMessageHandler::OnCreateRoute(
395 const base::ListValue* args) { 410 const base::ListValue* args) {
396 DVLOG(1) << "OnCreateRoute"; 411 DVLOG(1) << "OnCreateRoute";
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // Do nothing; no other issue action types require any other action. 708 // Do nothing; no other issue action types require any other action.
694 return true; 709 return true;
695 } 710 }
696 } 711 }
697 712
698 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { 713 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) {
699 set_web_ui(web_ui); 714 set_web_ui(web_ui);
700 } 715 }
701 716
702 } // namespace media_router 717 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698