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/ui/sync/one_click_signin_sync_observer.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/signin/signin_promo.h" | 10 #include "chrome/browser/signin/signin_promo.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // before this task has a chance to run. | 44 // before this task has a chance to run. |
45 base::MessageLoop::current()->PostTask( | 45 base::MessageLoop::current()->PostTask( |
46 FROM_HERE, | 46 FROM_HERE, |
47 base::Bind(&OneClickSigninSyncObserver::DeleteObserver, | 47 base::Bind(&OneClickSigninSyncObserver::DeleteObserver, |
48 weak_ptr_factory_.GetWeakPtr())); | 48 weak_ptr_factory_.GetWeakPtr())); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 OneClickSigninSyncObserver::~OneClickSigninSyncObserver() {} | 52 OneClickSigninSyncObserver::~OneClickSigninSyncObserver() {} |
53 | 53 |
54 void OneClickSigninSyncObserver::WebContentsDestroyed( | 54 void OneClickSigninSyncObserver::WebContentsDestroyed() { |
55 content::WebContents* web_contents) { | 55 ProfileSyncService* sync_service = GetSyncService(web_contents()); |
56 ProfileSyncService* sync_service = GetSyncService(web_contents); | |
57 if (sync_service) | 56 if (sync_service) |
58 sync_service->RemoveObserver(this); | 57 sync_service->RemoveObserver(this); |
59 | 58 |
60 delete this; | 59 delete this; |
61 } | 60 } |
62 | 61 |
63 void OneClickSigninSyncObserver::OnStateChanged() { | 62 void OneClickSigninSyncObserver::OnStateChanged() { |
64 ProfileSyncService* sync_service = GetSyncService(web_contents()); | 63 ProfileSyncService* sync_service = GetSyncService(web_contents()); |
65 | 64 |
66 // At this point, the sign-in process is complete, and control has been handed | 65 // At this point, the sign-in process is complete, and control has been handed |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 109 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
111 return ProfileSyncServiceFactory::GetForProfile(profile); | 110 return ProfileSyncServiceFactory::GetForProfile(profile); |
112 } | 111 } |
113 | 112 |
114 // static | 113 // static |
115 void OneClickSigninSyncObserver::DeleteObserver( | 114 void OneClickSigninSyncObserver::DeleteObserver( |
116 base::WeakPtr<OneClickSigninSyncObserver> observer) { | 115 base::WeakPtr<OneClickSigninSyncObserver> observer) { |
117 if (observer) | 116 if (observer) |
118 delete observer.get(); | 117 delete observer.get(); |
119 } | 118 } |
OLD | NEW |