Commit ec06b7d8 authored by rdsmith's avatar rdsmith Committed by Commit bot

Enable SDCH over HTTPS.

BUG=357769
R=mef@chromium.org

Review URL: https://codereview.chromium.org/593863002

Cr-Commit-Position: refs/heads/master@{#296451}
parent d8233279
...@@ -1374,28 +1374,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ...@@ -1374,28 +1374,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
browser_process_->intranet_redirect_detector(); browser_process_->intranet_redirect_detector();
GoogleSearchCounter::RegisterForNotifications(); GoogleSearchCounter::RegisterForNotifications();
if (parsed_command_line().HasSwitch(switches::kEnableSdchOverHttps)) { // Check SDCH field trial. Default is now that everything is enabled,
net::SdchManager::EnableSecureSchemeSupport(true); // so provide options for disabling HTTPS or all of SDCH.
} else { const char kSdchFieldTrialName[] = "SDCH";
// Check SDCH field trial. const char kEnabledHttpOnlyGroupName[] = "EnabledHttpOnly";
const char kSdchFieldTrialName[] = "SDCH"; const char kDisabledAllGroupName[] = "DisabledAll";
const char kEnabledAllGroupName[] = "EnabledAll";
const char kEnabledHttpOnlyGroupName[] = "EnabledHttpOnly"; // Store in a string on return to keep underlying storage for
const char kDisabledAllGroupName[] = "DisabledAll"; // StringPiece stable.
std::string sdch_trial_group_string =
// Store in a string on return to keep underlying storage for base::FieldTrialList::FindFullName(kSdchFieldTrialName);
// StringPiece stable. base::StringPiece sdch_trial_group(sdch_trial_group_string);
std::string sdch_trial_group_string = if (sdch_trial_group.starts_with(kEnabledHttpOnlyGroupName)) {
base::FieldTrialList::FindFullName(kSdchFieldTrialName); net::SdchManager::EnableSdchSupport(true);
base::StringPiece sdch_trial_group(sdch_trial_group_string); net::SdchManager::EnableSecureSchemeSupport(false);
if (sdch_trial_group.starts_with(kEnabledAllGroupName)) { } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) {
net::SdchManager::EnableSecureSchemeSupport(true); net::SdchManager::EnableSdchSupport(false);
net::SdchManager::EnableSdchSupport(true);
} else if (sdch_trial_group.starts_with(kEnabledHttpOnlyGroupName)) {
net::SdchManager::EnableSdchSupport(true);
} else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) {
net::SdchManager::EnableSdchSupport(false);
}
} }
#if defined(ENABLE_FULL_PRINTING) && !defined(OFFICIAL_BUILD) #if defined(ENABLE_FULL_PRINTING) && !defined(OFFICIAL_BUILD)
......
...@@ -54,7 +54,7 @@ const size_t SdchManager::kMaxDictionarySize = 1000 * 1000; ...@@ -54,7 +54,7 @@ const size_t SdchManager::kMaxDictionarySize = 1000 * 1000;
bool SdchManager::g_sdch_enabled_ = true; bool SdchManager::g_sdch_enabled_ = true;
// static // static
bool SdchManager::g_secure_scheme_supported_ = false; bool SdchManager::g_secure_scheme_supported_ = true;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SdchManager::Dictionary::Dictionary(const std::string& dictionary_text, SdchManager::Dictionary::Dictionary(const std::string& dictionary_text,
......
...@@ -24,15 +24,19 @@ static const char kTestVcdiffDictionary[] = "DictionaryFor" ...@@ -24,15 +24,19 @@ static const char kTestVcdiffDictionary[] = "DictionaryFor"
class SdchManagerTest : public testing::Test { class SdchManagerTest : public testing::Test {
protected: protected:
SdchManagerTest() SdchManagerTest()
: sdch_manager_(new SdchManager) { : sdch_manager_(new SdchManager),
default_support_(false),
default_https_support_(false) {
default_support_ = sdch_manager_->sdch_enabled();
default_https_support_ = sdch_manager_->secure_scheme_supported();
} }
SdchManager* sdch_manager() { return sdch_manager_.get(); } SdchManager* sdch_manager() { return sdch_manager_.get(); }
// Reset globals back to default state. // Reset globals back to default state.
virtual void TearDown() { virtual void TearDown() {
SdchManager::EnableSdchSupport(true); SdchManager::EnableSdchSupport(default_support_);
SdchManager::EnableSecureSchemeSupport(false); SdchManager::EnableSecureSchemeSupport(default_https_support_);
} }
// Attempt to add a dictionary to the manager and probe for success or // Attempt to add a dictionary to the manager and probe for success or
...@@ -51,6 +55,8 @@ class SdchManagerTest : public testing::Test { ...@@ -51,6 +55,8 @@ class SdchManagerTest : public testing::Test {
private: private:
scoped_ptr<SdchManager> sdch_manager_; scoped_ptr<SdchManager> sdch_manager_;
bool default_support_;
bool default_https_support_;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -192,6 +198,7 @@ TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) { ...@@ -192,6 +198,7 @@ TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) {
std::string dictionary_domain("x.y.z.google.com"); std::string dictionary_domain("x.y.z.google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain)); std::string dictionary_text(NewSdchDictionary(dictionary_domain));
SdchManager::EnableSecureSchemeSupport(false);
EXPECT_FALSE(AddSdchDictionary(dictionary_text, EXPECT_FALSE(AddSdchDictionary(dictionary_text,
GURL("https://" + dictionary_domain))); GURL("https://" + dictionary_domain)));
SdchManager::EnableSecureSchemeSupport(true); SdchManager::EnableSecureSchemeSupport(true);
...@@ -512,11 +519,11 @@ TEST_F(SdchManagerTest, HttpsCorrectlySupported) { ...@@ -512,11 +519,11 @@ TEST_F(SdchManagerTest, HttpsCorrectlySupported) {
GURL secure_url("https://www.google.com"); GURL secure_url("https://www.google.com");
EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url)); EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url));
EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(secure_url)); EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(secure_url));
SdchManager::EnableSecureSchemeSupport(true); SdchManager::EnableSecureSchemeSupport(false);
EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url)); EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(url));
EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(secure_url)); EXPECT_FALSE(sdch_manager()->IsInSupportedDomain(secure_url));
} }
TEST_F(SdchManagerTest, ClearDictionaryData) { TEST_F(SdchManagerTest, ClearDictionaryData) {
......
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