Commit 8e96399b authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Revert "Add timestamp to requests for experimental contextual suggestions."

This reverts commit e76e0e99.

Reason for revert: I suspect it caused recent Windows MSVC build failures (https://luci-milo.appspot.com/buildbot/chromium.win/WinMSVC64%20%28dbg%29/2260. The problematic file is chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc.

Original change's description:
> Add timestamp to requests for experimental contextual suggestions.
> 
> The experimental contextual suggestions service provides 0-suggest
> autocomplete suggestions based on the URL that is visited in the active
> tab, at the time the address bar is focused. This CL adds to the request
> a timestamp corresponding to the time the user started navigating the
> URL for which the suggestions are requested.
> 
> This change is a requirement for the process of enabling server-side
> logging of the contextual suggestions that are sent to Chrome clients.
> If logged, contextual suggestions are to be removed as soon as a
> synced user removes from their history the page that was visited at the
> time the suggestions were displayed. The timestamp is necessary for
> matching suggestions with the corresponding navigation.
> 
> TBR=rohitrao
> for mechanical changes to ios/c/b/a/*
> 
> Bug: 692471
> Change-Id: I6939d108cfab91b69640acdbb3b8307687999320
> Reviewed-on: https://chromium-review.googlesource.com/879167
> Commit-Queue: Gheorghe Comanici <gcomanici@chromium.org>
> Reviewed-by: Mark Pearson <mpearson@chromium.org>
> Reviewed-by: Rohit Rao <rohitrao@chromium.org>
> Reviewed-by: Justin Donnelly <jdonnelly@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#531999}

TBR=rohitrao@chromium.org,mpearson@chromium.org,jdonnelly@chromium.org,gcomanici@chromium.org

Change-Id: Ie588cd5849a59c845b51c9ca334b32bef4a61037
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 692471
Reviewed-on: https://chromium-review.googlesource.com/889142Reviewed-by: default avatarAdithya Srinivasan <adithyas@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532043}
parent f4e2d638
......@@ -37,7 +37,6 @@
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync/driver/sync_service_utils.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
......@@ -226,29 +225,6 @@ ChromeAutocompleteProviderClient::GetBuiltinsToProvideAsUserTypes() {
return builtins_to_provide;
}
base::Time ChromeAutocompleteProviderClient::GetCurrentVisitTimestamp() const {
// The timestamp is currenly used only for contextual zero suggest suggestions
// on desktop. Consider updating this if this will be used for mobile services.
#if !defined(OS_ANDROID)
const Browser* active_browser = BrowserList::GetInstance()->GetLastActive();
if (!active_browser)
return base::Time();
const content::WebContents* active_tab =
active_browser->tab_strip_model()->GetActiveWebContents();
if (!active_tab)
return base::Time();
const content::NavigationEntry* navigation =
active_tab->GetController().GetLastCommittedEntry();
if (!navigation)
return base::Time();
return navigation->GetTimestamp();
#endif // !defined(OS_ANDROID)
return base::Time();
}
bool ChromeAutocompleteProviderClient::IsOffTheRecord() const {
return profile_->IsOffTheRecord();
}
......
......@@ -45,9 +45,6 @@ class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
std::string GetEmbedderRepresentationOfAboutScheme() override;
std::vector<base::string16> GetBuiltinURLs() override;
std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override;
// GetCurrentVisitTimestamp is only implemented for desktop users. For mobile
// users, the function returns base::Time().
base::Time GetCurrentVisitTimestamp() const override;
bool IsOffTheRecord() const override;
bool SearchSuggestEnabled() const override;
bool TabSyncEnabledAndUnencrypted() const override;
......
......@@ -170,7 +170,6 @@ static_library("browser") {
"//components/sessions",
"//components/signin/core/browser",
"//components/strings",
"//components/sync",
"//components/toolbar",
"//components/url_formatter",
"//components/variations",
......
......@@ -16,7 +16,6 @@ include_rules = [
"+components/search",
"+components/search_engines",
"+components/sessions",
"+components/sync",
"+components/signin/core/browser",
"+components/strings/grit/components_strings.h",
"+components/toolbar",
......
......@@ -92,10 +92,6 @@ class AutocompleteProviderClient {
// most commonly-used URLs from that set.
virtual std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() = 0;
// The timestamp for the last visit of the page being displayed in the current
// tab.
virtual base::Time GetCurrentVisitTimestamp() const = 0;
virtual bool IsOffTheRecord() const = 0;
virtual bool SearchSuggestEnabled() const = 0;
......
......@@ -15,7 +15,6 @@
#include "components/data_use_measurement/core/data_use_user_data.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/search_engines/template_url_service.h"
#include "components/sync/base/time.h"
#include "components/variations/net/variations_http_headers.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
......@@ -57,22 +56,18 @@ void AddVariationHeaders(const std::unique_ptr<net::URLFetcher>& fetcher) {
//
// urls: {
// url : <current_url>
// // timestamp_usec is the timestamp for the page visit time.
// timestamp_usec: <visit_time>
// }
// // stream_type = 1 corresponds to zero suggest suggestions.
// stream_type: 1
// // experiment_id is only set when <experiment_id> is well defined.
// experiment_id: <experiment_id>
//
std::string FormatRequestBodyExperimentalService(const std::string& current_url,
const base::Time& visit_time) {
std::string FormatRequestBodyExperimentalService(
const std::string& current_url) {
auto request = std::make_unique<base::DictionaryValue>();
auto url_list = std::make_unique<base::ListValue>();
auto url_entry = std::make_unique<base::DictionaryValue>();
url_entry->SetString("url", current_url);
url_entry->SetString("timestamp_usec",
std::to_string(syncer::TimeToProtoTime(visit_time)));
url_list->Append(std::move(url_entry));
request->Set("urls", std::move(url_list));
// stream_type = 1 corresponds to zero suggest suggestions.
......@@ -101,14 +96,13 @@ ContextualSuggestionsService::~ContextualSuggestionsService() {}
void ContextualSuggestionsService::CreateContextualSuggestionsRequest(
const std::string& current_url,
const base::Time& visit_time,
const TemplateURLService* template_url_service,
net::URLFetcherDelegate* fetcher_delegate,
ContextualSuggestionsCallback callback) {
const GURL experimental_suggest_url =
ExperimentalContextualSuggestionsUrl(current_url, template_url_service);
if (experimental_suggest_url.is_valid())
CreateExperimentalRequest(current_url, visit_time, experimental_suggest_url,
CreateExperimentalRequest(current_url, experimental_suggest_url,
fetcher_delegate, std::move(callback));
else
CreateDefaultRequest(current_url, template_url_service, fetcher_delegate,
......@@ -240,7 +234,6 @@ void ContextualSuggestionsService::CreateDefaultRequest(
void ContextualSuggestionsService::CreateExperimentalRequest(
const std::string& current_url,
const base::Time& visit_time,
const GURL& suggest_url,
net::URLFetcherDelegate* fetcher_delegate,
ContextualSuggestionsCallback callback) {
......@@ -279,8 +272,7 @@ void ContextualSuggestionsService::CreateExperimentalRequest(
}
})");
const int kFetcherID = 1;
std::string request_body =
FormatRequestBodyExperimentalService(current_url, visit_time);
std::string request_body = FormatRequestBodyExperimentalService(current_url);
std::unique_ptr<net::URLFetcher> fetcher =
net::URLFetcher::Create(kFetcherID, suggest_url,
/*request_type=*/net::URLFetcher::POST,
......
......@@ -39,9 +39,6 @@ class ContextualSuggestionsService : public KeyedService {
// experimental suggestions service. It's possible the non-experimental
// service may decide to offer general-purpose suggestions.
//
// |visit_time| is the time of the visit for the URL for which suggestions
// should be fetched.
//
// |template_url_service| may be null, but some services may be disabled.
//
// |fetcher_delegate| is used to create a fetcher that is used to perform a
......@@ -58,7 +55,6 @@ class ContextualSuggestionsService : public KeyedService {
// instantiates |token_fetcher_|.
void CreateContextualSuggestionsRequest(
const std::string& current_url,
const base::Time& visit_time,
const TemplateURLService* template_url_service,
net::URLFetcherDelegate* fetcher_delegate,
ContextualSuggestionsCallback callback);
......@@ -116,7 +112,6 @@ class ContextualSuggestionsService : public KeyedService {
// This function is called by CreateContextualSuggestionsRequest. See its
// function definition for details on the parameters.
void CreateExperimentalRequest(const std::string& current_url,
const base::Time& visit_time,
const GURL& suggest_url,
net::URLFetcherDelegate* fetcher_delegate,
ContextualSuggestionsCallback callback);
......
......@@ -72,7 +72,6 @@ class MockAutocompleteProviderClient : public AutocompleteProviderClient {
MOCK_METHOD0(GetEmbedderRepresentationOfAboutScheme, std::string());
MOCK_METHOD0(GetBuiltinURLs, std::vector<base::string16>());
MOCK_METHOD0(GetBuiltinsToProvideAsUserTypes, std::vector<base::string16>());
MOCK_CONST_METHOD0(GetCurrentVisitTimestamp, base::Time());
MOCK_CONST_METHOD0(IsOffTheRecord, bool());
MOCK_CONST_METHOD0(SearchSuggestEnabled, bool());
MOCK_CONST_METHOD0(TabSyncEnabledAndUnencrypted, bool());
......
......@@ -182,8 +182,7 @@ void ZeroSuggestProvider::Start(const AutocompleteInput& input,
client()
->GetContextualSuggestionsService(/*create_if_necessary=*/true)
->CreateContextualSuggestionsRequest(
current_url, client()->GetCurrentVisitTimestamp(),
client()->GetTemplateURLService(),
current_url, client()->GetTemplateURLService(),
/*fetcher_delegate=*/this,
base::BindOnce(
&ZeroSuggestProvider::OnContextualSuggestionsFetcherAvailable,
......
......@@ -144,10 +144,6 @@ AutocompleteProviderClientImpl::GetBuiltinsToProvideAsUserTypes() {
base::ASCIIToUTF16(kChromeUIVersionURL)};
}
base::Time AutocompleteProviderClientImpl::GetCurrentVisitTimestamp() const {
return base::Time();
}
bool AutocompleteProviderClientImpl::IsOffTheRecord() const {
return browser_state_->IsOffTheRecord();
}
......
......@@ -46,9 +46,6 @@ class AutocompleteProviderClientImpl : public AutocompleteProviderClient {
std::string GetEmbedderRepresentationOfAboutScheme() override;
std::vector<base::string16> GetBuiltinURLs() override;
std::vector<base::string16> GetBuiltinsToProvideAsUserTypes() override;
// GetCurrentVisitTimestamp is only used by the contextual zero suggest
// suggestions for desktop users. This implementation returns base::Time().
base::Time GetCurrentVisitTimestamp() const override;
bool IsOffTheRecord() const override;
bool SearchSuggestEnabled() const override;
bool TabSyncEnabledAndUnencrypted() const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment