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

Unified Diff: content/child/appcache/web_application_cache_host_impl.cc

Issue 164933002: Expose details for appcache error events [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't leak details cross-origin Created 6 years, 9 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
Index: content/child/appcache/web_application_cache_host_impl.cc
diff --git a/content/child/appcache/web_application_cache_host_impl.cc b/content/child/appcache/web_application_cache_host_impl.cc
index 7d5f47b92fca08af60bbb154b968ccd4e6bd9261..fb996eeb30909affce65502b21fe7cf63719353f 100644
--- a/content/child/appcache/web_application_cache_host_impl.cc
+++ b/content/child/appcache/web_application_cache_host_impl.cc
@@ -8,12 +8,14 @@
#include "base/id_map.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
using blink::WebApplicationCacheHost;
using blink::WebApplicationCacheHostClient;
+using blink::WebString;
using blink::WebURLRequest;
using blink::WebURL;
using blink::WebURLResponse;
@@ -133,16 +135,26 @@ void WebApplicationCacheHostImpl::OnProgressEventRaised(
}
void WebApplicationCacheHostImpl::OnErrorEventRaised(
- const std::string& message) {
+ const appcache::ErrorDetails& details) {
// Emit logging output prior to calling out to script as we can get
// deleted within the script event handler.
const char* kFormatString = "Application Cache Error event: %s";
- std::string full_message = base::StringPrintf(kFormatString,
- message.c_str());
+ std::string full_message =
+ base::StringPrintf(kFormatString, details.message.c_str());
OnLogMessage(appcache::LOG_ERROR, full_message);
status_ = cache_info_.is_complete ? appcache::IDLE : appcache::UNCACHED;
- client_->notifyEventListener(static_cast<EventID>(appcache::ERROR_EVENT));
+ if (details.is_cross_origin) {
+ // Don't leak detailed information to script for cross-origin resources.
+ DCHECK_EQ(appcache::RESOURCE_ERROR, details.reason);
+ client_->notifyErrorEventListener(
+ static_cast<ErrorReason>(details.reason), details.url, 0, WebString());
michaeln 2014/03/27 01:05:37 lgtm
+ } else {
+ client_->notifyErrorEventListener(static_cast<ErrorReason>(details.reason),
+ details.url,
+ details.status,
+ WebString::fromUTF8(details.message));
+ }
}
void WebApplicationCacheHostImpl::willStartMainResourceRequest(

Powered by Google App Engine
This is Rietveld 408576698