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
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_SETUP_WIN_AUTH_CODE_GETTER_H
6 #define REMOTING_HOST_SETUP_WIN_AUTH_CODE_GETTER_H
13 #include "base/callback.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "base/timer/timer.h"
16 #include "base/win/scoped_comptr.h"
20 // A class for getting an OAuth authorization code.
21 class AuthCodeGetter
: public base::NonThreadSafe
{
26 // Starts a browser and navigates it to a URL that starts an Installed
27 // Application OAuth flow. |on_auth_code| will be called with an
28 // authorization code, or an empty string on error.
29 void GetAuthCode(base::Callback
<void(const std::string
&)> on_auth_code
);
32 // Starts a timer used to poll the browser's URL.
34 // Called when that timer fires.
36 // Returns whether to stop polling the browser's URL. If true, then
37 // |auth_code| is an authorization code, or the empty string on an error.
38 bool TestBrowserUrl(std::string
* auth_code
);
42 // The authorization code callback.
43 base::Callback
<void(const std::string
&)> on_auth_code_
;
44 // The browser through which the user requests an authorization code.
45 base::win::ScopedComPtr
<IWebBrowser2
, &IID_IWebBrowser2
> browser_
;
46 // A timer used to poll the browser's URL.
47 base::OneShotTimer
<AuthCodeGetter
> timer_
;
48 // The interval at which the timer fires.
49 base::TimeDelta timer_interval_
;
51 DISALLOW_COPY_AND_ASSIGN(AuthCodeGetter
);
54 } // namespace remoting
56 #endif // REMOTING_HOST_SETUP_WIN_AUTH_CODE_GETTER_H