[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "android_webview/renderer/aw_render_process_observer.h" | ||||
6 | |||||
7 | #include "android_webview/common/render_view_messages.h" | ||||
8 | #include "ipc/ipc_message_macros.h" | ||||
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 9 | #include "third_party/WebKit/public/web/WebCache.h" |
[email protected] | 6ec2787 | 2013-08-27 23:35:06 | [diff] [blame] | 10 | #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 11 | |
12 | namespace android_webview { | ||||
13 | |||||
[email protected] | 8937e96 | 2012-10-05 03:23:01 | [diff] [blame] | 14 | AwRenderProcessObserver::AwRenderProcessObserver() |
15 | : webkit_initialized_(false) { | ||||
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 16 | } |
17 | |||||
18 | AwRenderProcessObserver::~AwRenderProcessObserver() { | ||||
19 | } | ||||
20 | |||||
21 | bool AwRenderProcessObserver::OnControlMessageReceived( | ||||
22 | const IPC::Message& message) { | ||||
23 | bool handled = true; | ||||
24 | IPC_BEGIN_MESSAGE_MAP(AwRenderProcessObserver, message) | ||||
25 | IPC_MESSAGE_HANDLER(AwViewMsg_ClearCache, OnClearCache) | ||||
[email protected] | 6ec2787 | 2013-08-27 23:35:06 | [diff] [blame] | 26 | IPC_MESSAGE_HANDLER(AwViewMsg_SetJsOnlineProperty, OnSetJsOnlineProperty) |
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 27 | IPC_MESSAGE_UNHANDLED(handled = false) |
28 | IPC_END_MESSAGE_MAP() | ||||
29 | return handled; | ||||
30 | } | ||||
31 | |||||
[email protected] | 8937e96 | 2012-10-05 03:23:01 | [diff] [blame] | 32 | void AwRenderProcessObserver::WebKitInitialized() { |
33 | webkit_initialized_ = true; | ||||
34 | } | ||||
35 | |||||
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 36 | void AwRenderProcessObserver::OnClearCache() { |
[email protected] | 8937e96 | 2012-10-05 03:23:01 | [diff] [blame] | 37 | if (webkit_initialized_) |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 38 | blink::WebCache::clear(); |
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 39 | } |
40 | |||||
[email protected] | 6ec2787 | 2013-08-27 23:35:06 | [diff] [blame] | 41 | void AwRenderProcessObserver::OnSetJsOnlineProperty(bool network_up) { |
42 | if (webkit_initialized_) | ||||
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 43 | blink::WebNetworkStateNotifier::setOnLine(network_up); |
[email protected] | 6ec2787 | 2013-08-27 23:35:06 | [diff] [blame] | 44 | } |
45 | |||||
[email protected] | 86b74e06 | 2012-10-03 01:44:46 | [diff] [blame] | 46 | } // nanemspace android_webview |