| 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 "android_webview/renderer/aw_render_process_observer.h" | 5 #include "android_webview/renderer/aw_render_process_observer.h" |
| 6 | 6 |
| 7 #include "android_webview/common/render_view_messages.h" | 7 #include "android_webview/common/render_view_messages.h" |
| 8 #include "ipc/ipc_message_macros.h" | 8 #include "ipc/ipc_message_macros.h" |
| 9 #include "third_party/WebKit/public/web/WebCache.h" | 9 #include "third_party/WebKit/public/web/WebCache.h" |
| 10 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
| 10 | 11 |
| 11 namespace android_webview { | 12 namespace android_webview { |
| 12 | 13 |
| 13 AwRenderProcessObserver::AwRenderProcessObserver() | 14 AwRenderProcessObserver::AwRenderProcessObserver() |
| 14 : webkit_initialized_(false) { | 15 : webkit_initialized_(false) { |
| 15 } | 16 } |
| 16 | 17 |
| 17 AwRenderProcessObserver::~AwRenderProcessObserver() { | 18 AwRenderProcessObserver::~AwRenderProcessObserver() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 bool AwRenderProcessObserver::OnControlMessageReceived( | 21 bool AwRenderProcessObserver::OnControlMessageReceived( |
| 21 const IPC::Message& message) { | 22 const IPC::Message& message) { |
| 22 bool handled = true; | 23 bool handled = true; |
| 23 IPC_BEGIN_MESSAGE_MAP(AwRenderProcessObserver, message) | 24 IPC_BEGIN_MESSAGE_MAP(AwRenderProcessObserver, message) |
| 24 IPC_MESSAGE_HANDLER(AwViewMsg_ClearCache, OnClearCache) | 25 IPC_MESSAGE_HANDLER(AwViewMsg_ClearCache, OnClearCache) |
| 26 IPC_MESSAGE_HANDLER(AwViewMsg_SetJsOnlineProperty, OnSetJsOnlineProperty) |
| 25 IPC_MESSAGE_UNHANDLED(handled = false) | 27 IPC_MESSAGE_UNHANDLED(handled = false) |
| 26 IPC_END_MESSAGE_MAP() | 28 IPC_END_MESSAGE_MAP() |
| 27 return handled; | 29 return handled; |
| 28 } | 30 } |
| 29 | 31 |
| 30 void AwRenderProcessObserver::WebKitInitialized() { | 32 void AwRenderProcessObserver::WebKitInitialized() { |
| 31 webkit_initialized_ = true; | 33 webkit_initialized_ = true; |
| 32 } | 34 } |
| 33 | 35 |
| 34 void AwRenderProcessObserver::OnClearCache() { | 36 void AwRenderProcessObserver::OnClearCache() { |
| 35 if (webkit_initialized_) | 37 if (webkit_initialized_) |
| 36 WebKit::WebCache::clear(); | 38 WebKit::WebCache::clear(); |
| 37 } | 39 } |
| 38 | 40 |
| 41 void AwRenderProcessObserver::OnSetJsOnlineProperty(bool network_up) { |
| 42 if (webkit_initialized_) |
| 43 WebKit::WebNetworkStateNotifier::setOnLine(network_up); |
| 44 } |
| 45 |
| 39 } // nanemspace android_webview | 46 } // nanemspace android_webview |
| OLD | NEW |