OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CLOUD_PRINT_SERVICE_SERVICE_STATE_H_ |
| 6 #define CLOUD_PRINT_SERVICE_SERVICE_STATE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/values.h" |
| 13 |
| 14 class FilePath; |
| 15 |
| 16 // Manages Cloud Print part of Service State. |
| 17 class ServiceState { |
| 18 public: |
| 19 // Interface to access external options. |
| 20 class OptionsDelegate { |
| 21 public: |
| 22 virtual ~OptionsDelegate(); |
| 23 virtual std::string GetOption(const std::string& name, |
| 24 const std::string& default, |
| 25 bool secure) = 0; |
| 26 }; |
| 27 |
| 28 ServiceState(); |
| 29 virtual ~ServiceState(); |
| 30 |
| 31 void Reset(); |
| 32 |
| 33 // Initialize object from json. |
| 34 bool FromString(const std::string& json); |
| 35 |
| 36 // Returns object state as json. |
| 37 std::string ToString(); |
| 38 |
| 39 // Setups object using data provided by delegate. |
| 40 bool Configure(OptionsDelegate* delegate); |
| 41 |
| 42 // Returns authentication token provided by Google server. |
| 43 virtual std::string LoginToGoogle(const std::string& service, |
| 44 const std::string& email, |
| 45 const std::string& password); |
| 46 |
| 47 // Returns true of object state is valid. |
| 48 bool IsValid() const; |
| 49 |
| 50 std::string email() const { |
| 51 return email_; |
| 52 }; |
| 53 |
| 54 std::string password() const { |
| 55 return password_; |
| 56 }; |
| 57 |
| 58 std::string proxy_id() const { |
| 59 return proxy_id_; |
| 60 }; |
| 61 |
| 62 std::string robot_email() const { |
| 63 return robot_email_; |
| 64 }; |
| 65 |
| 66 std::string robot_token() const { |
| 67 return robot_token_; |
| 68 }; |
| 69 |
| 70 std::string auth_token() const { |
| 71 return auth_token_; |
| 72 }; |
| 73 |
| 74 std::string xmpp_auth_token() const { |
| 75 return xmpp_auth_token_; |
| 76 }; |
| 77 |
| 78 void set_email(const std::string& value) { |
| 79 email_ = value; |
| 80 }; |
| 81 |
| 82 void set_password(const std::string& value) { |
| 83 password_ = value; |
| 84 }; |
| 85 |
| 86 void set_proxy_id(const std::string& value) { |
| 87 proxy_id_ = value; |
| 88 }; |
| 89 |
| 90 void set_robot_email(const std::string& value) { |
| 91 robot_email_ = value; |
| 92 }; |
| 93 |
| 94 void set_robot_token(const std::string& value) { |
| 95 robot_token_ = value; |
| 96 }; |
| 97 |
| 98 void set_auth_token(const std::string& value) { |
| 99 auth_token_ = value; |
| 100 }; |
| 101 |
| 102 void set_xmpp_auth_token(const std::string& value) { |
| 103 xmpp_auth_token_ = value; |
| 104 }; |
| 105 |
| 106 private: |
| 107 std::string email_; |
| 108 std::string password_; |
| 109 std::string proxy_id_; |
| 110 std::string robot_email_; |
| 111 std::string robot_token_; |
| 112 std::string auth_token_; |
| 113 std::string xmpp_auth_token_; |
| 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(ServiceState); |
| 116 }; |
| 117 |
| 118 #endif // CLOUD_PRINT_SERVICE_SERVICE_STATE_H_ |
| 119 |
OLD | NEW |