summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortreib <treib@chromium.org>2016-03-21 07:43:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-21 14:45:04 +0000
commitd0e42b4255f3fcda9ae5180b855e2b745a9763b1 (patch)
treee01d1b959198dcc9c99467b3f0de1f7e9d1d8415
parent0869819900ada55ac050c31400665679b01fc8e5 (diff)
downloadchromium_src-d0e42b4255f3fcda9ae5180b855e2b745a9763b1.zip
chromium_src-d0e42b4255f3fcda9ae5180b855e2b745a9763b1.tar.gz
chromium_src-d0e42b4255f3fcda9ae5180b855e2b745a9763b1.tar.bz2
SuggestionsService: remove checks for launched UseOAuth2 feature
BUG=555443 Review URL: https://codereview.chromium.org/1760263004 Cr-Commit-Position: refs/heads/master@{#382285}
-rw-r--r--components/suggestions/suggestions_service.cc37
-rw-r--r--components/suggestions/suggestions_service.h5
-rw-r--r--components/suggestions/suggestions_service_unittest.cc12
3 files changed, 11 insertions, 43 deletions
diff --git a/components/suggestions/suggestions_service.cc b/components/suggestions/suggestions_service.cc
index 5293228..9ebb635 100644
--- a/components/suggestions/suggestions_service.cc
+++ b/components/suggestions/suggestions_service.cc
@@ -137,10 +137,6 @@ const char kPingURL[] =
// The default expiry timeout is 168 hours.
const int64_t kDefaultExpiryUsec = 168 * base::Time::kMicrosecondsPerHour;
-const base::Feature kOAuth2AuthenticationFeature {
- "SuggestionsServiceOAuth2", base::FEATURE_ENABLED_BY_DEFAULT
-};
-
} // namespace
// Helper class for fetching OAuth2 access tokens.
@@ -326,11 +322,6 @@ void SuggestionsService::RegisterProfilePrefs(
}
// static
-bool SuggestionsService::UseOAuth2() {
- return base::FeatureList::IsEnabled(kOAuth2AuthenticationFeature);
-}
-
-// static
GURL SuggestionsService::BuildSuggestionsURL() {
return GURL(base::StringPrintf(kSuggestionsURLFormat,
GetGoogleBaseURL().spec().c_str(),
@@ -395,24 +386,19 @@ void SuggestionsService::IssueRequestIfNoneOngoing(const GURL& url) {
if (pending_request_.get()) {
return;
}
- if (UseOAuth2()) {
- // If there is an ongoing token request, also wait for that.
- if (token_fetcher_->HasPendingRequest()) {
- return;
- }
- token_fetcher_->GetAccessToken(
- base::Bind(&SuggestionsService::IssueSuggestionsRequest,
- base::Unretained(this), url));
- } else {
- // No access token required.
- IssueSuggestionsRequest(url, std::string());
+ // If there is an ongoing token request, also wait for that.
+ if (token_fetcher_->HasPendingRequest()) {
+ return;
}
+ token_fetcher_->GetAccessToken(
+ base::Bind(&SuggestionsService::IssueSuggestionsRequest,
+ base::Unretained(this), url));
}
void SuggestionsService::IssueSuggestionsRequest(
const GURL& url,
const std::string& access_token) {
- if (UseOAuth2() && access_token.empty()) {
+ if (access_token.empty()) {
UpdateBlacklistDelay(false);
ScheduleBlacklistUpload();
return;
@@ -428,10 +414,9 @@ scoped_ptr<net::URLFetcher> SuggestionsService::CreateSuggestionsRequest(
net::URLFetcher::Create(0, url, net::URLFetcher::GET, this);
data_use_measurement::DataUseUserData::AttachToFetcher(
request.get(), data_use_measurement::DataUseUserData::SUGGESTIONS);
- int load_flags = net::LOAD_DISABLE_CACHE;
- if (UseOAuth2()) {
- load_flags |= net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES;
- }
+ int load_flags = net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SEND_COOKIES |
+ net::LOAD_DO_NOT_SAVE_COOKIES;
+
request->SetLoadFlags(load_flags);
request->SetRequestContext(url_request_context_);
// Add Chrome experiment state to the request headers.
@@ -439,7 +424,7 @@ scoped_ptr<net::URLFetcher> SuggestionsService::CreateSuggestionsRequest(
variations::AppendVariationHeaders(request->GetOriginalURL(), false, false,
&headers);
request->SetExtraRequestHeaders(headers.ToString());
- if (UseOAuth2() && !access_token.empty()) {
+ if (!access_token.empty()) {
request->AddExtraRequestHeader(
base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str()));
}
diff --git a/components/suggestions/suggestions_service.h b/components/suggestions/suggestions_service.h
index 49d2052..3532492 100644
--- a/components/suggestions/suggestions_service.h
+++ b/components/suggestions/suggestions_service.h
@@ -122,15 +122,10 @@ class SuggestionsService : public KeyedService,
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLRequestFails);
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, ClearBlacklist);
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UndoBlacklistURL);
- FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UndoBlacklistURLFailsHelper);
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, GetBlacklistedUrl);
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay);
FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, CheckDefaultTimeStamps);
- // Returns whether OAuth2 authentication is enabled. If false, cookies are
- // used for authentication.
- static bool UseOAuth2();
-
// Helpers to build the various suggestions URLs. These are static members
// rather than local functions in the .cc file to make them accessible to
// tests.
diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc
index 7398bda..01a9093 100644
--- a/components/suggestions/suggestions_service_unittest.cc
+++ b/components/suggestions/suggestions_service_unittest.cc
@@ -210,16 +210,6 @@ class SuggestionsServiceTest : public testing::Test {
~SuggestionsServiceTest() override {}
- void SetOAuth2FeatureEnabled(bool enabled) {
- base::FeatureList::ClearInstanceForTesting();
- scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
- if (enabled) {
- feature_list->InitializeFromCommandLine(
- "SuggestionsServiceOAuth2", std::string());
- }
- base::FeatureList::SetInstance(std::move(feature_list));
- }
-
void SetUp() override {
request_context_ =
new net::TestURLRequestContextGetter(io_message_loop_.task_runner());
@@ -413,8 +403,6 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncDisabled) {
}
TEST_F(SuggestionsServiceTest, FetchSuggestionsDataNoAccessToken) {
- SetOAuth2FeatureEnabled(true);
-
token_service_.RevokeCredentials(kAccountId);
scoped_ptr<SuggestionsService> suggestions_service(