Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1080)

Unified Diff: webkit/browser/appcache/appcache_update_job.cc

Issue 276093003: appcache content-type check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/browser/appcache/appcache_update_job.h ('k') | webkit/browser/appcache/manifest_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/appcache/appcache_update_job.cc
diff --git a/webkit/browser/appcache/appcache_update_job.cc b/webkit/browser/appcache/appcache_update_job.cc
index 0cd087ec80d6af499eab44dede9ef55bf981988e..6589e3a66e65027ffaffd0af66802f1cb1188014 100644
--- a/webkit/browser/appcache/appcache_update_job.cc
+++ b/webkit/browser/appcache/appcache_update_job.cc
@@ -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:
NotifyHostMap hosts_to_notify;
};
@@ -339,6 +350,7 @@ AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
master_entries_completed_(0),
url_fetches_completed_(0),
manifest_fetcher_(NULL),
+ manifest_has_valid_mime_type_(false),
stored_state_(UNSTORED),
storage_(service->storage()) {
service_->AddObserver(this);
@@ -489,6 +501,10 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted(
if (request->status().is_success()) {
response_code = request->GetResponseCode();
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) {
@@ -561,7 +577,11 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
Manifest manifest;
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 std::string message = base::StringPrintf(kFormatString,
manifest_url_.spec().c_str());
@@ -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);
NotifyAllAssociatedHosts(DOWNLOADING_EVENT);
FetchUrls();
@@ -958,6 +986,12 @@ void AppCacheUpdateJob::NotifyAllError(const ErrorDetails& 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(
HostNotifier* host_notifier) {
// Collect hosts so we only send one notification per frontend.
« no previous file with comments | « webkit/browser/appcache/appcache_update_job.h ('k') | webkit/browser/appcache/manifest_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698