• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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.
4 
5 #ifndef CLOUD_PRINT_GCP20_PROTOTYPE_PRINTER_STATE_H_
6 #define CLOUD_PRINT_GCP20_PROTOTYPE_PRINTER_STATE_H_
7 
8 #include <string>
9 
10 #include "base/memory/linked_ptr.h"
11 #include "base/time/time.h"
12 #include "cloud_print/gcp20/prototype/local_settings.h"
13 
14 namespace base {
15 class DictionaryValue;
16 class FilePath;
17 }  // namespace base
18 
19 struct PrinterState {
20   enum RegistrationState {
21     UNREGISTERED,
22     REGISTRATION_STARTED,  // |action=start| was called,
23                            // request to CloudPrint was sent.
24     REGISTRATION_CLAIM_TOKEN_READY,  // The same as previous, but request
25                                      // reply is already received.
26     REGISTRATION_COMPLETING,  // |action=complete| was called,
27                               // |complete| request was sent.
28     REGISTRATION_ERROR,  // Is set when server error was occurred.
29     REGISTERED,
30   };
31 
32   enum ConfirmationState {
33     CONFIRMATION_PENDING,
34     CONFIRMATION_CONFIRMED,
35     CONFIRMATION_DISCARDED,
36     CONFIRMATION_TIMEOUT,
37   };
38 
39   PrinterState();
40   ~PrinterState();
41 
42   // Registration process info
43   std::string user;
44   std::string registration_token;
45   std::string complete_invite_url;
46   RegistrationState registration_state;
47   ConfirmationState confirmation_state;
48 
49   // Printer workflow info
50   std::string refresh_token;
51   std::string device_id;
52   std::string xmpp_jid;
53   LocalSettings local_settings;
54   linked_ptr<base::DictionaryValue> cdd;
55 
56   // Last valid |access_token|.
57   std::string access_token;
58   base::Time access_token_update;
59 
60   // Contains error if |REGISTRATION_ERROR| is set.
61   std::string error_description;
62 };
63 
64 namespace printer_state {
65 
66 //
67 bool SaveToFile(const base::FilePath& path, const PrinterState& state);
68 
69 //
70 bool LoadFromFile(const base::FilePath& path, PrinterState* state);
71 
72 }  // namespace printer_state
73 
74 #endif  // CLOUD_PRINT_GCP20_PROTOTYPE_PRINTER_STATE_H_
75 
76