OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PROFILES_PROFILE_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Starts downloading profile information if the necessary authorization token | 44 // Starts downloading profile information if the necessary authorization token |
45 // is ready. If not, subscribes to token service and starts fetching if the | 45 // is ready. If not, subscribes to token service and starts fetching if the |
46 // token is available. Should not be called more than once. | 46 // token is available. Should not be called more than once. |
47 virtual void Start(); | 47 virtual void Start(); |
48 | 48 |
49 // Starts downloading profile information if the necessary authorization token | 49 // Starts downloading profile information if the necessary authorization token |
50 // is ready. If not, subscribes to token service and starts fetching if the | 50 // is ready. If not, subscribes to token service and starts fetching if the |
51 // token is available. Should not be called more than once. | 51 // token is available. Should not be called more than once. |
52 virtual void StartForAccount(const std::string& account_id); | 52 virtual void StartForAccount(const std::string& account_id); |
53 | 53 |
| 54 // On successful download this returns the hosted domain of the user. |
| 55 virtual base::string16 GetProfileHostedDomain() const; |
| 56 |
54 // On successful download this returns the full name of the user. For example | 57 // On successful download this returns the full name of the user. For example |
55 // "Pat Smith". | 58 // "Pat Smith". |
56 virtual base::string16 GetProfileFullName() const; | 59 virtual base::string16 GetProfileFullName() const; |
57 | 60 |
58 // On successful download this returns the given name of the user. For example | 61 // On successful download this returns the given name of the user. For example |
59 // if the name is "Pat Smith", the given name is "Pat". | 62 // if the name is "Pat Smith", the given name is "Pat". |
60 virtual base::string16 GetProfileGivenName() const; | 63 virtual base::string16 GetProfileGivenName() const; |
61 | 64 |
62 // On successful download this returns G+ locale preference of the user. | 65 // On successful download this returns G+ locale preference of the user. |
63 virtual std::string GetProfileLocale() const; | 66 virtual std::string GetProfileLocale() const; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const GoogleServiceAuthError& error) OVERRIDE; | 102 const GoogleServiceAuthError& error) OVERRIDE; |
100 | 103 |
101 // Parses the entry response and gets the name, profile image URL and locale. | 104 // Parses the entry response and gets the name, profile image URL and locale. |
102 // |data| should be the JSON formatted data return by the response. | 105 // |data| should be the JSON formatted data return by the response. |
103 // Returns false to indicate a parsing error. | 106 // Returns false to indicate a parsing error. |
104 static bool ParseProfileJSON(const std::string& data, | 107 static bool ParseProfileJSON(const std::string& data, |
105 base::string16* full_name, | 108 base::string16* full_name, |
106 base::string16* given_name, | 109 base::string16* given_name, |
107 std::string* url, | 110 std::string* url, |
108 int image_size, | 111 int image_size, |
109 std::string* profile_locale); | 112 std::string* profile_locale, |
| 113 base::string16* hosted_domain); |
110 // Returns true if the image url is url of the default profile picture. | 114 // Returns true if the image url is url of the default profile picture. |
111 static bool IsDefaultProfileImageURL(const std::string& url); | 115 static bool IsDefaultProfileImageURL(const std::string& url); |
112 | 116 |
113 // Issues the first request to get user profile image. | 117 // Issues the first request to get user profile image. |
114 void StartFetchingImage(); | 118 void StartFetchingImage(); |
115 | 119 |
116 // Gets the authorization header. | 120 // Gets the authorization header. |
117 const char* GetAuthorizationHeader() const; | 121 const char* GetAuthorizationHeader() const; |
118 | 122 |
119 // Starts fetching OAuth2 access token. This is needed before the GAIA info | 123 // Starts fetching OAuth2 access token. This is needed before the GAIA info |
120 // can be downloaded. | 124 // can be downloaded. |
121 void StartFetchingOAuth2AccessToken(); | 125 void StartFetchingOAuth2AccessToken(); |
122 | 126 |
123 ProfileDownloaderDelegate* delegate_; | 127 ProfileDownloaderDelegate* delegate_; |
124 std::string account_id_; | 128 std::string account_id_; |
125 std::string auth_token_; | 129 std::string auth_token_; |
126 scoped_ptr<net::URLFetcher> user_entry_fetcher_; | 130 scoped_ptr<net::URLFetcher> user_entry_fetcher_; |
127 scoped_ptr<net::URLFetcher> profile_image_fetcher_; | 131 scoped_ptr<net::URLFetcher> profile_image_fetcher_; |
128 scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_; | 132 scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_; |
| 133 base::string16 profile_hosted_domain_; |
129 base::string16 profile_full_name_; | 134 base::string16 profile_full_name_; |
130 base::string16 profile_given_name_; | 135 base::string16 profile_given_name_; |
131 std::string profile_locale_; | 136 std::string profile_locale_; |
132 SkBitmap profile_picture_; | 137 SkBitmap profile_picture_; |
133 PictureStatus picture_status_; | 138 PictureStatus picture_status_; |
134 std::string picture_url_; | 139 std::string picture_url_; |
135 | 140 |
136 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); | 141 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); |
137 }; | 142 }; |
138 | 143 |
139 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ | 144 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ |
OLD | NEW |