Index: remoting/host/remoting_me2me_host.cc |
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc |
index 15b79076ce4aa2726bc64a2b37d42d5bddf91a45..241abaa80a311283f655e1196fa04a5fc73ea51c 100644 |
--- a/remoting/host/remoting_me2me_host.cc |
+++ b/remoting/host/remoting_me2me_host.cc |
@@ -86,6 +86,14 @@ const char kOfficialOAuth2ClientId[] = |
"440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.apps.googleusercontent.com"; |
const char kOfficialOAuth2ClientSecret[] = "Bgur6DFiOMM1h8x-AQpuTQlK"; |
+// Whether a given string ends with a given suffix. |
+bool EndsWith(std::string s, std::string suffix) { |
+ if (s.length() < suffix.length()) { |
+ return false; |
+ } |
+ return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0; |
+} |
+ |
} // namespace |
namespace remoting { |
@@ -323,12 +331,31 @@ class HostProcess |
} |
bool bool_value; |
+ std::string string_value; |
+ if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName, |
+ &string_value)) { |
+ OnHostDomainPolicyUpdate(string_value); |
+ } |
if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, |
&bool_value)) { |
OnNatPolicyUpdate(bool_value); |
} |
} |
+ void OnHostDomainPolicyUpdate(const std::string& host_domain) { |
+ if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
+ context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( |
+ &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this), |
+ host_domain)); |
+ return; |
+ } |
+ |
+ if (!host_domain.empty() && |
+ !EndsWith(xmpp_login_, std::string("@") + host_domain)) { |
+ Shutdown(kInvalidHostDomainExitCode); |
+ } |
+ } |
+ |
void OnNatPolicyUpdate(bool nat_traversal_enabled) { |
if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( |
@@ -355,6 +382,9 @@ class HostProcess |
DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
DCHECK(!host_); |
+ if (shutting_down_) |
+ return; |
+ |
if (!signal_strategy_.get()) { |
signal_strategy_.reset( |
new XmppSignalStrategy(context_->url_request_context_getter(), |
@@ -479,8 +509,12 @@ class HostProcess |
shutting_down_ = true; |
exit_code_ = exit_code; |
- host_->Shutdown(base::Bind( |
- &HostProcess::OnShutdownFinished, base::Unretained(this))); |
+ if (host_) { |
+ host_->Shutdown(base::Bind( |
+ &HostProcess::OnShutdownFinished, base::Unretained(this))); |
+ } else { |
+ OnShutdownFinished(); |
+ } |
} |
void OnShutdownFinished() { |