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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_sync_observer.cc

Issue 2824363002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/ui (Closed)
Patch Set: Created 3 years, 8 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 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 29 matching lines...) Expand all
40 if (sync_service) { 40 if (sync_service) {
41 sync_service->AddObserver(this); 41 sync_service->AddObserver(this);
42 } else { 42 } else {
43 LoadContinueUrl(); 43 LoadContinueUrl();
44 // Post a task rather than calling |delete this| here, so that the 44 // Post a task rather than calling |delete this| here, so that the
45 // destructor is not called directly from the constructor. Note that it's 45 // destructor is not called directly from the constructor. Note that it's
46 // important to pass a weak pointer rather than base::Unretained(this) 46 // important to pass a weak pointer rather than base::Unretained(this)
47 // because it's possible for e.g. WebContentsDestroyed() to be called 47 // because it's possible for e.g. WebContentsDestroyed() to be called
48 // before this task has a chance to run. 48 // before this task has a chance to run.
49 base::ThreadTaskRunnerHandle::Get()->PostTask( 49 base::ThreadTaskRunnerHandle::Get()->PostTask(
50 FROM_HERE, base::Bind(&OneClickSigninSyncObserver::DeleteObserver, 50 FROM_HERE, base::BindOnce(&OneClickSigninSyncObserver::DeleteObserver,
51 weak_ptr_factory_.GetWeakPtr())); 51 weak_ptr_factory_.GetWeakPtr()));
52 } 52 }
53 } 53 }
54 54
55 OneClickSigninSyncObserver::~OneClickSigninSyncObserver() {} 55 OneClickSigninSyncObserver::~OneClickSigninSyncObserver() {}
56 56
57 void OneClickSigninSyncObserver::WebContentsDestroyed() { 57 void OneClickSigninSyncObserver::WebContentsDestroyed() {
58 browser_sync::ProfileSyncService* sync_service = 58 browser_sync::ProfileSyncService* sync_service =
59 GetSyncService(web_contents()); 59 GetSyncService(web_contents());
60 if (sync_service) 60 if (sync_service)
61 sync_service->RemoveObserver(this); 61 sync_service->RemoveObserver(this);
62 62
63 delete this; 63 delete this;
64 } 64 }
65 65
66 void OneClickSigninSyncObserver::OnStateChanged(syncer::SyncService* sync) { 66 void OneClickSigninSyncObserver::OnStateChanged(syncer::SyncService* sync) {
67 browser_sync::ProfileSyncService* sync_service = 67 browser_sync::ProfileSyncService* sync_service =
68 GetSyncService(web_contents()); 68 GetSyncService(web_contents());
69 69
70 // At this point, the sign-in process is complete, and control has been handed 70 // At this point, the sign-in process is complete, and control has been handed
71 // back to the sync engine. Close the gaia sign in tab if the |continue_url_| 71 // back to the sync engine. Close the gaia sign in tab if the |continue_url_|
72 // contains the |auto_close| parameter. Otherwise, wait for sync setup to 72 // contains the |auto_close| parameter. Otherwise, wait for sync setup to
73 // complete and then navigate to the |continue_url_|. 73 // complete and then navigate to the |continue_url_|.
74 if (signin::IsAutoCloseEnabledInURL(continue_url_)) { 74 if (signin::IsAutoCloseEnabledInURL(continue_url_)) {
75 // Close the Gaia sign-in tab via a task to make sure we aren't in the 75 // Close the Gaia sign-in tab via a task to make sure we aren't in the
76 // middle of any WebUI handler code. 76 // middle of any WebUI handler code.
77 base::ThreadTaskRunnerHandle::Get()->PostTask( 77 base::ThreadTaskRunnerHandle::Get()->PostTask(
78 FROM_HERE, base::Bind(&CloseTab, base::Unretained(web_contents()))); 78 FROM_HERE, base::BindOnce(&CloseTab, base::Unretained(web_contents())));
79 } else { 79 } else {
80 if (sync_service->IsFirstSetupInProgress()) { 80 if (sync_service->IsFirstSetupInProgress()) {
81 // Sync setup has not completed yet. Wait for it to complete. 81 // Sync setup has not completed yet. Wait for it to complete.
82 return; 82 return;
83 } 83 }
84 84
85 if (sync_service->IsSyncActive() && 85 if (sync_service->IsSyncActive() &&
86 signin::GetAccessPointForPromoURL(continue_url_) != 86 signin::GetAccessPointForPromoURL(continue_url_) !=
87 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS) { 87 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS) {
88 // TODO(isherman): Having multiple settings pages open can cause issues 88 // TODO(isherman): Having multiple settings pages open can cause issues
(...skipping 20 matching lines...) Expand all
109 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 109 Profile::FromBrowserContext(web_contents->GetBrowserContext());
110 return ProfileSyncServiceFactory::GetForProfile(profile); 110 return ProfileSyncServiceFactory::GetForProfile(profile);
111 } 111 }
112 112
113 // static 113 // static
114 void OneClickSigninSyncObserver::DeleteObserver( 114 void OneClickSigninSyncObserver::DeleteObserver(
115 base::WeakPtr<OneClickSigninSyncObserver> observer) { 115 base::WeakPtr<OneClickSigninSyncObserver> observer) {
116 if (observer) 116 if (observer)
117 delete observer.get(); 117 delete observer.get();
118 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator.cc ('k') | chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698