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

Unified Diff: remoting/host/it2me/it2me_native_messaging_host.cc

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Don't read real policies. 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/it2me/it2me_native_messaging_host.cc
diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc
index 9580d3d555249d70943723bdbeb25d8f6098a31c..e1079ca4b39d063d77e2d5f4e61cdbfda3fdeebb 100644
--- a/remoting/host/it2me/it2me_native_messaging_host.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host.cc
@@ -83,15 +83,13 @@ void OnPolicyError() {
It2MeNativeMessagingHost::It2MeNativeMessagingHost(
bool needs_elevation,
- policy::PolicyService* policy_service,
+ std::unique_ptr<PolicyWatcher> policy_watcher,
std::unique_ptr<ChromotingHostContext> context,
std::unique_ptr<It2MeHostFactory> factory)
: needs_elevation_(needs_elevation),
host_context_(std::move(context)),
factory_(std::move(factory)),
- policy_service_(policy_service),
- policy_watcher_(PolicyWatcher::Create(policy_service_,
- host_context_->file_task_runner())),
+ policy_watcher_(std::move(policy_watcher)),
weak_factory_(this) {
weak_ptr_ = weak_factory_.GetWeakPtr();
@@ -317,9 +315,10 @@ void It2MeNativeMessagingHost::ProcessConnect(
#endif // !defined(NDEBUG)
// Create the It2Me host and start connecting.
- it2me_host_ = factory_->CreateIt2MeHost(
- host_context_->Copy(), policy_service_, weak_ptr_,
- std::move(signal_strategy), username, directory_bot_jid);
+ it2me_host_ = factory_->CreateIt2MeHost(host_context_->Copy(), weak_ptr_,
+ std::move(signal_strategy), username,
+ directory_bot_jid);
+ it2me_host_->OnPolicyUpdate(policy_watcher_->GetCurrentPolicies());
it2me_host_->Connect();
SendMessageToClient(std::move(response));
@@ -469,30 +468,33 @@ std::string It2MeNativeMessagingHost::HostStateToString(
void It2MeNativeMessagingHost::OnPolicyUpdate(
std::unique_ptr<base::DictionaryValue> policies) {
- if (policy_received_) {
- // Don't dynamically change how the host operates since we don't have a good
- // way to communicate changes to the user.
- return;
- }
-
- bool allow_elevated_host = false;
- if (!policies->GetBoolean(
- policy::key::kRemoteAccessHostAllowUiAccessForRemoteAssistance,
- &allow_elevated_host)) {
- LOG(WARNING) << "Failed to retrieve elevated host policy value.";
- }
+ // Don't dynamically change the elevation status since we don't have a good
+ // way to communicate changes to the user.
+ if (!policy_received_) {
+ bool allow_elevated_host = false;
+ if (!policies->GetBoolean(
+ policy::key::kRemoteAccessHostAllowUiAccessForRemoteAssistance,
+ &allow_elevated_host)) {
+ LOG(WARNING) << "Failed to retrieve elevated host policy value.";
+ }
#if defined(OS_WIN)
- LOG(INFO) << "Allow UiAccess for Remote Assistance: " << allow_elevated_host;
+ LOG(INFO) << "Allow UiAccess for Remote Assistance: "
+ << allow_elevated_host;
#endif // defined(OS_WIN)
- policy_received_ = true;
+ policy_received_ = true;
- // If |allow_elevated_host| is false, then we will fall back to using a host
- // running in the current context regardless of the elevation request. This
- // may not be ideal, but is still functional.
- needs_elevation_ = needs_elevation_ && allow_elevated_host;
- if (!pending_connect_.is_null()) {
- base::ResetAndReturn(&pending_connect_).Run();
+ // If |allow_elevated_host| is false, then we will fall back to using a host
+ // running in the current context regardless of the elevation request. This
+ // may not be ideal, but is still functional.
+ needs_elevation_ = needs_elevation_ && allow_elevated_host;
+ if (!pending_connect_.is_null()) {
joedow 2017/05/05 14:42:15 nit: the style for this has changed, the preferred
Jamie 2017/05/05 16:49:05 Done, here and above.
+ base::ResetAndReturn(&pending_connect_).Run();
+ }
+ }
+
+ if (it2me_host_.get()) {
+ it2me_host_->OnPolicyUpdate(std::move(policies));
}
}

Powered by Google App Engine
This is Rietveld 408576698