mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 20:20:51 +01:00
Add support for navigator.onLine and online/offline window events (issue #234).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@234 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
abfc77abd1
commit
9a69e96950
@ -16,6 +16,7 @@
|
|||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "net/base/net_module.h"
|
#include "net/base/net_module.h"
|
||||||
#include "net/url_request/url_request.h"
|
#include "net/url_request/url_request.h"
|
||||||
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
|
||||||
#include "ui/gfx/gl/gl_implementation.h"
|
#include "ui/gfx/gl/gl_implementation.h"
|
||||||
#include "webkit/blob/blob_storage_controller.h"
|
#include "webkit/blob/blob_storage_controller.h"
|
||||||
#include "webkit/blob/blob_url_request_job.h"
|
#include "webkit/blob/blob_url_request_job.h"
|
||||||
@ -175,6 +176,16 @@ void CefProcessUIThread::Init() {
|
|||||||
webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path);
|
webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a network change notifier before starting the IO & File threads.
|
||||||
|
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
|
||||||
|
|
||||||
|
// Add a listener for OnOnlineStateChanged to notify WebKit of changes.
|
||||||
|
net::NetworkChangeNotifier::AddOnlineStateObserver(this);
|
||||||
|
|
||||||
|
// Initialize WebKit with the current state.
|
||||||
|
WebKit::WebNetworkStateNotifier::setOnLine(
|
||||||
|
!net::NetworkChangeNotifier::IsOffline());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefProcessUIThread::CleanUp() {
|
void CefProcessUIThread::CleanUp() {
|
||||||
@ -195,5 +206,15 @@ void CefProcessUIThread::CleanUp() {
|
|||||||
delete webkit_init_;
|
delete webkit_init_;
|
||||||
webkit_init_ = NULL;
|
webkit_init_ = NULL;
|
||||||
|
|
||||||
|
// Release the network change notifier after all other threads end.
|
||||||
|
net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
|
||||||
|
network_change_notifier_.reset();
|
||||||
|
|
||||||
PlatformCleanUp();
|
PlatformCleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefProcessUIThread::OnOnlineStateChanged(bool online) {
|
||||||
|
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
|
||||||
|
WebKit::WebNetworkStateNotifier::setOnLine(online);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#define _CEF_PROCESS_UI_THREAD
|
#define _CEF_PROCESS_UI_THREAD
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "cef_thread.h"
|
#include "cef_thread.h"
|
||||||
|
#include "net/base/network_change_notifier.h"
|
||||||
|
|
||||||
class BrowserWebKitInit;
|
class BrowserWebKitInit;
|
||||||
namespace base {
|
namespace base {
|
||||||
@ -23,7 +25,10 @@ class StatsTable;
|
|||||||
// Applications must initialize the COM library before they can call
|
// Applications must initialize the COM library before they can call
|
||||||
// COM library functions other than CoGetMalloc and memory allocation
|
// COM library functions other than CoGetMalloc and memory allocation
|
||||||
// functions, so this class initializes COM for those users.
|
// functions, so this class initializes COM for those users.
|
||||||
class CefProcessUIThread : public CefThread {
|
class CefProcessUIThread
|
||||||
|
: public net::NetworkChangeNotifier::OnlineStateObserver,
|
||||||
|
public CefThread
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit CefProcessUIThread();
|
explicit CefProcessUIThread();
|
||||||
CefProcessUIThread(MessageLoop* message_loop);
|
CefProcessUIThread(MessageLoop* message_loop);
|
||||||
@ -36,11 +41,16 @@ class CefProcessUIThread : public CefThread {
|
|||||||
void PlatformInit();
|
void PlatformInit();
|
||||||
void PlatformCleanUp();
|
void PlatformCleanUp();
|
||||||
|
|
||||||
|
// From net::NetworkChangeNotifier::OnlineStateObserver
|
||||||
|
void OnOnlineStateChanged(bool online);
|
||||||
|
|
||||||
base::StatsTable* statstable_;
|
base::StatsTable* statstable_;
|
||||||
|
|
||||||
// WebKit implementation class.
|
// WebKit implementation class.
|
||||||
BrowserWebKitInit* webkit_init_;
|
BrowserWebKitInit* webkit_init_;
|
||||||
|
|
||||||
|
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user