Infer appropriate GNU_STACK alignment for a shared library.
[chromium-blink-merge.git] / remoting / host / setup / win / auth_code_getter.h
blob7493d7c8931aa5b9fbe5c59f4ec32025a3693915
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
8 #include <ole2.h>
9 #include <exdisp.h>
11 #include <string>
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"
18 namespace remoting {
20 // A class for getting an OAuth authorization code.
21 class AuthCodeGetter : public base::NonThreadSafe {
22 public:
23 AuthCodeGetter();
24 ~AuthCodeGetter();
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);
31 private:
32 // Starts a timer used to poll the browser's URL.
33 void StartTimer();
34 // Called when that timer fires.
35 void OnTimer();
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);
39 // Kills the browser.
40 void KillBrowser();
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