Chromium Code Reviews| 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/WebLocalFrame.h" | |
| 11 #include "third_party/WebKit/public/web/WebView.h" | 12 #include "third_party/WebKit/public/web/WebView.h" |
| 12 | 13 |
| 13 using blink::WebApplicationCacheHostClient; | 14 using blink::WebApplicationCacheHostClient; |
| 14 using blink::WebConsoleMessage; | 15 using blink::WebConsoleMessage; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl( | 19 RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl( |
| 19 RenderViewImpl* render_view, | 20 RenderViewImpl* render_view, |
| 20 WebApplicationCacheHostClient* client, | 21 WebApplicationCacheHostClient* client, |
| 21 AppCacheBackend* backend, | 22 AppCacheBackend* backend, |
| 22 int appcache_host_id) | 23 int appcache_host_id) |
| 23 : WebApplicationCacheHostImpl(client, backend, appcache_host_id), | 24 : WebApplicationCacheHostImpl(client, backend, appcache_host_id), |
| 24 routing_id_(render_view->GetRoutingID()) {} | 25 routing_id_(render_view->GetRoutingID()) {} |
| 25 | 26 |
| 26 void RendererWebApplicationCacheHostImpl::OnLogMessage( | 27 void RendererWebApplicationCacheHostImpl::OnLogMessage( |
| 27 AppCacheLogLevel log_level, const std::string& message) { | 28 AppCacheLogLevel log_level, const std::string& message) { |
| 28 if (RenderThreadImpl::current()->layout_test_mode()) | 29 if (RenderThreadImpl::current()->layout_test_mode()) |
| 29 return; | 30 return; |
| 30 | 31 |
| 31 RenderViewImpl* render_view = GetRenderView(); | 32 RenderViewImpl* render_view = GetRenderView(); |
| 32 if (!render_view || !render_view->webview() || | 33 if (!render_view || !render_view->webview() || |
| 33 !render_view->webview()->mainFrame()) | 34 !render_view->webview()->mainFrame()) |
| 34 return; | 35 return; |
| 35 | 36 |
| 36 blink::WebFrame* frame = render_view->webview()->mainFrame(); | 37 blink::WebFrame* frame = render_view->webview()->mainFrame(); |
| 37 frame->addMessageToConsole(WebConsoleMessage( | 38 if (!frame->isWebLocalFrame()) |
| 38 static_cast<WebConsoleMessage::Level>(log_level), | 39 return; |
| 39 blink::WebString::fromUTF8(message.c_str()))); | 40 // TODO(michaeln): Make app cache host per-frame and correctly report to the |
|
dcheng
2016/12/27 08:48:59
+michaeln, +ananta since I know there's some appca
| |
| 41 // involved frame. | |
| 42 frame->toWebLocalFrame()->addMessageToConsole( | |
| 43 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(log_level), | |
| 44 blink::WebString::fromUTF8(message.c_str()))); | |
| 40 } | 45 } |
| 41 | 46 |
| 42 void RendererWebApplicationCacheHostImpl::OnContentBlocked( | 47 void RendererWebApplicationCacheHostImpl::OnContentBlocked( |
| 43 const GURL& manifest_url) { | 48 const GURL& manifest_url) { |
| 44 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( | 49 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( |
| 45 routing_id_, manifest_url, true)); | 50 routing_id_, manifest_url, true)); |
| 46 } | 51 } |
| 47 | 52 |
| 48 void RendererWebApplicationCacheHostImpl::OnCacheSelected( | 53 void RendererWebApplicationCacheHostImpl::OnCacheSelected( |
| 49 const AppCacheInfo& info) { | 54 const AppCacheInfo& info) { |
| 50 if (!info.manifest_url.is_empty()) { | 55 if (!info.manifest_url.is_empty()) { |
| 51 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( | 56 RenderThreadImpl::current()->Send(new ViewHostMsg_AppCacheAccessed( |
| 52 routing_id_, info.manifest_url, false)); | 57 routing_id_, info.manifest_url, false)); |
| 53 } | 58 } |
| 54 WebApplicationCacheHostImpl::OnCacheSelected(info); | 59 WebApplicationCacheHostImpl::OnCacheSelected(info); |
| 55 } | 60 } |
| 56 | 61 |
| 57 RenderViewImpl* RendererWebApplicationCacheHostImpl::GetRenderView() { | 62 RenderViewImpl* RendererWebApplicationCacheHostImpl::GetRenderView() { |
| 58 return RenderViewImpl::FromRoutingID(routing_id_); | 63 return RenderViewImpl::FromRoutingID(routing_id_); |
| 59 } | 64 } |
| 60 | 65 |
| 61 } // namespace content | 66 } // namespace content |
| OLD | NEW |