Commit b993171f authored by michaeln@chromium.org's avatar michaeln@chromium.org

Require a specific content-type for appcache intercepts.

BUG=372634
TESTS=unittests and manual

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270036 0039d316-1c4b-4281-b951-d872f2087c98
parent 3818dd0a
...@@ -23,6 +23,8 @@ using appcache::Manifest; ...@@ -23,6 +23,8 @@ using appcache::Manifest;
using appcache::Namespace; using appcache::Namespace;
using appcache::NamespaceVector; using appcache::NamespaceVector;
using appcache::NETWORK_NAMESPACE; using appcache::NETWORK_NAMESPACE;
using appcache::PARSE_MANIFEST_ALLOWING_INTERCEPTS;
using appcache::PARSE_MANIFEST_PER_STANDARD;
using appcache::Status; using appcache::Status;
namespace content { namespace content {
...@@ -577,8 +579,8 @@ TEST(AppCacheTest, ToFromDatabaseRecords) { ...@@ -577,8 +579,8 @@ TEST(AppCacheTest, ToFromDatabaseRecords) {
new AppCacheGroup(service.storage(), kManifestUrl, kGroupId); new AppCacheGroup(service.storage(), kManifestUrl, kGroupId);
scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
Manifest manifest; Manifest manifest;
EXPECT_TRUE( EXPECT_TRUE(ParseManifest(kManifestUrl, kData.c_str(), kData.length(),
ParseManifest(kManifestUrl, kData.c_str(), kData.length(), manifest)); PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
cache->InitializeWithManifest(&manifest); cache->InitializeWithManifest(&manifest);
EXPECT_EQ(NETWORK_NAMESPACE, cache->online_whitelist_namespaces_[0].type); EXPECT_EQ(NETWORK_NAMESPACE, cache->online_whitelist_namespaces_[0].type);
EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern); EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern);
......
...@@ -13,6 +13,8 @@ using appcache::NamespaceVector; ...@@ -13,6 +13,8 @@ using appcache::NamespaceVector;
using appcache::FALLBACK_NAMESPACE; using appcache::FALLBACK_NAMESPACE;
using appcache::INTERCEPT_NAMESPACE; using appcache::INTERCEPT_NAMESPACE;
using appcache::NETWORK_NAMESPACE; using appcache::NETWORK_NAMESPACE;
using appcache::PARSE_MANIFEST_ALLOWING_INTERCEPTS;
using appcache::PARSE_MANIFEST_PER_STANDARD;
namespace content { namespace content {
...@@ -22,8 +24,10 @@ class AppCacheManifestParserTest : public testing::Test { ...@@ -22,8 +24,10 @@ class AppCacheManifestParserTest : public testing::Test {
TEST(AppCacheManifestParserTest, NoData) { TEST(AppCacheManifestParserTest, NoData) {
GURL url; GURL url;
Manifest manifest; Manifest manifest;
EXPECT_FALSE(ParseManifest(url, "", 0, manifest)); EXPECT_FALSE(ParseManifest(url, "", 0,
EXPECT_FALSE(ParseManifest(url, "CACHE MANIFEST\r", 0, manifest)); // 0 len PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_FALSE(ParseManifest(url, "CACHE MANIFEST\r", 0, // Len is 0.
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
} }
TEST(AppCacheManifestParserTest, CheckSignature) { TEST(AppCacheManifestParserTest, CheckSignature) {
...@@ -43,7 +47,8 @@ TEST(AppCacheManifestParserTest, CheckSignature) { ...@@ -43,7 +47,8 @@ TEST(AppCacheManifestParserTest, CheckSignature) {
for (size_t i = 0; i < arraysize(kBadSignatures); ++i) { for (size_t i = 0; i < arraysize(kBadSignatures); ++i) {
const std::string bad = kBadSignatures[i]; const std::string bad = kBadSignatures[i];
EXPECT_FALSE(ParseManifest(url, bad.c_str(), bad.length(), manifest)); EXPECT_FALSE(ParseManifest(url, bad.c_str(), bad.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
} }
const std::string kGoodSignatures[] = { const std::string kGoodSignatures[] = {
...@@ -60,7 +65,8 @@ TEST(AppCacheManifestParserTest, CheckSignature) { ...@@ -60,7 +65,8 @@ TEST(AppCacheManifestParserTest, CheckSignature) {
for (size_t i = 0; i < arraysize(kGoodSignatures); ++i) { for (size_t i = 0; i < arraysize(kGoodSignatures); ++i) {
const std::string good = kGoodSignatures[i]; const std::string good = kGoodSignatures[i];
EXPECT_TRUE(ParseManifest(url, good.c_str(), good.length(), manifest)); EXPECT_TRUE(ParseManifest(url, good.c_str(), good.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
} }
} }
...@@ -70,7 +76,8 @@ TEST(AppCacheManifestParserTest, NoManifestUrl) { ...@@ -70,7 +76,8 @@ TEST(AppCacheManifestParserTest, NoManifestUrl) {
"relative/tobase.com\r" "relative/tobase.com\r"
"http://absolute.com/addme.com"); "http://absolute.com/addme.com");
const GURL kUrl; const GURL kUrl;
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.explicit_urls.empty()); EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
...@@ -97,7 +104,8 @@ TEST(AppCacheManifestParserTest, ExplicitUrls) { ...@@ -97,7 +104,8 @@ TEST(AppCacheManifestParserTest, ExplicitUrls) {
" \t relative/four#stripme\n\r" " \t relative/four#stripme\n\r"
"*\r"); "*\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all); EXPECT_FALSE(manifest.online_whitelist_all);
...@@ -112,6 +120,24 @@ TEST(AppCacheManifestParserTest, ExplicitUrls) { ...@@ -112,6 +120,24 @@ TEST(AppCacheManifestParserTest, ExplicitUrls) {
// Wildcard is treated as a relative URL in explicit section. // Wildcard is treated as a relative URL in explicit section.
EXPECT_TRUE(urls.find("http://www.foo.com/*") != urls.end()); EXPECT_TRUE(urls.find("http://www.foo.com/*") != urls.end());
// We should get the same results with intercepts disallowed.
manifest = Manifest();
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_PER_STANDARD, manifest));
EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all);
urls = manifest.explicit_urls;
ASSERT_EQ(kExpected, urls.size());
EXPECT_TRUE(urls.find("http://www.foo.com/relative/one") != urls.end());
EXPECT_TRUE(urls.find("http://www.foo.com/two") != urls.end());
EXPECT_TRUE(urls.find("http://www.diff.com/three") != urls.end());
EXPECT_TRUE(urls.find("http://www.foo.com/relative/four") != urls.end());
// Wildcard is treated as a relative URL in explicit section.
EXPECT_TRUE(urls.find("http://www.foo.com/*") != urls.end());
} }
TEST(AppCacheManifestParserTest, WhitelistUrls) { TEST(AppCacheManifestParserTest, WhitelistUrls) {
...@@ -134,7 +160,8 @@ TEST(AppCacheManifestParserTest, WhitelistUrls) { ...@@ -134,7 +160,8 @@ TEST(AppCacheManifestParserTest, WhitelistUrls) {
"http://www.five.com\r\n" "http://www.five.com\r\n"
"*foo\r"); "*foo\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.explicit_urls.empty()); EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.intercept_namespaces.empty()); EXPECT_TRUE(manifest.intercept_namespaces.empty());
...@@ -180,7 +207,8 @@ TEST(AppCacheManifestParserTest, FallbackUrls) { ...@@ -180,7 +207,8 @@ TEST(AppCacheManifestParserTest, FallbackUrls) {
"relative/four#strip relative/fourfb#strip\r" "relative/four#strip relative/fourfb#strip\r"
"http://www.glorp.com/notsame relative/skipped\r"); "http://www.glorp.com/notsame relative/skipped\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.explicit_urls.empty()); EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all); EXPECT_FALSE(manifest.online_whitelist_all);
...@@ -230,7 +258,8 @@ TEST(AppCacheManifestParserTest, FallbackUrlsWithPort) { ...@@ -230,7 +258,8 @@ TEST(AppCacheManifestParserTest, FallbackUrlsWithPort) {
"http://www.portme.com/noport http://www.portme.com:1234/skipped\r" "http://www.portme.com/noport http://www.portme.com:1234/skipped\r"
"http://www.portme.com:1234/skipme http://www.portme.com/noport\r"); "http://www.portme.com:1234/skipme http://www.portme.com/noport\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.explicit_urls.empty()); EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all); EXPECT_FALSE(manifest.online_whitelist_all);
...@@ -272,7 +301,8 @@ TEST(AppCacheManifestParserTest, InterceptUrls) { ...@@ -272,7 +301,8 @@ TEST(AppCacheManifestParserTest, InterceptUrls) {
"http://www.portme.com:1234/skipme return http://www.portme.com/noport\r" "http://www.portme.com:1234/skipme return http://www.portme.com/noport\r"
"relative/wrong/again missing/intercept_type\r"); "relative/wrong/again missing/intercept_type\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.explicit_urls.empty()); EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
...@@ -296,6 +326,16 @@ TEST(AppCacheManifestParserTest, InterceptUrls) { ...@@ -296,6 +326,16 @@ TEST(AppCacheManifestParserTest, InterceptUrls) {
intercepts[2].namespace_url); intercepts[2].namespace_url);
EXPECT_EQ(GURL("http://www.portme.com:1234/int3"), EXPECT_EQ(GURL("http://www.portme.com:1234/int3"),
intercepts[2].target_url); intercepts[2].target_url);
// Disallow intercepts ths time.
manifest = Manifest();
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_PER_STANDARD, manifest));
EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.explicit_urls.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
EXPECT_TRUE(manifest.intercept_namespaces.empty());
EXPECT_FALSE(manifest.online_whitelist_all);
} }
TEST(AppCacheManifestParserTest, ComboUrls) { TEST(AppCacheManifestParserTest, ComboUrls) {
...@@ -320,7 +360,8 @@ TEST(AppCacheManifestParserTest, ComboUrls) { ...@@ -320,7 +360,8 @@ TEST(AppCacheManifestParserTest, ComboUrls) {
"NETWORK:\r\n" "NETWORK:\r\n"
"relative/whitelist-3#strip\r" "relative/whitelist-3#strip\r"
"http://combo.com:99/whitelist-4\r"); "http://combo.com:99/whitelist-4\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.online_whitelist_all); EXPECT_TRUE(manifest.online_whitelist_all);
base::hash_set<std::string> urls = manifest.explicit_urls; base::hash_set<std::string> urls = manifest.explicit_urls;
...@@ -366,8 +407,8 @@ TEST(AppCacheManifestParserTest, UnusualUtf8) { ...@@ -366,8 +407,8 @@ TEST(AppCacheManifestParserTest, UnusualUtf8) {
const std::string kData("CACHE MANIFEST\r" const std::string kData("CACHE MANIFEST\r"
"\xC0" "invalidutf8\r" "\xC0" "invalidutf8\r"
"nonbmp" "\xF1\x84\xAB\xBC\r"); "nonbmp" "\xF1\x84\xAB\xBC\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
base::hash_set<std::string> urls = manifest.explicit_urls; base::hash_set<std::string> urls = manifest.explicit_urls;
EXPECT_TRUE(urls.find("http://bad.com/%EF%BF%BDinvalidutf8") != urls.end()); EXPECT_TRUE(urls.find("http://bad.com/%EF%BF%BDinvalidutf8") != urls.end());
EXPECT_TRUE(urls.find("http://bad.com/nonbmp%F1%84%AB%BC") != urls.end()); EXPECT_TRUE(urls.find("http://bad.com/nonbmp%F1%84%AB%BC") != urls.end());
...@@ -379,7 +420,8 @@ TEST(AppCacheManifestParserTest, IgnoreAfterSpace) { ...@@ -379,7 +420,8 @@ TEST(AppCacheManifestParserTest, IgnoreAfterSpace) {
const std::string kData( const std::string kData(
"CACHE MANIFEST\r" "CACHE MANIFEST\r"
"resource.txt this stuff after the white space should be ignored\r"); "resource.txt this stuff after the white space should be ignored\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
base::hash_set<std::string> urls = manifest.explicit_urls; base::hash_set<std::string> urls = manifest.explicit_urls;
EXPECT_TRUE(urls.find("http://smorg.borg/resource.txt") != urls.end()); EXPECT_TRUE(urls.find("http://smorg.borg/resource.txt") != urls.end());
...@@ -395,7 +437,8 @@ TEST(AppCacheManifestParserTest, DifferentOriginUrlWithSecureScheme) { ...@@ -395,7 +437,8 @@ TEST(AppCacheManifestParserTest, DifferentOriginUrlWithSecureScheme) {
"http://www.xyz.com/secureschemedifforigin\r" "http://www.xyz.com/secureschemedifforigin\r"
"https://www.xyz.com/secureschemedifforigin\r"); "https://www.xyz.com/secureschemedifforigin\r");
EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest)); EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.fallback_namespaces.empty()); EXPECT_TRUE(manifest.fallback_namespaces.empty());
EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
...@@ -433,7 +476,8 @@ TEST(AppCacheManifestParserTest, PatternMatching) { ...@@ -433,7 +476,8 @@ TEST(AppCacheManifestParserTest, PatternMatching) {
Manifest manifest; Manifest manifest;
EXPECT_TRUE(ParseManifest(kUrl, kManifestBody.c_str(), EXPECT_TRUE(ParseManifest(kUrl, kManifestBody.c_str(),
kManifestBody.length(), manifest)); kManifestBody.length(),
PARSE_MANIFEST_ALLOWING_INTERCEPTS, manifest));
EXPECT_TRUE(manifest.online_whitelist_all); EXPECT_TRUE(manifest.online_whitelist_all);
EXPECT_EQ(1u, manifest.explicit_urls.size()); EXPECT_EQ(1u, manifest.explicit_urls.size());
EXPECT_EQ(3u, manifest.intercept_namespaces.size()); EXPECT_EQ(3u, manifest.intercept_namespaces.size());
......
...@@ -85,6 +85,17 @@ class HostNotifier { ...@@ -85,6 +85,17 @@ class HostNotifier {
} }
} }
void SendLogMessage(const std::string& message) {
for (NotifyHostMap::iterator it = hosts_to_notify.begin();
it != hosts_to_notify.end(); ++it) {
AppCacheFrontend* frontend = it->first;
for (HostIds::iterator id = it->second.begin();
id != it->second.end(); ++id) {
frontend->OnLogMessage(*id, LOG_WARNING, message);
}
}
}
private: private:
NotifyHostMap hosts_to_notify; NotifyHostMap hosts_to_notify;
}; };
...@@ -339,6 +350,7 @@ AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service, ...@@ -339,6 +350,7 @@ AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
master_entries_completed_(0), master_entries_completed_(0),
url_fetches_completed_(0), url_fetches_completed_(0),
manifest_fetcher_(NULL), manifest_fetcher_(NULL),
manifest_has_valid_mime_type_(false),
stored_state_(UNSTORED), stored_state_(UNSTORED),
storage_(service->storage()) { storage_(service->storage()) {
service_->AddObserver(this); service_->AddObserver(this);
...@@ -489,6 +501,10 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted( ...@@ -489,6 +501,10 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted(
if (request->status().is_success()) { if (request->status().is_success()) {
response_code = request->GetResponseCode(); response_code = request->GetResponseCode();
is_valid_response_code = (response_code / 100 == 2); is_valid_response_code = (response_code / 100 == 2);
std::string mime_type;
request->GetMimeType(&mime_type);
manifest_has_valid_mime_type_ = (mime_type == "text/cache-manifest");
} }
if (is_valid_response_code) { if (is_valid_response_code) {
...@@ -561,7 +577,11 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) { ...@@ -561,7 +577,11 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
Manifest manifest; Manifest manifest;
if (!ParseManifest(manifest_url_, manifest_data_.data(), if (!ParseManifest(manifest_url_, manifest_data_.data(),
manifest_data_.length(), manifest)) { manifest_data_.length(),
manifest_has_valid_mime_type_ ?
PARSE_MANIFEST_ALLOWING_INTERCEPTS :
PARSE_MANIFEST_PER_STANDARD,
manifest)) {
const char* kFormatString = "Failed to parse manifest %s"; const char* kFormatString = "Failed to parse manifest %s";
const std::string message = base::StringPrintf(kFormatString, const std::string message = base::StringPrintf(kFormatString,
manifest_url_.spec().c_str()); manifest_url_.spec().c_str());
...@@ -591,6 +611,14 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) { ...@@ -591,6 +611,14 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
} }
} }
if (manifest.did_ignore_intercept_namespaces) {
// Must be done after associating all pending master hosts.
std::string message(
"Ignoring the INTERCEPT section of the application cache manifest "
"because the content type is not text/cache-manifest");
LogConsoleMessageToAll(message);
}
group_->SetUpdateStatus(AppCacheGroup::DOWNLOADING); group_->SetUpdateStatus(AppCacheGroup::DOWNLOADING);
NotifyAllAssociatedHosts(DOWNLOADING_EVENT); NotifyAllAssociatedHosts(DOWNLOADING_EVENT);
FetchUrls(); FetchUrls();
...@@ -958,6 +986,12 @@ void AppCacheUpdateJob::NotifyAllError(const ErrorDetails& details) { ...@@ -958,6 +986,12 @@ void AppCacheUpdateJob::NotifyAllError(const ErrorDetails& details) {
host_notifier.SendErrorNotifications(details); host_notifier.SendErrorNotifications(details);
} }
void AppCacheUpdateJob::LogConsoleMessageToAll(const std::string& message) {
HostNotifier host_notifier;
AddAllAssociatedHostsToNotifier(&host_notifier);
host_notifier.SendLogMessage(message);
}
void AppCacheUpdateJob::AddAllAssociatedHostsToNotifier( void AppCacheUpdateJob::AddAllAssociatedHostsToNotifier(
HostNotifier* host_notifier) { HostNotifier* host_notifier) {
// Collect hosts so we only send one notification per frontend. // Collect hosts so we only send one notification per frontend.
......
...@@ -209,6 +209,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob ...@@ -209,6 +209,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void NotifyAllProgress(const GURL& url); void NotifyAllProgress(const GURL& url);
void NotifyAllFinalProgress(); void NotifyAllFinalProgress();
void NotifyAllError(const ErrorDetails& detals); void NotifyAllError(const ErrorDetails& detals);
void LogConsoleMessageToAll(const std::string& message);
void AddAllAssociatedHostsToNotifier(HostNotifier* notifier); void AddAllAssociatedHostsToNotifier(HostNotifier* notifier);
// Checks if manifest is byte for byte identical with the manifest // Checks if manifest is byte for byte identical with the manifest
...@@ -319,6 +320,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob ...@@ -319,6 +320,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
scoped_refptr<net::IOBuffer> read_manifest_buffer_; scoped_refptr<net::IOBuffer> read_manifest_buffer_;
std::string loaded_manifest_data_; std::string loaded_manifest_data_;
scoped_ptr<AppCacheResponseReader> manifest_response_reader_; scoped_ptr<AppCacheResponseReader> manifest_response_reader_;
bool manifest_has_valid_mime_type_;
// New master entries added to the cache by this job, used to cleanup // New master entries added to the cache by this job, used to cleanup
// in error conditions. // in error conditions.
......
...@@ -70,12 +70,15 @@ enum InterceptVerb { ...@@ -70,12 +70,15 @@ enum InterceptVerb {
UNKNOWN_VERB, UNKNOWN_VERB,
}; };
Manifest::Manifest() : online_whitelist_all(false) {} Manifest::Manifest()
: online_whitelist_all(false),
did_ignore_intercept_namespaces(false) {
}
Manifest::~Manifest() {} Manifest::~Manifest() {}
bool ParseManifest(const GURL& manifest_url, const char* data, int length, bool ParseManifest(const GURL& manifest_url, const char* data, int length,
Manifest& manifest) { ParseMode parse_mode, Manifest& manifest) {
// This is an implementation of the parsing algorithm specified in // This is an implementation of the parsing algorithm specified in
// the HTML5 offline web application docs: // the HTML5 offline web application docs:
// http://www.w3.org/TR/html5/offline.html // http://www.w3.org/TR/html5/offline.html
...@@ -92,6 +95,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length, ...@@ -92,6 +95,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
DCHECK(manifest.fallback_namespaces.empty()); DCHECK(manifest.fallback_namespaces.empty());
DCHECK(manifest.online_whitelist_namespaces.empty()); DCHECK(manifest.online_whitelist_namespaces.empty());
DCHECK(!manifest.online_whitelist_all); DCHECK(!manifest.online_whitelist_all);
DCHECK(!manifest.did_ignore_intercept_namespaces);
Mode mode = EXPLICIT; Mode mode = EXPLICIT;
...@@ -218,6 +222,11 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length, ...@@ -218,6 +222,11 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
Namespace(NETWORK_NAMESPACE, url, GURL(), is_pattern)); Namespace(NETWORK_NAMESPACE, url, GURL(), is_pattern));
} }
} else if (mode == INTERCEPT) { } else if (mode == INTERCEPT) {
if (parse_mode != PARSE_MANIFEST_ALLOWING_INTERCEPTS) {
manifest.did_ignore_intercept_namespaces = true;
continue;
}
// Lines of the form, // Lines of the form,
// <urlnamespace> <intercept_type> <targeturl> // <urlnamespace> <intercept_type> <targeturl>
const wchar_t* line_p = line.c_str(); const wchar_t* line_p = line.c_str();
......
...@@ -52,12 +52,20 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT Manifest { ...@@ -52,12 +52,20 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT Manifest {
NamespaceVector fallback_namespaces; NamespaceVector fallback_namespaces;
NamespaceVector online_whitelist_namespaces; NamespaceVector online_whitelist_namespaces;
bool online_whitelist_all; bool online_whitelist_all;
bool did_ignore_intercept_namespaces;
}; };
WEBKIT_STORAGE_BROWSER_EXPORT bool ParseManifest(const GURL& manifest_url, enum ParseMode {
const char* data, PARSE_MANIFEST_PER_STANDARD,
int length, PARSE_MANIFEST_ALLOWING_INTERCEPTS
Manifest& manifest); };
WEBKIT_STORAGE_BROWSER_EXPORT bool ParseManifest(
const GURL& manifest_url,
const char* data,
int length,
ParseMode parse_mode,
Manifest& manifest);
} // namespace appcache } // namespace appcache
......
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