mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Improve thread safety and documentation and add support for thread-specific APIs (issue #175).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@174 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -47,41 +47,29 @@ public:
|
||||
#endif
|
||||
|
||||
// CefBrowser methods
|
||||
virtual bool CanGoBack();
|
||||
virtual bool CanGoBack() { return can_go_back(); }
|
||||
virtual void GoBack();
|
||||
virtual bool CanGoForward();
|
||||
virtual bool CanGoForward() { return can_go_forward(); }
|
||||
virtual void GoForward();
|
||||
virtual void Reload();
|
||||
virtual void ReloadIgnoreCache();
|
||||
virtual void StopLoad();
|
||||
virtual void SetFocus(bool enable);
|
||||
virtual CefWindowHandle GetWindowHandle();
|
||||
virtual bool IsPopup();
|
||||
virtual CefRefPtr<CefHandler> GetHandler();
|
||||
virtual CefRefPtr<CefFrame> GetMainFrame();
|
||||
virtual bool IsPopup() { return is_popup(); }
|
||||
virtual CefRefPtr<CefHandler> GetHandler() { return handler_; }
|
||||
virtual CefRefPtr<CefFrame> GetMainFrame() { return GetMainCefFrame(); }
|
||||
virtual CefRefPtr<CefFrame> GetFocusedFrame();
|
||||
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name);
|
||||
virtual void GetFrameNames(std::vector<CefString>& names);
|
||||
virtual void Find(int identifier, const CefString& searchText,
|
||||
bool forward, bool matchCase, bool findNext);
|
||||
virtual void StopFinding(bool clearSelection);
|
||||
virtual double GetZoomLevel();
|
||||
virtual double GetZoomLevel() { return zoom_level(); }
|
||||
virtual void SetZoomLevel(double zoomLevel);
|
||||
virtual void ShowDevTools();
|
||||
virtual void CloseDevTools();
|
||||
|
||||
// CefFrames are light-weight objects managed by the browser and loosely
|
||||
// coupled to a WebFrame object by name. If a CefFrame object does not
|
||||
// already exist for the specified WebFrame one will be created. There is no
|
||||
// guarantee that the same CefFrame object will be returned across different
|
||||
// calls to this function.
|
||||
CefRefPtr<CefFrame> GetCefFrame(WebKit::WebFrame* frame);
|
||||
void RemoveCefFrame(const CefString& name);
|
||||
|
||||
// Return the WebFrame object associated with the specified CefFrame. This
|
||||
// may return NULL if no WebFrame with the CefFrame's name exists.
|
||||
WebKit::WebFrame* GetWebFrame(CefRefPtr<CefFrame> frame);
|
||||
|
||||
// Frame-related methods
|
||||
void Undo(CefRefPtr<CefFrame> frame);
|
||||
void Redo(CefRefPtr<CefFrame> frame);
|
||||
@ -110,36 +98,62 @@ public:
|
||||
int startLine);
|
||||
CefString GetURL(CefRefPtr<CefFrame> frame);
|
||||
|
||||
WebKit::WebView* GetWebView() const {
|
||||
return webviewhost_.get() ? webviewhost_->webview() : NULL;
|
||||
}
|
||||
WebViewHost* GetWebViewHost() const {
|
||||
return webviewhost_.get();
|
||||
}
|
||||
BrowserWebViewDelegate* GetWebViewDelegate() const {
|
||||
return delegate_.get();
|
||||
}
|
||||
gfx::NativeView GetWebViewWndHandle() const {
|
||||
return webviewhost_->view_handle();
|
||||
}
|
||||
WebKit::WebWidget* GetPopup() const {
|
||||
return popuphost_ ? popuphost_->webwidget() : NULL;
|
||||
}
|
||||
WebWidgetHost* GetPopupHost() const {
|
||||
return popuphost_;
|
||||
}
|
||||
BrowserWebViewDelegate* GetPopupDelegate() const {
|
||||
return popup_delegate_.get();
|
||||
}
|
||||
gfx::NativeView GetPopupWndHandle() const {
|
||||
return popuphost_->view_handle();
|
||||
}
|
||||
gfx::NativeWindow GetMainWndHandle() const;
|
||||
// CefFrames are light-weight objects managed by the browser and loosely
|
||||
// coupled to a WebFrame object by name. If a CefFrame object does not
|
||||
// already exist for the specified name one will be created. There is no
|
||||
// guarantee that the same CefFrame object will be returned across different
|
||||
// calls to this function.
|
||||
CefRefPtr<CefFrame> GetCefFrame(const CefString& name);
|
||||
void RemoveCefFrame(const CefString& name);
|
||||
CefRefPtr<CefFrame> GetMainCefFrame();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD //
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
CefRefPtr<CefFrame> UIT_GetCefFrame(WebKit::WebFrame* frame);
|
||||
|
||||
// Return the main WebFrame object.
|
||||
WebKit::WebFrame* UIT_GetMainWebFrame();
|
||||
|
||||
// Return the WebFrame object associated with the specified CefFrame. This
|
||||
// may return NULL if no WebFrame with the CefFrame's name exists.
|
||||
WebKit::WebFrame* UIT_GetWebFrame(CefRefPtr<CefFrame> frame);
|
||||
|
||||
WebKit::WebView* UIT_GetWebView() const {
|
||||
REQUIRE_UIT();
|
||||
return webviewhost_.get() ? webviewhost_->webview() : NULL;
|
||||
}
|
||||
WebViewHost* UIT_GetWebViewHost() const {
|
||||
REQUIRE_UIT();
|
||||
return webviewhost_.get();
|
||||
}
|
||||
BrowserWebViewDelegate* UIT_GetWebViewDelegate() const {
|
||||
REQUIRE_UIT();
|
||||
return delegate_.get();
|
||||
}
|
||||
gfx::NativeView UIT_GetWebViewWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
return webviewhost_->view_handle();
|
||||
}
|
||||
WebKit::WebWidget* UIT_GetPopup() const {
|
||||
REQUIRE_UIT();
|
||||
return popuphost_ ? popuphost_->webwidget() : NULL;
|
||||
}
|
||||
WebWidgetHost* UIT_GetPopupHost() const {
|
||||
REQUIRE_UIT();
|
||||
return popuphost_;
|
||||
}
|
||||
BrowserWebViewDelegate* UIT_GetPopupDelegate() const {
|
||||
REQUIRE_UIT();
|
||||
return popup_delegate_.get();
|
||||
}
|
||||
gfx::NativeView UIT_GetPopupWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
return popuphost_->view_handle();
|
||||
}
|
||||
gfx::NativeWindow UIT_GetMainWndHandle() const;
|
||||
|
||||
BrowserNavigationController* UIT_GetNavigationController() {
|
||||
REQUIRE_UIT();
|
||||
return nav_controller_.get();
|
||||
@ -157,14 +171,14 @@ public:
|
||||
is_modal_ = val;
|
||||
}
|
||||
|
||||
void UIT_SetTitle(const CefString& title) {
|
||||
REQUIRE_UIT();
|
||||
title_ = title;
|
||||
}
|
||||
CefString UIT_GetTitle() {
|
||||
REQUIRE_UIT();
|
||||
return title_;
|
||||
}
|
||||
void UIT_SetTitle(const CefString& title) {
|
||||
REQUIRE_UIT();
|
||||
title_ = title;
|
||||
}
|
||||
|
||||
void UIT_CreateBrowser(const CefString& url);
|
||||
void UIT_DestroyBrowser();
|
||||
@ -209,13 +223,6 @@ public:
|
||||
// Save the document HTML to a temporary file and open in the default viewing
|
||||
// application
|
||||
bool UIT_ViewDocumentString(WebKit::WebFrame *frame);
|
||||
void UIT_GetDocumentStringNotify(CefFrame* frame,
|
||||
CefStreamWriter* writer,
|
||||
base::WaitableEvent* event);
|
||||
void UIT_GetDocumentTextNotify(CefFrame* frame, CefStreamWriter* writer,
|
||||
base::WaitableEvent* event);
|
||||
void UIT_CanGoBackNotify(bool *retVal, base::WaitableEvent* event);
|
||||
void UIT_CanGoForwardNotify(bool *retVal, base::WaitableEvent* event);
|
||||
|
||||
bool UIT_CanGoBack() { return !nav_controller_->IsAtStart(); }
|
||||
bool UIT_CanGoForward() { return !nav_controller_->IsAtEnd(); }
|
||||
@ -235,17 +242,26 @@ public:
|
||||
void UIT_NotifyFindStatus(int identifier, int count,
|
||||
const WebKit::WebRect& selection_rect,
|
||||
int active_match_ordinal, bool final_update);
|
||||
void UIT_SetZoomLevel(CefFrame* frame, double zoomLevel);
|
||||
void UIT_SetZoomLevel(double zoomLevel);
|
||||
void UIT_ShowDevTools();
|
||||
void UIT_CloseDevTools();
|
||||
|
||||
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
||||
|
||||
// These variables are read-only.
|
||||
const CefBrowserSettings& settings() const { return settings_; }
|
||||
const FilePath& file_system_root() const { return file_system_root_.path(); }
|
||||
bool is_popup() { return is_popup_; }
|
||||
|
||||
// These variables may be read/written from multiple threads.
|
||||
void set_zoom_level(double zoomLevel);
|
||||
double zoom_level();
|
||||
void set_nav_state(bool can_go_back, bool can_go_forward);
|
||||
bool can_go_back();
|
||||
bool can_go_forward();
|
||||
|
||||
static bool ImplementsThreadSafeReferenceCounting() { return true; }
|
||||
|
||||
protected:
|
||||
void CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
||||
void UIT_CreateDevToolsClient(BrowserDevToolsAgent* agent);
|
||||
|
||||
protected:
|
||||
CefWindowInfo window_info_;
|
||||
@ -264,6 +280,10 @@ protected:
|
||||
|
||||
CefString title_;
|
||||
|
||||
double zoom_level_;
|
||||
bool can_go_back_;
|
||||
bool can_go_forward_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Context object used to manage printing.
|
||||
printing::PrintingContext print_context_;
|
||||
@ -271,7 +291,7 @@ protected:
|
||||
|
||||
typedef std::map<CefString, CefFrame*> FrameMap;
|
||||
FrameMap frames_;
|
||||
CefFrame* frame_main_;
|
||||
CefFrame* main_frame_;
|
||||
|
||||
// Unique browser ID assigned by the context.
|
||||
int unique_id_;
|
||||
@ -285,9 +305,8 @@ protected:
|
||||
class CefFrameImpl : public CefThreadSafeBase<CefFrame>
|
||||
{
|
||||
public:
|
||||
CefFrameImpl(CefBrowserImpl* browser, const CefString& name)
|
||||
: browser_(browser), name_(name) {}
|
||||
virtual ~CefFrameImpl() { browser_->RemoveCefFrame(name_); }
|
||||
CefFrameImpl(CefBrowserImpl* browser, const CefString& name);
|
||||
virtual ~CefFrameImpl();
|
||||
|
||||
// CefFrame methods
|
||||
virtual void Undo() { browser_->Undo(this); }
|
||||
|
Reference in New Issue
Block a user