summaryrefslogtreecommitdiffstats
path: root/chrome/browser/local_discovery/cloud_print_account_manager.h
blob: 39c54487b65ac422c81c109ecb313be42a3e0a6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_ACCOUNT_MANAGER_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_ACCOUNT_MANAGER_H_

#include <string>
#include <vector>

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/local_discovery/cloud_print_base_api_flow.h"

namespace local_discovery {

class CloudPrintAccountManager : public CloudPrintBaseApiFlow::Delegate {
 public:
  typedef base::Callback<void(
      const std::vector<std::string>& /*accounts*/,
      const std::string& /*xsrf_token*/)> AccountsCallback;

  CloudPrintAccountManager(net::URLRequestContextGetter* request_context,
                           const std::string& cloud_print_url,
                           int token_user_index,
                           const AccountsCallback& callback);
  virtual ~CloudPrintAccountManager();

  void Start();

  // BaseCloudPrintApiFlow::Delegate implementation.
  virtual void OnCloudPrintAPIFlowError(
      CloudPrintBaseApiFlow* flow,
      CloudPrintBaseApiFlow::Status status) OVERRIDE;

  virtual void OnCloudPrintAPIFlowComplete(
        CloudPrintBaseApiFlow* flow,
        const base::DictionaryValue* value) OVERRIDE;

 private:
  void ReportEmptyUserList();

  CloudPrintBaseApiFlow flow_;
  AccountsCallback callback_;
};

}  // namespace local_discovery

#endif  // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_ACCOUNT_MANAGER_H_