| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/setup/win/auth_code_getter.h" | 5 #include "remoting/host/setup/win/auth_code_getter.h" |
| 6 | 6 |
| 7 #include <objbase.h> | 7 #include <objbase.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/win/scoped_bstr.h" | 11 #include "base/win/scoped_bstr.h" |
| 12 #include "base/win/scoped_variant.h" | 12 #include "base/win/scoped_variant.h" |
| 13 #include "remoting/base/oauth_helper.h" | 13 #include "remoting/base/oauth_helper.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const int kUrlPollIntervalMs = 100; | 16 const int kUrlPollIntervalMs = 100; |
| 17 } // namespace remoting | 17 } // namespace remoting |
| 18 | 18 |
| 19 namespace remoting { | 19 namespace remoting { |
| 20 | 20 |
| 21 AuthCodeGetter::AuthCodeGetter() : | 21 AuthCodeGetter::AuthCodeGetter() : |
| 22 browser_(nullptr), | 22 browser_(nullptr), |
| 23 timer_interval_(base::TimeDelta::FromMilliseconds(kUrlPollIntervalMs)) { | 23 timer_interval_(base::TimeDelta::FromMilliseconds(kUrlPollIntervalMs)) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 AuthCodeGetter::~AuthCodeGetter() { | 26 AuthCodeGetter::~AuthCodeGetter() { |
| 27 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 27 KillBrowser(); | 28 KillBrowser(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void AuthCodeGetter::GetAuthCode( | 31 void AuthCodeGetter::GetAuthCode( |
| 31 base::Callback<void(const std::string&)> on_auth_code) { | 32 base::Callback<void(const std::string&)> on_auth_code) { |
| 32 if (browser_.Get()) { | 33 if (browser_.Get()) { |
| 33 on_auth_code.Run(""); | 34 on_auth_code.Run(""); |
| 34 return; | 35 return; |
| 35 } | 36 } |
| 36 on_auth_code_ = on_auth_code; | 37 on_auth_code_ = on_auth_code; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 89 } |
| 89 | 90 |
| 90 void AuthCodeGetter::KillBrowser() { | 91 void AuthCodeGetter::KillBrowser() { |
| 91 if (browser_.Get()) { | 92 if (browser_.Get()) { |
| 92 browser_->Quit(); | 93 browser_->Quit(); |
| 93 browser_.Reset(); | 94 browser_.Reset(); |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace remoting | 98 } // namespace remoting |
| OLD | NEW |