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

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 336413006: Chrome suggestions are no longer served if the user doesn't sync his history on a given machine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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);
}
}
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | chrome/browser/ui/search/search_tab_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698