| 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 #include "chrome/browser/android/profiles/profile_downloader_android.h" | 5 #include "chrome/browser/android/profiles/profile_downloader_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 profile_image_downloader_.reset(new ProfileDownloader(this)); | 39 profile_image_downloader_.reset(new ProfileDownloader(this)); |
| 40 profile_image_downloader_->StartForAccount(account_id_); | 40 profile_image_downloader_->StartForAccount(account_id_); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void Shutdown() { | 43 void Shutdown() { |
| 44 profile_image_downloader_.reset(); | 44 profile_image_downloader_.reset(); |
| 45 delete this; | 45 delete this; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // ProfileDownloaderDelegate implementation: | 48 // ProfileDownloaderDelegate implementation: |
| 49 virtual bool NeedsProfilePicture() const OVERRIDE { | 49 virtual bool NeedsProfilePicture() const override { |
| 50 return desired_image_side_pixels_ > 0; | 50 return desired_image_side_pixels_ > 0; |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual int GetDesiredImageSideLength() const OVERRIDE { | 53 virtual int GetDesiredImageSideLength() const override { |
| 54 return desired_image_side_pixels_; | 54 return desired_image_side_pixels_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual Profile* GetBrowserProfile() OVERRIDE { | 57 virtual Profile* GetBrowserProfile() override { |
| 58 return profile_; | 58 return profile_; |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual std::string GetCachedPictureURL() const OVERRIDE { | 61 virtual std::string GetCachedPictureURL() const override { |
| 62 return std::string(); | 62 return std::string(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void OnProfileDownloadSuccess( | 65 virtual void OnProfileDownloadSuccess( |
| 66 ProfileDownloader* downloader) OVERRIDE { | 66 ProfileDownloader* downloader) override { |
| 67 ProfileDownloaderAndroid::OnProfileDownloadSuccess( | 67 ProfileDownloaderAndroid::OnProfileDownloadSuccess( |
| 68 email_, | 68 email_, |
| 69 downloader->GetProfileFullName(), | 69 downloader->GetProfileFullName(), |
| 70 downloader->GetProfilePicture()); | 70 downloader->GetProfilePicture()); |
| 71 Shutdown(); | 71 Shutdown(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void OnProfileDownloadFailure( | 74 virtual void OnProfileDownloadFailure( |
| 75 ProfileDownloader* downloader, | 75 ProfileDownloader* downloader, |
| 76 ProfileDownloaderDelegate::FailureReason reason) OVERRIDE { | 76 ProfileDownloaderDelegate::FailureReason reason) override { |
| 77 LOG(ERROR) << "Failed to download the profile information: " << reason; | 77 LOG(ERROR) << "Failed to download the profile information: " << reason; |
| 78 Shutdown(); | 78 Shutdown(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // The profile image downloader instance. | 81 // The profile image downloader instance. |
| 82 scoped_ptr<ProfileDownloader> profile_image_downloader_; | 82 scoped_ptr<ProfileDownloader> profile_image_downloader_; |
| 83 | 83 |
| 84 // The browser profile associated with this download request. | 84 // The browser profile associated with this download request. |
| 85 Profile* profile_; | 85 Profile* profile_; |
| 86 | 86 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 new AccountInfoRetriever( | 170 new AccountInfoRetriever( |
| 171 profile, gaia::CanonicalizeEmail(gaia::SanitizeEmail(email)), email, | 171 profile, gaia::CanonicalizeEmail(gaia::SanitizeEmail(email)), email, |
| 172 image_side_pixels); | 172 image_side_pixels); |
| 173 retriever->Start(); | 173 retriever->Start(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // static | 176 // static |
| 177 bool ProfileDownloaderAndroid::Register(JNIEnv* env) { | 177 bool ProfileDownloaderAndroid::Register(JNIEnv* env) { |
| 178 return RegisterNativesImpl(env); | 178 return RegisterNativesImpl(env); |
| 179 } | 179 } |
| OLD | NEW |