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 |
| 20 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
| 21 class Profile; | 23 class Profile; |
| 22 class ProfileOAuth2TokenService; | 24 class ProfileOAuth2TokenService; |
|
bartfab (slow)
2014/08/21 12:04:25
Nit: No longer used.
davidyu
2014/08/22 04:23:10
Done.
| |
| 23 | 25 |
| 24 namespace chromeos { | 26 namespace chromeos { |
| 25 class CryptohomeClient; | 27 class CryptohomeClient; |
| 26 } | 28 } |
| 27 | 29 |
| 28 namespace cryptohome { | 30 namespace cryptohome { |
| 29 class BaseReply; | 31 class BaseReply; |
| 30 } | 32 } |
| 31 | 33 |
| 32 namespace policy { | 34 namespace policy { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 const base::Time& expiration_time) OVERRIDE; | 112 const base::Time& expiration_time) OVERRIDE; |
| 111 virtual void OnGetTokenFailure( | 113 virtual void OnGetTokenFailure( |
| 112 const OAuth2TokenService::Request* request, | 114 const OAuth2TokenService::Request* request, |
| 113 const GoogleServiceAuthError& error) OVERRIDE; | 115 const GoogleServiceAuthError& error) OVERRIDE; |
| 114 | 116 |
| 115 OAuth2TokenService::Request* GetTokenRequestForTesting() { | 117 OAuth2TokenService::Request* GetTokenRequestForTesting() { |
| 116 return token_request_.get(); | 118 return token_request_.get(); |
| 117 } | 119 } |
| 118 | 120 |
| 119 private: | 121 private: |
| 122 class DesktopNotificationDelegate : public NotificationDelegate { | |
|
oshima
2014/08/21 22:47:07
Looks like you're not using this in the header. In
bartfab (slow)
2014/08/21 23:35:45
I have seen inlining of virtual methods done in .c
oshima
2014/08/22 00:44:05
http://www.chromium.org/developers/coding-style/cp
davidyu
2014/08/22 04:23:10
Moved to .cc.
bartfab (slow)
2014/08/25 13:07:30
In addition to the Dos and Don'ts you linked to, t
oshima
2014/08/25 13:42:04
That line describe the rule for accessor method.
T
| |
| 123 public: | |
| 124 // |button_click_callback| is called when the button in the notification is | |
| 125 // clicked. | |
| 126 DesktopNotificationDelegate( | |
| 127 const std::string& id, | |
| 128 const base::Closure& button_click_callback); | |
| 129 | |
| 130 virtual ~DesktopNotificationDelegate(); | |
| 131 | |
| 132 // NotificationDelegate: | |
| 133 virtual std::string id() const OVERRIDE; | |
| 134 virtual content::WebContents* GetWebContents() const OVERRIDE; | |
| 135 virtual void Display() OVERRIDE; | |
| 136 virtual void ButtonClick(int button_index) OVERRIDE; | |
| 137 virtual void Error() OVERRIDE; | |
| 138 virtual void Close(bool by_user) OVERRIDE; | |
| 139 virtual void Click() OVERRIDE; | |
| 140 | |
| 141 private: | |
| 142 std::string id_; | |
| 143 base::Closure button_click_callback_; | |
| 144 | |
| 145 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationDelegate); | |
| 146 }; | |
| 147 | |
| 120 void OnGetBootAttributeDone( | 148 void OnGetBootAttributeDone( |
| 121 const GetOwnerCallback& callback, | 149 const GetOwnerCallback& callback, |
| 122 chromeos::DBusMethodCallStatus call_status, | 150 chromeos::DBusMethodCallStatus call_status, |
| 123 bool dbus_success, | 151 bool dbus_success, |
| 124 const cryptohome::BaseReply& reply); | 152 const cryptohome::BaseReply& reply); |
| 125 | 153 |
| 126 void OnSetBootAttributeDone(const SetOwnerCallback& callback, | 154 void OnSetBootAttributeDone(const SetOwnerCallback& callback, |
| 127 chromeos::DBusMethodCallStatus call_status, | 155 chromeos::DBusMethodCallStatus call_status, |
| 128 bool dbus_success, | 156 bool dbus_success, |
| 129 const cryptohome::BaseReply& reply); | 157 const cryptohome::BaseReply& reply); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 148 void OnOwnerAccessTokenAvailable(const std::string& access_token); | 176 void OnOwnerAccessTokenAvailable(const std::string& access_token); |
| 149 | 177 |
| 150 // Called upon the completion of the enrollment process. | 178 // Called upon the completion of the enrollment process. |
| 151 void OnEnrollmentCompleted(EnrollmentStatus status); | 179 void OnEnrollmentCompleted(EnrollmentStatus status); |
| 152 | 180 |
| 153 // Ends the enrollment process and shows a desktop notification if the | 181 // Ends the enrollment process and shows a desktop notification if the |
| 154 // current user is the owner. | 182 // current user is the owner. |
| 155 void EndEnrollment(ConsumerEnrollmentState state); | 183 void EndEnrollment(ConsumerEnrollmentState state); |
| 156 | 184 |
| 157 // Shows a desktop notification and resets the enrollment state. | 185 // Shows a desktop notification and resets the enrollment state. |
| 158 void ShowDesktopNotificationAndResetState(ConsumerEnrollmentState state); | 186 void ShowDesktopNotificationAndResetState(ConsumerEnrollmentState state, |
| 187 Profile* profile); | |
| 188 | |
| 189 // Opens the settings page. | |
| 190 void OpenSettingsPage(Profile* profile) const; | |
| 191 | |
| 192 // Opens the enrollment confirmation dialog in the settings page. | |
| 193 void TryEnrollmentAgain(Profile* profile) const; | |
| 194 | |
| 195 // Returns the sign-in authenticated account ID of the profile. | |
| 196 const std::string& GetAccountIdFromProfile(Profile* profile) const; | |
|
bartfab (slow)
2014/08/21 12:04:25
Nit 1: "sign-in authenticated account ID" is reall
davidyu
2014/08/22 04:23:10
Done.
| |
| 159 | 197 |
| 160 chromeos::CryptohomeClient* client_; | 198 chromeos::CryptohomeClient* client_; |
| 161 | 199 |
| 162 std::string enrolling_account_id_; | 200 Profile* enrolling_profile_; |
| 163 ProfileOAuth2TokenService* enrolling_token_service_; | |
| 164 | |
| 165 scoped_ptr<OAuth2TokenService::Request> token_request_; | 201 scoped_ptr<OAuth2TokenService::Request> token_request_; |
| 166 content::NotificationRegistrar registrar_; | 202 content::NotificationRegistrar registrar_; |
| 167 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; | 203 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; |
| 168 | 204 |
| 169 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); | 205 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); |
| 170 }; | 206 }; |
| 171 | 207 |
| 172 } // namespace policy | 208 } // namespace policy |
| 173 | 209 |
| 174 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | 210 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |