1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
7 #include "content/common/view_messages.h"
8 #include "content/renderer/render_thread_impl.h"
9 #include "content/renderer/render_view_impl.h"
10 #include "third_party/WebKit/public/web/WebFrame.h"
11 #include "third_party/WebKit/public/web/WebView.h"
13 using blink::WebApplicationCacheHostClient
;
14 using blink::WebConsoleMessage
;
18 RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
19 RenderViewImpl
* render_view
,
20 WebApplicationCacheHostClient
* client
,
21 AppCacheBackend
* backend
)
22 : WebApplicationCacheHostImpl(client
, backend
),
23 routing_id_(render_view
->routing_id()) {
26 void RendererWebApplicationCacheHostImpl::OnLogMessage(
27 AppCacheLogLevel log_level
, const std::string
& message
) {
28 if (RenderThreadImpl::current()->layout_test_mode())
31 RenderViewImpl
* render_view
= GetRenderView();
32 if (!render_view
|| !render_view
->webview() ||
33 !render_view
->webview()->mainFrame())
36 blink::WebFrame
* frame
= render_view
->webview()->mainFrame();
37 frame
->addMessageToConsole(WebConsoleMessage(
38 static_cast<WebConsoleMessage::Level
>(log_level
),
39 blink::WebString::fromUTF8(message
.c_str())));
42 void RendererWebApplicationCacheHostImpl::OnContentBlocked(
43 const GURL
& manifest_url
) {
44 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed(
45 routing_id_
, manifest_url
, true));
48 void RendererWebApplicationCacheHostImpl::OnCacheSelected(
49 const AppCacheInfo
& info
) {
50 if (!info
.manifest_url
.is_empty()) {
51 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed(
52 routing_id_
, info
.manifest_url
, false));
54 WebApplicationCacheHostImpl::OnCacheSelected(info
);
57 RenderViewImpl
* RendererWebApplicationCacheHostImpl::GetRenderView() {
58 return RenderViewImpl::FromRoutingID(routing_id_
);
61 } // namespace content