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

Unified Diff: chrome/browser/profiles/profile_downloader.cc

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: Added comment on "list of preferred languages". 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_downloader.cc
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index 08da574b808479a3afea1600ac7f2f5c87cda1da..9bdb89662baede52ee7043fe757d8535146a4aa8 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -16,6 +16,7 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "content/public/browser/browser_thread.h"
@@ -45,6 +46,9 @@ const char kAPIScope[] = "https://www.googleapis.com/auth/userinfo.profile";
// Path in JSON dictionary to user's photo thumbnail URL.
const char kPhotoThumbnailURLPath[] = "picture";
+// Path in JSON dictionary to user's preferred locale.
+const char kLocalePath[] = "locale";
+
const char kNickNamePath[] = "name";
// Path format for specifying thumbnail's size.
@@ -120,15 +124,19 @@ bool GetImageURLWithSize(const GURL& old_url, int size, GURL* new_url) {
} // namespace
-// static
-bool ProfileDownloader::GetProfileNameAndImageURL(const std::string& data,
- string16* nick_name,
- std::string* url,
- int image_size) {
+// Parses the entry response and gets the name and profile image URL.
+// |data| should be the JSON formatted data return by the response.
+// Returns false to indicate a parsing error.
+bool ProfileDownloader::ParseProfileJSON(const std::string& data,
+ string16* nick_name,
+ std::string* url,
+ int image_size,
+ std::string* profile_locale) {
DCHECK(nick_name);
DCHECK(url);
*nick_name = string16();
*url = std::string();
+ *profile_locale = std::string();
int error_code = -1;
std::string error_message;
@@ -147,6 +155,7 @@ bool ProfileDownloader::GetProfileNameAndImageURL(const std::string& data,
base::DictionaryValue* root_dictionary =
static_cast<base::DictionaryValue*>(root_value.get());
+ root_dictionary->GetString(kLocalePath, profile_locale);
root_dictionary->GetString(kNickNamePath, nick_name);
std::string url_string;
@@ -220,6 +229,10 @@ string16 ProfileDownloader::GetProfileFullName() const {
return profile_full_name_;
}
+std::string ProfileDownloader::GetProfileLocale() const {
+ return profile_locale_;
+}
+
SkBitmap ProfileDownloader::GetProfilePicture() const {
return profile_picture_;
}
@@ -279,8 +292,11 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
if (source == user_entry_fetcher_.get()) {
std::string image_url;
- if (!GetProfileNameAndImageURL(data, &profile_full_name_, &image_url,
- delegate_->GetDesiredImageSideLength())) {
+ if (!ParseProfileJSON(data,
+ &profile_full_name_,
+ &image_url,
+ delegate_->GetDesiredImageSideLength(),
+ &profile_locale_)) {
delegate_->OnProfileDownloadFailure(
this, ProfileDownloaderDelegate::SERVICE_ERROR);
return;

Powered by Google App Engine
This is Rietveld 408576698