Continue OnDownloadUpdated notifications after navigation (issue #1833)

This commit is contained in:
Marshall Greenblatt
2016-02-12 17:31:22 -05:00
parent 8972bbfcb6
commit e601e76445
5 changed files with 270 additions and 50 deletions

View File

@ -24,6 +24,7 @@
#include "libcef/common/response_manager.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/notification_observer.h"
@ -71,6 +72,18 @@ class CefBrowserHostImpl : public CefBrowserHost,
virtual void OnResponse(const std::string& response) =0;
};
// Interface to implement for observers that wish to be informed of changes
// to the CefBrowserHostImpl. All methods will be called on the UI thread.
class Observer {
public:
// Called before |browser| is destroyed. Any references to |browser| should
// be cleared when this method is called.
virtual void OnBrowserDestroyed(CefBrowserHostImpl* browser) =0;
protected:
virtual ~Observer() {}
};
~CefBrowserHostImpl() override;
// Create a new CefBrowserHostImpl instance.
@ -420,6 +433,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
// Override to provide a thread safe implementation.
bool Send(IPC::Message* message) override;
// Manage observer objects. The observer must either outlive this object or
// remove itself before destruction. These methods can only be called on the
// UI thread.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
bool HasObserver(Observer* observer) const;
private:
class DevToolsWebContentsObserver;
@ -570,6 +590,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
// destroyed.
CefDevToolsFrontend* devtools_frontend_;
// Observers that want to be notified of changes to this object.
base::ObserverList<Observer> observers_;
IMPLEMENT_REFCOUNTING(CefBrowserHostImpl);
DISALLOW_COPY_AND_ASSIGN(CefBrowserHostImpl);
};