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

Side by Side Diff: remoting/host/setup/win/auth_code_getter.cc

Issue 2887243002: Remove ScopedComPtr::CreateInstance() (Closed)
Patch Set: 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
« no previous file with comments | « remoting/host/desktop_session_win.cc ('k') | ui/gfx/win/direct_manipulation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
8
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h" 10 #include "base/time/time.h"
9 #include "base/win/scoped_bstr.h" 11 #include "base/win/scoped_bstr.h"
10 #include "base/win/scoped_variant.h" 12 #include "base/win/scoped_variant.h"
11 #include "remoting/base/oauth_helper.h" 13 #include "remoting/base/oauth_helper.h"
12 14
13 namespace { 15 namespace {
14 const int kUrlPollIntervalMs = 100; 16 const int kUrlPollIntervalMs = 100;
15 } // namespace remoting 17 } // namespace remoting
16 18
17 namespace remoting { 19 namespace remoting {
18 20
19 AuthCodeGetter::AuthCodeGetter() : 21 AuthCodeGetter::AuthCodeGetter() :
20 browser_(nullptr), 22 browser_(nullptr),
21 timer_interval_(base::TimeDelta::FromMilliseconds(kUrlPollIntervalMs)) { 23 timer_interval_(base::TimeDelta::FromMilliseconds(kUrlPollIntervalMs)) {
22 } 24 }
23 25
24 AuthCodeGetter::~AuthCodeGetter() { 26 AuthCodeGetter::~AuthCodeGetter() {
25 KillBrowser(); 27 KillBrowser();
26 } 28 }
27 29
28 void AuthCodeGetter::GetAuthCode( 30 void AuthCodeGetter::GetAuthCode(
29 base::Callback<void(const std::string&)> on_auth_code) { 31 base::Callback<void(const std::string&)> on_auth_code) {
30 if (browser_.Get()) { 32 if (browser_.Get()) {
31 on_auth_code.Run(""); 33 on_auth_code.Run("");
32 return; 34 return;
33 } 35 }
34 on_auth_code_ = on_auth_code; 36 on_auth_code_ = on_auth_code;
35 HRESULT hr = browser_.CreateInstance(CLSID_InternetExplorer, nullptr, 37 HRESULT hr = ::CoCreateInstance(CLSID_InternetExplorer, nullptr,
36 CLSCTX_LOCAL_SERVER); 38 CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&browser_));
37 if (FAILED(hr)) { 39 if (FAILED(hr)) {
38 on_auth_code_.Run(""); 40 on_auth_code_.Run("");
39 return; 41 return;
40 } 42 }
41 base::win::ScopedBstr url(base::UTF8ToWide( 43 base::win::ScopedBstr url(base::UTF8ToWide(
42 GetOauthStartUrl(GetDefaultOauthRedirectUrl())).c_str()); 44 GetOauthStartUrl(GetDefaultOauthRedirectUrl())).c_str());
43 base::win::ScopedVariant empty_variant; 45 base::win::ScopedVariant empty_variant;
44 hr = browser_->Navigate(url, empty_variant.AsInput(), empty_variant.AsInput(), 46 hr = browser_->Navigate(url, empty_variant.AsInput(), empty_variant.AsInput(),
45 empty_variant.AsInput(), empty_variant.AsInput()); 47 empty_variant.AsInput(), empty_variant.AsInput());
46 if (FAILED(hr)) { 48 if (FAILED(hr)) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 88 }
87 89
88 void AuthCodeGetter::KillBrowser() { 90 void AuthCodeGetter::KillBrowser() {
89 if (browser_.Get()) { 91 if (browser_.Get()) {
90 browser_->Quit(); 92 browser_->Quit();
91 browser_.Reset(); 93 browser_.Reset();
92 } 94 }
93 } 95 }
94 96
95 } // namespace remoting 97 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_session_win.cc ('k') | ui/gfx/win/direct_manipulation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698