blob: 42aae612c26b82df2ba9c165e8c4e9730891d14f [file] [log] [blame]
[email protected]629ddf852012-07-20 16:17:291// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]035545f2010-04-09 13:10:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]acb94722011-03-18 01:33:345#include "content/renderer/renderer_webapplicationcachehost_impl.h"
[email protected]035545f2010-04-09 13:10:216
[email protected]0aed2f52011-03-23 18:06:367#include "content/common/view_messages.h"
[email protected]f1a29a02011-10-06 23:08:448#include "content/renderer/render_thread_impl.h"
[email protected]310ebd6302011-10-10 19:06:289#include "content/renderer/render_view_impl.h"
[email protected]2255a9332013-06-17 05:12:3110#include "third_party/WebKit/public/web/WebFrame.h"
11#include "third_party/WebKit/public/web/WebView.h"
[email protected]035545f2010-04-09 13:10:2112
[email protected]180ef242013-11-07 06:50:4613using blink::WebApplicationCacheHostClient;
14using blink::WebConsoleMessage;
[email protected]035545f2010-04-09 13:10:2115
[email protected]e9ff79c2012-10-19 21:31:2616namespace content {
17
[email protected]035545f2010-04-09 13:10:2118RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
[email protected]310ebd6302011-10-10 19:06:2819 RenderViewImpl* render_view,
[email protected]035545f2010-04-09 13:10:2120 WebApplicationCacheHostClient* client,
21 AppCacheBackend* backend)
22 : WebApplicationCacheHostImpl(client, backend),
[email protected]035545f2010-04-09 13:10:2123 routing_id_(render_view->routing_id()) {
24}
25
[email protected]df4cd152010-06-25 00:46:0226void RendererWebApplicationCacheHostImpl::OnLogMessage(
[email protected]98d6d4562014-06-25 20:57:5527 AppCacheLogLevel log_level, const std::string& message) {
[email protected]70dee7e2013-05-29 18:28:3028 if (RenderThreadImpl::current()->layout_test_mode())
[email protected]04dd7122012-12-12 23:13:5929 return;
30
[email protected]310ebd6302011-10-10 19:06:2831 RenderViewImpl* render_view = GetRenderView();
[email protected]df4cd152010-06-25 00:46:0232 if (!render_view || !render_view->webview() ||
33 !render_view->webview()->mainFrame())
34 return;
35
[email protected]180ef242013-11-07 06:50:4636 blink::WebFrame* frame = render_view->webview()->mainFrame();
[email protected]df4cd152010-06-25 00:46:0237 frame->addMessageToConsole(WebConsoleMessage(
38 static_cast<WebConsoleMessage::Level>(log_level),
[email protected]180ef242013-11-07 06:50:4639 blink::WebString::fromUTF8(message.c_str())));
[email protected]035545f2010-04-09 13:10:2140}
41
[email protected]5c7d5982010-07-12 09:12:5942void RendererWebApplicationCacheHostImpl::OnContentBlocked(
43 const GURL& manifest_url) {
[email protected]f1a29a02011-10-06 23:08:4444 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed(
[email protected]5c7d5982010-07-12 09:12:5945 routing_id_, manifest_url, true));
46}
47
48void RendererWebApplicationCacheHostImpl::OnCacheSelected(
[email protected]98d6d4562014-06-25 20:57:5549 const AppCacheInfo& info) {
[email protected]5fd77382010-08-04 20:00:3450 if (!info.manifest_url.is_empty()) {
[email protected]f1a29a02011-10-06 23:08:4451 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed(
[email protected]5fd77382010-08-04 20:00:3452 routing_id_, info.manifest_url, false));
53 }
[email protected]ec5c1922010-07-28 03:14:3754 WebApplicationCacheHostImpl::OnCacheSelected(info);
[email protected]035545f2010-04-09 13:10:2155}
[email protected]df4cd152010-06-25 00:46:0256
[email protected]310ebd6302011-10-10 19:06:2857RenderViewImpl* RendererWebApplicationCacheHostImpl::GetRenderView() {
[email protected]bae061f72013-04-26 16:22:2958 return RenderViewImpl::FromRoutingID(routing_id_);
[email protected]df4cd152010-06-25 00:46:0259}
[email protected]e9ff79c2012-10-19 21:31:2660
61} // namespace content