| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "chrome/browser/android/signin/signin_manager_android.h" | 7 #include "chrome/browser/android/signin/signin_manager_android.h" |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/message_loop/message_loop_proxy.h" | 15 #include "base/message_loop/message_loop_proxy.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/thread_task_runner_handle.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 18 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/signin/account_tracker_service_factory.h" | 24 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 23 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" | 25 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" |
| 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 using bookmarks::BookmarkModel; | 50 using bookmarks::BookmarkModel; |
| 49 | 51 |
| 50 namespace { | 52 namespace { |
| 51 | 53 |
| 52 // A BrowsingDataRemover::Observer that clears all Profile data and then | 54 // A BrowsingDataRemover::Observer that clears all Profile data and then |
| 53 // invokes a callback and deletes itself. | 55 // invokes a callback and deletes itself. |
| 54 class ProfileDataRemover : public BrowsingDataRemover::Observer { | 56 class ProfileDataRemover : public BrowsingDataRemover::Observer { |
| 55 public: | 57 public: |
| 56 ProfileDataRemover(Profile* profile, const base::Closure& callback) | 58 ProfileDataRemover(Profile* profile, const base::Closure& callback) |
| 57 : callback_(callback), | 59 : callback_(callback), |
| 58 origin_loop_(base::MessageLoopProxy::current()), | 60 origin_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 59 remover_(BrowsingDataRemover::CreateForUnboundedRange(profile)) { | 61 remover_(BrowsingDataRemover::CreateForUnboundedRange(profile)) { |
| 60 remover_->AddObserver(this); | 62 remover_->AddObserver(this); |
| 61 remover_->Remove(BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL); | 63 remover_->Remove(BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL); |
| 62 } | 64 } |
| 63 | 65 |
| 64 ~ProfileDataRemover() override {} | 66 ~ProfileDataRemover() override {} |
| 65 | 67 |
| 66 void OnBrowsingDataRemoverDone() override { | 68 void OnBrowsingDataRemoverDone() override { |
| 67 remover_->RemoveObserver(this); | 69 remover_->RemoveObserver(this); |
| 68 origin_loop_->PostTask(FROM_HERE, callback_); | 70 origin_runner_->PostTask(FROM_HERE, callback_); |
| 69 origin_loop_->DeleteSoon(FROM_HERE, this); | 71 origin_runner_->DeleteSoon(FROM_HERE, this); |
| 70 } | 72 } |
| 71 | 73 |
| 72 private: | 74 private: |
| 73 base::Closure callback_; | 75 base::Closure callback_; |
| 74 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 76 scoped_refptr<base::SingleThreadTaskRunner> origin_runner_; |
| 75 BrowsingDataRemover* remover_; | 77 BrowsingDataRemover* remover_; |
| 76 | 78 |
| 77 DISALLOW_COPY_AND_ASSIGN(ProfileDataRemover); | 79 DISALLOW_COPY_AND_ASSIGN(ProfileDataRemover); |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 } // namespace | 82 } // namespace |
| 81 | 83 |
| 82 SigninManagerAndroid::SigninManagerAndroid(JNIEnv* env, jobject obj) | 84 SigninManagerAndroid::SigninManagerAndroid(JNIEnv* env, jobject obj) |
| 83 : profile_(NULL), | 85 : profile_(NULL), |
| 84 weak_factory_(this) { | 86 weak_factory_(this) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); | 304 return !policy::BrowserPolicyConnector::IsNonEnterpriseUser(username); |
| 303 #else | 305 #else |
| 304 return false; | 306 return false; |
| 305 #endif | 307 #endif |
| 306 } | 308 } |
| 307 | 309 |
| 308 // static | 310 // static |
| 309 bool SigninManagerAndroid::Register(JNIEnv* env) { | 311 bool SigninManagerAndroid::Register(JNIEnv* env) { |
| 310 return RegisterNativesImpl(env); | 312 return RegisterNativesImpl(env); |
| 311 } | 313 } |
| OLD | NEW |