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