Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
index 962e93b6c22268f7fbad69e4d51a769535f05cc6..cc9bb9c13d0672336454781a28d6a2c68a7507ca 100644 |
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
@@ -373,7 +373,8 @@ class PrintPreviewHandler::AccessTokenService |
: public OAuth2TokenService::Consumer { |
public: |
explicit AccessTokenService(PrintPreviewHandler* handler) |
- : handler_(handler) { |
+ : handler_(handler), |
+ weak_factory_(this) { |
} |
void RequestToken(const std::string& type) { |
@@ -392,13 +393,32 @@ class PrintPreviewHandler::AccessTokenService |
} |
} else if (type == "device") { |
#if defined(OS_CHROMEOS) |
- chromeos::DeviceOAuth2TokenService* token_service = |
- chromeos::DeviceOAuth2TokenServiceFactory::Get(); |
- account_id = token_service->GetRobotAccountId(); |
- service = token_service; |
+ chromeos::DeviceOAuth2TokenServiceFactory::Get( |
+ base::Bind( |
+ &PrintPreviewHandler::AccessTokenService::DidGetTokenService, |
pneubeck (no reviews)
2013/10/22 09:05:03
PrintPreviewHandler:: really required? I thought q
satorux1
2013/10/22 09:56:43
good point. will fix.
satorux1
2013/10/23 06:35:44
Done.
|
+ weak_factory_.GetWeakPtr(), |
+ type)); |
+ return; |
#endif |
} |
+ ContinueRequestToken(type, service, account_id); |
+ } |
+ |
+#if defined(OS_CHROMEOS) |
+ // Continuation of RequestToken(). |
+ void DidGetTokenService(const std::string& type, |
+ chromeos::DeviceOAuth2TokenService* token_service) { |
hashimoto
2013/10/22 08:49:51
nit: No need to have a NULL check here?
satorux1
2013/10/22 09:56:43
will add.
satorux1
2013/10/23 06:35:44
Done.
|
+ ContinueRequestToken(type, |
+ token_service, |
+ token_service->GetRobotAccountId()); |
+ } |
+#endif |
+ |
+ // Continuation of RequestToken(). |
+ void ContinueRequestToken(const std::string& type, |
+ OAuth2TokenService* service, |
+ const std::string& account_id) { |
if (service) { |
OAuth2TokenService::ScopeSet oauth_scopes; |
oauth_scopes.insert(cloud_print::kCloudPrintAuth); |
@@ -438,6 +458,7 @@ class PrintPreviewHandler::AccessTokenService |
linked_ptr<OAuth2TokenService::Request> > Requests; |
Requests requests_; |
PrintPreviewHandler* handler_; |
+ base::WeakPtrFactory<AccessTokenService> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(AccessTokenService); |
}; |