| 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 "base/time.h" | 7 #include "base/time.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/win/scoped_bstr.h" | 9 #include "base/win/scoped_bstr.h" |
| 10 #include "base/win/scoped_variant.h" | 10 #include "base/win/scoped_variant.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 on_auth_code_ = on_auth_code; | 35 on_auth_code_ = on_auth_code; |
| 36 HRESULT hr = browser_.CreateInstance(CLSID_InternetExplorer, NULL, | 36 HRESULT hr = browser_.CreateInstance(CLSID_InternetExplorer, NULL, |
| 37 CLSCTX_LOCAL_SERVER); | 37 CLSCTX_LOCAL_SERVER); |
| 38 if (FAILED(hr)) { | 38 if (FAILED(hr)) { |
| 39 on_auth_code_.Run(""); | 39 on_auth_code_.Run(""); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 browser_running_ = true; | 42 browser_running_ = true; |
| 43 base::win::ScopedBstr url(UTF8ToWide(GetOauthStartUrl()).c_str()); | 43 base::win::ScopedBstr url(UTF8ToWide( |
| 44 GetOauthStartUrl(GetDefaultOauthRedirectUrl())).c_str()); |
| 44 base::win::ScopedVariant empty_variant; | 45 base::win::ScopedVariant empty_variant; |
| 45 hr = browser_->Navigate(url, empty_variant.AsInput(), empty_variant.AsInput(), | 46 hr = browser_->Navigate(url, empty_variant.AsInput(), empty_variant.AsInput(), |
| 46 empty_variant.AsInput(), empty_variant.AsInput()); | 47 empty_variant.AsInput(), empty_variant.AsInput()); |
| 47 if (FAILED(hr)) { | 48 if (FAILED(hr)) { |
| 48 KillBrowser(); | 49 KillBrowser(); |
| 49 on_auth_code_.Run(""); | 50 on_auth_code_.Run(""); |
| 50 return; | 51 return; |
| 51 } | 52 } |
| 52 browser_->put_Visible(VARIANT_TRUE); | 53 browser_->put_Visible(VARIANT_TRUE); |
| 53 StartTimer(); | 54 StartTimer(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 *auth_code = ""; | 71 *auth_code = ""; |
| 71 if (!browser_running_) { | 72 if (!browser_running_) { |
| 72 return true; | 73 return true; |
| 73 } | 74 } |
| 74 base::win::ScopedBstr url; | 75 base::win::ScopedBstr url; |
| 75 HRESULT hr = browser_->get_LocationName(url.Receive()); | 76 HRESULT hr = browser_->get_LocationName(url.Receive()); |
| 76 if (!SUCCEEDED(hr)) { | 77 if (!SUCCEEDED(hr)) { |
| 77 KillBrowser(); | 78 KillBrowser(); |
| 78 return true; | 79 return true; |
| 79 } | 80 } |
| 80 *auth_code = GetOauthCodeInUrl(WideToUTF8(static_cast<BSTR>(url))); | 81 *auth_code = GetOauthCodeInUrl(WideToUTF8(static_cast<BSTR>(url)), |
| 82 GetDefaultOauthRedirectUrl()); |
| 81 if (!auth_code->empty()) { | 83 if (!auth_code->empty()) { |
| 82 KillBrowser(); | 84 KillBrowser(); |
| 83 return true; | 85 return true; |
| 84 } | 86 } |
| 85 return false; | 87 return false; |
| 86 } | 88 } |
| 87 | 89 |
| 88 void AuthCodeGetter::KillBrowser() { | 90 void AuthCodeGetter::KillBrowser() { |
| 89 if (browser_running_) { | 91 if (browser_running_) { |
| 90 browser_->Quit(); | 92 browser_->Quit(); |
| 91 browser_running_ = false; | 93 browser_running_ = false; |
| 92 } | 94 } |
| 93 } | 95 } |
| 94 | 96 |
| 95 } // namespace remoting | 97 } // namespace remoting |
| OLD | NEW |