mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-22 15:07:42 +01: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:
parent
c89349cf5a
commit
7f1694fb68
377
include/cef.h
377
include/cef.h
@ -63,27 +63,29 @@ class CefV8Handler;
|
||||
class CefV8Value;
|
||||
|
||||
|
||||
// This function should be called once when the application is started to
|
||||
// initialize CEF. A return value of true indicates that it succeeded and
|
||||
// false indicates that it failed.
|
||||
// This function should be called on the main application thread to initialize
|
||||
// CEF when the application is started. A return value of true indicates that
|
||||
// it succeeded and false indicates that it failed.
|
||||
/*--cef()--*/
|
||||
bool CefInitialize(const CefSettings& settings,
|
||||
const CefBrowserSettings& browser_defaults);
|
||||
|
||||
// This function should be called once before the application exits to shut down
|
||||
// CEF.
|
||||
// This function should be called on the main application thread to shut down
|
||||
// CEF before the application exits.
|
||||
/*--cef()--*/
|
||||
void CefShutdown();
|
||||
|
||||
// Perform message loop processing. Has no affect if the browser UI loop is
|
||||
// running in a separate thread.
|
||||
// Perform message loop processing. This function must be called on the main
|
||||
// application thread if CefInitialize() is called with a
|
||||
// CefSettings.multi_threaded_message_loop value of false.
|
||||
/*--cef()--*/
|
||||
void CefDoMessageLoopWork();
|
||||
|
||||
// Register a new V8 extension with the specified JavaScript extension code and
|
||||
// handler. Functions implemented by the handler are prototyped using the
|
||||
// keyword 'native'. The calling of a native function is restricted to the scope
|
||||
// in which the prototype of the native function is defined.
|
||||
// in which the prototype of the native function is defined. This function may
|
||||
// be called on any thread.
|
||||
//
|
||||
// Example JavaScript extension code:
|
||||
//
|
||||
@ -145,7 +147,8 @@ bool CefRegisterExtension(const CefString& extension_name,
|
||||
// Register a custom scheme handler factory for the specified |scheme_name| and
|
||||
// |host_name|. All URLs beginning with scheme_name://host_name/ can be handled
|
||||
// by CefSchemeHandler instances returned by the factory. Specify an empty
|
||||
// |host_name| value to match all host names.
|
||||
// |host_name| value to match all host names. This function may be called on any
|
||||
// thread.
|
||||
/*--cef()--*/
|
||||
bool CefRegisterScheme(const CefString& scheme_name,
|
||||
const CefString& host_name,
|
||||
@ -158,18 +161,20 @@ typedef cef_thread_id_t CefThreadId;
|
||||
// types of tasks. The UI thread creates the browser window and is used for all
|
||||
// interaction with the WebKit rendering engine and V8 JavaScript engine (The
|
||||
// UI thread will be the same as the main application thread if CefInitialize()
|
||||
// was called with a |multi_threaded_message_loop| value of false.) The IO
|
||||
// thread is used for handling schema and network requests. The FILE thread is
|
||||
// used for the application cache and other miscellaneous activities. This
|
||||
// method will return true if called on the specified thread.
|
||||
// is called with a CefSettings.multi_threaded_message_loop value of false.) The
|
||||
// IO thread is used for handling schema and network requests. The FILE thread
|
||||
// is used for the application cache and other miscellaneous activities. This
|
||||
// function will return true if called on the specified thread.
|
||||
/*--cef()--*/
|
||||
bool CefCurrentlyOn(CefThreadId threadId);
|
||||
|
||||
// Post a task for execution on the specified thread.
|
||||
// Post a task for execution on the specified thread. This function may be
|
||||
// called on any thread.
|
||||
/*--cef()--*/
|
||||
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task);
|
||||
|
||||
// Post a task for delayed execution on the specified thread.
|
||||
// Post a task for delayed execution on the specified thread. This function may
|
||||
// be called on any thread.
|
||||
/*--cef()--*/
|
||||
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
|
||||
long delay_ms);
|
||||
@ -329,7 +334,8 @@ inline bool operator!=(const CefRect& a, const CefRect& b)
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
// Implement this interface for task execution.
|
||||
// Implement this interface for task execution. The methods of this class may
|
||||
// be called on any thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefTask : public CefBase
|
||||
{
|
||||
@ -340,26 +346,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent a browser window. All methods exposed by this class
|
||||
// should be thread safe.
|
||||
// Class used to represent a browser window. The methods of this class may be
|
||||
// called on any thread unless otherwise indicated in the comments.
|
||||
/*--cef(source=library)--*/
|
||||
class CefBrowser : public CefBase
|
||||
{
|
||||
public:
|
||||
// Create a new browser window using the window parameters specified
|
||||
// by |windowInfo|. All values will be copied internally and the actual
|
||||
// window will be created on the UI thread. The |popup| parameter should
|
||||
// be true if the new window is a popup window. This method call will not
|
||||
// block.
|
||||
// Create a new browser window using the window parameters specified by
|
||||
// |windowInfo|. All values will be copied internally and the actual window
|
||||
// will be created on the UI thread. The |popup| parameter should be true if
|
||||
// the new window is a popup window. This method call will not block.
|
||||
/*--cef()--*/
|
||||
static bool CreateBrowser(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler,
|
||||
const CefString& url);
|
||||
|
||||
// Create a new browser window using the window parameters specified
|
||||
// by |windowInfo|. The |popup| parameter should be true if the new window is
|
||||
// a popup window. This method call will block and can only be used if
|
||||
// the |multi_threaded_message_loop| parameter to CefInitialize() is false.
|
||||
// Create a new browser window using the window parameters specified by
|
||||
// |windowInfo|. The |popup| parameter should be true if the new window is a
|
||||
// popup window. This method should only be called on the UI thread.
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||
bool popup,
|
||||
@ -388,8 +392,8 @@ public:
|
||||
/*--cef()--*/
|
||||
virtual void StopLoad() =0;
|
||||
|
||||
// Set focus for the browser window. If |enable| is true focus will be set
|
||||
// to the window. Otherwise, focus will be removed.
|
||||
// Set focus for the browser window. If |enable| is true focus will be set to
|
||||
// the window. Otherwise, focus will be removed.
|
||||
/*--cef()--*/
|
||||
virtual void SetFocus(bool enable) =0;
|
||||
|
||||
@ -409,15 +413,18 @@ public:
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefFrame> GetMainFrame() =0;
|
||||
|
||||
// Returns the focused frame for the browser window.
|
||||
// Returns the focused frame for the browser window. This method should only
|
||||
// be called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefFrame> GetFocusedFrame() =0;
|
||||
|
||||
// Returns the frame with the specified name, or NULL if not found.
|
||||
// Returns the frame with the specified name, or NULL if not found. This
|
||||
// method should only be called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) =0;
|
||||
|
||||
// Returns the names of all existing frames.
|
||||
// Returns the names of all existing frames. This method should only be called
|
||||
// on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual void GetFrameNames(std::vector<CefString>& names) =0;
|
||||
|
||||
@ -453,8 +460,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent a frame in the browser window. All methods exposed
|
||||
// by this class should be thread safe.
|
||||
// Class used to represent a frame in the browser window. The methods of this
|
||||
// class may be called on any thread unless otherwise indicated in the comments.
|
||||
/*--cef(source=library)--*/
|
||||
class CefFrame : public CefBase
|
||||
{
|
||||
@ -491,11 +498,13 @@ public:
|
||||
/*--cef()--*/
|
||||
virtual void ViewSource() =0;
|
||||
|
||||
// Returns this frame's HTML source as a string.
|
||||
// Returns this frame's HTML source as a string. This method should only be
|
||||
// called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual CefString GetSource() =0;
|
||||
|
||||
// Returns this frame's display text as a string.
|
||||
// Returns this frame's display text as a string. This method should only be
|
||||
// called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual CefString GetText() =0;
|
||||
|
||||
@ -531,7 +540,8 @@ public:
|
||||
/*--cef()--*/
|
||||
virtual bool IsMain() =0;
|
||||
|
||||
// Returns true if this is the focused frame.
|
||||
// Returns true if this is the focused frame. This method should only be
|
||||
// called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual bool IsFocused() =0;
|
||||
|
||||
@ -539,15 +549,16 @@ public:
|
||||
/*--cef()--*/
|
||||
virtual CefString GetName() =0;
|
||||
|
||||
// Return the URL currently loaded in this frame.
|
||||
// Return the URL currently loaded in this frame. This method should only be
|
||||
// called on the UI thread.
|
||||
/*--cef()--*/
|
||||
virtual CefString GetURL() =0;
|
||||
};
|
||||
|
||||
|
||||
// Interface that should be implemented to handle events generated by the
|
||||
// browser window. All methods exposed by this class should be thread safe.
|
||||
// Each method in the interface returns a RetVal value.
|
||||
// browser window. The methods of this class will be called on the thread
|
||||
// indicated in the method comments.
|
||||
/*--cef(source=client)--*/
|
||||
class CefHandler : public CefBase
|
||||
{
|
||||
@ -559,9 +570,9 @@ public:
|
||||
// should be called.
|
||||
typedef cef_retval_t RetVal;
|
||||
|
||||
// Event called before a new window is created. The |parentBrowser| parameter
|
||||
// will point to the parent browser window, if any. The |popup| parameter
|
||||
// will be true if the new window is a popup window, in which case
|
||||
// Called on the UI thread before a new window is created. The |parentBrowser|
|
||||
// parameter will point to the parent browser window, if any. The |popup|
|
||||
// parameter will be true if the new window is a popup window, in which case
|
||||
// |popupFeatures| will contain information about the style of popup window
|
||||
// requested. If you create the window yourself you should populate the window
|
||||
// handle member of |createInfo| and return RV_HANDLED. Otherwise, return
|
||||
@ -577,20 +588,20 @@ public:
|
||||
CefString& url,
|
||||
CefBrowserSettings& settings) =0;
|
||||
|
||||
// Event called after a new window is created. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread after a new window is created. The return value is
|
||||
// currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser) =0;
|
||||
|
||||
// Event called when a frame's address has changed. The return value is
|
||||
// currently ignored.
|
||||
// Called on the UI thread when a frame's address has changed. The return
|
||||
// value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& url) =0;
|
||||
|
||||
// Event called when the page title changes. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread when the page title changes. The return value is
|
||||
// currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) =0;
|
||||
@ -598,31 +609,32 @@ public:
|
||||
// Various browser navigation types supported by chrome.
|
||||
typedef cef_handler_navtype_t NavType;
|
||||
|
||||
// Event called before browser navigation. The client has an opportunity to
|
||||
// modify the |request| object if desired. Return RV_HANDLED to cancel
|
||||
// navigation.
|
||||
// Called on the UI thread before browser navigation. The client has an
|
||||
// opportunity to modify the |request| object if desired. Return RV_HANDLED
|
||||
// to cancel navigation.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavType navType, bool isRedirect) =0;
|
||||
|
||||
// Event called when the browser begins loading a page. The |frame| pointer
|
||||
// will be empty if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true if this
|
||||
// load is for the main content area and not an iframe. This method may not
|
||||
// be called if the load request fails. The return value is currently ignored.
|
||||
// Called on the UI thread when the browser begins loading a page. The |frame|
|
||||
// pointer will be empty if the event represents the overall load status and
|
||||
// not the load status for a particular frame. |isMainContent| will be true if
|
||||
// this load is for the main content area and not an iframe. This method may
|
||||
// not be called if the load request fails. The return value is currently
|
||||
// ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
bool isMainContent) =0;
|
||||
|
||||
// Event called when the browser is done loading a page. The |frame| pointer
|
||||
// will be empty if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true if this
|
||||
// load is for the main content area and not an iframe. This method will be
|
||||
// called irrespective of whether the request completes successfully. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread when the browser is done loading a page. The
|
||||
// |frame| pointer will be empty if the event represents the overall load
|
||||
// status and not the load status for a particular frame. |isMainContent| will
|
||||
// be true if this load is for the main content area and not an iframe. This
|
||||
// method will be called irrespective of whether the request completes
|
||||
// successfully. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
@ -633,10 +645,11 @@ public:
|
||||
// descriptions of the error codes.
|
||||
typedef cef_handler_errorcode_t ErrorCode;
|
||||
|
||||
// Called when the browser fails to load a resource. |errorCode| is the
|
||||
// error code number and |failedUrl| is the URL that failed to load. To
|
||||
// provide custom error text assign the text to |errorText| and return
|
||||
// RV_HANDLED. Otherwise, return RV_CONTINUE for the default error text.
|
||||
// Called on the UI thread when the browser fails to load a resource.
|
||||
// |errorCode| is the error code number and |failedUrl| is the URL that failed
|
||||
// to load. To provide custom error text assign the text to |errorText| and
|
||||
// return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error
|
||||
// text.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
@ -644,13 +657,13 @@ public:
|
||||
const CefString& failedUrl,
|
||||
CefString& errorText) =0;
|
||||
|
||||
// Event called before a resource is loaded. To allow the resource to load
|
||||
// normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
// populate the |redirectUrl| value and return RV_CONTINUE. To specify
|
||||
// data for the resource return a CefStream object in |resourceStream|, set
|
||||
// |mimeType| to the resource stream's mime type, and return RV_CONTINUE.
|
||||
// To cancel loading of the resource return RV_HANDLED. Any modifications
|
||||
// to |request| will be observed. If the URL in |request| is changed and
|
||||
// Called on the IO thread before a resource is loaded. To allow the resource
|
||||
// to load normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
// populate the |redirectUrl| value and return RV_CONTINUE. To specify data
|
||||
// for the resource return a CefStream object in |resourceStream|, set
|
||||
// |mimeType| to the resource stream's mime type, and return RV_CONTINUE. To
|
||||
// cancel loading of the resource return RV_HANDLED. Any modifications to
|
||||
// |request| will be observed. If the URL in |request| is changed and
|
||||
// |redirectUrl| is also set, the URL in |request| will be used.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
@ -660,13 +673,13 @@ public:
|
||||
CefString& mimeType,
|
||||
int loadFlags) =0;
|
||||
|
||||
// Called to handle requests for URLs with an unknown protocol component.
|
||||
// Return RV_HANDLED to indicate that the request should succeed because it
|
||||
// was externally handled. Set |allow_os_execution| to true and return
|
||||
// RV_CONTINUE to attempt execution via the registered OS protocol handler,
|
||||
// if any. If RV_CONTINUE is returned and either |allow_os_execution| is false
|
||||
// or OS protocol handler execution fails then the request will fail with an
|
||||
// error condition.
|
||||
// Called on the IO thread to handle requests for URLs with an unknown
|
||||
// protocol component. Return RV_HANDLED to indicate that the request should
|
||||
// succeed because it was externally handled. Set |allow_os_execution| to true
|
||||
// and return RV_CONTINUE to attempt execution via the registered OS protocol
|
||||
// handler, if any. If RV_CONTINUE is returned and either |allow_os_execution|
|
||||
// is false or OS protocol handler execution fails then the request will fail
|
||||
// with an error condition.
|
||||
// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
|
||||
// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
|
||||
/*--cef()--*/
|
||||
@ -674,13 +687,13 @@ public:
|
||||
const CefString& url,
|
||||
bool* allow_os_execution) =0;
|
||||
|
||||
// Called when a server indicates via the 'Content-Disposition' header that a
|
||||
// response represents a file to download. |mimeType| is the mime type for
|
||||
// the download, |fileName| is the suggested target file name and
|
||||
// |contentLength| is either the value of the 'Content-Size' header or -1 if
|
||||
// no size was provided. Set |handler| to the CefDownloadHandler instance that
|
||||
// will recieve the file contents. Return RV_CONTINUE to download the file
|
||||
// or RV_HANDLED to cancel the file download.
|
||||
// Called on the UI thread when a server indicates via the
|
||||
// 'Content-Disposition' header that a response represents a file to download.
|
||||
// |mimeType| is the mime type for the download, |fileName| is the suggested
|
||||
// target file name and |contentLength| is either the value of the
|
||||
// 'Content-Size' header or -1 if no size was provided. Set |handler| to the
|
||||
// CefDownloadHandler instance that will recieve the file contents. Return
|
||||
// RV_CONTINUE to download the file or RV_HANDLED to cancel the file download.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& mimeType,
|
||||
@ -688,10 +701,10 @@ public:
|
||||
int64 contentLength,
|
||||
CefRefPtr<CefDownloadHandler>& handler) =0;
|
||||
|
||||
// Called when the browser needs credentials from the user. |isProxy|
|
||||
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||
// Called on the IO thread when the browser needs credentials from the user.
|
||||
// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
// hostname and port number. Set |username| and |password| and return
|
||||
// RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||
bool isProxy,
|
||||
@ -704,8 +717,8 @@ public:
|
||||
// Structure representing menu information.
|
||||
typedef cef_handler_menuinfo_t MenuInfo;
|
||||
|
||||
// Event called before a context menu is displayed. To cancel display of the
|
||||
// default context menu return RV_HANDLED.
|
||||
// Called on the UI thread before a context menu is displayed. To cancel
|
||||
// display of the default context menu return RV_HANDLED.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
||||
const MenuInfo& menuInfo) =0;
|
||||
@ -713,15 +726,15 @@ public:
|
||||
// Supported menu ID values.
|
||||
typedef cef_handler_menuid_t MenuId;
|
||||
|
||||
// Event called to optionally override the default text for a context menu
|
||||
// item. |label| contains the default text and may be modified to substitute
|
||||
// alternate text. The return value is currently ignored.
|
||||
// Called on the UI thread to optionally override the default text for a
|
||||
// context menu item. |label| contains the default text and may be modified to
|
||||
// substitute alternate text. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId, CefString& label) =0;
|
||||
|
||||
// Event called when an option is selected from the default context menu.
|
||||
// Return RV_HANDLED to cancel default handling of the action.
|
||||
// Called on the UI thread when an option is selected from the default context
|
||||
// menu. Return RV_HANDLED to cancel default handling of the action.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId) =0;
|
||||
@ -729,25 +742,25 @@ public:
|
||||
// Structure representing print options.
|
||||
typedef cef_print_options_t CefPrintOptions;
|
||||
|
||||
// Event called to allow customization of standard print options before the
|
||||
// print dialog is displayed. |printOptions| allows specification of paper
|
||||
// size, orientation and margins. Note that the specified margins may be
|
||||
// adjusted if they are outside the range supported by the printer. All units
|
||||
// are in inches. Return RV_CONTINUE to display the default print options or
|
||||
// RV_HANDLED to display the modified |printOptions|.
|
||||
// Called on the UI thread to allow customization of standard print options
|
||||
// before the print dialog is displayed. |printOptions| allows specification
|
||||
// of paper size, orientation and margins. Note that the specified margins may
|
||||
// be adjusted if they are outside the range supported by the printer. All
|
||||
// units are in inches. Return RV_CONTINUE to display the default print
|
||||
// options or RV_HANDLED to display the modified |printOptions|.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandlePrintOptions(CefRefPtr<CefBrowser> browser,
|
||||
CefPrintOptions& printOptions) = 0;
|
||||
|
||||
// Event called to format print headers and footers. |printInfo| contains
|
||||
// platform-specific information about the printer context. |url| is the
|
||||
// URL if the currently printing page, |title| is the title of the currently
|
||||
// printing page, |currentPage| is the current page number and |maxPages| is
|
||||
// the total number of pages. Six default header locations are provided
|
||||
// by the implementation: top left, top center, top right, bottom left,
|
||||
// bottom center and bottom right. To use one of these default locations
|
||||
// just assign a string to the appropriate variable. To draw the header
|
||||
// and footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
||||
// Called on the UI thread to format print headers and footers. |printInfo|
|
||||
// contains platform-specific information about the printer context. |url| is
|
||||
// the URL if the currently printing page, |title| is the title of the
|
||||
// currently printing page, |currentPage| is the current page number and
|
||||
// |maxPages| is the total number of pages. Six default header locations are
|
||||
// provided by the implementation: top left, top center, top right, bottom
|
||||
// left, bottom center and bottom right. To use one of these default locations
|
||||
// just assign a string to the appropriate variable. To draw the header and
|
||||
// footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
||||
// variables and return RV_CONTINUE.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
@ -763,25 +776,26 @@ public:
|
||||
CefString& bottomCenter,
|
||||
CefString& bottomRight) =0;
|
||||
|
||||
// Run a JS alert message. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert.
|
||||
// Called on the UI thread to run a JS alert message. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& message) =0;
|
||||
|
||||
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
||||
// set |retval| to true if the user accepted the confirmation.
|
||||
// Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert. If
|
||||
// you handled the alert set |retval| to true if the user accepted the
|
||||
// confirmation.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& message, bool& retval) =0;
|
||||
|
||||
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
||||
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
||||
// set |retval| to true if the user accepted the prompt and request and
|
||||
// |result| to the resulting value.
|
||||
// Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to
|
||||
// display the default prompt or RV_HANDLED if you displayed a custom prompt.
|
||||
// If you handled the prompt set |retval| to true if the user accepted the
|
||||
// prompt and request and |result| to the resulting value.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
@ -790,29 +804,29 @@ public:
|
||||
bool& retval,
|
||||
CefString& result) =0;
|
||||
|
||||
// Event called for adding values to a frame's JavaScript 'window' object. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread for adding values to a frame's JavaScript 'window'
|
||||
// object. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object) =0;
|
||||
|
||||
// Called just before a window is closed. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread just before a window is closed. The return value is
|
||||
// currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser) =0;
|
||||
|
||||
// Called when the browser component is about to loose focus. For instance,
|
||||
// if focus was on the last HTML element and the user pressed the TAB key.
|
||||
// The return value is currently ignored.
|
||||
// Called on the UI thread when the browser component is about to loose focus.
|
||||
// For instance, if focus was on the last HTML element and the user pressed
|
||||
// the TAB key. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
|
||||
bool reverse) =0;
|
||||
|
||||
// Called when the browser component is requesting focus. |isWidget| will be
|
||||
// true if the focus is requested for a child widget of the browser window.
|
||||
// Return RV_CONTINUE to allow the focus to be set or RV_HANDLED to cancel
|
||||
// setting the focus.
|
||||
// Called on the UI thread when the browser component is requesting focus.
|
||||
// |isWidget| will be true if the focus is requested for a child widget of the
|
||||
// browser window. Return RV_CONTINUE to allow the focus to be set or
|
||||
// RV_HANDLED to cancel setting the focus.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser,
|
||||
bool isWidget) =0;
|
||||
@ -820,14 +834,14 @@ public:
|
||||
// Supported keyboard event types.
|
||||
typedef cef_handler_keyevent_type_t KeyEventType;
|
||||
|
||||
// Called when the browser component receives a keyboard event.
|
||||
// |type| is the type of keyboard event (see |KeyEventType|).
|
||||
// |code| is the windows scan-code for the event.
|
||||
// |modifiers| is a set of bit-flags describing any pressed modifier keys.
|
||||
// |isSystemKey| is set if Windows considers this a 'system key' message;
|
||||
// (see http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx)
|
||||
// Return RV_HANDLED if the keyboard event was handled or RV_CONTINUE
|
||||
// to allow the browser component to handle the event.
|
||||
// Called on the UI thread when the browser component receives a keyboard
|
||||
// event. |type| is the type of keyboard event, |code| is the windows scan-
|
||||
// code for the event, |modifiers| is a set of bit-flags describing any
|
||||
// pressed modifier keys and |isSystemKey| is true if Windows considers this a
|
||||
// 'system key' message (see
|
||||
// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return
|
||||
// RV_HANDLED if the keyboard event was handled or RV_CONTINUE to allow the
|
||||
// browser component to handle the event.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
KeyEventType type,
|
||||
@ -835,11 +849,11 @@ public:
|
||||
int modifiers,
|
||||
bool isSystemKey) =0;
|
||||
|
||||
// Event called when the browser is about to display a tooltip. |text|
|
||||
// contains the text that will be displayed in the tooltip. To handle
|
||||
// the display of the tooltip yourself return RV_HANDLED. Otherwise,
|
||||
// you can optionally modify |text| and then return RV_CONTINUE to allow
|
||||
// the browser to display the tooltip.
|
||||
// Called on the UI thread when the browser is about to display a tooltip.
|
||||
// |text| contains the text that will be displayed in the tooltip. To handle
|
||||
// the display of the tooltip yourself return RV_HANDLED. Otherwise, you can
|
||||
// optionally modify |text| and then return RV_CONTINUE to allow the browser
|
||||
// to display the tooltip.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
|
||||
CefString& text) =0;
|
||||
@ -847,27 +861,28 @@ public:
|
||||
// Status message types.
|
||||
typedef cef_handler_statustype_t StatusType;
|
||||
|
||||
// Event called when the browser has a status message. |text| contains the
|
||||
// text that will be displayed in the status message and |type| indicates the
|
||||
// status message type. The return value is currently ignored.
|
||||
// Called on the UI thread when the browser has a status message. |text|
|
||||
// contains the text that will be displayed in the status message and |type|
|
||||
// indicates the status message type. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleStatus(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& value,
|
||||
StatusType type) =0;
|
||||
|
||||
// Called to display a console message. Return RV_HANDLED to stop the message
|
||||
// from being output to the console.
|
||||
// Called on the UI thread to display a console message. Return RV_HANDLED to
|
||||
// stop the message from being output to the console.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message,
|
||||
const CefString& source, int line) =0;
|
||||
|
||||
// Called to report find results returned by CefBrowser::Find(). |identifer|
|
||||
// is the identifier passed to CefBrowser::Find(), |count| is the number of
|
||||
// matches currently identified, |selectionRect| is the location of where the
|
||||
// match was found (in window coordinates), |activeMatchOrdinal| is the
|
||||
// current position in the search results, and |finalUpdate| is true if this
|
||||
// is the last find notification. The return value is currently ignored.
|
||||
// Called on the UI thread to report find results returned by
|
||||
// CefBrowser::Find(). |identifer| is the identifier passed to
|
||||
// CefBrowser::Find(), |count| is the number of matches currently identified,
|
||||
// |selectionRect| is the location of where the match was found (in window
|
||||
// coordinates), |activeMatchOrdinal| is the current position in the search
|
||||
// results, and |finalUpdate| is true if this is the last find notification.
|
||||
// The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
virtual RetVal HandleFindResult(CefRefPtr<CefBrowser> browser,
|
||||
int identifier, int count,
|
||||
@ -876,7 +891,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent a web request.
|
||||
// Class used to represent a web request. The methods of this class may be
|
||||
// called on any thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefRequest : public CefBase
|
||||
{
|
||||
@ -921,7 +937,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent post data for a web request.
|
||||
// Class used to represent post data for a web request. The methods of this
|
||||
// class may be called on any thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefPostData : public CefBase
|
||||
{
|
||||
@ -955,7 +972,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent a single element in the request post data.
|
||||
// Class used to represent a single element in the request post data. The
|
||||
// methods of this class may be called on any thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefPostDataElement : public CefBase
|
||||
{
|
||||
@ -999,7 +1017,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Interface the client can implement to provide a custom stream reader.
|
||||
// Interface the client can implement to provide a custom stream reader. The
|
||||
// methods of this class may be called on any thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefReadHandler : public CefBase
|
||||
{
|
||||
@ -1023,7 +1042,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to read data from a stream.
|
||||
// Class used to read data from a stream. The methods of this class may be
|
||||
// called on any thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefStreamReader : public CefBase
|
||||
{
|
||||
@ -1034,7 +1054,8 @@ public:
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefStreamReader> CreateForData(void* data, size_t size);
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefStreamReader> CreateForHandler(CefRefPtr<CefReadHandler> handler);
|
||||
static CefRefPtr<CefStreamReader> CreateForHandler(
|
||||
CefRefPtr<CefReadHandler> handler);
|
||||
|
||||
// Read raw binary data.
|
||||
/*--cef()--*/
|
||||
@ -1056,7 +1077,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Interface the client can implement to provide a custom stream writer.
|
||||
// Interface the client can implement to provide a custom stream writer. The
|
||||
// methods of this class may be called on any thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefWriteHandler : public CefBase
|
||||
{
|
||||
@ -1080,7 +1102,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to write data to a stream.
|
||||
// Class used to write data to a stream. The methods of this class may be called
|
||||
// on any thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefStreamWriter : public CefBase
|
||||
{
|
||||
@ -1089,7 +1112,8 @@ public:
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefStreamWriter> CreateForFile(const CefString& fileName);
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefStreamWriter> CreateForHandler(CefRefPtr<CefWriteHandler> handler);
|
||||
static CefRefPtr<CefStreamWriter> CreateForHandler(
|
||||
CefRefPtr<CefWriteHandler> handler);
|
||||
|
||||
// Write raw binary data.
|
||||
/*--cef()--*/
|
||||
@ -1112,7 +1136,8 @@ public:
|
||||
|
||||
typedef std::vector<CefRefPtr<CefV8Value> > CefV8ValueList;
|
||||
|
||||
// Interface that should be implemented to handle V8 function calls.
|
||||
// Interface that should be implemented to handle V8 function calls. The methods
|
||||
// of this class will always be called on the UI thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefV8Handler : public CefBase
|
||||
{
|
||||
@ -1128,7 +1153,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class representing a V8 value.
|
||||
// Class representing a V8 value. The methods of this class should only be
|
||||
// called on the UI thread.
|
||||
/*--cef(source=library)--*/
|
||||
class CefV8Value : public CefBase
|
||||
{
|
||||
@ -1254,7 +1280,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class that creates CefSchemeHandler instances.
|
||||
// Class that creates CefSchemeHandler instances. The methods of this class will
|
||||
// always be called on the IO thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefSchemeHandlerFactory : public CefBase
|
||||
{
|
||||
@ -1265,7 +1292,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to represent a custom scheme handler interface.
|
||||
// Class used to represent a custom scheme handler interface. The methods of
|
||||
// this class will always be called on the IO thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefSchemeHandler : public CefBase
|
||||
{
|
||||
@ -1296,7 +1324,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Class used to handle file downloads.
|
||||
// Class used to handle file downloads. The methods of this class will always be
|
||||
// called on the UI thread.
|
||||
/*--cef(source=client)--*/
|
||||
class CefDownloadHandler : public CefBase
|
||||
{
|
||||
@ -1314,6 +1343,8 @@ public:
|
||||
|
||||
|
||||
// Class that supports the reading of XML data via the libxml streaming API.
|
||||
// The methods of this class should only be called on the thread that creates
|
||||
// the object.
|
||||
/*--cef(source=library)--*/
|
||||
class CefXmlReader : public CefBase
|
||||
{
|
||||
@ -1476,6 +1507,8 @@ public:
|
||||
|
||||
|
||||
// Class that supports the reading of zip archives via the zlib unzip API.
|
||||
// The methods of this class should only be called on the thread that creates
|
||||
// the object.
|
||||
/*--cef(source=library)--*/
|
||||
class CefZipReader : public CefBase
|
||||
{
|
||||
|
@ -48,24 +48,26 @@ extern "C" {
|
||||
#include "cef_types.h"
|
||||
|
||||
|
||||
// This function should be called once when the application is started to
|
||||
// initialize CEF. A return value of true (1) indicates that it succeeded and
|
||||
// false (0) indicates that it failed.
|
||||
// This function should be called on the main application thread to initialize
|
||||
// CEF when the application is started. A return value of true (1) indicates
|
||||
// that it succeeded and false (0) indicates that it failed.
|
||||
CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings,
|
||||
const struct _cef_browser_settings_t* browser_defaults);
|
||||
|
||||
// This function should be called once before the application exits to shut down
|
||||
// CEF.
|
||||
// This function should be called on the main application thread to shut down
|
||||
// CEF before the application exits.
|
||||
CEF_EXPORT void cef_shutdown();
|
||||
|
||||
// Perform message loop processing. Has no affect if the browser UI loop is
|
||||
// running in a separate thread.
|
||||
// Perform message loop processing. This function must be called on the main
|
||||
// application thread if cef_initialize() is called with a
|
||||
// CefSettings.multi_threaded_message_loop value of false (0).
|
||||
CEF_EXPORT void cef_do_message_loop_work();
|
||||
|
||||
// Register a new V8 extension with the specified JavaScript extension code and
|
||||
// handler. Functions implemented by the handler are prototyped using the
|
||||
// keyword 'native'. The calling of a native function is restricted to the scope
|
||||
// in which the prototype of the native function is defined.
|
||||
// in which the prototype of the native function is defined. This function may
|
||||
// be called on any thread.
|
||||
//
|
||||
// Example JavaScript extension code:
|
||||
//
|
||||
@ -124,7 +126,8 @@ CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
|
||||
// Register a custom scheme handler factory for the specified |scheme_name| and
|
||||
// |host_name|. All URLs beginning with scheme_name://host_name/ can be handled
|
||||
// by cef_scheme_handler_t instances returned by the factory. Specify an NULL
|
||||
// |host_name| value to match all host names.
|
||||
// |host_name| value to match all host names. This function may be called on any
|
||||
// thread.
|
||||
CEF_EXPORT int cef_register_scheme(const cef_string_t* scheme_name,
|
||||
const cef_string_t* host_name,
|
||||
struct _cef_scheme_handler_factory_t* factory);
|
||||
@ -132,18 +135,20 @@ CEF_EXPORT int cef_register_scheme(const cef_string_t* scheme_name,
|
||||
// CEF maintains multiple internal threads that are used for handling different
|
||||
// types of tasks. The UI thread creates the browser window and is used for all
|
||||
// interaction with the WebKit rendering engine and V8 JavaScript engine (The UI
|
||||
// thread will be the same as the main application thread if cef_initialize()
|
||||
// was called with a |multi_threaded_message_loop| value of false (0).) The IO
|
||||
// thread is used for handling schema and network requests. The FILE thread is
|
||||
// used for the application cache and other miscellaneous activities. This
|
||||
// function will return true (1) if called on the specified thread.
|
||||
// thread will be the same as the main application thread if cef_initialize() is
|
||||
// called with a CefSettings.multi_threaded_message_loop value of false (0).)
|
||||
// The IO thread is used for handling schema and network requests. The FILE
|
||||
// thread is used for the application cache and other miscellaneous activities.
|
||||
// This function will return true (1) if called on the specified thread.
|
||||
CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId);
|
||||
|
||||
// Post a task for execution on the specified thread.
|
||||
// Post a task for execution on the specified thread. This function may be
|
||||
// called on any thread.
|
||||
CEF_EXPORT int cef_post_task(cef_thread_id_t threadId,
|
||||
struct _cef_task_t* task);
|
||||
|
||||
// Post a task for delayed execution on the specified thread.
|
||||
// Post a task for delayed execution on the specified thread. This function may
|
||||
// be called on any thread.
|
||||
CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId,
|
||||
struct _cef_task_t* task, long delay_ms);
|
||||
|
||||
@ -171,7 +176,8 @@ typedef struct _cef_base_t
|
||||
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
||||
|
||||
|
||||
// Implement this structure for task execution.
|
||||
// Implement this structure for task execution. The functions of this structure
|
||||
// may be called on any thread.
|
||||
typedef struct _cef_task_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -184,8 +190,8 @@ typedef struct _cef_task_t
|
||||
} cef_task_t;
|
||||
|
||||
|
||||
// Structure used to represent a browser window. All functions exposed by this
|
||||
// structure should be thread safe.
|
||||
// Structure used to represent a browser window. The functions of this structure
|
||||
// may be called on any thread unless otherwise indicated in the comments.
|
||||
typedef struct _cef_browser_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -212,8 +218,8 @@ typedef struct _cef_browser_t
|
||||
// Stop loading the page.
|
||||
void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self);
|
||||
|
||||
// Set focus for the browser window. If |enable| is true (1) focus will be
|
||||
// set to the window. Otherwise, focus will be removed.
|
||||
// Set focus for the browser window. If |enable| is true (1) focus will be set
|
||||
// to the window. Otherwise, focus will be removed.
|
||||
void (CEF_CALLBACK *set_focus)(struct _cef_browser_t* self, int enable);
|
||||
|
||||
// Retrieve the window handle for this browser.
|
||||
@ -231,15 +237,18 @@ typedef struct _cef_browser_t
|
||||
struct _cef_frame_t* (CEF_CALLBACK *get_main_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
// Returns the focused frame for the browser window.
|
||||
// Returns the focused frame for the browser window. This function should only
|
||||
// be called on the UI thread.
|
||||
struct _cef_frame_t* (CEF_CALLBACK *get_focused_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
// Returns the frame with the specified name, or NULL if not found.
|
||||
// Returns the frame with the specified name, or NULL if not found. This
|
||||
// function should only be called on the UI thread.
|
||||
struct _cef_frame_t* (CEF_CALLBACK *get_frame)(struct _cef_browser_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
// Returns the names of all existing frames.
|
||||
// Returns the names of all existing frames. This function should only be
|
||||
// called on the UI thread.
|
||||
void (CEF_CALLBACK *get_frame_names)(struct _cef_browser_t* self,
|
||||
cef_string_list_t names);
|
||||
|
||||
@ -275,21 +284,21 @@ typedef struct _cef_browser_t
|
||||
|
||||
// Create a new browser window using the window parameters specified by
|
||||
// |windowInfo|. All values will be copied internally and the actual window will
|
||||
// be created on the UI thread. The |popup| parameter should be true (1) if the
|
||||
// be created on the UI thread. The |popup| parameter should be true (1) if the
|
||||
// new window is a popup window. This function call will not block.
|
||||
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup,
|
||||
struct _cef_handler_t* handler, const cef_string_t* url);
|
||||
|
||||
// Create a new browser window using the window parameters specified by
|
||||
// |windowInfo|. The |popup| parameter should be true (1) if the new window is a
|
||||
// popup window. This function call will block and can only be used if the
|
||||
// |multi_threaded_message_loop| parameter to cef_initialize() is false (0).
|
||||
// popup window. This function should only be called on the UI thread.
|
||||
CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo,
|
||||
int popup, struct _cef_handler_t* handler, const cef_string_t* url);
|
||||
|
||||
|
||||
// Structure used to represent a frame in the browser window. All functions
|
||||
// exposed by this structure should be thread safe.
|
||||
// Structure used to represent a frame in the browser window. The functions of
|
||||
// this structure may be called on any thread unless otherwise indicated in the
|
||||
// comments.
|
||||
typedef struct _cef_frame_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -324,11 +333,13 @@ typedef struct _cef_frame_t
|
||||
// default text viewing application.
|
||||
void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self);
|
||||
|
||||
// Returns this frame's HTML source as a string.
|
||||
// Returns this frame's HTML source as a string. This function should only be
|
||||
// called on the UI thread.
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_source)(struct _cef_frame_t* self);
|
||||
|
||||
// Returns this frame's display text as a string.
|
||||
// Returns this frame's display text as a string. This function should only be
|
||||
// called on the UI thread.
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_text)(struct _cef_frame_t* self);
|
||||
|
||||
@ -360,14 +371,16 @@ typedef struct _cef_frame_t
|
||||
// Returns true (1) if this is the main frame.
|
||||
int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self);
|
||||
|
||||
// Returns true (1) if this is the focused frame.
|
||||
// Returns true (1) if this is the focused frame. This function should only be
|
||||
// called on the UI thread.
|
||||
int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self);
|
||||
|
||||
// Returns this frame's name.
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
|
||||
|
||||
// Return the URL currently loaded in this frame.
|
||||
// Return the URL currently loaded in this frame. This function should only be
|
||||
// called on the UI thread.
|
||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||
cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);
|
||||
|
||||
@ -375,22 +388,22 @@ typedef struct _cef_frame_t
|
||||
|
||||
|
||||
// Structure that should be implemented to handle events generated by the
|
||||
// browser window. All functions exposed by this structure should be thread
|
||||
// safe. Each function in the structure returns a RetVal value.
|
||||
// browser window. The functions of this structure will be called on the thread
|
||||
// indicated in the function comments.
|
||||
typedef struct _cef_handler_t
|
||||
{
|
||||
// Base structure.
|
||||
cef_base_t base;
|
||||
|
||||
// Event called before a new window is created. The |parentBrowser| parameter
|
||||
// will point to the parent browser window, if any. The |popup| parameter will
|
||||
// be true (1) if the new window is a popup window, in which case
|
||||
// |popupFeatures| will contain information about the style of popup window
|
||||
// requested. If you create the window yourself you should populate the window
|
||||
// handle member of |createInfo| and return RV_HANDLED. Otherwise, return
|
||||
// RV_CONTINUE and the framework will create the window. By default, a newly
|
||||
// created window will recieve the same handler as the parent window. To
|
||||
// change the handler for the new window modify the object that |handler|
|
||||
// Called on the UI thread before a new window is created. The |parentBrowser|
|
||||
// parameter will point to the parent browser window, if any. The |popup|
|
||||
// parameter will be true (1) if the new window is a popup window, in which
|
||||
// case |popupFeatures| will contain information about the style of popup
|
||||
// window requested. If you create the window yourself you should populate the
|
||||
// window handle member of |createInfo| and return RV_HANDLED. Otherwise,
|
||||
// return RV_CONTINUE and the framework will create the window. By default, a
|
||||
// newly created window will recieve the same handler as the parent window.
|
||||
// To change the handler for the new window modify the object that |handler|
|
||||
// points to.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_before_created)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* parentBrowser,
|
||||
@ -399,148 +412,149 @@ typedef struct _cef_handler_t
|
||||
struct _cef_handler_t** handler, cef_string_t* url,
|
||||
struct _cef_browser_settings_t* settings);
|
||||
|
||||
// Event called after a new window is created. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread after a new window is created. The return value is
|
||||
// currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_after_created)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser);
|
||||
|
||||
// Event called when a frame's address has changed. The return value is
|
||||
// currently ignored.
|
||||
// Called on the UI thread when a frame's address has changed. The return
|
||||
// value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_address_change)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, const cef_string_t* url);
|
||||
|
||||
// Event called when the page title changes. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread when the page title changes. The return value is
|
||||
// currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_title_change)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
const cef_string_t* title);
|
||||
|
||||
// Event called before browser navigation. The client has an opportunity to
|
||||
// modify the |request| object if desired. Return RV_HANDLED to cancel
|
||||
// navigation.
|
||||
// Called on the UI thread before browser navigation. The client has an
|
||||
// opportunity to modify the |request| object if desired. Return RV_HANDLED
|
||||
// to cancel navigation.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_before_browse)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, struct _cef_request_t* request,
|
||||
enum cef_handler_navtype_t navType, int isRedirect);
|
||||
|
||||
// Event called when the browser begins loading a page. The |frame| pointer
|
||||
// will be NULL if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true (1) if
|
||||
// this load is for the main content area and not an iframe. This function may
|
||||
// not be called if the load request fails. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread when the browser begins loading a page. The |frame|
|
||||
// pointer will be NULL if the event represents the overall load status and
|
||||
// not the load status for a particular frame. |isMainContent| will be true
|
||||
// (1) if this load is for the main content area and not an iframe. This
|
||||
// function may not be called if the load request fails. The return value is
|
||||
// currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_load_start)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, int isMainContent);
|
||||
|
||||
// Event called when the browser is done loading a page. The |frame| pointer
|
||||
// will be NULL if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true (1) if
|
||||
// this load is for the main content area and not an iframe. This function
|
||||
// will be called irrespective of whether the request completes successfully.
|
||||
// The return value is currently ignored.
|
||||
// Called on the UI thread when the browser is done loading a page. The
|
||||
// |frame| pointer will be NULL if the event represents the overall load
|
||||
// status and not the load status for a particular frame. |isMainContent| will
|
||||
// be true (1) if this load is for the main content area and not an iframe.
|
||||
// This function will be called irrespective of whether the request completes
|
||||
// successfully. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_load_end)(struct _cef_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
int isMainContent, int httpStatusCode);
|
||||
|
||||
// Called when the browser fails to load a resource. |errorCode| is the error
|
||||
// code number and |failedUrl| is the URL that failed to load. To provide
|
||||
// custom error text assign the text to |errorText| and return RV_HANDLED.
|
||||
// Otherwise, return RV_CONTINUE for the default error text.
|
||||
// Called on the UI thread when the browser fails to load a resource.
|
||||
// |errorCode| is the error code number and |failedUrl| is the URL that failed
|
||||
// to load. To provide custom error text assign the text to |errorText| and
|
||||
// return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error
|
||||
// text.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_load_error)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, enum cef_handler_errorcode_t errorCode,
|
||||
const cef_string_t* failedUrl, cef_string_t* errorText);
|
||||
|
||||
// Event called before a resource is loaded. To allow the resource to load
|
||||
// normally return RV_CONTINUE. To redirect the resource to a new url populate
|
||||
// the |redirectUrl| value and return RV_CONTINUE. To specify data for the
|
||||
// resource return a CefStream object in |resourceStream|, set |mimeType| to
|
||||
// the resource stream's mime type, and return RV_CONTINUE. To cancel loading
|
||||
// of the resource return RV_HANDLED. Any modifications to |request| will be
|
||||
// observed. If the URL in |request| is changed and |redirectUrl| is also
|
||||
// set, the URL in |request| will be used.
|
||||
// Called on the IO thread before a resource is loaded. To allow the resource
|
||||
// to load normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
// populate the |redirectUrl| value and return RV_CONTINUE. To specify data
|
||||
// for the resource return a CefStream object in |resourceStream|, set
|
||||
// |mimeType| to the resource stream's mime type, and return RV_CONTINUE. To
|
||||
// cancel loading of the resource return RV_HANDLED. Any modifications to
|
||||
// |request| will be observed. If the URL in |request| is changed and
|
||||
// |redirectUrl| is also set, the URL in |request| will be used.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_before_resource_load)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_request_t* request, cef_string_t* redirectUrl,
|
||||
struct _cef_stream_reader_t** resourceStream, cef_string_t* mimeType,
|
||||
int loadFlags);
|
||||
|
||||
// Called to handle requests for URLs with an unknown protocol component.
|
||||
// Return RV_HANDLED to indicate that the request should succeed because it
|
||||
// was externally handled. Set |allow_os_execution| to true (1) and return
|
||||
// RV_CONTINUE to attempt execution via the registered OS protocol handler, if
|
||||
// any. If RV_CONTINUE is returned and either |allow_os_execution| is false
|
||||
// (0) or OS protocol handler execution fails then the request will fail with
|
||||
// an error condition. SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE
|
||||
// RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS
|
||||
// EXECUTION.
|
||||
// Called on the IO thread to handle requests for URLs with an unknown
|
||||
// protocol component. Return RV_HANDLED to indicate that the request should
|
||||
// succeed because it was externally handled. Set |allow_os_execution| to true
|
||||
// (1) and return RV_CONTINUE to attempt execution via the registered OS
|
||||
// protocol handler, if any. If RV_CONTINUE is returned and either
|
||||
// |allow_os_execution| is false (0) or OS protocol handler execution fails
|
||||
// then the request will fail with an error condition. SECURITY WARNING: YOU
|
||||
// SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR
|
||||
// OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_protocol_execution)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
const cef_string_t* url, int* allow_os_execution);
|
||||
|
||||
// Called when a server indicates via the 'Content-Disposition' header that a
|
||||
// response represents a file to download. |mimeType| is the mime type for the
|
||||
// download, |fileName| is the suggested target file name and |contentLength|
|
||||
// is either the value of the 'Content-Size' header or -1 if no size was
|
||||
// provided. Set |handler| to the cef_download_handler_t instance that will
|
||||
// recieve the file contents. Return RV_CONTINUE to download the file or
|
||||
// RV_HANDLED to cancel the file download.
|
||||
// Called on the UI thread when a server indicates via the 'Content-
|
||||
// Disposition' header that a response represents a file to download.
|
||||
// |mimeType| is the mime type for the download, |fileName| is the suggested
|
||||
// target file name and |contentLength| is either the value of the 'Content-
|
||||
// Size' header or -1 if no size was provided. Set |handler| to the
|
||||
// cef_download_handler_t instance that will recieve the file contents. Return
|
||||
// RV_CONTINUE to download the file or RV_HANDLED to cancel the file download.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_download_response)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
const cef_string_t* mimeType, const cef_string_t* fileName,
|
||||
int64 contentLength, struct _cef_download_handler_t** handler);
|
||||
|
||||
// Called when the browser needs credentials from the user. |isProxy|
|
||||
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||
// Called on the IO thread when the browser needs credentials from the user.
|
||||
// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
// hostname and port number. Set |username| and |password| and return
|
||||
// RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_authentication_request)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser, int isProxy,
|
||||
const cef_string_t* host, const cef_string_t* realm,
|
||||
const cef_string_t* scheme, cef_string_t* username,
|
||||
cef_string_t* password);
|
||||
|
||||
// Event called before a context menu is displayed. To cancel display of the
|
||||
// default context menu return RV_HANDLED.
|
||||
// Called on the UI thread before a context menu is displayed. To cancel
|
||||
// display of the default context menu return RV_HANDLED.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_before_menu)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
const struct _cef_handler_menuinfo_t* menuInfo);
|
||||
|
||||
// Event called to optionally override the default text for a context menu
|
||||
// item. |label| contains the default text and may be modified to substitute
|
||||
// alternate text. The return value is currently ignored.
|
||||
// Called on the UI thread to optionally override the default text for a
|
||||
// context menu item. |label| contains the default text and may be modified to
|
||||
// substitute alternate text. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_get_menu_label)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
enum cef_handler_menuid_t menuId, cef_string_t* label);
|
||||
|
||||
// Event called when an option is selected from the default context menu.
|
||||
// Return RV_HANDLED to cancel default handling of the action.
|
||||
// Called on the UI thread when an option is selected from the default context
|
||||
// menu. Return RV_HANDLED to cancel default handling of the action.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_menu_action)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
enum cef_handler_menuid_t menuId);
|
||||
|
||||
// Event called to allow customization of standard print options before the
|
||||
// print dialog is displayed. |printOptions| allows specification of paper
|
||||
// size, orientation and margins. Note that the specified margins may be
|
||||
// adjusted if they are outside the range supported by the printer. All units
|
||||
// are in inches. Return RV_CONTINUE to display the default print options or
|
||||
// RV_HANDLED to display the modified |printOptions|.
|
||||
// Called on the UI thread to allow customization of standard print options
|
||||
// before the print dialog is displayed. |printOptions| allows specification
|
||||
// of paper size, orientation and margins. Note that the specified margins may
|
||||
// be adjusted if they are outside the range supported by the printer. All
|
||||
// units are in inches. Return RV_CONTINUE to display the default print
|
||||
// options or RV_HANDLED to display the modified |printOptions|.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_print_options)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_print_options_t* printOptions);
|
||||
|
||||
// Event called to format print headers and footers. |printInfo| contains
|
||||
// platform-specific information about the printer context. |url| is the URL
|
||||
// if the currently printing page, |title| is the title of the currently
|
||||
// printing page, |currentPage| is the current page number and |maxPages| is
|
||||
// the total number of pages. Six default header locations are provided by
|
||||
// the implementation: top left, top center, top right, bottom left, bottom
|
||||
// center and bottom right. To use one of these default locations just assign
|
||||
// a string to the appropriate variable. To draw the header and footer
|
||||
// yourself return RV_HANDLED. Otherwise, populate the approprate variables
|
||||
// and return RV_CONTINUE.
|
||||
// Called on the UI thread to format print headers and footers. |printInfo|
|
||||
// contains platform-specific information about the printer context. |url| is
|
||||
// the URL if the currently printing page, |title| is the title of the
|
||||
// currently printing page, |currentPage| is the current page number and
|
||||
// |maxPages| is the total number of pages. Six default header locations are
|
||||
// provided by the implementation: top left, top center, top right, bottom
|
||||
// left, bottom center and bottom right. To use one of these default locations
|
||||
// just assign a string to the appropriate variable. To draw the header and
|
||||
// footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
||||
// variables and return RV_CONTINUE.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, struct _cef_print_info_t* printInfo,
|
||||
@ -549,95 +563,96 @@ typedef struct _cef_handler_t
|
||||
cef_string_t* topRight, cef_string_t* bottomLeft,
|
||||
cef_string_t* bottomCenter, cef_string_t* bottomRight);
|
||||
|
||||
// Run a JS alert message. Return RV_CONTINUE to display the default alert or
|
||||
// RV_HANDLED if you displayed a custom alert.
|
||||
// Called on the UI thread to run a JS alert message. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_jsalert)(struct _cef_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
const cef_string_t* message);
|
||||
|
||||
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
||||
// set |retval| to true (1) if the user accepted the confirmation.
|
||||
// Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert. If
|
||||
// you handled the alert set |retval| to true (1) if the user accepted the
|
||||
// confirmation.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, const cef_string_t* message, int* retval);
|
||||
|
||||
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
||||
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
||||
// set |retval| to true (1) if the user accepted the prompt and request and
|
||||
// |result| to the resulting value.
|
||||
// Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to
|
||||
// display the default prompt or RV_HANDLED if you displayed a custom prompt.
|
||||
// If you handled the prompt set |retval| to true (1) if the user accepted the
|
||||
// prompt and request and |result| to the resulting value.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)(struct _cef_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||
const cef_string_t* message, const cef_string_t* defaultValue,
|
||||
int* retval, cef_string_t* result);
|
||||
|
||||
// Event called for adding values to a frame's JavaScript 'window' object. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread for adding values to a frame's JavaScript 'window'
|
||||
// object. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_jsbinding)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, struct _cef_v8value_t* object);
|
||||
|
||||
// Called just before a window is closed. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread just before a window is closed. The return value is
|
||||
// currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_before_window_close)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser);
|
||||
|
||||
// Called when the browser component is about to loose focus. For instance, if
|
||||
// focus was on the last HTML element and the user pressed the TAB key. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread when the browser component is about to loose focus.
|
||||
// For instance, if focus was on the last HTML element and the user pressed
|
||||
// the TAB key. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_take_focus)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
int reverse);
|
||||
|
||||
// Called when the browser component is requesting focus. |isWidget| will be
|
||||
// true (1) if the focus is requested for a child widget of the browser
|
||||
// window. Return RV_CONTINUE to allow the focus to be set or RV_HANDLED to
|
||||
// cancel setting the focus.
|
||||
// Called on the UI thread when the browser component is requesting focus.
|
||||
// |isWidget| will be true (1) if the focus is requested for a child widget of
|
||||
// the browser window. Return RV_CONTINUE to allow the focus to be set or
|
||||
// RV_HANDLED to cancel setting the focus.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_set_focus)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
int isWidget);
|
||||
|
||||
// Called when the browser component receives a keyboard event. |type| is the
|
||||
// type of keyboard event (see |KeyEventType|). |code| is the windows scan-
|
||||
// code for the event. |modifiers| is a set of bit-flags describing any
|
||||
// pressed modifier keys. |isSystemKey| is set if Windows considers this a
|
||||
// 'system key' message;
|
||||
// (see http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx)
|
||||
// Return RV_HANDLED if the keyboard event was handled or RV_CONTINUE to allow
|
||||
// the browser component to handle the event.
|
||||
// Called on the UI thread when the browser component receives a keyboard
|
||||
// event. |type| is the type of keyboard event, |code| is the windows scan-
|
||||
// code for the event, |modifiers| is a set of bit-flags describing any
|
||||
// pressed modifier keys and |isSystemKey| is true (1) if Windows considers
|
||||
// this a 'system key' message (see http://msdn.microsoft.com/en-
|
||||
// us/library/ms646286(VS.85).aspx). Return RV_HANDLED if the keyboard event
|
||||
// was handled or RV_CONTINUE to allow the browser component to handle the
|
||||
// event.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_key_event)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
enum cef_handler_keyevent_type_t type, int code, int modifiers,
|
||||
int isSystemKey);
|
||||
|
||||
// Event called when the browser is about to display a tooltip. |text|
|
||||
// contains the text that will be displayed in the tooltip. To handle the
|
||||
// display of the tooltip yourself return RV_HANDLED. Otherwise, you can
|
||||
// Called on the UI thread when the browser is about to display a tooltip.
|
||||
// |text| contains the text that will be displayed in the tooltip. To handle
|
||||
// the display of the tooltip yourself return RV_HANDLED. Otherwise, you can
|
||||
// optionally modify |text| and then return RV_CONTINUE to allow the browser
|
||||
// to display the tooltip.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_tooltip)(struct _cef_handler_t* self,
|
||||
struct _cef_browser_t* browser, cef_string_t* text);
|
||||
|
||||
// Event called when the browser has a status message. |text| contains the
|
||||
// text that will be displayed in the status message and |type| indicates the
|
||||
// status message type. The return value is currently ignored.
|
||||
// Called on the UI thread when the browser has a status message. |text|
|
||||
// contains the text that will be displayed in the status message and |type|
|
||||
// indicates the status message type. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_status)(struct _cef_handler_t* self,
|
||||
struct _cef_browser_t* browser, const cef_string_t* value,
|
||||
enum cef_handler_statustype_t type);
|
||||
|
||||
// Called to display a console message. Return RV_HANDLED to stop the message
|
||||
// from being output to the console.
|
||||
// Called on the UI thread to display a console message. Return RV_HANDLED to
|
||||
// stop the message from being output to the console.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_console_message)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
const cef_string_t* message, const cef_string_t* source, int line);
|
||||
|
||||
// Called to report find results returned by cef_browser_t::find().
|
||||
// |identifer| is the identifier passed to cef_browser_t::find(), |count| is
|
||||
// the number of matches currently identified, |selectionRect| is the location
|
||||
// of where the match was found (in window coordinates), |activeMatchOrdinal|
|
||||
// is the current position in the search results, and |finalUpdate| is true
|
||||
// (1) if this is the last find notification. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread to report find results returned by
|
||||
// cef_browser_t::find(). |identifer| is the identifier passed to
|
||||
// cef_browser_t::find(), |count| is the number of matches currently
|
||||
// identified, |selectionRect| is the location of where the match was found
|
||||
// (in window coordinates), |activeMatchOrdinal| is the current position in
|
||||
// the search results, and |finalUpdate| is true (1) if this is the last find
|
||||
// notification. The return value is currently ignored.
|
||||
enum cef_retval_t (CEF_CALLBACK *handle_find_result)(
|
||||
struct _cef_handler_t* self, struct _cef_browser_t* browser,
|
||||
int identifier, int count, const cef_rect_t* selectionRect,
|
||||
@ -646,7 +661,8 @@ typedef struct _cef_handler_t
|
||||
} cef_handler_t;
|
||||
|
||||
|
||||
// Structure used to represent a web request.
|
||||
// Structure used to represent a web request. The functions of this structure
|
||||
// may be called on any thread.
|
||||
typedef struct _cef_request_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -689,7 +705,8 @@ typedef struct _cef_request_t
|
||||
CEF_EXPORT cef_request_t* cef_request_create();
|
||||
|
||||
|
||||
// Structure used to represent post data for a web request.
|
||||
// Structure used to represent post data for a web request. The functions of
|
||||
// this structure may be called on any thread.
|
||||
typedef struct _cef_post_data_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -721,7 +738,8 @@ typedef struct _cef_post_data_t
|
||||
CEF_EXPORT cef_post_data_t* cef_post_data_create();
|
||||
|
||||
|
||||
// Structure used to represent a single element in the request post data.
|
||||
// Structure used to represent a single element in the request post data. The
|
||||
// functions of this structure may be called on any thread.
|
||||
typedef struct _cef_post_data_element_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -763,7 +781,8 @@ typedef struct _cef_post_data_element_t
|
||||
CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create();
|
||||
|
||||
|
||||
// Structure the client can implement to provide a custom stream reader.
|
||||
// Structure the client can implement to provide a custom stream reader. The
|
||||
// functions of this structure may be called on any thread.
|
||||
typedef struct _cef_read_handler_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -787,7 +806,8 @@ typedef struct _cef_read_handler_t
|
||||
} cef_read_handler_t;
|
||||
|
||||
|
||||
// Structure used to read data from a stream.
|
||||
// Structure used to read data from a stream. The functions of this structure
|
||||
// may be called on any thread.
|
||||
typedef struct _cef_stream_reader_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -820,7 +840,8 @@ CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
|
||||
cef_read_handler_t* handler);
|
||||
|
||||
|
||||
// Structure the client can implement to provide a custom stream writer.
|
||||
// Structure the client can implement to provide a custom stream writer. The
|
||||
// functions of this structure may be called on any thread.
|
||||
typedef struct _cef_write_handler_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -844,7 +865,8 @@ typedef struct _cef_write_handler_t
|
||||
} cef_write_handler_t;
|
||||
|
||||
|
||||
// Structure used to write data to a stream.
|
||||
// Structure used to write data to a stream. The functions of this structure may
|
||||
// be called on any thread.
|
||||
typedef struct _cef_stream_writer_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -875,7 +897,8 @@ CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
|
||||
cef_write_handler_t* handler);
|
||||
|
||||
|
||||
// Structure that should be implemented to handle V8 function calls.
|
||||
// Structure that should be implemented to handle V8 function calls. The
|
||||
// functions of this structure will always be called on the UI thread.
|
||||
typedef struct _cef_v8handler_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -891,7 +914,8 @@ typedef struct _cef_v8handler_t
|
||||
} cef_v8handler_t;
|
||||
|
||||
|
||||
// Structure representing a V8 value.
|
||||
// Structure representing a V8 value. The functions of this structure should
|
||||
// only be called on the UI thread.
|
||||
typedef struct _cef_v8value_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -998,7 +1022,8 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
|
||||
cef_v8handler_t* handler);
|
||||
|
||||
|
||||
// Structure that creates cef_scheme_handler_t instances.
|
||||
// Structure that creates cef_scheme_handler_t instances. The functions of this
|
||||
// structure will always be called on the IO thread.
|
||||
typedef struct _cef_scheme_handler_factory_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -1011,7 +1036,8 @@ typedef struct _cef_scheme_handler_factory_t
|
||||
} cef_scheme_handler_factory_t;
|
||||
|
||||
|
||||
// Structure used to represent a custom scheme handler structure.
|
||||
// Structure used to represent a custom scheme handler structure. The functions
|
||||
// of this structure will always be called on the IO thread.
|
||||
typedef struct _cef_scheme_handler_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -1042,7 +1068,8 @@ typedef struct _cef_scheme_handler_t
|
||||
} cef_scheme_handler_t;
|
||||
|
||||
|
||||
// Structure used to handle file downloads.
|
||||
// Structure used to handle file downloads. The functions of this structure will
|
||||
// always be called on the UI thread.
|
||||
typedef struct _cef_download_handler_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -1061,6 +1088,8 @@ typedef struct _cef_download_handler_t
|
||||
|
||||
|
||||
// Structure that supports the reading of XML data via the libxml streaming API.
|
||||
// The functions of this structure should only be called on the thread that
|
||||
// creates the object.
|
||||
typedef struct _cef_xml_reader_t
|
||||
{
|
||||
// Base structure.
|
||||
@ -1222,6 +1251,8 @@ CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream,
|
||||
|
||||
|
||||
// Structure that supports the reading of zip archives via the zlib unzip API.
|
||||
// The functions of this structure should only be called on the thread that
|
||||
// creates the object.
|
||||
typedef struct _cef_zip_reader_t
|
||||
{
|
||||
// Base structure.
|
||||
|
@ -29,7 +29,7 @@ BrowserDevToolsClient::BrowserDevToolsClient(CefBrowserImpl* browser,
|
||||
: ALLOW_THIS_IN_INITIALIZER_LIST(call_method_factory_(this)),
|
||||
browser_(browser),
|
||||
dev_tools_agent_(agent),
|
||||
web_view_(browser->GetWebView()) {
|
||||
web_view_(browser->UIT_GetWebView()) {
|
||||
web_tools_frontend_.reset(WebDevToolsFrontend::create(web_view_, this,
|
||||
WebString::fromUTF8("en-US")));
|
||||
dev_tools_agent_->attach(this);
|
||||
|
@ -44,12 +44,95 @@ using WebKit::WebURL;
|
||||
using WebKit::WebURLRequest;
|
||||
using WebKit::WebView;
|
||||
|
||||
namespace {
|
||||
|
||||
class CreateBrowserHelper
|
||||
{
|
||||
public:
|
||||
CreateBrowserHelper(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler, const CefString& url)
|
||||
: window_info_(windowInfo), popup_(popup),
|
||||
handler_(handler), url_(url) {}
|
||||
|
||||
CefWindowInfo window_info_;
|
||||
bool popup_;
|
||||
CefRefPtr<CefHandler> handler_;
|
||||
CefString url_;
|
||||
};
|
||||
|
||||
void UIT_CreateBrowserWithHelper(CreateBrowserHelper* helper)
|
||||
{
|
||||
CefBrowser::CreateBrowserSync(helper->window_info_, helper->popup_,
|
||||
helper->handler_, helper->url_);
|
||||
delete helper;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler,
|
||||
const CefString& url)
|
||||
{
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the browser on the UI thread.
|
||||
CreateBrowserHelper* helper =
|
||||
new CreateBrowserHelper(windowInfo, popup, handler, url);
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableFunction(
|
||||
UIT_CreateBrowserWithHelper, helper));
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||
bool popup, CefRefPtr<CefHandler> handler, const CefString& url)
|
||||
{
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefString newUrl = url;
|
||||
CefRefPtr<CefBrowser> alternateBrowser;
|
||||
CefBrowserSettings settings(_Context->browser_defaults());
|
||||
|
||||
if(handler.get())
|
||||
{
|
||||
// Give the handler an opportunity to modify window attributes, handler,
|
||||
// or cancel the window creation.
|
||||
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
|
||||
popup, CefPopupFeatures(), handler, newUrl, settings);
|
||||
if(rv == RV_HANDLED)
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> browser(
|
||||
new CefBrowserImpl(windowInfo, settings, popup, handler));
|
||||
static_cast<CefBrowserImpl*>(browser.get())->UIT_CreateBrowser(newUrl);
|
||||
|
||||
return browser;
|
||||
}
|
||||
|
||||
|
||||
CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
|
||||
const CefBrowserSettings& settings, bool popup,
|
||||
CefRefPtr<CefHandler> handler)
|
||||
: window_info_(windowInfo), settings_(settings), is_popup_(popup),
|
||||
is_modal_(false), handler_(handler), webviewhost_(NULL), popuphost_(NULL),
|
||||
frame_main_(NULL), unique_id_(0)
|
||||
zoom_level_(0.0), can_go_back_(false), can_go_forward_(false),
|
||||
main_frame_(NULL), unique_id_(0)
|
||||
{
|
||||
delegate_.reset(new BrowserWebViewDelegate(this));
|
||||
popup_delegate_.reset(new BrowserWebViewDelegate(this));
|
||||
@ -62,69 +145,12 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CefBrowserImpl::CanGoBack()
|
||||
{
|
||||
if(!CefThread::CurrentlyOn(CefThread::UI))
|
||||
{
|
||||
// We need to send the request to the UI thread and wait for the result
|
||||
|
||||
// Event that will be used to signal that data is available. Start
|
||||
// in non-signaled mode so that the event will block.
|
||||
base::WaitableEvent event(false, false);
|
||||
|
||||
bool retVal = true;
|
||||
|
||||
// Request the data from the UI thread
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_CanGoBackNotify, &retVal, &event));
|
||||
|
||||
// Wait for the UI thread callback to tell us that the data is available
|
||||
event.Wait();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call the method directly
|
||||
return UIT_CanGoBack();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserImpl::GoBack()
|
||||
{
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_BACK));
|
||||
}
|
||||
|
||||
bool CefBrowserImpl::CanGoForward()
|
||||
{
|
||||
if(!CefThread::CurrentlyOn(CefThread::UI))
|
||||
{
|
||||
// We need to send the request to the UI thread and wait for the result
|
||||
|
||||
// Event that will be used to signal that data is available. Start
|
||||
// in non-signaled mode so that the event will block.
|
||||
base::WaitableEvent event(false, false);
|
||||
|
||||
bool retVal = true;
|
||||
|
||||
// Request the data from the UI thread
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_CanGoForwardNotify, &retVal, &event));
|
||||
|
||||
// Wait for the UI thread callback to tell us that the data is available
|
||||
event.Wait();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call the method directly
|
||||
return UIT_CanGoForward();
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserImpl::GoForward()
|
||||
{
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
@ -151,55 +177,53 @@ void CefBrowserImpl::StopLoad()
|
||||
|
||||
void CefBrowserImpl::SetFocus(bool enable)
|
||||
{
|
||||
if (CefThread::CurrentlyOn(CefThread::UI))
|
||||
{
|
||||
UIT_SetFocus(GetWebViewHost(), enable);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
UIT_SetFocus(UIT_GetWebViewHost(), enable);
|
||||
} else {
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_SetFocus, GetWebViewHost(), enable));
|
||||
&CefBrowserImpl::UIT_SetFocus, UIT_GetWebViewHost(), enable));
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserImpl::IsPopup()
|
||||
{
|
||||
Lock();
|
||||
bool popup = is_popup_;
|
||||
Unlock();
|
||||
return popup;
|
||||
}
|
||||
|
||||
CefRefPtr<CefHandler> CefBrowserImpl::GetHandler()
|
||||
{
|
||||
return handler_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetMainFrame()
|
||||
{
|
||||
return GetWebView() ? GetCefFrame(GetWebView()->mainFrame()) : NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame()
|
||||
{
|
||||
return GetWebView() ? GetCefFrame(GetWebView()->focusedFrame()) : NULL;
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WebView* view = UIT_GetWebView();
|
||||
return view ? UIT_GetCefFrame(view->focusedFrame()) : NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetFrame(const CefString& name)
|
||||
{
|
||||
WebView* view = GetWebView();
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return NULL;
|
||||
|
||||
WebFrame* frame = view->findFrameByName(string16(name));
|
||||
if(frame)
|
||||
return GetCefFrame(frame);
|
||||
return UIT_GetCefFrame(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::GetFrameNames(std::vector<CefString>& names)
|
||||
{
|
||||
WebView* view = GetWebView();
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
@ -234,6 +258,12 @@ void CefBrowserImpl::StopFinding(bool clearSelection)
|
||||
&CefBrowserImpl::UIT_StopFinding, clearSelection));
|
||||
}
|
||||
|
||||
void CefBrowserImpl::SetZoomLevel(double zoomLevel)
|
||||
{
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_SetZoomLevel, zoomLevel));
|
||||
}
|
||||
|
||||
void CefBrowserImpl::ShowDevTools()
|
||||
{
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
@ -246,63 +276,6 @@ void CefBrowserImpl::CloseDevTools()
|
||||
&CefBrowserImpl::UIT_CloseDevTools));
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(WebFrame* frame)
|
||||
{
|
||||
CefRefPtr<CefFrame> cef_frame;
|
||||
Lock();
|
||||
|
||||
WebView *view = GetWebView();
|
||||
if(view) {
|
||||
if(frame == view->mainFrame()) {
|
||||
// Use or create the single main frame reference.
|
||||
if(frame_main_ == NULL)
|
||||
frame_main_ = new CefFrameImpl(this, CefString());
|
||||
cef_frame = frame_main_;
|
||||
} else {
|
||||
// Locate or create the appropriate named reference.
|
||||
CefString name = string16(frame->name());
|
||||
DCHECK(!name.empty());
|
||||
FrameMap::const_iterator it = frames_.find(name);
|
||||
if(it != frames_.end())
|
||||
cef_frame = it->second;
|
||||
else {
|
||||
cef_frame = new CefFrameImpl(this, name);
|
||||
frames_.insert(std::make_pair(name, cef_frame.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Unlock();
|
||||
return cef_frame;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::RemoveCefFrame(const CefString& name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
if(name.empty())
|
||||
frame_main_ = NULL;
|
||||
else {
|
||||
FrameMap::iterator it = frames_.find(name);
|
||||
if(it != frames_.end())
|
||||
frames_.erase(it);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
WebFrame* CefBrowserImpl::GetWebFrame(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
WebView* view = GetWebView();
|
||||
if (!view)
|
||||
return NULL;
|
||||
|
||||
CefString name = frame->GetName();
|
||||
if(name.empty())
|
||||
return view ->mainFrame();
|
||||
return view ->findFrameByName(string16(name));
|
||||
}
|
||||
|
||||
void CefBrowserImpl::Undo(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
frame->AddRef();
|
||||
@ -369,70 +342,32 @@ void CefBrowserImpl::ViewSource(CefRefPtr<CefFrame> frame)
|
||||
|
||||
CefString CefBrowserImpl::GetSource(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
if(!CefThread::CurrentlyOn(CefThread::UI))
|
||||
{
|
||||
// We need to send the request to the UI thread and wait for the result
|
||||
|
||||
// Event that will be used to signal that data is available. Start
|
||||
// in non-signaled mode so that the event will block.
|
||||
base::WaitableEvent event(false, false);
|
||||
|
||||
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
||||
|
||||
// Request the data from the UI thread
|
||||
frame->AddRef();
|
||||
stream->AddRef();
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_GetDocumentStringNotify, frame.get(), stream.get(),
|
||||
&event));
|
||||
|
||||
// Wait for the UI thread callback to tell us that the data is available
|
||||
event.Wait();
|
||||
|
||||
return static_cast<CefBytesWriter*>(stream.get())->GetDataString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Retrieve the document string directly
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return string16(web_frame->contentAsMarkup());
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return CefString();
|
||||
}
|
||||
|
||||
// Retrieve the document string directly
|
||||
WebKit::WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return string16(web_frame->contentAsMarkup());
|
||||
return CefString();
|
||||
}
|
||||
|
||||
CefString CefBrowserImpl::GetText(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
if(!CefThread::CurrentlyOn(CefThread::UI))
|
||||
{
|
||||
// We need to send the request to the UI thread and wait for the result
|
||||
|
||||
// Event that will be used to signal that data is available. Start
|
||||
// in non-signaled mode so that the event will block.
|
||||
base::WaitableEvent event(false, false);
|
||||
|
||||
CefRefPtr<CefStreamWriter> stream(new CefBytesWriter(BUFFER_SIZE));
|
||||
|
||||
// Request the data from the UI thread
|
||||
frame->AddRef();
|
||||
stream->AddRef();
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_GetDocumentTextNotify, frame.get(), stream.get(),
|
||||
&event));
|
||||
|
||||
// Wait for the UI thread callback to tell us that the data is available
|
||||
event.Wait();
|
||||
|
||||
return static_cast<CefBytesWriter*>(stream.get())->GetDataString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Retrieve the document text directly
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return webkit_glue::DumpDocumentText(web_frame);
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return CefString();
|
||||
}
|
||||
|
||||
// Retrieve the document text directly
|
||||
WebKit::WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return webkit_glue::DumpDocumentText(web_frame);
|
||||
return CefString();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::LoadRequest(CefRefPtr<CefFrame> frame,
|
||||
@ -487,96 +422,107 @@ void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
|
||||
|
||||
CefString CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return CefString();
|
||||
}
|
||||
|
||||
WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
return std::string(web_frame->url().spec());
|
||||
return CefString();
|
||||
}
|
||||
|
||||
double CefBrowserImpl::GetZoomLevel()
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(const CefString& name)
|
||||
{
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(this->GetMainFrame());
|
||||
CefRefPtr<CefFrame> cef_frame;
|
||||
|
||||
if(web_frame && web_frame->view())
|
||||
return web_frame->view()->zoomLevel();
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::SetZoomLevel(double zoomLevel)
|
||||
{
|
||||
CefRefPtr<CefFrame> frame = this->GetMainFrame();
|
||||
frame->AddRef();
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||
&CefBrowserImpl::UIT_SetZoomLevel, frame.get(), zoomLevel));
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
|
||||
CefRefPtr<CefHandler> handler,
|
||||
const CefString& url)
|
||||
{
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
if(name.empty()) {
|
||||
// Use the single main frame reference.
|
||||
cef_frame = GetMainCefFrame();
|
||||
} else {
|
||||
// Locate or create the appropriate named reference.
|
||||
AutoLock lock_scope(this);
|
||||
FrameMap::const_iterator it = frames_.find(name);
|
||||
if(it != frames_.end())
|
||||
cef_frame = it->second;
|
||||
else {
|
||||
cef_frame = new CefFrameImpl(this, name);
|
||||
frames_.insert(std::make_pair(name, cef_frame.get()));
|
||||
}
|
||||
}
|
||||
|
||||
CefString newUrl = url;
|
||||
CefBrowserSettings settings(_Context->browser_defaults());
|
||||
|
||||
if(handler.get())
|
||||
{
|
||||
// Give the handler an opportunity to modify window attributes, handler,
|
||||
// or cancel the window creation.
|
||||
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
|
||||
popup, CefPopupFeatures(), handler, newUrl, settings);
|
||||
if(rv == RV_HANDLED)
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserImpl> browser(
|
||||
new CefBrowserImpl(windowInfo, settings, popup, handler));
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(browser.get(),
|
||||
&CefBrowserImpl::UIT_CreateBrowser, newUrl));
|
||||
return true;
|
||||
return cef_frame;
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
|
||||
bool popup, CefRefPtr<CefHandler> handler, const CefString& url)
|
||||
void CefBrowserImpl::RemoveCefFrame(const CefString& name)
|
||||
{
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED();
|
||||
AutoLock lock_scope(this);
|
||||
if(name.empty()) {
|
||||
// Clear the single main frame reference.
|
||||
main_frame_ = NULL;
|
||||
} else {
|
||||
// Remove the appropriate named reference.
|
||||
FrameMap::iterator it = frames_.find(name);
|
||||
if(it != frames_.end())
|
||||
frames_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::GetMainCefFrame()
|
||||
{
|
||||
// Return the single main frame reference.
|
||||
AutoLock lock_scope(this);
|
||||
if(main_frame_ == NULL)
|
||||
main_frame_ = new CefFrameImpl(this, CefString());
|
||||
return main_frame_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserImpl::UIT_GetCefFrame(WebFrame* frame)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
CefRefPtr<CefFrame> cef_frame;
|
||||
|
||||
WebView *view = UIT_GetWebView();
|
||||
if(view) {
|
||||
if(frame == view->mainFrame()) {
|
||||
// Use the single main frame reference.
|
||||
cef_frame = GetMainCefFrame();
|
||||
} else {
|
||||
// Locate or create the appropriate named reference.
|
||||
CefString name = string16(frame->name());
|
||||
DCHECK(!name.empty());
|
||||
cef_frame = GetCefFrame(name);
|
||||
}
|
||||
}
|
||||
|
||||
return cef_frame;
|
||||
}
|
||||
|
||||
WebFrame* CefBrowserImpl::UIT_GetMainWebFrame()
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (view)
|
||||
return view ->mainFrame();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WebFrame* CefBrowserImpl::UIT_GetWebFrame(CefRefPtr<CefFrame> frame)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefString newUrl = url;
|
||||
CefRefPtr<CefBrowser> alternateBrowser;
|
||||
CefBrowserSettings settings(_Context->browser_defaults());
|
||||
|
||||
if(handler.get())
|
||||
{
|
||||
// Give the handler an opportunity to modify window attributes, handler,
|
||||
// or cancel the window creation.
|
||||
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
|
||||
popup, CefPopupFeatures(), handler, newUrl, settings);
|
||||
if(rv == RV_HANDLED)
|
||||
return false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> browser(
|
||||
new CefBrowserImpl(windowInfo, settings, popup, handler));
|
||||
static_cast<CefBrowserImpl*>(browser.get())->UIT_CreateBrowser(newUrl);
|
||||
|
||||
return browser;
|
||||
CefString name = frame->GetName();
|
||||
if(name.empty())
|
||||
return view ->mainFrame();
|
||||
return view ->findFrameByName(string16(name));
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_DestroyBrowser()
|
||||
@ -585,7 +531,7 @@ void CefBrowserImpl::UIT_DestroyBrowser()
|
||||
// Notify the handler that the window is about to be closed.
|
||||
handler_->HandleBeforeWindowClose(this);
|
||||
}
|
||||
GetWebViewDelegate()->RevokeDragDrop();
|
||||
UIT_GetWebViewDelegate()->RevokeDragDrop();
|
||||
|
||||
if (dev_tools_agent_.get()) {
|
||||
BrowserDevToolsClient* client = dev_tools_agent_->client();
|
||||
@ -594,7 +540,7 @@ void CefBrowserImpl::UIT_DestroyBrowser()
|
||||
}
|
||||
|
||||
// Clean up anything associated with the WebViewHost widget.
|
||||
GetWebViewHost()->webwidget()->close();
|
||||
UIT_GetWebViewHost()->webwidget()->close();
|
||||
webviewhost_.reset();
|
||||
|
||||
// Remove the reference added in UIT_CreateBrowser().
|
||||
@ -680,7 +626,7 @@ void CefBrowserImpl::UIT_LoadHTML(CefFrame* frame,
|
||||
return;
|
||||
}
|
||||
|
||||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
web_frame->loadHTMLString(std::string(html), gurl);
|
||||
|
||||
@ -717,7 +663,7 @@ void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefFrame* frame,
|
||||
}
|
||||
while(read > 0);
|
||||
|
||||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame)
|
||||
web_frame->loadHTMLString(ss.str(), gurl);
|
||||
|
||||
@ -732,7 +678,7 @@ void CefBrowserImpl::UIT_ExecuteJavaScript(CefFrame* frame,
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebFrame* web_frame = GetWebFrame(frame);
|
||||
WebFrame* web_frame = UIT_GetWebFrame(frame);
|
||||
if(web_frame) {
|
||||
web_frame->executeScript(WebScriptSource(string16(js_code),
|
||||
WebURL(GURL(std::string(script_url))), start_line));
|
||||
@ -759,7 +705,7 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebView* view = GetWebView();
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return false;
|
||||
|
||||
@ -830,7 +776,7 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||
// thread for additional details:
|
||||
// http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168
|
||||
view->setFocusedFrame(frame);
|
||||
UIT_SetFocus(GetWebViewHost(), true);
|
||||
UIT_SetFocus(UIT_GetWebViewHost(), true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -886,7 +832,7 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
||||
|
||||
WebFrame* web_frame = NULL;
|
||||
if(frame)
|
||||
web_frame = GetWebFrame(frame);
|
||||
web_frame = UIT_GetWebFrame(frame);
|
||||
|
||||
switch(menuId)
|
||||
{
|
||||
@ -903,8 +849,8 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
||||
UIT_Reload(true);
|
||||
break;
|
||||
case MENU_ID_NAV_STOP:
|
||||
if (GetWebView())
|
||||
GetWebView()->mainFrame()->stopLoading();
|
||||
if (UIT_GetWebView())
|
||||
UIT_GetWebView()->mainFrame()->stopLoading();
|
||||
break;
|
||||
case MENU_ID_UNDO:
|
||||
if(web_frame)
|
||||
@ -948,76 +894,10 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
||||
frame->Release();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_GetDocumentStringNotify(CefFrame* frame,
|
||||
CefStreamWriter* writer,
|
||||
base::WaitableEvent* event)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame) {
|
||||
// Retrieve the document string
|
||||
std::string markup = web_frame->contentAsMarkup().utf8();
|
||||
// Write the document string to the stream
|
||||
writer->Write(markup.c_str(), markup.size(), 1);
|
||||
}
|
||||
|
||||
// Notify the calling thread that the data is now available
|
||||
event->Signal();
|
||||
|
||||
writer->Release();
|
||||
frame->Release();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_GetDocumentTextNotify(CefFrame* frame,
|
||||
CefStreamWriter* writer,
|
||||
base::WaitableEvent* event)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
if(web_frame) {
|
||||
// Retrieve the document string
|
||||
string16 wstr = webkit_glue::DumpDocumentText(web_frame);
|
||||
std::string str;
|
||||
UTF16ToUTF8(wstr.c_str(), wstr.length(), &str);
|
||||
// Write the document string to the stream
|
||||
writer->Write(str.c_str(), str.size(), 1);
|
||||
}
|
||||
|
||||
// Notify the calling thread that the data is now available
|
||||
event->Signal();
|
||||
|
||||
writer->Release();
|
||||
frame->Release();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CanGoBackNotify(bool *retVal,
|
||||
base::WaitableEvent* event)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
*retVal = UIT_CanGoBack();
|
||||
|
||||
// Notify the calling thread that the data is now available
|
||||
event->Signal();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CanGoForwardNotify(bool *retVal,
|
||||
base::WaitableEvent* event)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
*retVal = UIT_CanGoForward();
|
||||
|
||||
// Notify the calling thread that the data is now available
|
||||
event->Signal();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_Find(int identifier, const CefString& search_text,
|
||||
const WebKit::WebFindOptions& options)
|
||||
{
|
||||
WebView* view = GetWebView();
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
@ -1140,7 +1020,7 @@ void CefBrowserImpl::UIT_Find(int identifier, const CefString& search_text,
|
||||
|
||||
void CefBrowserImpl::UIT_StopFinding(bool clear_selection)
|
||||
{
|
||||
WebView* view = GetWebView();
|
||||
WebView* view = UIT_GetWebView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
@ -1169,8 +1049,7 @@ void CefBrowserImpl::UIT_NotifyFindStatus(int identifier, int count,
|
||||
int active_match_ordinal,
|
||||
bool final_update)
|
||||
{
|
||||
if(handler_.get())
|
||||
{
|
||||
if(handler_.get()) {
|
||||
CefRect rect(selection_rect.x, selection_rect.y, selection_rect.width,
|
||||
selection_rect.height);
|
||||
handler_->HandleFindResult(this, identifier, count, rect,
|
||||
@ -1178,17 +1057,15 @@ void CefBrowserImpl::UIT_NotifyFindStatus(int identifier, int count,
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_SetZoomLevel(CefFrame* frame, double zoomLevel)
|
||||
void CefBrowserImpl::UIT_SetZoomLevel(double zoomLevel)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
WebKit::WebFrame* web_frame = GetWebFrame(frame);
|
||||
|
||||
if(web_frame && web_frame->view()) {
|
||||
WebKit::WebFrame* web_frame = UIT_GetMainWebFrame();
|
||||
if(web_frame) {
|
||||
web_frame->view()->setZoomLevel(false, zoomLevel);
|
||||
ZoomMap::GetInstance()->set(web_frame->url(), zoomLevel);
|
||||
set_zoom_level(zoomLevel);
|
||||
}
|
||||
|
||||
frame->Release();
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_ShowDevTools()
|
||||
@ -1209,7 +1086,7 @@ void CefBrowserImpl::UIT_ShowDevTools()
|
||||
CefPopupFeatures features;
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
UIT_CreatePopupWindow(devtools_path.value(), features);
|
||||
browser->CreateDevToolsClient(dev_tools_agent_.get());
|
||||
browser->UIT_CreateDevToolsClient(dev_tools_agent_.get());
|
||||
browser->UIT_Show(WebKit::WebNavigationPolicyNewWindow);
|
||||
} else {
|
||||
// Give focus to the existing inspector window.
|
||||
@ -1217,7 +1094,38 @@ void CefBrowserImpl::UIT_ShowDevTools()
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserImpl::CreateDevToolsClient(BrowserDevToolsAgent *agent)
|
||||
void CefBrowserImpl::set_zoom_level(double zoomLevel)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
zoom_level_ = zoomLevel;
|
||||
}
|
||||
|
||||
double CefBrowserImpl::zoom_level()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return zoom_level_;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::set_nav_state(bool can_go_back, bool can_go_forward)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
can_go_back_ = can_go_back;
|
||||
can_go_forward_ = can_go_forward;
|
||||
}
|
||||
|
||||
bool CefBrowserImpl::can_go_back()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return can_go_back_;
|
||||
}
|
||||
|
||||
bool CefBrowserImpl::can_go_forward()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return can_go_forward_;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent)
|
||||
{
|
||||
dev_tools_client_.reset(new BrowserDevToolsClient(this, agent));
|
||||
}
|
||||
@ -1225,9 +1133,25 @@ void CefBrowserImpl::CreateDevToolsClient(BrowserDevToolsAgent *agent)
|
||||
|
||||
// CefFrameImpl
|
||||
|
||||
CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, const CefString& name)
|
||||
: browser_(browser), name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
CefFrameImpl::~CefFrameImpl()
|
||||
{
|
||||
browser_->RemoveCefFrame(name_);
|
||||
}
|
||||
|
||||
bool CefFrameImpl::IsFocused()
|
||||
{
|
||||
return (browser_->GetWebView() &&
|
||||
(browser_->GetWebFrame(this) ==
|
||||
browser_->GetWebView()->focusedFrame()));
|
||||
// Verify that this method is being called on the UI thread.
|
||||
if (!CefThread::CurrentlyOn(CefThread::UI)) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
return (browser_->UIT_GetWebView() &&
|
||||
(browser_->UIT_GetWebFrame(this) ==
|
||||
browser_->UIT_GetWebView()->focusedFrame()));
|
||||
}
|
||||
|
@ -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); }
|
||||
|
@ -20,13 +20,12 @@ using WebKit::WebSize;
|
||||
|
||||
CefWindowHandle CefBrowserImpl::GetWindowHandle()
|
||||
{
|
||||
Lock();
|
||||
CefWindowHandle handle = window_info_.m_Widget;
|
||||
Unlock();
|
||||
return handle;
|
||||
AutoLock lock_scope(this);
|
||||
return window_info_.m_Widget;
|
||||
}
|
||||
|
||||
gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
|
||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
GtkWidget* toplevel = gtk_widget_get_ancestor(window_info_.m_Widget,
|
||||
GTK_TYPE_WINDOW);
|
||||
return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
|
||||
@ -35,7 +34,8 @@ gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
|
||||
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
Lock();
|
||||
|
||||
// Add a reference that will be released in UIT_DestroyBrowser().
|
||||
AddRef();
|
||||
|
||||
@ -58,7 +58,9 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
dev_tools_agent_->SetWebView(webviewhost_->webview());
|
||||
|
||||
window_info_.m_Widget = webviewhost_->view_handle();
|
||||
|
||||
|
||||
Unlock();
|
||||
|
||||
if(handler_.get()) {
|
||||
// Notify the handler that we're done creating the new window
|
||||
handler_->HandleAfterCreated(this);
|
||||
|
@ -21,20 +21,20 @@ using WebKit::WebSize;
|
||||
|
||||
CefWindowHandle CefBrowserImpl::GetWindowHandle()
|
||||
{
|
||||
Lock();
|
||||
CefWindowHandle handle = window_info_.m_View;
|
||||
Unlock();
|
||||
return handle;
|
||||
AutoLock lock_scope(this);
|
||||
return window_info_.m_View;
|
||||
}
|
||||
|
||||
gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
|
||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
return (NSWindow*)window_info_.m_View;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
Lock();
|
||||
|
||||
// Add a reference that will be released in UIT_DestroyBrowser().
|
||||
AddRef();
|
||||
|
||||
@ -63,7 +63,9 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
BrowserWebView* browserView = (BrowserWebView*)webviewhost_->view_handle();
|
||||
browserView.browser = this;
|
||||
window_info_.m_View = (void*)browserView;
|
||||
|
||||
|
||||
Unlock();
|
||||
|
||||
if(handler_.get()) {
|
||||
// Notify the handler that we're done creating the new window
|
||||
handler_->HandleAfterCreated(this);
|
||||
|
@ -57,23 +57,23 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
|
||||
return 0;
|
||||
|
||||
case WM_SIZE:
|
||||
if (browser && browser->GetWebView()) {
|
||||
if (browser && browser->UIT_GetWebView()) {
|
||||
// resize the web view window to the full size of the browser window
|
||||
RECT rc;
|
||||
GetClientRect(browser->GetMainWndHandle(), &rc);
|
||||
MoveWindow(browser->GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom,
|
||||
GetClientRect(browser->UIT_GetMainWndHandle(), &rc);
|
||||
MoveWindow(browser->UIT_GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom,
|
||||
TRUE);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
if (browser && browser->GetWebView())
|
||||
browser->GetWebView()->setFocus(true);
|
||||
if (browser && browser->UIT_GetWebView())
|
||||
browser->UIT_GetWebView()->setFocus(true);
|
||||
return 0;
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
if (browser && browser->GetWebView())
|
||||
browser->GetWebView()->setFocus(false);
|
||||
if (browser && browser->UIT_GetWebView())
|
||||
browser->UIT_GetWebView()->setFocus(false);
|
||||
return 0;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
@ -85,19 +85,19 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
|
||||
|
||||
CefWindowHandle CefBrowserImpl::GetWindowHandle()
|
||||
{
|
||||
Lock();
|
||||
CefWindowHandle handle = window_info_.m_hWnd;
|
||||
Unlock();
|
||||
return handle;
|
||||
AutoLock lock_scope(this);
|
||||
return window_info_.m_hWnd;
|
||||
}
|
||||
|
||||
gfx::NativeWindow CefBrowserImpl::GetMainWndHandle() const {
|
||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() const {
|
||||
REQUIRE_UIT();
|
||||
return window_info_.m_hWnd;
|
||||
}
|
||||
|
||||
void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
Lock();
|
||||
|
||||
std::wstring windowName(CefString(&window_info_.m_windowName));
|
||||
|
||||
@ -136,10 +136,12 @@ void CefBrowserImpl::UIT_CreateBrowser(const CefString& url)
|
||||
if (!settings_.drag_drop_disabled)
|
||||
delegate_->RegisterDragDrop();
|
||||
|
||||
Unlock();
|
||||
|
||||
// Size the web view window to the browser window
|
||||
RECT cr;
|
||||
GetClientRect(window_info_.m_hWnd, &cr);
|
||||
SetWindowPos(GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right,
|
||||
SetWindowPos(UIT_GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right,
|
||||
cr.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
|
||||
|
||||
if(handler_.get()) {
|
||||
@ -172,7 +174,7 @@ WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
|
||||
|
||||
DCHECK(!popuphost_);
|
||||
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
|
||||
ShowWindow(GetPopupWndHandle(), SW_SHOW);
|
||||
ShowWindow(UIT_GetPopupWndHandle(), SW_SHOW);
|
||||
|
||||
return popuphost_->webwidget();
|
||||
}
|
||||
@ -181,7 +183,7 @@ void CefBrowserImpl::UIT_ClosePopupWidget()
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
PostMessage(GetPopupWndHandle(), WM_CLOSE, 0, 0);
|
||||
PostMessage(UIT_GetPopupWndHandle(), WM_CLOSE, 0, 0);
|
||||
popuphost_ = NULL;
|
||||
}
|
||||
|
||||
@ -225,7 +227,7 @@ bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame)
|
||||
std::string markup = frame->contentAsMarkup().utf8();
|
||||
WriteTextToFile(markup, szTempName);
|
||||
|
||||
int errorCode = (int)ShellExecute(GetMainWndHandle(), L"open", szTempName,
|
||||
int errorCode = (int)ShellExecute(UIT_GetMainWndHandle(), L"open", szTempName,
|
||||
NULL, NULL, SW_SHOWNORMAL);
|
||||
if(errorCode <= 32)
|
||||
return false;
|
||||
@ -322,7 +324,7 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
|
||||
|
||||
// allow the handler to format print header and/or footer
|
||||
CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this,
|
||||
GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages,
|
||||
UIT_GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages,
|
||||
topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight);
|
||||
|
||||
if(rv != RV_HANDLED) {
|
||||
@ -408,7 +410,7 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
|
||||
}
|
||||
|
||||
if(print_context_.AskUserForSettings(
|
||||
GetMainWndHandle(), UIT_GetPagesCount(frame), false)
|
||||
UIT_GetMainWndHandle(), UIT_GetPagesCount(frame), false)
|
||||
!= printing::PrintingContext::OK)
|
||||
return;
|
||||
|
||||
@ -497,5 +499,5 @@ void CefBrowserImpl::UIT_CloseDevTools()
|
||||
|
||||
BrowserDevToolsClient* client = dev_tools_agent_->client();
|
||||
if (client)
|
||||
PostMessage(client->browser()->GetMainWndHandle(), WM_CLOSE, 0, 0);
|
||||
PostMessage(client->browser()->UIT_GetMainWndHandle(), WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ WebView* BrowserWebViewDelegate::createView(WebFrame* creator,
|
||||
TranslatePopupFeatures(features, cefFeatures);
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
browser_->UIT_CreatePopupWindow(url, cefFeatures);
|
||||
return browser.get() ? browser->GetWebView() : NULL;
|
||||
return browser.get() ? browser->UIT_GetWebView() : NULL;
|
||||
}
|
||||
|
||||
WebWidget* BrowserWebViewDelegate::createPopupMenu(WebPopupType popup_type) {
|
||||
@ -215,8 +215,11 @@ void BrowserWebViewDelegate::didAddMessageToConsole(
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::printPage(WebFrame* frame) {
|
||||
if (!frame)
|
||||
frame = browser_->GetWebView() ? browser_->GetWebView()->mainFrame() : NULL;
|
||||
if (!frame) {
|
||||
WebView* view = browser_->UIT_GetWebView();
|
||||
if (view)
|
||||
frame = view->mainFrame();
|
||||
}
|
||||
if (frame)
|
||||
browser_->UIT_PrintPages(frame);
|
||||
}
|
||||
@ -299,8 +302,10 @@ bool BrowserWebViewDelegate::handleCurrentKeyboardEvent() {
|
||||
if (edit_command_name_.empty())
|
||||
return false;
|
||||
|
||||
WebFrame* frame = browser_->GetWebView() ?
|
||||
browser_->GetWebView()->focusedFrame() : NULL;
|
||||
WebView* view = browser_->UIT_GetWebView();
|
||||
WebFrame* frame = NULL;
|
||||
if (view)
|
||||
frame = view->focusedFrame();
|
||||
if (!frame)
|
||||
return false;
|
||||
|
||||
@ -335,7 +340,7 @@ void BrowserWebViewDelegate::runModalAlertDialog(
|
||||
CefString messageStr = string16(message);
|
||||
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
||||
if(handler.get()) {
|
||||
rv = handler->HandleJSAlert(browser_, browser_->GetCefFrame(frame),
|
||||
rv = handler->HandleJSAlert(browser_, browser_->UIT_GetCefFrame(frame),
|
||||
messageStr);
|
||||
}
|
||||
if(rv != RV_HANDLED)
|
||||
@ -349,7 +354,7 @@ bool BrowserWebViewDelegate::runModalConfirmDialog(
|
||||
bool retval = false;
|
||||
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
||||
if(handler.get()) {
|
||||
rv = handler->HandleJSConfirm(browser_, browser_->GetCefFrame(frame),
|
||||
rv = handler->HandleJSConfirm(browser_, browser_->UIT_GetCefFrame(frame),
|
||||
messageStr, retval);
|
||||
}
|
||||
if(rv != RV_HANDLED)
|
||||
@ -370,7 +375,7 @@ bool BrowserWebViewDelegate::runModalPromptDialog(
|
||||
bool retval = false;
|
||||
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
||||
if(handler.get()) {
|
||||
rv = handler->HandleJSPrompt(browser_, browser_->GetCefFrame(frame),
|
||||
rv = handler->HandleJSPrompt(browser_, browser_->UIT_GetCefFrame(frame),
|
||||
messageStr, defaultValueStr, retval, actualValueStr);
|
||||
}
|
||||
if(rv != RV_HANDLED) {
|
||||
@ -426,8 +431,9 @@ void BrowserWebViewDelegate::startDragging(
|
||||
//HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(),
|
||||
// ok_effect, &effect);
|
||||
//DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res);
|
||||
if (browser_->GetWebView())
|
||||
browser_->GetWebView()->dragSourceSystemDragEnded();
|
||||
WebView* view = browser_->UIT_GetWebView();
|
||||
if (view)
|
||||
view->dragSourceSystemDragEnded();
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::focusNext() {
|
||||
@ -591,7 +597,7 @@ WebNavigationPolicy BrowserWebViewDelegate::decidePolicyForNavigation(
|
||||
|
||||
// Notify the handler of a browse request
|
||||
CefHandler::RetVal rv = handler->HandleBeforeBrowse(browser_,
|
||||
browser_->GetCefFrame(frame), req, (CefHandler::NavType)type,
|
||||
browser_->UIT_GetCefFrame(frame), req, (CefHandler::NavType)type,
|
||||
is_redirect);
|
||||
if(rv == RV_HANDLED)
|
||||
return WebKit::WebNavigationPolicyIgnore;
|
||||
@ -673,7 +679,7 @@ void BrowserWebViewDelegate::didFailProvisionalLoad(
|
||||
if(handler.get()) {
|
||||
// give the handler an opportunity to generate a custom error message
|
||||
rv = handler->HandleLoadError(browser_,
|
||||
browser_->GetCefFrame(frame),
|
||||
browser_->UIT_GetCefFrame(frame),
|
||||
static_cast<CefHandler::ErrorCode>(error.reason),
|
||||
std::string(failed_ds->request().url().spec().data()), errorStr);
|
||||
}
|
||||
@ -724,18 +730,17 @@ void BrowserWebViewDelegate::didCommitProvisionalLoad(
|
||||
if(handler.get()) {
|
||||
// Notify the handler that loading has started.
|
||||
handler->HandleLoadStart(browser_,
|
||||
(frame == top_loading_frame_) ? NULL : browser_->GetCefFrame(frame),
|
||||
(frame == top_loading_frame_) ? NULL : browser_->UIT_GetCefFrame(frame),
|
||||
is_main_content_);
|
||||
}
|
||||
|
||||
// Apply zoom settings only on top-level frames.
|
||||
if(frame->parent() == NULL) {
|
||||
// Restore the zoom value that we have for this URL, if any.
|
||||
double zoomLevel;
|
||||
if(ZoomMap::GetInstance()->get(frame->url(), zoomLevel))
|
||||
frame->view()->setZoomLevel(false, zoomLevel);
|
||||
else
|
||||
frame->view()->setZoomLevel(false, 0.0);
|
||||
double zoomLevel = 0.0;
|
||||
ZoomMap::GetInstance()->get(frame->url(), zoomLevel);
|
||||
frame->view()->setZoomLevel(false, zoomLevel);
|
||||
browser_->set_zoom_level(zoomLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,7 +754,7 @@ void BrowserWebViewDelegate::didClearWindowObject(WebFrame* frame) {
|
||||
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
CefRefPtr<CefFrame> cframe(browser_->GetCefFrame(frame));
|
||||
CefRefPtr<CefFrame> cframe(browser_->UIT_GetCefFrame(frame));
|
||||
CefRefPtr<CefV8Value> object = new CefV8ValueImpl(context->Global());
|
||||
handler->HandleJSBinding(browser_, cframe, object);
|
||||
}
|
||||
@ -869,15 +874,15 @@ void BrowserWebViewDelegate::RegisterDragDrop() {
|
||||
#if defined(OS_WIN)
|
||||
// TODO(port): add me once drag and drop works.
|
||||
DCHECK(!drop_delegate_);
|
||||
drop_delegate_ = new BrowserDropDelegate(browser_->GetWebViewWndHandle(),
|
||||
browser_->GetWebView());
|
||||
drop_delegate_ = new BrowserDropDelegate(browser_->UIT_GetWebViewWndHandle(),
|
||||
browser_->UIT_GetWebView());
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::RevokeDragDrop() {
|
||||
#if defined(OS_WIN)
|
||||
if (drop_delegate_.get())
|
||||
::RevokeDragDrop(browser_->GetWebViewWndHandle());
|
||||
::RevokeDragDrop(browser_->UIT_GetWebViewWndHandle());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -926,8 +931,8 @@ void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) {
|
||||
// Notify the handler that loading has ended.
|
||||
int httpStatusCode = frame->dataSource()->response().httpStatusCode();
|
||||
handler->HandleLoadEnd(browser_,
|
||||
(is_top_frame) ? NULL : browser_->GetCefFrame(frame), is_main_content_,
|
||||
httpStatusCode);
|
||||
(is_top_frame) ? NULL : browser_->UIT_GetCefFrame(frame),
|
||||
is_main_content_, httpStatusCode);
|
||||
}
|
||||
|
||||
if (is_top_frame && is_main_content_)
|
||||
@ -935,10 +940,10 @@ void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) {
|
||||
}
|
||||
|
||||
WebWidgetHost* BrowserWebViewDelegate::GetWidgetHost() {
|
||||
if (this == browser_->GetWebViewDelegate())
|
||||
return browser_->GetWebViewHost();
|
||||
if (this == browser_->GetPopupDelegate())
|
||||
return browser_->GetPopupHost();
|
||||
if (this == browser_->UIT_GetWebViewDelegate())
|
||||
return browser_->UIT_GetWebViewHost();
|
||||
if (this == browser_->UIT_GetPopupDelegate())
|
||||
return browser_->UIT_GetPopupHost();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -989,7 +994,8 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
|
||||
if(handler.get()) {
|
||||
// Notify the handler of an address change
|
||||
std::string url = std::string(entry->GetURL().spec().c_str());
|
||||
handler->HandleAddressChange(browser_, browser_->GetCefFrame(frame), url);
|
||||
handler->HandleAddressChange(browser_, browser_->UIT_GetCefFrame(frame),
|
||||
url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -997,7 +1003,10 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
|
||||
if (!history_item.isNull())
|
||||
entry->SetContentState(webkit_glue::HistoryItemToString(history_item));
|
||||
|
||||
browser_->UIT_GetNavigationController()->DidNavigateToEntry(entry.release());
|
||||
BrowserNavigationController* controller =
|
||||
browser_->UIT_GetNavigationController();
|
||||
controller->DidNavigateToEntry(entry.release());
|
||||
browser_->set_nav_state(!controller->IsAtStart(), !controller->IsAtEnd());
|
||||
|
||||
last_page_id_updated_ = std::max(last_page_id_updated_, page_id_);
|
||||
}
|
||||
@ -1014,11 +1023,11 @@ void BrowserWebViewDelegate::UpdateSessionHistory(WebFrame* frame) {
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
if (!browser_->GetWebView())
|
||||
WebView* view = browser_->UIT_GetWebView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
const WebHistoryItem& history_item =
|
||||
browser_->GetWebView()->mainFrame()->previousHistoryItem();
|
||||
const WebHistoryItem& history_item = view->mainFrame()->previousHistoryItem();
|
||||
if (history_item.isNull())
|
||||
return;
|
||||
|
||||
|
@ -102,10 +102,10 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::closeWidgetSoon() {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
|
||||
>k_widget_destroy, GTK_WIDGET(browser_->GetMainWndHandle())));
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
>k_widget_destroy, GTK_WIDGET(browser_->UIT_GetMainWndHandle())));
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
|
||||
gdk_cursor = gfx::GetCursor(cursor_type);
|
||||
}
|
||||
cursor_type_ = cursor_type;
|
||||
gdk_window_set_cursor(browser_->GetWebViewWndHandle()->window, gdk_cursor);
|
||||
gdk_window_set_cursor(browser_->UIT_GetWebViewWndHandle()->window, gdk_cursor);
|
||||
}
|
||||
|
||||
WebRect BrowserWebViewDelegate::windowRect() {
|
||||
@ -152,9 +152,9 @@ WebRect BrowserWebViewDelegate::windowRect() {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
// TODO(port): Set the window rectangle.
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
WebWidgetHost* host = GetWidgetHost();
|
||||
GtkWidget* drawing_area = host->view_handle();
|
||||
GtkWidget* window =
|
||||
@ -198,7 +198,7 @@ webkit::npapi::WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
|
||||
// TODO(evanm): we probably shouldn't be doing this mapping to X ids at
|
||||
// this level.
|
||||
GdkNativeWindow plugin_parent =
|
||||
GDK_WINDOW_XWINDOW(browser_->GetWebViewHost()->view_handle()->window);
|
||||
GDK_WINDOW_XWINDOW(browser_->UIT_GetWebViewHost()->view_handle()->window);
|
||||
|
||||
return webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type,
|
||||
plugin_parent);
|
||||
@ -206,12 +206,12 @@ webkit::npapi::WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
|
||||
|
||||
void BrowserWebViewDelegate::CreatedPluginWindow(
|
||||
gfx::PluginWindowHandle id) {
|
||||
browser_->GetWebViewHost()->CreatePluginContainer(id);
|
||||
browser_->UIT_GetWebViewHost()->CreatePluginContainer(id);
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::WillDestroyPluginWindow(
|
||||
gfx::PluginWindowHandle id) {
|
||||
browser_->GetWebViewHost()->DestroyPluginContainer(id);
|
||||
browser_->UIT_GetWebViewHost()->DestroyPluginContainer(id);
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::DidMovePlugin(
|
||||
|
@ -42,7 +42,7 @@ void BrowserWebViewDelegate::showContextMenu(
|
||||
void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
if (!popup_menu_info_.get())
|
||||
return;
|
||||
if (this != browser_->GetPopupDelegate())
|
||||
if (this != browser_->UIT_GetPopupDelegate())
|
||||
return;
|
||||
// Display a HTML select menu.
|
||||
|
||||
@ -59,7 +59,7 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
const WebRect& bounds = popup_bounds_;
|
||||
|
||||
// Set up the menu position.
|
||||
NSView* web_view = browser_->GetWebViewWndHandle();
|
||||
NSView* web_view = browser_->UIT_GetWebViewWndHandle();
|
||||
NSRect view_rect = [web_view bounds];
|
||||
int y_offset = bounds.y + bounds.height;
|
||||
NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset,
|
||||
@ -71,15 +71,15 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
fontSize:font_size
|
||||
rightAligned:right_aligned]);
|
||||
|
||||
[menu_runner runMenuInView:browser_->GetWebViewWndHandle()
|
||||
[menu_runner runMenuInView:browser_->UIT_GetWebViewWndHandle()
|
||||
withBounds:position
|
||||
initialIndex:selected_index];
|
||||
|
||||
// Get the selected item and forward to WebKit. WebKit expects an input event
|
||||
// (mouse down, keyboard activity) for this, so we calculate the proper
|
||||
// position based on the selected index and provided bounds.
|
||||
WebWidgetHost* popup = browser_->GetPopupHost();
|
||||
int window_num = [browser_->GetMainWndHandle() windowNumber];
|
||||
WebWidgetHost* popup = browser_->UIT_GetPopupHost();
|
||||
int window_num = [browser_->UIT_GetMainWndHandle() windowNumber];
|
||||
NSEvent* event =
|
||||
webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen],
|
||||
window_num, item_height,
|
||||
@ -98,10 +98,10 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::closeWidgetSoon() {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
NSWindow *win = browser_->GetMainWndHandle();
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
NSWindow *win = browser_->UIT_GetMainWndHandle();
|
||||
[win performSelector:@selector(performClose:) withObject:nil afterDelay:0];
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
}
|
||||
}
|
||||
@ -121,9 +121,9 @@ WebRect BrowserWebViewDelegate::windowRect() {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
// TODO(port): Set the window rectangle.
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
popup_bounds_ = rect; // The initial position of the popup.
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ void BrowserWebViewDelegate::show(WebNavigationPolicy) {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::closeWidgetSoon() {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
PostMessage(browser_->GetMainWndHandle(), WM_CLOSE, 0, 0);
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
PostMessage(browser_->UIT_GetMainWndHandle(), WM_CLOSE, 0, 0);
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
browser_->UIT_ClosePopupWidget();
|
||||
}
|
||||
}
|
||||
@ -91,10 +91,10 @@ WebRect BrowserWebViewDelegate::windowRect() {
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
|
||||
if (this == browser_->GetWebViewDelegate()) {
|
||||
if (this == browser_->UIT_GetWebViewDelegate()) {
|
||||
// ignored
|
||||
} else if (this == browser_->GetPopupDelegate()) {
|
||||
MoveWindow(browser_->GetPopupWndHandle(),
|
||||
} else if (this == browser_->UIT_GetPopupDelegate()) {
|
||||
MoveWindow(browser_->UIT_GetPopupWndHandle(),
|
||||
rect.x, rect.y, rect.width, rect.height, FALSE);
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,7 @@ void BrowserWebViewDelegate::runModal() {
|
||||
i = list->begin();
|
||||
for (; i != list->end(); ++i) {
|
||||
if (i->get()->IsPopup())
|
||||
EnableWindow(i->get()->GetMainWndHandle(), FALSE);
|
||||
EnableWindow(i->get()->UIT_GetMainWndHandle(), FALSE);
|
||||
}
|
||||
_Context->Unlock();
|
||||
|
||||
@ -140,7 +140,7 @@ void BrowserWebViewDelegate::runModal() {
|
||||
list = _Context->GetBrowserList();
|
||||
i = list->begin();
|
||||
for (; i != list->end(); ++i)
|
||||
EnableWindow(i->get()->GetMainWndHandle(), TRUE);
|
||||
EnableWindow(i->get()->UIT_GetMainWndHandle(), TRUE);
|
||||
_Context->Unlock();
|
||||
}
|
||||
|
||||
@ -150,12 +150,13 @@ webkit::npapi::WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
|
||||
const FilePath& file_path,
|
||||
const std::string& mime_type)
|
||||
{
|
||||
HWND hwnd = browser_->GetWebViewHost() ?
|
||||
browser_->GetWebViewHost()->view_handle() : NULL;
|
||||
HWND hwnd = browser_->UIT_GetWebViewHost() ?
|
||||
browser_->UIT_GetWebViewHost()->view_handle() : NULL;
|
||||
if (!hwnd)
|
||||
return NULL;
|
||||
|
||||
return webkit::npapi::WebPluginDelegateImpl::Create(file_path, mime_type, hwnd);
|
||||
return webkit::npapi::WebPluginDelegateImpl::Create(file_path, mime_type,
|
||||
hwnd);
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::CreatedPluginWindow(
|
||||
@ -242,7 +243,7 @@ void BrowserWebViewDelegate::showContextMenu(
|
||||
WebFrame* frame, const WebContextMenuData& data)
|
||||
{
|
||||
POINT screen_pt = { data.mousePosition.x, data.mousePosition.y };
|
||||
MapWindowPoints(browser_->GetMainWndHandle(), HWND_DESKTOP,
|
||||
MapWindowPoints(browser_->UIT_GetMainWndHandle(), HWND_DESKTOP,
|
||||
&screen_pt, 1);
|
||||
|
||||
HMENU menu = NULL;
|
||||
@ -356,7 +357,7 @@ void BrowserWebViewDelegate::showContextMenu(
|
||||
// show the context menu
|
||||
int selected_id = TrackPopupMenu(menu,
|
||||
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
||||
screen_pt.x, screen_pt.y, 0, browser_->GetMainWndHandle(), NULL);
|
||||
screen_pt.x, screen_pt.y, 0, browser_->UIT_GetMainWndHandle(), NULL);
|
||||
|
||||
if(selected_id != 0) {
|
||||
// An action was chosen
|
||||
@ -391,8 +392,8 @@ void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe,
|
||||
// TODO(cef): Think about what we should be showing as the prompt caption
|
||||
std::wstring messageStr = message;
|
||||
std::wstring titleStr = browser_->UIT_GetTitle();
|
||||
MessageBox(browser_->GetMainWndHandle(), messageStr.c_str(), titleStr.c_str(),
|
||||
MB_OK | MB_ICONWARNING);
|
||||
MessageBox(browser_->UIT_GetMainWndHandle(), messageStr.c_str(),
|
||||
titleStr.c_str(), MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe,
|
||||
@ -401,7 +402,7 @@ bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe,
|
||||
// TODO(cef): Think about what we should be showing as the prompt caption
|
||||
std::wstring messageStr = message;
|
||||
std::wstring titleStr = browser_->UIT_GetTitle();
|
||||
int rv = MessageBox(browser_->GetMainWndHandle(), messageStr.c_str(),
|
||||
int rv = MessageBox(browser_->UIT_GetMainWndHandle(), messageStr.c_str(),
|
||||
titleStr.c_str(), MB_YESNO | MB_ICONQUESTION);
|
||||
return (rv == IDYES);
|
||||
}
|
||||
@ -511,11 +512,12 @@ bool BrowserWebViewDelegate::ShowFileChooser(std::vector<FilePath>& file_names,
|
||||
bool result = false;
|
||||
|
||||
if (multi_select) {
|
||||
result = RunOpenMultiFileDialog(L"", browser_->GetMainWndHandle(),
|
||||
result = RunOpenMultiFileDialog(L"", browser_->UIT_GetMainWndHandle(),
|
||||
&file_names);
|
||||
} else {
|
||||
FilePath file_name;
|
||||
result = RunOpenFileDialog(L"", browser_->GetMainWndHandle(), &file_name);
|
||||
result = RunOpenFileDialog(L"", browser_->UIT_GetMainWndHandle(),
|
||||
&file_name);
|
||||
if (result)
|
||||
file_names.push_back(file_name);
|
||||
}
|
||||
|
@ -52,90 +52,90 @@
|
||||
CGContextSetRGBFillColor (context, 1, 0, 1, 1);
|
||||
CGContextFillRect(context, NSRectToCGRect(rect));
|
||||
|
||||
if (browser_ && browser_->GetWebView()) {
|
||||
if (browser_ && browser_->UIT_GetWebView()) {
|
||||
gfx::Rect client_rect(NSRectToCGRect(rect));
|
||||
// flip from cocoa coordinates
|
||||
client_rect.set_y([self frame].size.height -
|
||||
client_rect.height() - client_rect.y());
|
||||
|
||||
browser_->GetWebViewHost()->UpdatePaintRect(client_rect);
|
||||
browser_->GetWebViewHost()->Paint();
|
||||
browser_->UIT_GetWebViewHost()->UpdatePaintRect(client_rect);
|
||||
browser_->UIT_GetWebViewHost()->Paint();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)otherMouseDown:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)rightMouseUp:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)otherMouseUp:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)scrollWheel:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->WheelEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->WheelEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)rightMouseDragged:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)otherMouseDragged:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->MouseEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->KeyEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->KeyEvent(theEvent);
|
||||
}
|
||||
|
||||
- (void)keyUp:(NSEvent *)theEvent {
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->KeyEvent(theEvent);
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->KeyEvent(theEvent);
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque {
|
||||
@ -143,16 +143,16 @@
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyView {
|
||||
return browser_ && browser_->GetWebView();
|
||||
return browser_ && browser_->UIT_GetWebView();
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder {
|
||||
return browser_ && browser_->GetWebView();
|
||||
return browser_ && browser_->UIT_GetWebView();
|
||||
}
|
||||
|
||||
- (BOOL)becomeFirstResponder {
|
||||
if (browser_ && browser_->GetWebView()) {
|
||||
browser_->GetWebViewHost()->SetFocus(YES);
|
||||
if (browser_ && browser_->UIT_GetWebView()) {
|
||||
browser_->UIT_GetWebViewHost()->SetFocus(YES);
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -160,8 +160,8 @@
|
||||
}
|
||||
|
||||
- (BOOL)resignFirstResponder {
|
||||
if (browser_ && browser_->GetWebView()) {
|
||||
browser_->GetWebViewHost()->SetFocus(NO);
|
||||
if (browser_ && browser_->UIT_GetWebView()) {
|
||||
browser_->UIT_GetWebViewHost()->SetFocus(NO);
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -170,8 +170,8 @@
|
||||
|
||||
- (void)setFrame:(NSRect)frameRect {
|
||||
[super setFrame:frameRect];
|
||||
if (browser_ && browser_->GetWebView())
|
||||
browser_->GetWebViewHost()->Resize(gfx::Rect(NSRectToCGRect(frameRect)));
|
||||
if (browser_ && browser_->UIT_GetWebView())
|
||||
browser_->UIT_GetWebViewHost()->Resize(gfx::Rect(NSRectToCGRect(frameRect)));
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ ClientHandler::~ClientHandler()
|
||||
CefHandler::RetVal ClientHandler::HandleAfterCreated(
|
||||
CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
Lock();
|
||||
if(!browser->IsPopup())
|
||||
{
|
||||
@ -62,6 +64,8 @@ CefHandler::RetVal ClientHandler::HandleAfterCreated(
|
||||
CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, bool isMainContent)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(!browser->IsPopup() && !frame.get())
|
||||
{
|
||||
Lock();
|
||||
@ -77,6 +81,8 @@ CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, bool isMainContent, int httpStatusCode)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(!browser->IsPopup() && !frame.get())
|
||||
{
|
||||
Lock();
|
||||
@ -93,6 +99,8 @@ CefHandler::RetVal ClientHandler::HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& failedUrl,
|
||||
CefString& errorText)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(errorCode == ERR_CACHE_MISS)
|
||||
{
|
||||
// Usually caused by navigating to a page with POST data via back or
|
||||
@ -123,6 +131,8 @@ CefHandler::RetVal ClientHandler::HandleDownloadResponse(
|
||||
const CefString& fileName, int64 contentLength,
|
||||
CefRefPtr<CefDownloadHandler>& handler)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Create the handler for the file download.
|
||||
handler = CreateDownloadHandler(m_DownloadListener, fileName);
|
||||
return RV_CONTINUE;
|
||||
@ -135,6 +145,8 @@ CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
|
||||
CefString& topCenter, CefString& topRight, CefString& bottomLeft,
|
||||
CefString& bottomCenter, CefString& bottomRight)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Place the page title at top left
|
||||
topLeft = title;
|
||||
// Place the page URL at top right
|
||||
@ -151,6 +163,8 @@ CefHandler::RetVal ClientHandler::HandlePrintHeaderFooter(
|
||||
CefHandler::RetVal ClientHandler::HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Value> object)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Add the V8 bindings.
|
||||
InitBindingTest(browser, frame, object);
|
||||
|
||||
@ -160,6 +174,8 @@ CefHandler::RetVal ClientHandler::HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
||||
CefHandler::RetVal ClientHandler::HandleBeforeWindowClose(
|
||||
CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(m_BrowserHwnd == browser->GetWindowHandle())
|
||||
{
|
||||
// Free the browser pointer so that the browser can be destroyed
|
||||
@ -172,6 +188,8 @@ CefHandler::RetVal ClientHandler::HandleConsoleMessage(
|
||||
CefRefPtr<CefBrowser> browser, const CefString& message,
|
||||
const CefString& source, int line)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
Lock();
|
||||
bool first_message = m_LogFile.empty();
|
||||
if(first_message) {
|
||||
@ -271,28 +289,52 @@ CefWindowHandle AppGetMainHwnd()
|
||||
return g_handler->GetMainHwnd();
|
||||
}
|
||||
|
||||
void RunGetSourceTest(CefRefPtr<CefFrame> frame)
|
||||
void RunGetSourceTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
// Retrieve the current page source and display.
|
||||
std::string source = frame->GetSource();
|
||||
source = StringReplace(source, "<", "<");
|
||||
source = StringReplace(source, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Source:" << "<pre>" << source
|
||||
<< "</pre></body></html>";
|
||||
frame->LoadString(ss.str(), "http://tests/getsource");
|
||||
// Execute the GetSource() call on the UI thread.
|
||||
class ExecTask : public CefThreadSafeBase<CefTask>
|
||||
{
|
||||
public:
|
||||
ExecTask(CefRefPtr<CefFrame> frame) : m_Frame(frame) {}
|
||||
virtual void Execute(CefThreadId threadId)
|
||||
{
|
||||
// Retrieve the current page source and display.
|
||||
std::string source = m_Frame->GetSource();
|
||||
source = StringReplace(source, "<", "<");
|
||||
source = StringReplace(source, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Source:" << "<pre>" << source
|
||||
<< "</pre></body></html>";
|
||||
m_Frame->LoadString(ss.str(), "http://tests/getsource");
|
||||
}
|
||||
private:
|
||||
CefRefPtr<CefFrame> m_Frame;
|
||||
};
|
||||
CefPostTask(TID_UI, new ExecTask(browser->GetMainFrame()));
|
||||
}
|
||||
|
||||
void RunGetTextTest(CefRefPtr<CefFrame> frame)
|
||||
void RunGetTextTest(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
// Retrieve the current page text and display.
|
||||
std::string text = frame->GetText();
|
||||
text = StringReplace(text, "<", "<");
|
||||
text = StringReplace(text, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Text:" << "<pre>" << text
|
||||
<< "</pre></body></html>";
|
||||
frame->LoadString(ss.str(), "http://tests/gettext");
|
||||
// Execute the GetText() call on the UI thread.
|
||||
class ExecTask : public CefThreadSafeBase<CefTask>
|
||||
{
|
||||
public:
|
||||
ExecTask(CefRefPtr<CefFrame> frame) : m_Frame(frame) {}
|
||||
virtual void Execute(CefThreadId threadId)
|
||||
{
|
||||
// Retrieve the current page text and display.
|
||||
std::string text = m_Frame->GetText();
|
||||
text = StringReplace(text, "<", "<");
|
||||
text = StringReplace(text, ">", ">");
|
||||
std::stringstream ss;
|
||||
ss << "<html><body>Text:" << "<pre>" << text
|
||||
<< "</pre></body></html>";
|
||||
m_Frame->LoadString(ss.str(), "http://tests/gettext");
|
||||
}
|
||||
private:
|
||||
CefRefPtr<CefFrame> m_Frame;
|
||||
};
|
||||
CefPostTask(TID_UI, new ExecTask(browser->GetMainFrame()));
|
||||
}
|
||||
|
||||
void RunRequestTest(CefRefPtr<CefBrowser> browser)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "download_handler.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
// Client implementation of the browser handler class
|
||||
class ClientHandler : public CefThreadSafeBase<CefHandler>
|
||||
@ -32,14 +32,16 @@ public:
|
||||
ClientHandler();
|
||||
~ClientHandler();
|
||||
|
||||
// Event called before a new window is created. The |parentBrowser| parameter
|
||||
// will point to the parent browser window, if any. The |popup| parameter
|
||||
// will be true if the new window is a popup window. If you create the window
|
||||
// yourself you should populate the window handle member of |createInfo| and
|
||||
// return RV_HANDLED. Otherwise, return RV_CONTINUE and the framework will
|
||||
// create the window. By default, a newly created window will recieve the
|
||||
// same handler as the parent window. To change the handler for the new
|
||||
// window modify the object that |handler| points to.
|
||||
// Called on the UI thread before a new window is created. The |parentBrowser|
|
||||
// parameter will point to the parent browser window, if any. The |popup|
|
||||
// parameter will be true if the new window is a popup window, in which case
|
||||
// |popupFeatures| will contain information about the style of popup window
|
||||
// requested. If you create the window yourself you should populate the window
|
||||
// handle member of |createInfo| and return RV_HANDLED. Otherwise, return
|
||||
// RV_CONTINUE and the framework will create the window. By default, a newly
|
||||
// created window will recieve the same handler as the parent window. To
|
||||
// change the handler for the new window modify the object that |handler|
|
||||
// points to.
|
||||
virtual RetVal HandleBeforeCreated(CefRefPtr<CefBrowser> parentBrowser,
|
||||
CefWindowInfo& createInfo, bool popup,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
@ -47,68 +49,73 @@ public:
|
||||
CefString& url,
|
||||
CefBrowserSettings& settings);
|
||||
|
||||
// Event called after a new window is created. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread after a new window is created. The return value is
|
||||
// currently ignored.
|
||||
virtual RetVal HandleAfterCreated(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// Event called when the address bar changes. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread when a frame's address has changed. The return
|
||||
// value is currently ignored.
|
||||
virtual RetVal HandleAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& url);
|
||||
|
||||
// Event called when the page title changes. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread when the page title changes. The return value is
|
||||
// currently ignored.
|
||||
virtual RetVal HandleTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title);
|
||||
|
||||
// Event called before browser navigation. The client has an opportunity to
|
||||
// modify the |request| object if desired. Return RV_HANDLED to cancel
|
||||
// navigation.
|
||||
// Called on the UI thread before browser navigation. The client has an
|
||||
// opportunity to modify the |request| object if desired. Return RV_HANDLED
|
||||
// to cancel navigation.
|
||||
virtual RetVal HandleBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavType navType, bool isRedirect)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called when the browser begins loading a page. The |frame| pointer
|
||||
// will be empty if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true if this
|
||||
// load is for the main content area and not an iframe. This method may not
|
||||
// be called if the load request fails. The return value is currently ignored.
|
||||
// Called on the UI thread when the browser begins loading a page. The |frame|
|
||||
// pointer will be empty if the event represents the overall load status and
|
||||
// not the load status for a particular frame. |isMainContent| will be true if
|
||||
// this load is for the main content area and not an iframe. This method may
|
||||
// not be called if the load request fails. The return value is currently
|
||||
// ignored.
|
||||
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
bool isMainContent);
|
||||
|
||||
// Event called when the browser is done loading a page. The |frame| pointer
|
||||
// will be empty if the event represents the overall load status and not the
|
||||
// load status for a particular frame. |isMainContent| will be true if this
|
||||
// load is for the main content area and not an iframe. This method will be
|
||||
// called irrespective of whether the request completes successfully. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread when the browser is done loading a page. The
|
||||
// |frame| pointer will be empty if the event represents the overall load
|
||||
// status and not the load status for a particular frame. |isMainContent| will
|
||||
// be true if this load is for the main content area and not an iframe. This
|
||||
// method will be called irrespective of whether the request completes
|
||||
// successfully. The return value is currently ignored.
|
||||
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
bool isMainContent,
|
||||
int httpStatusCode);
|
||||
|
||||
// Called when the browser fails to load a resource. |errorCode| is the
|
||||
// error code number and |failedUrl| is the URL that failed to load. To
|
||||
// provide custom error text assign the text to |errorText| and return
|
||||
// RV_HANDLED. Otherwise, return RV_CONTINUE for the default error text.
|
||||
// Called on the UI thread when the browser fails to load a resource.
|
||||
// |errorCode| is the error code number and |failedUrl| is the URL that failed
|
||||
// to load. To provide custom error text assign the text to |errorText| and
|
||||
// return RV_HANDLED. Otherwise, return RV_CONTINUE for the default error
|
||||
// text.
|
||||
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& failedUrl,
|
||||
CefString& errorText);
|
||||
|
||||
// Event called before a resource is loaded. To allow the resource to load
|
||||
// normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
// populate the |redirectUrl| value and return RV_CONTINUE. To specify
|
||||
// data for the resource return a CefStream object in |resourceStream|, set
|
||||
// 'mimeType| to the resource stream's mime type, and return RV_CONTINUE.
|
||||
// To cancel loading of the resource return RV_HANDLED.
|
||||
// Called on the IO thread before a resource is loaded. To allow the resource
|
||||
// to load normally return RV_CONTINUE. To redirect the resource to a new url
|
||||
// populate the |redirectUrl| value and return RV_CONTINUE. To specify data
|
||||
// for the resource return a CefStream object in |resourceStream|, set
|
||||
// |mimeType| to the resource stream's mime type, and return RV_CONTINUE. To
|
||||
// cancel loading of the resource return RV_HANDLED. Any modifications to
|
||||
// |request| will be observed. If the URL in |request| is changed and
|
||||
// |redirectUrl| is also set, the URL in |request| will be used.
|
||||
virtual RetVal HandleBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefString& redirectUrl,
|
||||
@ -116,39 +123,40 @@ public:
|
||||
CefString& mimeType,
|
||||
int loadFlags);
|
||||
|
||||
// Called to handle requests for URLs with an unknown protocol component.
|
||||
// Return RV_HANDLED to indicate that the request should succeed because it
|
||||
// was externally handled. Set |allow_os_execution| to true and return
|
||||
// RV_CONTINUE to attempt execution via the registered OS protocol handler,
|
||||
// if any. If RV_CONTINUE is returned and either |allow_os_execution| is false
|
||||
// or OS protocol handler execution fails then the request will fail with an
|
||||
// error condition.
|
||||
// Called on the IO thread to handle requests for URLs with an unknown
|
||||
// protocol component. Return RV_HANDLED to indicate that the request should
|
||||
// succeed because it was externally handled. Set |allow_os_execution| to true
|
||||
// and return RV_CONTINUE to attempt execution via the registered OS protocol
|
||||
// handler, if any. If RV_CONTINUE is returned and either |allow_os_execution|
|
||||
// is false or OS protocol handler execution fails then the request will fail
|
||||
// with an error condition.
|
||||
// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
|
||||
// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
|
||||
virtual RetVal HandleProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& url,
|
||||
bool* allow_os_execution)
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Called when a server indicates via the 'Content-Disposition' header that a
|
||||
// response represents a file to download. |mime_type| is the mime type for
|
||||
// the download, |file_name| is the suggested target file name and
|
||||
// |content_length| is either the value of the 'Content-Size' header or -1 if
|
||||
// no size was provided. Set |handler| to the CefDownloadHandler instance that
|
||||
// will recieve the file contents. Return RV_CONTINUE to download the file
|
||||
// or RV_HANDLED to cancel the file download.
|
||||
// Called on the UI thread when a server indicates via the
|
||||
// 'Content-Disposition' header that a response represents a file to download.
|
||||
// |mimeType| is the mime type for the download, |fileName| is the suggested
|
||||
// target file name and |contentLength| is either the value of the
|
||||
// 'Content-Size' header or -1 if no size was provided. Set |handler| to the
|
||||
// CefDownloadHandler instance that will recieve the file contents. Return
|
||||
// RV_CONTINUE to download the file or RV_HANDLED to cancel the file download.
|
||||
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& mimeType,
|
||||
const CefString& fileName,
|
||||
int64 contentLength,
|
||||
CefRefPtr<CefDownloadHandler>& handler);
|
||||
|
||||
// Called when the browser needs credentials from the user. |isProxy|
|
||||
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||
// Called on the IO thread when the browser needs credentials from the user.
|
||||
// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
// hostname and port number. Set |username| and |password| and return
|
||||
// RV_HANDLED to handle the request. Return RV_CONTINUE to cancel the request.
|
||||
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||
bool isProxy,
|
||||
const CefString& host,
|
||||
@ -157,55 +165,60 @@ public:
|
||||
CefString& username,
|
||||
CefString& password)
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called before a context menu is displayed. To cancel display of the
|
||||
// default context menu return RV_HANDLED.
|
||||
// Called on the UI thread before a context menu is displayed. To cancel
|
||||
// display of the default context menu return RV_HANDLED.
|
||||
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
||||
const MenuInfo& menuInfo)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called to optionally override the default text for a context menu
|
||||
// item. |label| contains the default text and may be modified to substitute
|
||||
// alternate text. The return value is currently ignored.
|
||||
// Called on the UI thread to optionally override the default text for a
|
||||
// context menu item. |label| contains the default text and may be modified to
|
||||
// substitute alternate text. The return value is currently ignored.
|
||||
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId, CefString& label)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called when an option is selected from the default context menu.
|
||||
// Return RV_HANDLED to cancel default handling of the action.
|
||||
// Called on the UI thread when an option is selected from the default context
|
||||
// menu. Return RV_HANDLED to cancel default handling of the action.
|
||||
virtual RetVal HandleMenuAction(CefRefPtr<CefBrowser> browser,
|
||||
MenuId menuId)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called to allow customization of standard print options before the
|
||||
// print dialog is displayed. |printOptions| allows specification of paper
|
||||
// size, orientation and margins. Note that the specified margins may be
|
||||
// adjusted if they are outside the range supported by the printer. All units
|
||||
// are in inches. Return RV_CONTINUE to display the default print options or
|
||||
// RV_HANDLED to display the modified |printOptions|.
|
||||
// Called on the UI thread to allow customization of standard print options
|
||||
// before the print dialog is displayed. |printOptions| allows specification
|
||||
// of paper size, orientation and margins. Note that the specified margins may
|
||||
// be adjusted if they are outside the range supported by the printer. All
|
||||
// units are in inches. Return RV_CONTINUE to display the default print
|
||||
// options or RV_HANDLED to display the modified |printOptions|.
|
||||
virtual RetVal HandlePrintOptions(CefRefPtr<CefBrowser> browser,
|
||||
CefPrintOptions& printOptions)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called to format print headers and footers. |printInfo| contains
|
||||
// platform-specific information about the printer context. |url| is the
|
||||
// URL if the currently printing page, |title| is the title of the currently
|
||||
// printing page, |currentPage| is the current page number and |maxPages| is
|
||||
// the total number of pages. Six default header locations are provided
|
||||
// by the implementation: top left, top center, top right, bottom left,
|
||||
// bottom center and bottom right. To use one of these default locations
|
||||
// just assign a string to the appropriate variable. To draw the header
|
||||
// and footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
||||
// Called on the UI thread to format print headers and footers. |printInfo|
|
||||
// contains platform-specific information about the printer context. |url| is
|
||||
// the URL if the currently printing page, |title| is the title of the
|
||||
// currently printing page, |currentPage| is the current page number and
|
||||
// |maxPages| is the total number of pages. Six default header locations are
|
||||
// provided by the implementation: top left, top center, top right, bottom
|
||||
// left, bottom center and bottom right. To use one of these default locations
|
||||
// just assign a string to the appropriate variable. To draw the header and
|
||||
// footer yourself return RV_HANDLED. Otherwise, populate the approprate
|
||||
// variables and return RV_CONTINUE.
|
||||
virtual RetVal HandlePrintHeaderFooter(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
@ -220,29 +233,32 @@ public:
|
||||
CefString& bottomCenter,
|
||||
CefString& bottomRight);
|
||||
|
||||
// Run a JS alert message. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert.
|
||||
// Called on the UI thread to run a JS alert message. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert.
|
||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& message)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
||||
// set |retval| to true if the user accepted the confirmation.
|
||||
// Called on the UI thread to run a JS confirm request. Return RV_CONTINUE to
|
||||
// display the default alert or RV_HANDLED if you displayed a custom alert. If
|
||||
// you handled the alert set |retval| to true if the user accepted the
|
||||
// confirmation.
|
||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& message, bool& retval)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
||||
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
||||
// set |retval| to true if the user accepted the prompt and request and
|
||||
// |result| to the resulting value.
|
||||
// Called on the UI thread to run a JS prompt request. Return RV_CONTINUE to
|
||||
// display the default prompt or RV_HANDLED if you displayed a custom prompt.
|
||||
// If you handled the prompt set |retval| to true if the user accepted the
|
||||
// prompt and request and |result| to the resulting value.
|
||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& message,
|
||||
@ -250,92 +266,99 @@ public:
|
||||
bool& retval,
|
||||
CefString& result)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called for binding to a frame's JavaScript global object. The
|
||||
// return value is currently ignored.
|
||||
// Called on the UI thread for adding values to a frame's JavaScript 'window'
|
||||
// object. The return value is currently ignored.
|
||||
virtual RetVal HandleJSBinding(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object);
|
||||
|
||||
// Called just before a window is closed. The return value is currently
|
||||
// ignored.
|
||||
// Called on the UI thread just before a window is closed. The return value is
|
||||
// currently ignored.
|
||||
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// Called when the browser component is about to loose focus. For instance,
|
||||
// if focus was on the last HTML element and the user pressed the TAB key.
|
||||
// The return value is currently ignored.
|
||||
// Called on the UI thread when the browser component is about to loose focus.
|
||||
// For instance, if focus was on the last HTML element and the user pressed
|
||||
// the TAB key. The return value is currently ignored.
|
||||
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser, bool reverse)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Called when the browser component is requesting focus. |isWidget| will be
|
||||
// true if the focus is requested for a child widget of the browser window.
|
||||
// Return RV_CONTINUE to allow the focus to be set or RV_HANDLED to cancel
|
||||
// setting the focus.
|
||||
// Called on the UI thread when the browser component is requesting focus.
|
||||
// |isWidget| will be true if the focus is requested for a child widget of the
|
||||
// browser window. Return RV_CONTINUE to allow the focus to be set or
|
||||
// RV_HANDLED to cancel setting the focus.
|
||||
virtual RetVal HandleSetFocus(CefRefPtr<CefBrowser> browser,
|
||||
bool isWidget)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called when the browser is about to display a tooltip. |text|
|
||||
// contains the text that will be displayed in the tooltip. To handle
|
||||
// the display of the tooltip yourself return RV_HANDLED. Otherwise,
|
||||
// you can optionally modify |text| and then return RV_CONTINUE to allow
|
||||
// the browser to display the tooltip.
|
||||
// Called on the UI thread when the browser component receives a keyboard
|
||||
// event. |type| is the type of keyboard event, |code| is the windows scan-
|
||||
// code for the event, |modifiers| is a set of bit-flags describing any
|
||||
// pressed modifier keys and |isSystemKey| is true if Windows considers this a
|
||||
// 'system key' message (see
|
||||
// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx). Return
|
||||
// RV_HANDLED if the keyboard event was handled or RV_CONTINUE to allow the
|
||||
// browser component to handle the event.
|
||||
virtual RetVal HandleKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
KeyEventType type,
|
||||
int code,
|
||||
int modifiers,
|
||||
bool isSystemKey)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Called on the UI thread when the browser is about to display a tooltip.
|
||||
// |text| contains the text that will be displayed in the tooltip. To handle
|
||||
// the display of the tooltip yourself return RV_HANDLED. Otherwise, you can
|
||||
// optionally modify |text| and then return RV_CONTINUE to allow the browser
|
||||
// to display the tooltip.
|
||||
virtual RetVal HandleTooltip(CefRefPtr<CefBrowser> browser,
|
||||
CefString& text)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Event called when the browser has a status message. |text| contains the
|
||||
// text that will be displayed in the status message and |type| indicates the
|
||||
// status message type. The return value is currently ignored.
|
||||
/*--cef()--*/
|
||||
// Called on the UI thread when the browser has a status message. |text|
|
||||
// contains the text that will be displayed in the status message and |type|
|
||||
// indicates the status message type. The return value is currently ignored.
|
||||
virtual RetVal HandleStatus(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& text, StatusType type)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Called when the browser component receives a keyboard event.
|
||||
// |type| is the type of keyboard event (see |KeyEventType|).
|
||||
// |code| is the windows scan-code for the event.
|
||||
// |modifiers| is a set of bit-flags describing any pressed modifier keys.
|
||||
// |isSystemKey| is set if Windows considers this a 'system key' message;
|
||||
// (see http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx)
|
||||
// Return RV_HANDLED if the keyboard event was handled or RV_CONTINUE
|
||||
// to allow the browser component to handle the event.
|
||||
RetVal HandleKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
KeyEventType type,
|
||||
int code,
|
||||
int modifiers,
|
||||
bool isSystemKey)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
// Called on the UI thread to display a console message. Return RV_HANDLED to
|
||||
// stop the message from being output to the console.
|
||||
virtual RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message,
|
||||
const CefString& source, int line);
|
||||
|
||||
// Called to display a console message. Return RV_HANDLED to stop the message
|
||||
// from being output to the console.
|
||||
RetVal HandleConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& message,
|
||||
const CefString& source, int line);
|
||||
|
||||
// Called to report find results returned by CefBrowser::Find(). |identifer|
|
||||
// is the identifier passed to CefBrowser::Find(), |count| is the number of
|
||||
// matches currently identified, |selectionRect| is the location of where the
|
||||
// match was found (in window coordinates), |activeMatchOrdinal| is the
|
||||
// current position in the search results, and |finalUpdate| is true if this
|
||||
// is the last find notification. The return value is currently ignored.
|
||||
// Called on the UI thread to report find results returned by
|
||||
// CefBrowser::Find(). |identifer| is the identifier passed to
|
||||
// CefBrowser::Find(), |count| is the number of matches currently identified,
|
||||
// |selectionRect| is the location of where the match was found (in window
|
||||
// coordinates), |activeMatchOrdinal| is the current position in the search
|
||||
// results, and |finalUpdate| is true if this is the last find notification.
|
||||
// The return value is currently ignored.
|
||||
virtual RetVal HandleFindResult(CefRefPtr<CefBrowser> browser,
|
||||
int identifier, int count,
|
||||
const CefRect& selectionRect,
|
||||
int activeMatchOrdinal, bool finalUpdate)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
@ -400,8 +423,8 @@ CefWindowHandle AppGetMainHwnd();
|
||||
std::string AppGetWorkingDirectory();
|
||||
|
||||
// Implementations for various tests.
|
||||
void RunGetSourceTest(CefRefPtr<CefFrame> frame);
|
||||
void RunGetTextTest(CefRefPtr<CefFrame> frame);
|
||||
void RunGetSourceTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunGetTextTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunRequestTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunJavaScriptExecuteTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunPopupTest(CefRefPtr<CefBrowser> browser);
|
||||
|
@ -292,12 +292,12 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
|
||||
- (IBAction)testGetSource:(id)sender {
|
||||
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunGetSourceTest(g_handler->GetBrowser()->GetMainFrame());
|
||||
RunGetSourceTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testGetText:(id)sender {
|
||||
if(g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunGetTextTest(g_handler->GetBrowser()->GetMainFrame());
|
||||
RunGetTextTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testJSBinding:(id)sender {
|
||||
@ -372,6 +372,7 @@ CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
||||
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
||||
CefString& url, CefBrowserSettings& settings)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
@ -379,6 +380,8 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& url)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
|
||||
{
|
||||
// Set the edit window text
|
||||
@ -393,6 +396,8 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
CefRefPtr<CefBrowser> browser, const CefString& title)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
// Set the frame window title bar
|
||||
NSWindow* window = (NSWindow*)m_MainHwnd;
|
||||
std::string titleStr(title);
|
||||
@ -406,6 +411,8 @@ CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
|
||||
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
CefString& mimeType, int loadFlags)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
std::string url = request->GetURL();
|
||||
if(url == "http://tests/request") {
|
||||
// Show the request contents
|
||||
|
@ -472,50 +472,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
browser->StopLoad();
|
||||
return 0;
|
||||
case ID_TESTS_GETSOURCE: // Test the GetSource function
|
||||
if(browser.get()) {
|
||||
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
RunGetSourceTest(browser->GetMainFrame());
|
||||
#else // !TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
// Execute the GetSource() call on the FILE thread to avoid blocking
|
||||
// the UI thread when using a multi-threaded message loop
|
||||
// (issue #79).
|
||||
class ExecTask : public CefThreadSafeBase<CefTask>
|
||||
{
|
||||
public:
|
||||
ExecTask(CefRefPtr<CefFrame> frame) : m_Frame(frame) {}
|
||||
virtual void Execute(CefThreadId threadId)
|
||||
{
|
||||
RunGetSourceTest(m_Frame);
|
||||
}
|
||||
private:
|
||||
CefRefPtr<CefFrame> m_Frame;
|
||||
};
|
||||
CefPostTask(TID_FILE, new ExecTask(browser->GetMainFrame()));
|
||||
#endif // !TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
}
|
||||
if(browser.get())
|
||||
RunGetSourceTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_GETTEXT: // Test the GetText function
|
||||
if(browser.get()) {
|
||||
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
RunGetTextTest(browser->GetMainFrame());
|
||||
#else // !TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
// Execute the GetText() call on the FILE thread to avoid blocking
|
||||
// the UI thread when using a multi-threaded message loop
|
||||
// (issue #79).
|
||||
class ExecTask : public CefThreadSafeBase<CefTask>
|
||||
{
|
||||
public:
|
||||
ExecTask(CefRefPtr<CefFrame> frame) : m_Frame(frame) {}
|
||||
virtual void Execute(CefThreadId threadId)
|
||||
{
|
||||
RunGetTextTest(m_Frame);
|
||||
}
|
||||
private:
|
||||
CefRefPtr<CefFrame> m_Frame;
|
||||
};
|
||||
CefPostTask(TID_FILE, new ExecTask(browser->GetMainFrame()));
|
||||
#endif // !TEST_SINGLE_THREADED_MESSAGE_LOOP
|
||||
}
|
||||
if(browser.get())
|
||||
RunGetTextTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_JAVASCRIPT_BINDING: // Test the V8 binding handler
|
||||
if(browser.get())
|
||||
@ -679,6 +641,8 @@ CefHandler::RetVal ClientHandler::HandleBeforeCreated(
|
||||
const CefPopupFeatures& popupFeatures, CefRefPtr<CefHandler>& handler,
|
||||
CefString& url, CefBrowserSettings& settings)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(popup) {
|
||||
if(popupFeatures.xSet)
|
||||
createInfo.m_x = popupFeatures.x;
|
||||
@ -697,6 +661,8 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& url)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain())
|
||||
{
|
||||
// Set the edit window text
|
||||
@ -708,6 +674,8 @@ CefHandler::RetVal ClientHandler::HandleAddressChange(
|
||||
CefHandler::RetVal ClientHandler::HandleTitleChange(
|
||||
CefRefPtr<CefBrowser> browser, const CefString& title)
|
||||
{
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Set the frame window title bar
|
||||
CefWindowHandle hwnd = browser->GetWindowHandle();
|
||||
if(!browser->IsPopup())
|
||||
@ -724,6 +692,8 @@ CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad(
|
||||
CefString& redirectUrl, CefRefPtr<CefStreamReader>& resourceStream,
|
||||
CefString& mimeType, int loadFlags)
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
|
||||
DWORD dwSize;
|
||||
LPBYTE pBytes;
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
// continue receiving data and |false| to cancel.
|
||||
virtual bool ReceivedData(void* data, int data_size)
|
||||
{
|
||||
ASSERT(CefCurrentlyOn(TID_UI));
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
if(data_size == 0)
|
||||
return true;
|
||||
@ -118,7 +118,7 @@ public:
|
||||
// The download is complete.
|
||||
virtual void Complete()
|
||||
{
|
||||
ASSERT(CefCurrentlyOn(TID_UI));
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Flush and close the file on the FILE thread.
|
||||
PostOnThread(TID_FILE, this, &ClientDownloadHandler::OnComplete);
|
||||
@ -130,7 +130,7 @@ public:
|
||||
|
||||
void OnOpen()
|
||||
{
|
||||
ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
REQUIRE_FILE_THREAD();
|
||||
|
||||
if(file_)
|
||||
return;
|
||||
@ -179,7 +179,7 @@ public:
|
||||
|
||||
void OnComplete()
|
||||
{
|
||||
ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
REQUIRE_FILE_THREAD();
|
||||
|
||||
if(!file_)
|
||||
return;
|
||||
@ -196,7 +196,7 @@ public:
|
||||
|
||||
void OnReceivedData()
|
||||
{
|
||||
ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
REQUIRE_FILE_THREAD();
|
||||
|
||||
std::vector<std::vector<char>*> data;
|
||||
|
||||
|
@ -3,9 +3,10 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "include/cef_wrapper.h"
|
||||
#include "resource_util.h"
|
||||
#include "scheme_test.h"
|
||||
#include "string_util.h"
|
||||
#include "resource_util.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "resource.h"
|
||||
@ -30,6 +31,8 @@ public:
|
||||
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
|
||||
CefString& mime_type, int* response_length)
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
|
||||
bool handled = false;
|
||||
|
||||
Lock();
|
||||
@ -91,6 +94,7 @@ public:
|
||||
// Cancel processing of the request.
|
||||
virtual void Cancel()
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
}
|
||||
|
||||
// Copy up to |bytes_to_read| bytes into |data_out|. If the copy succeeds
|
||||
@ -99,6 +103,8 @@ public:
|
||||
virtual bool ReadResponse(void* data_out, int bytes_to_read,
|
||||
int* bytes_read)
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
|
||||
bool has_data = false;
|
||||
*bytes_read = 0;
|
||||
|
||||
@ -134,6 +140,7 @@ public:
|
||||
// Return a new scheme handler instance to handle the request.
|
||||
virtual CefRefPtr<CefSchemeHandler> Create()
|
||||
{
|
||||
REQUIRE_IO_THREAD();
|
||||
return new ClientSchemeHandler();
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
@ -6,6 +6,8 @@
|
||||
#ifndef _CEFCLIENT_UTIL_H
|
||||
#define _CEFCLIENT_UTIL_H
|
||||
|
||||
#include "include/cef.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
@ -56,4 +58,8 @@
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI));
|
||||
#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO));
|
||||
#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
|
||||
#endif // _CEFCLIENT_UTIL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user