| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" | |
| 6 | |
| 7 #include "chrome/common/content_settings_types.h" | |
| 8 #include "chrome/common/render_messages.h" | |
| 9 #include "chrome/renderer/render_thread.h" | |
| 10 #include "chrome/renderer/render_view.h" | |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
| 13 | |
| 14 using appcache::AppCacheBackend; | |
| 15 using WebKit::WebApplicationCacheHostClient; | |
| 16 using WebKit::WebConsoleMessage; | |
| 17 | |
| 18 RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl( | |
| 19 RenderView* render_view, | |
| 20 WebApplicationCacheHostClient* client, | |
| 21 AppCacheBackend* backend) | |
| 22 : WebApplicationCacheHostImpl(client, backend), | |
| 23 content_blocked_(false), | |
| 24 routing_id_(render_view->routing_id()) { | |
| 25 } | |
| 26 | |
| 27 void RendererWebApplicationCacheHostImpl::OnLogMessage( | |
| 28 appcache::LogLevel log_level, const std::string& message) { | |
| 29 RenderView* render_view = GetRenderView(); | |
| 30 if (!render_view || !render_view->webview() || | |
| 31 !render_view->webview()->mainFrame()) | |
| 32 return; | |
| 33 | |
| 34 WebKit::WebFrame* frame = render_view->webview()->mainFrame(); | |
| 35 frame->addMessageToConsole(WebConsoleMessage( | |
| 36 static_cast<WebConsoleMessage::Level>(log_level), | |
| 37 WebKit::WebString::fromUTF8(message.c_str()))); | |
| 38 } | |
| 39 | |
| 40 void RendererWebApplicationCacheHostImpl::OnContentBlocked( | |
| 41 const GURL& manifest_url) { | |
| 42 RenderThread::current()->Send(new ViewHostMsg_AppCacheAccessed( | |
| 43 routing_id_, manifest_url, true)); | |
| 44 } | |
| 45 | |
| 46 void RendererWebApplicationCacheHostImpl::OnCacheSelected( | |
| 47 const appcache::AppCacheInfo& info) { | |
| 48 if (!info.manifest_url.is_empty()) { | |
| 49 RenderThread::current()->Send(new ViewHostMsg_AppCacheAccessed( | |
| 50 routing_id_, info.manifest_url, false)); | |
| 51 } | |
| 52 WebApplicationCacheHostImpl::OnCacheSelected(info); | |
| 53 } | |
| 54 | |
| 55 RenderView* RendererWebApplicationCacheHostImpl::GetRenderView() { | |
| 56 return static_cast<RenderView*> | |
| 57 (RenderThread::current()->ResolveRoute(routing_id_)); | |
| 58 } | |
| OLD | NEW |