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