Add new CefBrowser::GetIdentifier method (issue #811).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@953 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
f782b4b1e0
commit
991a513473
|
@ -122,6 +122,11 @@ typedef struct _cef_browser_t {
|
||||||
cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)(
|
cef_window_handle_t (CEF_CALLBACK *get_opener_window_handle)(
|
||||||
struct _cef_browser_t* self);
|
struct _cef_browser_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the globally unique identifier for this browser.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *get_identifier)(struct _cef_browser_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the window is a popup window.
|
// Returns true (1) if the window is a popup window.
|
||||||
///
|
///
|
||||||
|
|
|
@ -147,6 +147,12 @@ class CefBrowser : public virtual CefBase {
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual CefWindowHandle GetOpenerWindowHandle() =0;
|
virtual CefWindowHandle GetOpenerWindowHandle() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns the globally unique identifier for this browser.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual int GetIdentifier() =0;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true if the window is a popup window.
|
// Returns true if the window is a popup window.
|
||||||
///
|
///
|
||||||
|
|
|
@ -170,7 +170,7 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
|
||||||
has_document_(false),
|
has_document_(false),
|
||||||
is_dropping_(false),
|
is_dropping_(false),
|
||||||
is_in_onsetfocus_(false),
|
is_in_onsetfocus_(false),
|
||||||
unique_id_(0)
|
browser_id_(_Context->GetNextBrowserID())
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
, opener_was_disabled_by_modal_loop_(false),
|
, opener_was_disabled_by_modal_loop_(false),
|
||||||
internal_modal_message_loop_is_active_(false)
|
internal_modal_message_loop_is_active_(false)
|
||||||
|
|
|
@ -83,6 +83,7 @@ class CefBrowserImpl : public CefBrowser {
|
||||||
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
||||||
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE
|
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE
|
||||||
{ return opener_window(); }
|
{ return opener_window(); }
|
||||||
|
virtual int GetIdentifier() OVERRIDE { return browser_id(); }
|
||||||
virtual bool IsPopup() OVERRIDE { return is_popup(); }
|
virtual bool IsPopup() OVERRIDE { return is_popup(); }
|
||||||
virtual bool HasDocument() OVERRIDE { return has_document(); }
|
virtual bool HasDocument() OVERRIDE { return has_document(); }
|
||||||
virtual CefRefPtr<CefClient> GetClient() OVERRIDE { return client_; }
|
virtual CefRefPtr<CefClient> GetClient() OVERRIDE { return client_; }
|
||||||
|
@ -303,9 +304,6 @@ class CefBrowserImpl : public CefBrowser {
|
||||||
const gfx::Size& canvas_size, WebKit::WebFrame* frame);
|
const gfx::Size& canvas_size, WebKit::WebFrame* frame);
|
||||||
int UIT_GetPagesCount(WebKit::WebFrame* frame);
|
int UIT_GetPagesCount(WebKit::WebFrame* frame);
|
||||||
|
|
||||||
void UIT_SetUniqueID(int id) { unique_id_ = id; }
|
|
||||||
int UIT_GetUniqueID() { return unique_id_; }
|
|
||||||
|
|
||||||
void UIT_Find(int identifier, const CefString& search_text,
|
void UIT_Find(int identifier, const CefString& search_text,
|
||||||
const WebKit::WebFindOptions& options);
|
const WebKit::WebFindOptions& options);
|
||||||
void UIT_StopFinding(bool clear_selection);
|
void UIT_StopFinding(bool clear_selection);
|
||||||
|
@ -328,6 +326,7 @@ class CefBrowserImpl : public CefBrowser {
|
||||||
// These variables are read-only.
|
// These variables are read-only.
|
||||||
const CefBrowserSettings& settings() const { return settings_; }
|
const CefBrowserSettings& settings() const { return settings_; }
|
||||||
gfx::NativeView opener_window() { return opener_; }
|
gfx::NativeView opener_window() { return opener_; }
|
||||||
|
int browser_id() const { return browser_id_; }
|
||||||
bool is_popup() { return (opener_ != NULL); }
|
bool is_popup() { return (opener_ != NULL); }
|
||||||
|
|
||||||
// These variables may be read/written from multiple threads.
|
// These variables may be read/written from multiple threads.
|
||||||
|
@ -425,8 +424,8 @@ class CefBrowserImpl : public CefBrowser {
|
||||||
FrameObjectMap;
|
FrameObjectMap;
|
||||||
FrameObjectMap frame_objects_;
|
FrameObjectMap frame_objects_;
|
||||||
|
|
||||||
// Unique browser ID assigned by the context.
|
// Globally unique identifier for this browser.
|
||||||
int unique_id_;
|
int browser_id_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
|
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
|
||||||
IMPLEMENT_LOCKING(CefBrowserImpl);
|
IMPLEMENT_LOCKING(CefBrowserImpl);
|
||||||
|
@ -491,7 +490,7 @@ class CefFrameImpl : public CefFrame {
|
||||||
private:
|
private:
|
||||||
CefRefPtr<CefBrowserImpl> browser_;
|
CefRefPtr<CefBrowserImpl> browser_;
|
||||||
CefString name_;
|
CefString name_;
|
||||||
|
|
||||||
// The below values must be protected by the lock.
|
// The below values must be protected by the lock.
|
||||||
base::Lock lock_;
|
base::Lock lock_;
|
||||||
int64 id_;
|
int64 id_;
|
||||||
|
|
|
@ -190,7 +190,7 @@ WebKit::WebGraphicsContext3D* BrowserWebViewDelegate::createGraphicsContext3D(
|
||||||
WebKit::WebView* web_view = browser_->UIT_GetWebView();
|
WebKit::WebView* web_view = browser_->UIT_GetWebView();
|
||||||
if (!web_view)
|
if (!web_view)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const CefSettings& settings = _Context->settings();
|
const CefSettings& settings = _Context->settings();
|
||||||
return webkit_glue::CreateGraphicsContext3D(settings.graphics_implementation,
|
return webkit_glue::CreateGraphicsContext3D(settings.graphics_implementation,
|
||||||
attributes, web_view, true);
|
attributes, web_view, true);
|
||||||
|
@ -981,7 +981,7 @@ void BrowserWebViewDelegate::willSendRequest(
|
||||||
|
|
||||||
// The requestor ID is used by the resource loader bridge to locate the
|
// The requestor ID is used by the resource loader bridge to locate the
|
||||||
// browser that originated the request.
|
// browser that originated the request.
|
||||||
request.setRequestorID(browser_->UIT_GetUniqueID());
|
request.setRequestorID(browser_->browser_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWebViewDelegate::didChangeContentsSize(
|
void BrowserWebViewDelegate::didChangeContentsSize(
|
||||||
|
|
|
@ -34,10 +34,6 @@ CefRefPtr<CefContext> _Context;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Both the CefContext constuctor and the CefContext::RemoveBrowser method need
|
|
||||||
// to initialize or reset to the same value.
|
|
||||||
const int kNextBrowserIdReset = 1;
|
|
||||||
|
|
||||||
// Used in multi-threaded message loop mode to observe shutdown of the UI
|
// Used in multi-threaded message loop mode to observe shutdown of the UI
|
||||||
// thread.
|
// thread.
|
||||||
class DestructionObserver : public MessageLoop::DestructionObserver {
|
class DestructionObserver : public MessageLoop::DestructionObserver {
|
||||||
|
@ -226,7 +222,6 @@ CefContext::CefContext()
|
||||||
: initialized_(false),
|
: initialized_(false),
|
||||||
shutting_down_(false),
|
shutting_down_(false),
|
||||||
request_context_(NULL),
|
request_context_(NULL),
|
||||||
next_browser_id_(kNextBrowserIdReset),
|
|
||||||
current_webviewhost_(NULL),
|
current_webviewhost_(NULL),
|
||||||
dev_tools_client_count_(0) {
|
dev_tools_client_count_(0) {
|
||||||
}
|
}
|
||||||
|
@ -308,30 +303,17 @@ void CefContext::Shutdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefContext::AddBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
int CefContext::GetNextBrowserID() {
|
||||||
bool found = false;
|
return next_browser_id_.GetNext() + 1;
|
||||||
|
|
||||||
AutoLock lock_scope(this);
|
|
||||||
|
|
||||||
// check that the browser isn't already in the list before adding
|
|
||||||
BrowserList::const_iterator it = browserlist_.begin();
|
|
||||||
for (; it != browserlist_.end(); ++it) {
|
|
||||||
if (it->get() == browser.get()) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
browser->UIT_SetUniqueID(next_browser_id_++);
|
|
||||||
browserlist_.push_back(browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
return !found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
void CefContext::AddBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
||||||
bool deleted = false;
|
AutoLock lock_scope(this);
|
||||||
|
|
||||||
|
browserlist_.push_back(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
||||||
bool empty = false;
|
bool empty = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -341,15 +323,12 @@ bool CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
||||||
for (; it != browserlist_.end(); ++it) {
|
for (; it != browserlist_.end(); ++it) {
|
||||||
if (it->get() == browser.get()) {
|
if (it->get() == browser.get()) {
|
||||||
browserlist_.erase(it);
|
browserlist_.erase(it);
|
||||||
deleted = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browserlist_.empty()) {
|
if (browserlist_.empty())
|
||||||
next_browser_id_ = kNextBrowserIdReset;
|
|
||||||
empty = true;
|
empty = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
|
@ -360,8 +339,6 @@ bool CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser) {
|
||||||
base::Bind(webkit_glue::ClearCache));
|
base::Bind(webkit_glue::ClearCache));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return deleted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id) {
|
CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id) {
|
||||||
|
@ -369,7 +346,7 @@ CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id) {
|
||||||
|
|
||||||
BrowserList::const_iterator it = browserlist_.begin();
|
BrowserList::const_iterator it = browserlist_.begin();
|
||||||
for (; it != browserlist_.end(); ++it) {
|
for (; it != browserlist_.end(); ++it) {
|
||||||
if (it->get()->UIT_GetUniqueID() == id)
|
if (it->get()->browser_id() == id)
|
||||||
return it->get();
|
return it->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "libcef/cef_process.h"
|
#include "libcef/cef_process.h"
|
||||||
|
|
||||||
#include "base/at_exit.h"
|
#include "base/at_exit.h"
|
||||||
|
#include "base/atomic_sequence_num.h"
|
||||||
#include "base/file_path.h"
|
#include "base/file_path.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/files/scoped_temp_dir.h"
|
#include "base/files/scoped_temp_dir.h"
|
||||||
|
@ -49,8 +50,9 @@ class CefContext : public CefBase {
|
||||||
|
|
||||||
CefProcess* process() { return process_.get(); }
|
CefProcess* process() { return process_.get(); }
|
||||||
|
|
||||||
bool AddBrowser(CefRefPtr<CefBrowserImpl> browser);
|
int GetNextBrowserID();
|
||||||
bool RemoveBrowser(CefRefPtr<CefBrowserImpl> browser);
|
void AddBrowser(CefRefPtr<CefBrowserImpl> browser);
|
||||||
|
void RemoveBrowser(CefRefPtr<CefBrowserImpl> browser);
|
||||||
CefRefPtr<CefBrowserImpl> GetBrowserByID(int id);
|
CefRefPtr<CefBrowserImpl> GetBrowserByID(int id);
|
||||||
BrowserList* GetBrowserList() { return &browserlist_; }
|
BrowserList* GetBrowserList() { return &browserlist_; }
|
||||||
|
|
||||||
|
@ -131,7 +133,7 @@ class CefContext : public CefBase {
|
||||||
BrowserList browserlist_;
|
BrowserList browserlist_;
|
||||||
|
|
||||||
// Used for assigning unique IDs to browser instances.
|
// Used for assigning unique IDs to browser instances.
|
||||||
int next_browser_id_;
|
base::AtomicSequenceNumber next_browser_id_;
|
||||||
|
|
||||||
WebViewHost* current_webviewhost_;
|
WebViewHost* current_webviewhost_;
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,20 @@ cef_window_handle_t CEF_CALLBACK browser_get_opener_window_handle(
|
||||||
return _retval;
|
return _retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK browser_get_identifier(struct _cef_browser_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = CefBrowserCppToC::Get(self)->GetIdentifier();
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) {
|
int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
@ -733,6 +747,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
||||||
struct_.struct_.set_focus = browser_set_focus;
|
struct_.struct_.set_focus = browser_set_focus;
|
||||||
struct_.struct_.get_window_handle = browser_get_window_handle;
|
struct_.struct_.get_window_handle = browser_get_window_handle;
|
||||||
struct_.struct_.get_opener_window_handle = browser_get_opener_window_handle;
|
struct_.struct_.get_opener_window_handle = browser_get_opener_window_handle;
|
||||||
|
struct_.struct_.get_identifier = browser_get_identifier;
|
||||||
struct_.struct_.is_popup = browser_is_popup;
|
struct_.struct_.is_popup = browser_is_popup;
|
||||||
struct_.struct_.has_document = browser_has_document;
|
struct_.struct_.has_document = browser_has_document;
|
||||||
struct_.struct_.get_client = browser_get_client;
|
struct_.struct_.get_client = browser_get_client;
|
||||||
|
|
|
@ -198,6 +198,19 @@ CefWindowHandle CefBrowserCToCpp::GetOpenerWindowHandle() {
|
||||||
return _retval;
|
return _retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CefBrowserCToCpp::GetIdentifier() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, get_identifier))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->get_identifier(struct_);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserCToCpp::IsPopup() {
|
bool CefBrowserCToCpp::IsPopup() {
|
||||||
if (CEF_MEMBER_MISSING(struct_, is_popup))
|
if (CEF_MEMBER_MISSING(struct_, is_popup))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -47,6 +47,7 @@ class CefBrowserCToCpp
|
||||||
virtual void SetFocus(bool enable) OVERRIDE;
|
virtual void SetFocus(bool enable) OVERRIDE;
|
||||||
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
||||||
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE;
|
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE;
|
||||||
|
virtual int GetIdentifier() OVERRIDE;
|
||||||
virtual bool IsPopup() OVERRIDE;
|
virtual bool IsPopup() OVERRIDE;
|
||||||
virtual bool HasDocument() OVERRIDE;
|
virtual bool HasDocument() OVERRIDE;
|
||||||
virtual CefRefPtr<CefClient> GetClient() OVERRIDE;
|
virtual CefRefPtr<CefClient> GetClient() OVERRIDE;
|
||||||
|
|
Loading…
Reference in New Issue