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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host.cc

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Fix unit tests Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "remoting/host/it2me/it2me_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 SendErrorAndExit(std::move(response), 313 SendErrorAndExit(std::move(response),
314 "'directoryBotJid' not found in request."); 314 "'directoryBotJid' not found in request.");
315 return; 315 return;
316 } 316 }
317 #endif // !defined(NDEBUG) 317 #endif // !defined(NDEBUG)
318 318
319 // Create the It2Me host and start connecting. 319 // Create the It2Me host and start connecting.
320 it2me_host_ = factory_->CreateIt2MeHost( 320 it2me_host_ = factory_->CreateIt2MeHost(
321 host_context_->Copy(), policy_service_, weak_ptr_, 321 host_context_->Copy(), policy_service_, weak_ptr_,
322 std::move(signal_strategy), username, directory_bot_jid); 322 std::move(signal_strategy), username, directory_bot_jid);
323 it2me_host_->OnPolicyUpdate(policy_watcher_->GetCurrentPolicies());
323 it2me_host_->Connect(); 324 it2me_host_->Connect();
324 325
325 SendMessageToClient(std::move(response)); 326 SendMessageToClient(std::move(response));
326 } 327 }
327 328
328 void It2MeNativeMessagingHost::ProcessDisconnect( 329 void It2MeNativeMessagingHost::ProcessDisconnect(
329 std::unique_ptr<base::DictionaryValue> message, 330 std::unique_ptr<base::DictionaryValue> message,
330 std::unique_ptr<base::DictionaryValue> response) { 331 std::unique_ptr<base::DictionaryValue> response) {
331 DCHECK(task_runner()->BelongsToCurrentThread()); 332 DCHECK(task_runner()->BelongsToCurrentThread());
332 DCHECK(policy_received_); 333 DCHECK(policy_received_);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 463 }
463 464
464 /* static */ 465 /* static */
465 std::string It2MeNativeMessagingHost::HostStateToString( 466 std::string It2MeNativeMessagingHost::HostStateToString(
466 It2MeHostState host_state) { 467 It2MeHostState host_state) {
467 return ValueToName(kIt2MeHostStates, host_state); 468 return ValueToName(kIt2MeHostStates, host_state);
468 } 469 }
469 470
470 void It2MeNativeMessagingHost::OnPolicyUpdate( 471 void It2MeNativeMessagingHost::OnPolicyUpdate(
471 std::unique_ptr<base::DictionaryValue> policies) { 472 std::unique_ptr<base::DictionaryValue> policies) {
472 if (policy_received_) { 473 // Don't dynamically change the elevation status since we don't have a good
473 // Don't dynamically change how the host operates since we don't have a good 474 // way to communicate changes to the user.
rkjnsn 2017/05/03 21:31:47 Out of curiosity, in most places we try to enforce
Jamie 2017/05/03 23:41:10 I'm not sure (Joe might be able to shed some light
joedow 2017/05/04 17:24:22 Not all policy changes force a restart (for instan
rkjnsn 2017/05/04 20:45:45 Isn't the native messaging host potentially long-r
474 // way to communicate changes to the user. 475 if (!policy_received_) {
475 return; 476 bool allow_elevated_host = false;
477 if (!policies->GetBoolean(
478 policy::key::kRemoteAccessHostAllowUiAccessForRemoteAssistance,
479 &allow_elevated_host)) {
480 LOG(WARNING) << "Failed to retrieve elevated host policy value.";
481 }
482 #if defined(OS_WIN)
483 LOG(INFO) << "Allow UiAccess for Remote Assistance: "
484 << allow_elevated_host;
485 #endif // defined(OS_WIN)
486
487 policy_received_ = true;
488
489 // If |allow_elevated_host| is false, then we will fall back to using a host
490 // running in the current context regardless of the elevation request. This
491 // may not be ideal, but is still functional.
492 needs_elevation_ = needs_elevation_ && allow_elevated_host;
493 if (!pending_connect_.is_null()) {
494 base::ResetAndReturn(&pending_connect_).Run();
495 }
476 } 496 }
477 497
478 bool allow_elevated_host = false; 498 if (it2me_host_.get()) {
479 if (!policies->GetBoolean( 499 it2me_host_->OnPolicyUpdate(std::move(policies));
480 policy::key::kRemoteAccessHostAllowUiAccessForRemoteAssistance,
481 &allow_elevated_host)) {
482 LOG(WARNING) << "Failed to retrieve elevated host policy value.";
483 }
484 #if defined(OS_WIN)
485 LOG(INFO) << "Allow UiAccess for Remote Assistance: " << allow_elevated_host;
486 #endif // defined(OS_WIN)
487
488 policy_received_ = true;
489
490 // If |allow_elevated_host| is false, then we will fall back to using a host
491 // running in the current context regardless of the elevation request. This
492 // may not be ideal, but is still functional.
493 needs_elevation_ = needs_elevation_ && allow_elevated_host;
494 if (!pending_connect_.is_null()) {
495 base::ResetAndReturn(&pending_connect_).Run();
496 } 500 }
497 } 501 }
498 502
499 #if defined(OS_WIN) 503 #if defined(OS_WIN)
500 504
501 bool It2MeNativeMessagingHost::DelegateToElevatedHost( 505 bool It2MeNativeMessagingHost::DelegateToElevatedHost(
502 std::unique_ptr<base::DictionaryValue> message) { 506 std::unique_ptr<base::DictionaryValue> message) {
503 DCHECK(task_runner()->BelongsToCurrentThread()); 507 DCHECK(task_runner()->BelongsToCurrentThread());
504 DCHECK(needs_elevation_); 508 DCHECK(needs_elevation_);
505 509
(...skipping 24 matching lines...) Expand all
530 534
531 bool It2MeNativeMessagingHost::DelegateToElevatedHost( 535 bool It2MeNativeMessagingHost::DelegateToElevatedHost(
532 std::unique_ptr<base::DictionaryValue> message) { 536 std::unique_ptr<base::DictionaryValue> message) {
533 NOTREACHED(); 537 NOTREACHED();
534 return false; 538 return false;
535 } 539 }
536 540
537 #endif // !defined(OS_WIN) 541 #endif // !defined(OS_WIN)
538 542
539 } // namespace remoting 543 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698