Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/profiles/profile_downloader.h

Issue 23095006: If user profile doesn't contain language setting, default to his Google account settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 virtual void Start(); 47 virtual void Start();
48 48
49 // On successful download this returns the full name of the user. For example 49 // On successful download this returns the full name of the user. For example
50 // "Pat Smith". 50 // "Pat Smith".
51 virtual string16 GetProfileFullName() const; 51 virtual string16 GetProfileFullName() const;
52 52
53 // On successful download this returns the given name of the user. For example 53 // On successful download this returns the given name of the user. For example
54 // if the name is "Pat Smith", the given name is "Pat". 54 // if the name is "Pat Smith", the given name is "Pat".
55 virtual string16 GetProfileGivenName() const; 55 virtual string16 GetProfileGivenName() const;
56 56
57 // On successful download this returns G+ locale preference of the user.
58 virtual std::string GetProfileLocale() const;
59
57 // On successful download this returns the profile picture of the user. 60 // On successful download this returns the profile picture of the user.
58 // For users with no profile picture set (that is, they have the default 61 // For users with no profile picture set (that is, they have the default
59 // profile picture) this will return an Null bitmap. 62 // profile picture) this will return an Null bitmap.
60 virtual SkBitmap GetProfilePicture() const; 63 virtual SkBitmap GetProfilePicture() const;
61 64
62 // Gets the profile picture status. 65 // Gets the profile picture status.
63 virtual PictureStatus GetProfilePictureStatus() const; 66 virtual PictureStatus GetProfilePictureStatus() const;
64 67
65 // Gets the URL for the profile picture. This can be cached so that the same 68 // Gets the URL for the profile picture. This can be cached so that the same
66 // picture is not downloaded multiple times. This value should only be used 69 // picture is not downloaded multiple times. This value should only be used
(...skipping 16 matching lines...) Expand all
83 // Overriden from OAuth2TokenService::Observer: 86 // Overriden from OAuth2TokenService::Observer:
84 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 87 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
85 88
86 // Overriden from OAuth2TokenService::Consumer: 89 // Overriden from OAuth2TokenService::Consumer:
87 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 90 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
88 const std::string& access_token, 91 const std::string& access_token,
89 const base::Time& expiration_time) OVERRIDE; 92 const base::Time& expiration_time) OVERRIDE;
90 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 93 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
91 const GoogleServiceAuthError& error) OVERRIDE; 94 const GoogleServiceAuthError& error) OVERRIDE;
92 95
93 // Parses the entry response and gets the full name, the given name, 96 // Parses the entry response and gets the name, profile image URL and locale.
94 // and profile image URL. |data| should be the JSON formatted data returned 97 // |data| should be the JSON formatted data return by the response.
95 // by the response. Returns false to indicate a parsing error. 98 // Returns false to indicate a parsing error.
96 static bool GetProfileNameAndImageURL(const std::string& data, 99 static bool ParseProfileJSON(const std::string& data,
97 string16* full_name, 100 string16* full_name,
98 string16* given_name, 101 string16* given_name,
99 std::string* url, 102 std::string* url,
100 int image_size); 103 int image_size,
101 104 std::string* profile_locale);
102 // Returns true if the image url is url of the default profile picture. 105 // Returns true if the image url is url of the default profile picture.
103 static bool IsDefaultProfileImageURL(const std::string& url); 106 static bool IsDefaultProfileImageURL(const std::string& url);
104 107
105 // Issues the first request to get user profile image. 108 // Issues the first request to get user profile image.
106 void StartFetchingImage(); 109 void StartFetchingImage();
107 110
108 // Gets the authorization header. 111 // Gets the authorization header.
109 const char* GetAuthorizationHeader() const; 112 const char* GetAuthorizationHeader() const;
110 113
111 // Starts fetching OAuth2 access token. This is needed before the GAIA info 114 // Starts fetching OAuth2 access token. This is needed before the GAIA info
112 // can be downloaded. 115 // can be downloaded.
113 void StartFetchingOAuth2AccessToken(); 116 void StartFetchingOAuth2AccessToken();
114 117
115 ProfileDownloaderDelegate* delegate_; 118 ProfileDownloaderDelegate* delegate_;
116 std::string auth_token_; 119 std::string auth_token_;
117 scoped_ptr<net::URLFetcher> user_entry_fetcher_; 120 scoped_ptr<net::URLFetcher> user_entry_fetcher_;
118 scoped_ptr<net::URLFetcher> profile_image_fetcher_; 121 scoped_ptr<net::URLFetcher> profile_image_fetcher_;
119 scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_; 122 scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_;
120 string16 profile_full_name_; 123 string16 profile_full_name_;
121 string16 profile_given_name_; 124 string16 profile_given_name_;
125 std::string profile_locale_;
122 SkBitmap profile_picture_; 126 SkBitmap profile_picture_;
123 PictureStatus picture_status_; 127 PictureStatus picture_status_;
124 std::string picture_url_; 128 std::string picture_url_;
125 129
126 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader); 130 DISALLOW_COPY_AND_ASSIGN(ProfileDownloader);
127 }; 131 };
128 132
129 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_ 133 #endif // CHROME_BROWSER_PROFILES_PROFILE_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.cc ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698