summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.cc19
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.h7
-rw-r--r--webkit/appcache/appcache_interfaces.cc10
-rw-r--r--webkit/appcache/appcache_interfaces.h1
-rw-r--r--webkit/appcache/web_application_cache_host_impl.cc22
-rw-r--r--webkit/appcache/web_application_cache_host_impl.h4
6 files changed, 52 insertions, 11 deletions
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.cc b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
index 88ffd2c..6a2d6e3 100644
--- a/chrome/renderer/renderer_webapplicationcachehost_impl.cc
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
@@ -7,9 +7,11 @@
#include "chrome/common/content_settings_types.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
using appcache::AppCacheBackend;
using WebKit::WebApplicationCacheHostClient;
+using WebKit::WebConsoleMessage;
RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
RenderView* render_view,
@@ -20,7 +22,17 @@ RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
routing_id_(render_view->routing_id()) {
}
-RendererWebApplicationCacheHostImpl::~RendererWebApplicationCacheHostImpl() {
+void RendererWebApplicationCacheHostImpl::OnLogMessage(
+ appcache::LogLevel log_level, const std::string& message) {
+ RenderView* render_view = GetRenderView();
+ if (!render_view || !render_view->webview() ||
+ !render_view->webview()->mainFrame())
+ return;
+
+ WebKit::WebFrame* frame = render_view->webview()->mainFrame();
+ frame->addMessageToConsole(WebConsoleMessage(
+ static_cast<WebConsoleMessage::Level>(log_level),
+ WebKit::WebString::fromUTF8(message.c_str())));
}
void RendererWebApplicationCacheHostImpl::OnContentBlocked() {
@@ -30,3 +42,8 @@ void RendererWebApplicationCacheHostImpl::OnContentBlocked() {
content_blocked_ = true;
}
}
+
+RenderView* RendererWebApplicationCacheHostImpl::GetRenderView() {
+ return static_cast<RenderView*>
+ (RenderThread::current()->ResolveRoute(routing_id_));
+}
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.h b/chrome/renderer/renderer_webapplicationcachehost_impl.h
index 8a00032..0e4173e 100644
--- a/chrome/renderer/renderer_webapplicationcachehost_impl.h
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.h
@@ -17,14 +17,15 @@ class RendererWebApplicationCacheHostImpl
WebKit::WebApplicationCacheHostClient* client,
appcache::AppCacheBackend* backend);
- virtual ~RendererWebApplicationCacheHostImpl();
-
// appcache::WebApplicationCacheHostImpl methods.
+ virtual void OnLogMessage(appcache::LogLevel log_level,
+ const std::string& message);
virtual void OnContentBlocked();
private:
- bool content_blocked_;
+ RenderView* GetRenderView();
+ bool content_blocked_;
int routing_id_;
};
diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc
index b70cadf..a818bb9 100644
--- a/webkit/appcache/appcache_interfaces.cc
+++ b/webkit/appcache/appcache_interfaces.cc
@@ -7,8 +7,10 @@
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"
#include "third_party/WebKit/WebKit/chromium/public/WebApplicationCacheHost.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h"
using WebKit::WebApplicationCacheHost;
+using WebKit::WebConsoleMessage;
namespace appcache {
@@ -74,5 +76,13 @@ COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent ==
(int)CACHED_EVENT, CachedEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent ==
(int)OBSOLETE_EVENT, ObsoleteEvent);
+COMPILE_ASSERT((int)WebConsoleMessage::LevelTip ==
+ (int)LOG_TIP, LevelTip);
+COMPILE_ASSERT((int)WebConsoleMessage::LevelLog ==
+ (int)LOG_INFO, LevelLog);
+COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning ==
+ (int)LOG_WARNING, LevelWarning);
+COMPILE_ASSERT((int)WebConsoleMessage::LevelError ==
+ (int)LOG_ERROR, LevelError);
} // namespace
diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h
index a57ba67..b2a954e 100644
--- a/webkit/appcache/appcache_interfaces.h
+++ b/webkit/appcache/appcache_interfaces.h
@@ -45,6 +45,7 @@ enum EventID {
};
enum LogLevel {
+ LOG_TIP,
LOG_INFO,
LOG_WARNING,
LOG_ERROR,
diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc
index 0f1258d..15ef1db 100644
--- a/webkit/appcache/web_application_cache_host_impl.cc
+++ b/webkit/appcache/web_application_cache_host_impl.cc
@@ -92,12 +92,6 @@ void WebApplicationCacheHostImpl::OnProgressEventRaised(
client_->notifyEventListener(WebApplicationCacheHost::ProgressEvent);
}
-void WebApplicationCacheHostImpl::OnLogMessage(
- LogLevel log_level, const std::string& message) {
- // TODO(michaeln): Widen the webkit api with this addition.
- // client_->notifyLogMessage(log_level, message);
-}
-
void WebApplicationCacheHostImpl::willStartMainResourceRequest(
WebURLRequest& request) {
request.setAppCacheHostID(host_id_);
@@ -112,6 +106,9 @@ void WebApplicationCacheHostImpl::willStartSubResourceRequest(
}
void WebApplicationCacheHostImpl::selectCacheWithoutManifest() {
+ if (document_response_.appCacheID() != kNoCacheId)
+ LogLoadedFromCacheMessage();
+
// Reset any previous status values we've received from the backend
// since we're now selecting a new cache.
has_status_ = false;
@@ -124,6 +121,9 @@ void WebApplicationCacheHostImpl::selectCacheWithoutManifest() {
bool WebApplicationCacheHostImpl::selectCacheWithManifest(
const WebURL& manifest_url) {
+ if (document_response_.appCacheID() != kNoCacheId)
+ LogLoadedFromCacheMessage();
+
// Reset any previous status values we've received from the backend
// since we're now selecting a new cache.
has_status_ = false;
@@ -237,4 +237,14 @@ bool WebApplicationCacheHostImpl::swapCache() {
return backend_->SwapCache(host_id_);
}
+void WebApplicationCacheHostImpl::LogLoadedFromCacheMessage() {
+ DCHECK(!document_response_.appCacheManifestURL().isEmpty());
+ GURL manifest_url = document_response_.appCacheManifestURL();
+ std::string message = StringPrintf(
+ "Document %s was loaded from appcache %s",
+ document_url_.spec().c_str(),
+ manifest_url.spec().c_str());
+ OnLogMessage(LOG_INFO, message);
+}
+
} // appcache namespace
diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h
index 6f19b0d..9990c2c 100644
--- a/webkit/appcache/web_application_cache_host_impl.h
+++ b/webkit/appcache/web_application_cache_host_impl.h
@@ -36,7 +36,7 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
void OnStatusChanged(appcache::Status);
void OnEventRaised(appcache::EventID);
void OnProgressEventRaised(const GURL& url, int num_total, int num_complete);
- void OnLogMessage(LogLevel log_level, const std::string& message);
+ virtual void OnLogMessage(LogLevel log_level, const std::string& message) {}
virtual void OnContentBlocked() {}
// WebApplicationCacheHost methods
@@ -58,6 +58,8 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
NO
};
+ void LogLoadedFromCacheMessage();
+
WebKit::WebApplicationCacheHostClient* client_;
AppCacheBackend* backend_;
int host_id_;