Chromium Code Reviews| Index: chrome/browser/ui/search/search_tab_helper.cc |
| diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc |
| index b117ad020d24c398cc3042ed0019dc3e3e713317..cd435dff683168d95a4bc61e1ba4cdcd73c02a2b 100644 |
| --- a/chrome/browser/ui/search/search_tab_helper.cc |
| +++ b/chrome/browser/ui/search/search_tab_helper.cc |
| @@ -17,6 +17,8 @@ |
| #include "chrome/browser/search/instant_service_factory.h" |
| #include "chrome/browser/search/search.h" |
| #include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/sync/profile_sync_service.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/ui/app_list/app_list_util.h" |
| #include "chrome/browser/ui/browser_navigator.h" |
| #include "chrome/browser/ui/browser_window.h" |
| @@ -120,6 +122,16 @@ void RecordNewTabLoadTime(content::WebContents* contents) { |
| core_tab_helper->set_new_tab_start_time(base::TimeTicks()); |
| } |
| +// Returns true if the user is signed in and full history sync is enabled, |
| +// and false otherwise. |
| +bool IsHistorySyncEnabled(Profile* profile) { |
| + ProfileSyncService* sync = |
| + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| + return sync && |
| + sync->sync_initialized() && |
| + sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES); |
|
Jered
2014/06/17 22:38:19
I don't understand what HISTORY_DELETE_DIRECTIVES
beaudoin
2014/06/18 13:49:04
It's the one used by other pieces of the code that
|
| +} |
| + |
| } // namespace |
| SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) |
| @@ -526,8 +538,11 @@ void SearchTabHelper::OnChromeIdentityCheck(const base::string16& identity) { |
| if (manager) { |
| const base::string16 username = |
| base::UTF8ToUTF16(manager->GetAuthenticatedUsername()); |
| - ipc_router_.SendChromeIdentityCheckResult(identity, |
| - identity == username); |
| + // The identity check only passes if the user is syncing their history. |
| + // TODO(beaudoin): Change this function name and related APIs now that it's |
| + // checking both the identity and the user's sync state. |
| + bool matches = IsHistorySyncEnabled(profile()) && identity == username; |
| + ipc_router_.SendChromeIdentityCheckResult(identity, matches); |
| } |
| } |