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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 base::Bind(&CloseTab, base::Unretained(web_contents()))); | 75 base::Bind(&CloseTab, base::Unretained(web_contents()))); |
76 } else { | 76 } else { |
77 if (sync_service->FirstSetupInProgress()) { | 77 if (sync_service->FirstSetupInProgress()) { |
78 // Sync setup has not completed yet. Wait for it to complete. | 78 // Sync setup has not completed yet. Wait for it to complete. |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 if (sync_service->sync_initialized() && | 82 if (sync_service->sync_initialized() && |
83 signin::GetSourceForPromoURL(continue_url_) | 83 signin::GetSourceForPromoURL(continue_url_) |
84 != signin::SOURCE_SETTINGS) { | 84 != signin::SOURCE_SETTINGS) { |
85 // TODO(isherman): Redirecting after Sync is set up still has some bugs: | 85 // TODO(isherman): Having multiple settings pages open can cause issues |
86 // http://crbug.com/355885 | 86 // redirecting after Sync is set up: http://crbug.com/355885 |
87 // Having multiple settings pages open can cause issues. | |
88 // http://crbug.com/357901 | |
89 // Selecting anything other than "Sync Everything" when configuring Sync | |
90 // prevents the redirect. | |
91 LoadContinueUrl(); | 87 LoadContinueUrl(); |
92 } | 88 } |
93 } | 89 } |
94 | 90 |
95 sync_service->RemoveObserver(this); | 91 sync_service->RemoveObserver(this); |
96 delete this; | 92 delete this; |
97 } | 93 } |
98 | 94 |
99 void OneClickSigninSyncObserver::LoadContinueUrl() { | 95 void OneClickSigninSyncObserver::LoadContinueUrl() { |
100 web_contents()->GetController().LoadURL( | 96 web_contents()->GetController().LoadURL( |
101 continue_url_, | 97 continue_url_, |
102 content::Referrer(), | 98 content::Referrer(), |
103 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 99 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
104 std::string()); | 100 std::string()); |
105 } | 101 } |
106 | 102 |
107 ProfileSyncService* OneClickSigninSyncObserver::GetSyncService( | 103 ProfileSyncService* OneClickSigninSyncObserver::GetSyncService( |
108 content::WebContents* web_contents) { | 104 content::WebContents* web_contents) { |
109 Profile* profile = | 105 Profile* profile = |
110 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 106 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
111 return ProfileSyncServiceFactory::GetForProfile(profile); | 107 return ProfileSyncServiceFactory::GetForProfile(profile); |
112 } | 108 } |
113 | 109 |
114 // static | 110 // static |
115 void OneClickSigninSyncObserver::DeleteObserver( | 111 void OneClickSigninSyncObserver::DeleteObserver( |
116 base::WeakPtr<OneClickSigninSyncObserver> observer) { | 112 base::WeakPtr<OneClickSigninSyncObserver> observer) { |
117 if (observer) | 113 if (observer) |
118 delete observer.get(); | 114 delete observer.get(); |
119 } | 115 } |
OLD | NEW |