Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | |
| 16 #include "chrome/browser/notifications/notification_delegate.h" | |
| 15 #include "chromeos/dbus/dbus_method_call_status.h" | 17 #include "chromeos/dbus/dbus_method_call_status.h" |
| 16 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 18 #include "google_apis/gaia/oauth2_token_service.h" | 20 #include "google_apis/gaia/oauth2_token_service.h" |
| 19 | 21 |
| 22 class NotificationUIManager; | |
|
bartfab (slow)
2014/08/20 13:55:52
Nit: Not used.
davidyu
2014/08/21 04:08:25
Done.
| |
| 20 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
| 21 class Profile; | 24 class Profile; |
| 22 class ProfileOAuth2TokenService; | 25 class ProfileOAuth2TokenService; |
| 23 | 26 |
| 24 namespace chromeos { | 27 namespace chromeos { |
| 25 class CryptohomeClient; | 28 class CryptohomeClient; |
| 26 } | 29 } |
| 27 | 30 |
| 31 namespace content { | |
| 32 class WebContents; | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: This is unnecessary, because WebContents is u
davidyu
2014/08/21 04:08:25
Done.
davidyu
2014/08/21 04:08:26
Done.
| |
| 33 } | |
| 34 | |
| 28 namespace cryptohome { | 35 namespace cryptohome { |
| 29 class BaseReply; | 36 class BaseReply; |
| 30 } | 37 } |
| 31 | 38 |
| 32 namespace policy { | 39 namespace policy { |
| 33 | 40 |
| 34 class EnrollmentStatus; | 41 class EnrollmentStatus; |
| 35 | 42 |
| 36 // The consumer management service handles several things: | 43 // The consumer management service handles several things: |
| 37 // | 44 // |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 const base::Time& expiration_time) OVERRIDE; | 117 const base::Time& expiration_time) OVERRIDE; |
| 111 virtual void OnGetTokenFailure( | 118 virtual void OnGetTokenFailure( |
| 112 const OAuth2TokenService::Request* request, | 119 const OAuth2TokenService::Request* request, |
| 113 const GoogleServiceAuthError& error) OVERRIDE; | 120 const GoogleServiceAuthError& error) OVERRIDE; |
| 114 | 121 |
| 115 OAuth2TokenService::Request* GetTokenRequestForTesting() { | 122 OAuth2TokenService::Request* GetTokenRequestForTesting() { |
| 116 return token_request_.get(); | 123 return token_request_.get(); |
| 117 } | 124 } |
| 118 | 125 |
| 119 private: | 126 private: |
| 127 class DesktopNotificationDelegate : public NotificationDelegate { | |
| 128 public: | |
| 129 // |display_callback| is called when the notification is displayed. | |
|
bartfab (slow)
2014/08/20 13:55:52
There is no |display_callback|?
davidyu
2014/08/21 04:08:25
Done.
| |
| 130 // |button_click_callback| is called when the button of notification | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: s/of/in the/
davidyu
2014/08/21 04:08:25
Done.
| |
| 131 // clicked. | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: s/clicked/is clicked/
davidyu
2014/08/21 04:08:25
Done.
| |
| 132 DesktopNotificationDelegate( | |
| 133 const std::string& id, | |
| 134 const base::Closure& button_click_callback); | |
|
oshima
2014/08/20 13:24:01
virtual dtor
davidyu
2014/08/21 04:08:25
Done.
| |
| 135 | |
| 136 // NotificationDelegate implementation. | |
|
oshima
2014/08/20 13:24:01
// NotificationDelegate:
is new style.
davidyu
2014/08/21 04:08:25
Done.
| |
| 137 virtual std::string id() const OVERRIDE { | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:25
Done.
| |
| 138 return id_; | |
| 139 }; | |
| 140 virtual content::WebContents* GetWebContents() const OVERRIDE { | |
|
bartfab (slow)
2014/08/20 13:55:52
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:25
Done.
| |
| 141 return NULL; | |
| 142 } | |
| 143 | |
| 144 // message_center::NotificationDelegate implementation. | |
|
oshima
2014/08/20 13:24:01
is this dup?
bartfab (slow)
2014/08/20 13:55:51
Nit: That's the same NotificationDelegate as refer
davidyu
2014/08/21 04:08:25
Done.
| |
| 145 virtual void Display() OVERRIDE {} | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:26
Done.
| |
| 146 virtual void ButtonClick(int button_index) OVERRIDE; | |
| 147 virtual void Error() OVERRIDE {} | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:26
Done.
| |
| 148 virtual void Close(bool by_user) OVERRIDE {} | |
|
bartfab (slow)
2014/08/20 13:55:52
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:25
Done.
| |
| 149 virtual void Click() OVERRIDE {} | |
|
bartfab (slow)
2014/08/20 13:55:51
Nit: The style guide forbids inlining virtual func
davidyu
2014/08/21 04:08:25
Done.
| |
| 150 | |
| 151 private: | |
| 152 std::string id_; | |
| 153 base::Closure button_click_callback_; | |
| 154 | |
| 155 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationDelegate); | |
| 156 }; | |
| 157 | |
| 120 void OnGetBootAttributeDone( | 158 void OnGetBootAttributeDone( |
| 121 const GetOwnerCallback& callback, | 159 const GetOwnerCallback& callback, |
| 122 chromeos::DBusMethodCallStatus call_status, | 160 chromeos::DBusMethodCallStatus call_status, |
| 123 bool dbus_success, | 161 bool dbus_success, |
| 124 const cryptohome::BaseReply& reply); | 162 const cryptohome::BaseReply& reply); |
| 125 | 163 |
| 126 void OnSetBootAttributeDone(const SetOwnerCallback& callback, | 164 void OnSetBootAttributeDone(const SetOwnerCallback& callback, |
| 127 chromeos::DBusMethodCallStatus call_status, | 165 chromeos::DBusMethodCallStatus call_status, |
| 128 bool dbus_success, | 166 bool dbus_success, |
| 129 const cryptohome::BaseReply& reply); | 167 const cryptohome::BaseReply& reply); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 148 void OnOwnerAccessTokenAvailable(const std::string& access_token); | 186 void OnOwnerAccessTokenAvailable(const std::string& access_token); |
| 149 | 187 |
| 150 // Called upon the completion of the enrollment process. | 188 // Called upon the completion of the enrollment process. |
| 151 void OnEnrollmentCompleted(EnrollmentStatus status); | 189 void OnEnrollmentCompleted(EnrollmentStatus status); |
| 152 | 190 |
| 153 // Ends the enrollment process and shows a desktop notification if the | 191 // Ends the enrollment process and shows a desktop notification if the |
| 154 // current user is the owner. | 192 // current user is the owner. |
| 155 void EndEnrollment(ConsumerEnrollmentState state); | 193 void EndEnrollment(ConsumerEnrollmentState state); |
| 156 | 194 |
| 157 // Shows a desktop notification and resets the enrollment state. | 195 // Shows a desktop notification and resets the enrollment state. |
| 158 void ShowDesktopNotificationAndResetState(ConsumerEnrollmentState state); | 196 void ShowDesktopNotificationAndResetState(ConsumerEnrollmentState state, |
| 197 Profile* profile); | |
| 198 | |
| 199 // Opens the settings page. | |
| 200 void OpenSettingsPage(Profile* profile) const; | |
| 201 | |
| 202 // Opens the enrollment confirmation dialog in the settings page. | |
| 203 void TryEnrollmentAgain(Profile* profile) const; | |
| 204 | |
| 205 // Shows a desktop notification with a button. | |
| 206 void ShowDesktopNotification( | |
| 207 Profile* profile, | |
| 208 const std::string& id, | |
| 209 const std::string& origin_url, | |
| 210 const base::string16& title, | |
| 211 const base::string16& body, | |
| 212 const base::string16& button_label, | |
| 213 const base::Closure& button_click_callback) const; | |
| 159 | 214 |
| 160 chromeos::CryptohomeClient* client_; | 215 chromeos::CryptohomeClient* client_; |
| 161 | 216 |
| 162 std::string enrolling_account_id_; | 217 std::string enrolling_account_id_; |
|
bartfab (slow)
2014/08/20 13:55:51
Now that there is an |enrolling_profile_|, we can
davidyu
2014/08/21 04:08:25
Done.
| |
| 218 Profile* enrolling_profile_; | |
|
bartfab (slow)
2014/08/20 13:55:52
Now that there is an |enrolling_profile_|, we can
davidyu
2014/08/21 04:08:25
Done.
| |
| 163 ProfileOAuth2TokenService* enrolling_token_service_; | 219 ProfileOAuth2TokenService* enrolling_token_service_; |
| 164 bool is_observing_token_service_; | 220 bool is_observing_token_service_; |
| 165 | 221 |
| 166 scoped_ptr<OAuth2TokenService::Request> token_request_; | 222 scoped_ptr<OAuth2TokenService::Request> token_request_; |
| 167 content::NotificationRegistrar registrar_; | 223 content::NotificationRegistrar registrar_; |
| 168 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; | 224 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; |
| 169 | 225 |
| 170 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); | 226 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); |
| 171 }; | 227 }; |
| 172 | 228 |
| 173 } // namespace policy | 229 } // namespace policy |
| 174 | 230 |
| 175 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | 231 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |