[email protected] | 629ddf85 | 2012-07-20 16:17:29 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | acb9472 | 2011-03-18 01:33:34 | [diff] [blame] | 5 | #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 6 | |
[email protected] | 0aed2f5 | 2011-03-23 18:06:36 | [diff] [blame] | 7 | #include "content/common/view_messages.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 8 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 9 | #include "content/renderer/render_view_impl.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 10 | #include "third_party/WebKit/public/web/WebFrame.h" |
| 11 | #include "third_party/WebKit/public/web/WebView.h" |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 12 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 13 | using blink::WebApplicationCacheHostClient; |
| 14 | using blink::WebConsoleMessage; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 15 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 16 | namespace content { |
| 17 | |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 18 | RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl( |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 19 | RenderViewImpl* render_view, |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 20 | WebApplicationCacheHostClient* client, |
| 21 | AppCacheBackend* backend) |
| 22 | : WebApplicationCacheHostImpl(client, backend), |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 23 | routing_id_(render_view->routing_id()) { |
| 24 | } |
| 25 | |
[email protected] | df4cd15 | 2010-06-25 00:46:02 | [diff] [blame] | 26 | void RendererWebApplicationCacheHostImpl::OnLogMessage( |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 27 | AppCacheLogLevel log_level, const std::string& message) { |
[email protected] | 70dee7e | 2013-05-29 18:28:30 | [diff] [blame] | 28 | if (RenderThreadImpl::current()->layout_test_mode()) |
[email protected] | 04dd712 | 2012-12-12 23:13:59 | [diff] [blame] | 29 | return; |
| 30 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 31 | RenderViewImpl* render_view = GetRenderView(); |
[email protected] | df4cd15 | 2010-06-25 00:46:02 | [diff] [blame] | 32 | if (!render_view || !render_view->webview() || |
| 33 | !render_view->webview()->mainFrame()) |
| 34 | return; |
| 35 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 36 | blink::WebFrame* frame = render_view->webview()->mainFrame(); |
[email protected] | df4cd15 | 2010-06-25 00:46:02 | [diff] [blame] | 37 | frame->addMessageToConsole(WebConsoleMessage( |
| 38 | static_cast<WebConsoleMessage::Level>(log_level), |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 39 | blink::WebString::fromUTF8(message.c_str()))); |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 40 | } |
| 41 | |
[email protected] | 5c7d598 | 2010-07-12 09:12:59 | [diff] [blame] | 42 | void RendererWebApplicationCacheHostImpl::OnContentBlocked( |
| 43 | const GURL& manifest_url) { |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 44 | RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( |
[email protected] | 5c7d598 | 2010-07-12 09:12:59 | [diff] [blame] | 45 | routing_id_, manifest_url, true)); |
| 46 | } |
| 47 | |
| 48 | void RendererWebApplicationCacheHostImpl::OnCacheSelected( |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 49 | const AppCacheInfo& info) { |
[email protected] | 5fd7738 | 2010-08-04 20:00:34 | [diff] [blame] | 50 | if (!info.manifest_url.is_empty()) { |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 51 | RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( |
[email protected] | 5fd7738 | 2010-08-04 20:00:34 | [diff] [blame] | 52 | routing_id_, info.manifest_url, false)); |
| 53 | } |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 54 | WebApplicationCacheHostImpl::OnCacheSelected(info); |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 55 | } |
[email protected] | df4cd15 | 2010-06-25 00:46:02 | [diff] [blame] | 56 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 57 | RenderViewImpl* RendererWebApplicationCacheHostImpl::GetRenderView() { |
[email protected] | bae061f7 | 2013-04-26 16:22:29 | [diff] [blame] | 58 | return RenderViewImpl::FromRoutingID(routing_id_); |
[email protected] | df4cd15 | 2010-06-25 00:46:02 | [diff] [blame] | 59 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 60 | |
| 61 | } // namespace content |