Compare commits

...

43 Commits
3359 ... 1025

Author SHA1 Message Date
Marshall Greenblatt
811d5c9467 Merge revision 824 changes:
- Add CefZoomHandler interface to support custom zoom handling (issue #733).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@826 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-10-01 20:38:01 +00:00
Marshall Greenblatt
b0435f2ffa Merge revision 799 changes:
- Mac: Trigger keydown events for single keystrokes (issue #664).


git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@801 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-09-26 16:45:01 +00:00
Marshall Greenblatt
494b676c5f Merge revision 756 changes:
- Rename PROXY_TYPE values to avoid naming conflict (issue #548).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@758 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-09-04 18:56:53 +00:00
Marshall Greenblatt
aaf8df75df Merge revision 753 changes:
- Add patch to fix opening of password protected files with CefZipReader (issue #496).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@755 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-09-04 17:10:13 +00:00
Marshall Greenblatt
e390fbe5b6 Merge revision 745 changes:
- Improve the handling of invalidation/painting for off-screen rendering (issue #695).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@746 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-21 19:49:11 +00:00
Marshall Greenblatt
71500d0792 Merge revision 743 changes:
- Optimize the cefclient off-screen rendering example (issue #697).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@744 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-16 19:22:25 +00:00
Marshall Greenblatt
6eaeda0ebb Merge revision 741 changes:
- Add the ability to customize the animation frame rate (issue #697).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@742 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-15 15:16:39 +00:00
Marshall Greenblatt
4a9c00b2e7 Merge revision 739 changes:
- Add the ability to customize the animation frame rate (issue #697).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@740 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-14 23:34:56 +00:00
Marshall Greenblatt
f0e11cc5df Merge revision 736 and revision 737 changes:
- Fix crashes/assertions when CefBrowserImpl is destroyed on a non-UI thread (issue #694).
- Improve the handling of invalidation/painting for off-screen rendering (issue #695).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@738 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-13 16:36:57 +00:00
Marshall Greenblatt
be1fd6d3c3 Merge revision 734 changes:
- Only release the request context proxy if it exists (issue #677).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@735 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-07 17:19:31 +00:00
Marshall Greenblatt
2bb74087b6 Mac: Fix compile error.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@724 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-29 23:08:26 +00:00
Marshall Greenblatt
f68c8439b6 Merge revision 698 and 699 changes:
- Add persistent HTML5 application cache support (issue #543).
- Standardize the approach for creating new directories.
- Allow empty message parameters passed to CefJSDialogHandler.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@700 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-20 19:46:23 +00:00
Marshall Greenblatt
748b664824 Merge revision 634 changes:
- Linux: Fix compile error due to gdk_pixbuf_unref deprecation (issue #593).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@693 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-11 20:47:29 +00:00
Marshall Greenblatt
74c98bf3fb Merge revision 686 changes:
- Mac: Fix the need to press the delete key twice to delete a character after changing the IME language (issue #635).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@687 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-11 18:44:29 +00:00
Marshall Greenblatt
0eba41d901 Update the AUTHORS.txt file.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@685 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-11 17:40:38 +00:00
Marshall Greenblatt
6fc2dd37f9 Merge revision 676 changes:
- Mac: Add IME support (issue #557).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@677 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-07 18:44:21 +00:00
Marshall Greenblatt
962b2a254d Merge revision 663 changes:
- Mac: Delay destroying the browser window until pending drag operations have completed (issue #610).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@664 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-01 18:43:15 +00:00
Marshall Greenblatt
252e8f9cb6 Merge revision 661 changes:
- Fix misspelling of the Referer HTTP header (issue #619).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@662 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-06-01 17:42:50 +00:00
Marshall Greenblatt
99ebb866b6 Merge revision 655 changes:
- Windows: Delay destroying the browser window until pending drag operations have completed (issue #610).
- Revert: Windows: Reset the window procedure in the WebWidgetHost destructor to avoid crashes if messages are delivered after the window is destroyed.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@656 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-30 18:06:58 +00:00
Marshall Greenblatt
46021aafbd Merge revision 650 changes:
- Make sure BrowserRequestContextProxy is only used on the IO thread (issue #542).
- Windows: Reset the window procedure in the WebWidgetHost destructor to avoid crashes if messages are delivered after the window is destroyed.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@651 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-25 20:46:44 +00:00
Marshall Greenblatt
0bccf1bff2 Merge revision 643 and revision 648 changes:
- Improve the cefclient transparency test by adding the ability to view individual pixel values (issue #584).
- Change cefclient off-screen rendering example to account for premultiplied alpha values (issue #584).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@649 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-25 14:33:01 +00:00
Marshall Greenblatt
2bd2007fb9 Update tools_gyp.patch.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@641 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-22 18:33:20 +00:00
Marshall Greenblatt
b43117ea8e Merge revision 638 changes:
- Add missing break statements in CefContext::GetDataResource (issue #236).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@639 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-22 16:47:23 +00:00
Marshall Greenblatt
93e32f3c9b Merge revision 568 changes:
- Execute the CefFocusHandler::OnSetFocus callback for calls to CefBrowser::SetFocus and mouse clicks on the view (issue #563).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@637 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-22 15:29:13 +00:00
Marshall Greenblatt
7da9e04940 Merge revision 635 changes:
- Win: Fix mouse wheel scrolling in second monitor (issue #595).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@636 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-18 21:58:38 +00:00
Marshall Greenblatt
8cd487c1fe Merge revision 569 and 624 changes:
- Add off-screen rendering support for Mac OS-X (issue #540).
- Add patch for ninja build support on Mac OS-X.
- Avoid calling OnSetFocus multiple times (issue #563).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@626 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-16 17:02:04 +00:00
Marshall Greenblatt
36657868d3 Merge revision 617 changes:
- Fix usage of ReadRawData return value in scheme handler implementation (issue #534).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@618 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-05-04 18:35:09 +00:00
Marshall Greenblatt
fd1549571d Update to Chromium version 18.0.1025.166.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@607 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-04-26 18:25:20 +00:00
Marshall Greenblatt
f73db66461 Merge revision 603 changes:
- Fix memory leak when returning zero-length strings from V8 (issue #581).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@605 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-04-25 20:01:47 +00:00
Marshall Greenblatt
b1f9c5428c Merge revision 600 changes:
- Add ability to directly retrieve plugin information (issue #575).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@601 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-04-20 21:15:58 +00:00
Marshall Greenblatt
77a340ec9c Merge revision 598 changes:
- Mac: Add flagsChanged: signal handler so that modifier keys are correctly passed to JS (issue #574).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@599 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-04-20 18:49:43 +00:00
Marshall Greenblatt
af17a1a12d Merge revision 574 changes:
- Add CefCookieManager::SetSupportedSchemes method which supports cookie storage for non-http(s) schemes (issue #567).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@575 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-04-03 19:25:36 +00:00
Marshall Greenblatt
7ab2a3b36a Merge revision 561 changes:
- Fix problem with CefBrowser::GetMainFrame() clearing the frame URL value (issue #556).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@562 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-30 17:19:41 +00:00
Marshall Greenblatt
0d33fc8cd2 Merge revision 556 changes:
- Fix race condition in CefCookieManagerImpl constructor (issue #542).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@558 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-29 16:53:16 +00:00
Marshall Greenblatt
6c669ab484 Fix compile errors.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@547 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-23 00:20:54 +00:00
Marshall Greenblatt
b23f791dd5 Merge revision 542 changes:
- Add CefCookieManager interface and CefRequestHandler::GetCookieManager for custom cookie handling (issue #542).
- Support getting and setting cookies with custom scheme handlers (issue #555).
- Support calling CefFrame::GetIdentifier and CefFrame::GetURL on any thread (issue #556).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@543 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-22 22:09:09 +00:00
Marshall Greenblatt
c48206e801 Revert revision 535 changes: Add CefCookieManager interface and CefRequestHandler::GetCookieManager for custom cookie handling (issue #542).
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@540 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-21 16:13:31 +00:00
Marshall Greenblatt
ee6315dd47 Mac: Fix compile error.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@537 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-16 14:01:57 +00:00
Marshall Greenblatt
7d59dad3b5 Merge revision 534 changes:
- Add CefCookieManager interface and CefRequestHandler::GetCookieManager for custom cookie handling (issue #542).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@535 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-15 22:39:36 +00:00
Marshall Greenblatt
ce081248da Update to Chromium version 18.0.1025.54.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@530 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-13 18:35:46 +00:00
Marshall Greenblatt
2f7c28cb00 Merge revision 526 changes:
- Invalidate the entire scroll rect when using off-screen rendering mode (issue #469).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@527 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-03-13 15:06:54 +00:00
Marshall Greenblatt
c84e36a96d Merge revision 514 changes:
- Windows: Fix crash in cefclient when entering long URLs via the address bar (issue #532).

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@515 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-02-21 22:51:01 +00:00
Marshall Greenblatt
e501bfad99 Create 1025 release branch.
git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1025@507 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-02-17 17:35:06 +00:00
131 changed files with 6785 additions and 2054 deletions

View File

@@ -20,3 +20,7 @@ Joinerysoft Ltd. <cpinfold@joinerysoft.com>
Johan Björk <phb@spotify.com> Johan Björk <phb@spotify.com>
Dmitry Azaraev <dmitry.azaraev@gmail.com> Dmitry Azaraev <dmitry.azaraev@gmail.com>
David Xue <ddxue27@gmail.com> David Xue <ddxue27@gmail.com>
Russell (Rusty) Richards <fe3o4y@gmail.com>
Brian Power <powerbf.it@gmail.com>
Corey Lucier <clucier@adobe.com>
Mihai Tica <mitica@adobe.com>

View File

@@ -16,6 +16,5 @@
# http://dev.chromium.org/developers/how-tos/get-the-code # http://dev.chromium.org/developers/how-tos/get-the-code
{ {
'chromium_url': 'http://src.chromium.org/svn/trunk/src', 'release_url': 'http://src.chromium.org/svn/releases/18.0.1025.166',
'chromium_revision': '119867',
} }

10
cef.gyp
View File

@@ -212,6 +212,7 @@
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework', '$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
], ],
}, },
'sources': [ 'sources': [
@@ -490,6 +491,7 @@
], ],
'xcode_settings': { 'xcode_settings': {
'INSTALL_PATH': '@executable_path', 'INSTALL_PATH': '@executable_path',
'DYLIB_INSTALL_NAME_BASE': '@executable_path',
# The libcef_static target contains ObjC categories. Passing the -ObjC flag # The libcef_static target contains ObjC categories. Passing the -ObjC flag
# is necessary to properly load them and avoid a "selector not recognized" # is necessary to properly load them and avoid a "selector not recognized"
# runtime error. See http://developer.apple.com/library/mac/#qa/qa1490/_index.html # runtime error. See http://developer.apple.com/library/mac/#qa/qa1490/_index.html
@@ -679,6 +681,8 @@
'libcef/browser_persistent_cookie_store.h', 'libcef/browser_persistent_cookie_store.h',
'libcef/browser_request_context.cc', 'libcef/browser_request_context.cc',
'libcef/browser_request_context.h', 'libcef/browser_request_context.h',
'libcef/browser_request_context_proxy.cc',
'libcef/browser_request_context_proxy.h',
'libcef/browser_resource_loader_bridge.cc', 'libcef/browser_resource_loader_bridge.cc',
'libcef/browser_resource_loader_bridge.h', 'libcef/browser_resource_loader_bridge.h',
'libcef/browser_settings.cc', 'libcef/browser_settings.cc',
@@ -720,7 +724,10 @@
'libcef/cef_time.cc', 'libcef/cef_time.cc',
'libcef/cef_time_util.h', 'libcef/cef_time_util.h',
'libcef/command_line_impl.cc', 'libcef/command_line_impl.cc',
'libcef/cookie_impl.cc', 'libcef/cookie_manager_impl.cc',
'libcef/cookie_manager_impl.h',
'libcef/cookie_store_proxy.cc',
'libcef/cookie_store_proxy.h',
'libcef/drag_data_impl.cc', 'libcef/drag_data_impl.cc',
'libcef/drag_data_impl.h', 'libcef/drag_data_impl.h',
'libcef/drag_download_file.cc', 'libcef/drag_download_file.cc',
@@ -762,6 +769,7 @@
'libcef/url_impl.cc', 'libcef/url_impl.cc',
'libcef/v8_impl.cc', 'libcef/v8_impl.cc',
'libcef/v8_impl.h', 'libcef/v8_impl.h',
'libcef/web_plugin_impl.cc',
'libcef/web_urlrequest_impl.cc', 'libcef/web_urlrequest_impl.cc',
'libcef/web_urlrequest_impl.h', 'libcef/web_urlrequest_impl.h',
'libcef/webview_host.cc', 'libcef/webview_host.cc',

View File

@@ -47,9 +47,11 @@
'include/cef_url.h', 'include/cef_url.h',
'include/cef_v8.h', 'include/cef_v8.h',
'include/cef_v8context_handler.h', 'include/cef_v8context_handler.h',
'include/cef_web_plugin.h',
'include/cef_web_urlrequest.h', 'include/cef_web_urlrequest.h',
'include/cef_xml_reader.h', 'include/cef_xml_reader.h',
'include/cef_zip_reader.h', 'include/cef_zip_reader.h',
'include/cef_zoom_handler.h',
], ],
'autogen_capi_includes': [ 'autogen_capi_includes': [
'include/capi/cef_app_capi.h', 'include/capi/cef_app_capi.h',
@@ -87,9 +89,11 @@
'include/capi/cef_url_capi.h', 'include/capi/cef_url_capi.h',
'include/capi/cef_v8_capi.h', 'include/capi/cef_v8_capi.h',
'include/capi/cef_v8context_handler_capi.h', 'include/capi/cef_v8context_handler_capi.h',
'include/capi/cef_web_plugin_capi.h',
'include/capi/cef_web_urlrequest_capi.h', 'include/capi/cef_web_urlrequest_capi.h',
'include/capi/cef_xml_reader_capi.h', 'include/capi/cef_xml_reader_capi.h',
'include/capi/cef_zip_reader_capi.h', 'include/capi/cef_zip_reader_capi.h',
'include/capi/cef_zoom_handler_capi.h',
], ],
'autogen_library_side': [ 'autogen_library_side': [
'libcef_dll/ctocpp/app_ctocpp.cc', 'libcef_dll/ctocpp/app_ctocpp.cc',
@@ -102,6 +106,8 @@
'libcef_dll/cpptoc/command_line_cpptoc.h', 'libcef_dll/cpptoc/command_line_cpptoc.h',
'libcef_dll/ctocpp/content_filter_ctocpp.cc', 'libcef_dll/ctocpp/content_filter_ctocpp.cc',
'libcef_dll/ctocpp/content_filter_ctocpp.h', 'libcef_dll/ctocpp/content_filter_ctocpp.h',
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc', 'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
'libcef_dll/ctocpp/cookie_visitor_ctocpp.h', 'libcef_dll/ctocpp/cookie_visitor_ctocpp.h',
'libcef_dll/cpptoc/domdocument_cpptoc.cc', 'libcef_dll/cpptoc/domdocument_cpptoc.cc',
@@ -186,6 +192,8 @@
'libcef_dll/ctocpp/v8handler_ctocpp.h', 'libcef_dll/ctocpp/v8handler_ctocpp.h',
'libcef_dll/cpptoc/v8value_cpptoc.cc', 'libcef_dll/cpptoc/v8value_cpptoc.cc',
'libcef_dll/cpptoc/v8value_cpptoc.h', 'libcef_dll/cpptoc/v8value_cpptoc.h',
'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc',
'libcef_dll/cpptoc/web_plugin_info_cpptoc.h',
'libcef_dll/cpptoc/web_urlrequest_cpptoc.cc', 'libcef_dll/cpptoc/web_urlrequest_cpptoc.cc',
'libcef_dll/cpptoc/web_urlrequest_cpptoc.h', 'libcef_dll/cpptoc/web_urlrequest_cpptoc.h',
'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc', 'libcef_dll/ctocpp/web_urlrequest_client_ctocpp.cc',
@@ -196,6 +204,8 @@
'libcef_dll/cpptoc/xml_reader_cpptoc.h', 'libcef_dll/cpptoc/xml_reader_cpptoc.h',
'libcef_dll/cpptoc/zip_reader_cpptoc.cc', 'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
'libcef_dll/cpptoc/zip_reader_cpptoc.h', 'libcef_dll/cpptoc/zip_reader_cpptoc.h',
'libcef_dll/ctocpp/zoom_handler_ctocpp.cc',
'libcef_dll/ctocpp/zoom_handler_ctocpp.h',
], ],
'autogen_client_side': [ 'autogen_client_side': [
'libcef_dll/cpptoc/app_cpptoc.cc', 'libcef_dll/cpptoc/app_cpptoc.cc',
@@ -208,6 +218,8 @@
'libcef_dll/ctocpp/command_line_ctocpp.h', 'libcef_dll/ctocpp/command_line_ctocpp.h',
'libcef_dll/cpptoc/content_filter_cpptoc.cc', 'libcef_dll/cpptoc/content_filter_cpptoc.cc',
'libcef_dll/cpptoc/content_filter_cpptoc.h', 'libcef_dll/cpptoc/content_filter_cpptoc.h',
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc', 'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
'libcef_dll/cpptoc/cookie_visitor_cpptoc.h', 'libcef_dll/cpptoc/cookie_visitor_cpptoc.h',
'libcef_dll/ctocpp/domdocument_ctocpp.cc', 'libcef_dll/ctocpp/domdocument_ctocpp.cc',
@@ -292,6 +304,8 @@
'libcef_dll/cpptoc/v8handler_cpptoc.h', 'libcef_dll/cpptoc/v8handler_cpptoc.h',
'libcef_dll/ctocpp/v8value_ctocpp.cc', 'libcef_dll/ctocpp/v8value_ctocpp.cc',
'libcef_dll/ctocpp/v8value_ctocpp.h', 'libcef_dll/ctocpp/v8value_ctocpp.h',
'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc',
'libcef_dll/ctocpp/web_plugin_info_ctocpp.h',
'libcef_dll/ctocpp/web_urlrequest_ctocpp.cc', 'libcef_dll/ctocpp/web_urlrequest_ctocpp.cc',
'libcef_dll/ctocpp/web_urlrequest_ctocpp.h', 'libcef_dll/ctocpp/web_urlrequest_ctocpp.h',
'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc', 'libcef_dll/cpptoc/web_urlrequest_client_cpptoc.cc',
@@ -302,6 +316,8 @@
'libcef_dll/ctocpp/xml_reader_ctocpp.h', 'libcef_dll/ctocpp/xml_reader_ctocpp.h',
'libcef_dll/ctocpp/zip_reader_ctocpp.cc', 'libcef_dll/ctocpp/zip_reader_ctocpp.cc',
'libcef_dll/ctocpp/zip_reader_ctocpp.h', 'libcef_dll/ctocpp/zip_reader_ctocpp.h',
'libcef_dll/cpptoc/zoom_handler_cpptoc.cc',
'libcef_dll/cpptoc/zoom_handler_cpptoc.h',
], ],
}, },
} }

View File

@@ -111,6 +111,8 @@
'tests/cefclient/client_handler_win.cpp', 'tests/cefclient/client_handler_win.cpp',
'tests/cefclient/clientplugin.cpp', 'tests/cefclient/clientplugin.cpp',
'tests/cefclient/clientplugin.h', 'tests/cefclient/clientplugin.h',
'tests/cefclient/osrenderer.cpp',
'tests/cefclient/osrenderer.h',
'tests/cefclient/osrplugin.cpp', 'tests/cefclient/osrplugin.cpp',
'tests/cefclient/osrplugin.h', 'tests/cefclient/osrplugin.h',
'tests/cefclient/osrplugin_test.cpp', 'tests/cefclient/osrplugin_test.cpp',
@@ -135,6 +137,10 @@
'cefclient_sources_mac': [ 'cefclient_sources_mac': [
'tests/cefclient/cefclient_mac.mm', 'tests/cefclient/cefclient_mac.mm',
'tests/cefclient/client_handler_mac.mm', 'tests/cefclient/client_handler_mac.mm',
'tests/cefclient/osrenderer.cpp',
'tests/cefclient/osrenderer.h',
'tests/cefclient/osrtest_mac.h',
'tests/cefclient/osrtest_mac.mm',
'tests/cefclient/resource_util_mac.mm', 'tests/cefclient/resource_util_mac.mm',
], ],
'cefclient_bundle_resources_mac': [ 'cefclient_bundle_resources_mac': [
@@ -146,6 +152,9 @@
'tests/cefclient/res/extensionperf.html', 'tests/cefclient/res/extensionperf.html',
'tests/cefclient/res/localstorage.html', 'tests/cefclient/res/localstorage.html',
'tests/cefclient/res/logo.png', 'tests/cefclient/res/logo.png',
'tests/cefclient/res/logoball.png',
'tests/cefclient/res/osrtest.html',
'tests/cefclient/res/transparency.html',
'tests/cefclient/res/xmlhttprequest.html', 'tests/cefclient/res/xmlhttprequest.html',
], ],
'cefclient_sources_linux': [ 'cefclient_sources_linux': [

View File

@@ -259,8 +259,8 @@ typedef struct _cef_browser_t {
// Send a key event to the browser. // Send a key event to the browser.
/// ///
void (CEF_CALLBACK *send_key_event)(struct _cef_browser_t* self, void (CEF_CALLBACK *send_key_event)(struct _cef_browser_t* self,
enum cef_key_type_t type, int key, int modifiers, int sysChar, enum cef_key_type_t type, const struct _cef_key_info_t* keyInfo,
int imeChar); int modifiers);
/// ///
// Send a mouse click event to the browser. The |x| and |y| coordinates are // Send a mouse click event to the browser. The |x| and |y| coordinates are
@@ -279,10 +279,11 @@ typedef struct _cef_browser_t {
/// ///
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are // Send a mouse wheel event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view. // relative to the upper-left corner of the view. The |deltaX| and |deltaY|
// values represent the movement delta in the X and Y directions respectively.
/// ///
void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_t* self, void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_t* self,
int x, int y, int delta); int x, int y, int deltaX, int deltaY);
/// ///
// Send a focus event to the browser. // Send a focus event to the browser.

View File

@@ -137,6 +137,13 @@ typedef struct _cef_client_t {
/// ///
struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)( struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)(
struct _cef_client_t* self); struct _cef_client_t* self);
///
// Return the handler for zoom events. If no handler is provided the default
// zoom behavior will be used.
///
struct _cef_zoom_handler_t* (CEF_CALLBACK *get_zoom_handler)(
struct _cef_client_t* self);
} cef_client_t; } cef_client_t;

View File

@@ -46,49 +46,87 @@ extern "C" {
/// ///
// Visit all cookies. The returned cookies are ordered by longest path, then by // Structure used for managing cookies. The functions of this structure may be
// earliest creation date. Returns false (0) if cookies cannot be accessed. // called on any thread unless otherwise indicated.
/// ///
CEF_EXPORT int cef_visit_all_cookies(struct _cef_cookie_visitor_t* visitor); typedef struct _cef_cookie_manager_t {
///
// Base structure.
///
cef_base_t base;
///
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. Must be called before any cookies are
// accessed.
///
void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self,
cef_string_list_t schemes);
///
// Visit all cookies. The returned cookies are ordered by longest path, then
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
///
int (CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t* self,
struct _cef_cookie_visitor_t* visitor);
///
// Visit a subset of cookies. The results are filtered by the given url
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
// cookies will also be included in the results. The returned cookies are
// ordered by longest path, then by earliest creation date. Returns false (0)
// if cookies cannot be accessed.
///
int (CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t* self,
const cef_string_t* url, int includeHttpOnly,
struct _cef_cookie_visitor_t* visitor);
///
// Sets a cookie given a valid URL and explicit user-provided cookie
// attributes. This function expects each attribute to be well-formed. It will
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and will return false (0) without
// setting the cookie if such characters are found. This function must be
// called on the IO thread.
///
int (CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t* self,
const cef_string_t* url, const struct _cef_cookie_t* cookie);
///
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
// cookies for all hosts and domains will be deleted. Returns false (0) if a
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
// function must be called on the IO thread.
///
int (CEF_CALLBACK *delete_cookies)(struct _cef_cookie_manager_t* self,
const cef_string_t* url, const cef_string_t* cookie_name);
///
// Sets the directory path that will be used for storing cookie data. If
// |path| is NULL data will be stored in memory only. Returns false (0) if
// cookies cannot be accessed.
///
int (CEF_CALLBACK *set_storage_path)(struct _cef_cookie_manager_t* self,
const cef_string_t* path);
} cef_cookie_manager_t;
/// ///
// Visit a subset of cookies. The results are filtered by the given url scheme, // Returns the global cookie manager. By default data will be stored at
// host, domain and path. If |includeHttpOnly| is true (1) HTTP-only cookies // CefSettings.cache_path if specified or in memory otherwise.
// will also be included in the results. The returned cookies are ordered by
// longest path, then by earliest creation date. Returns false (0) if cookies
// cannot be accessed.
/// ///
CEF_EXPORT int cef_visit_url_cookies(const cef_string_t* url, CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager();
int includeHttpOnly, struct _cef_cookie_visitor_t* visitor);
/// ///
// Sets a cookie given a valid URL and explicit user-provided cookie attributes. // Creates a new cookie manager. If |path| is NULL data will be stored in memory
// This function expects each attribute to be well-formed. It will check for // only. Returns NULL if creation fails.
// disallowed characters (e.g. the ';' character is disallowed within the cookie
// value attribute) and will return false (0) without setting the cookie if such
// characters are found. This function must be called on the IO thread.
/// ///
CEF_EXPORT int cef_set_cookie(const cef_string_t* url, CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
const struct _cef_cookie_t* cookie); const cef_string_t* path);
///
// Delete all cookies that match the specified parameters. If both |url| and
// |cookie_name| are specified all host and domain cookies matching both values
// will be deleted. If only |url| is specified all host cookies (but not domain
// cookies) irrespective of path will be deleted. If |url| is NULL all cookies
// for all hosts and domains will be deleted. Returns false (0) if a non-NULL
// invalid URL is specified or if cookies cannot be accessed. This function must
// be called on the IO thread.
///
CEF_EXPORT int cef_delete_cookies(const cef_string_t* url,
const cef_string_t* cookie_name);
///
// Sets the directory path that will be used for storing cookie data. If |path|
// is NULL data will be stored in memory only. By default the cookie path is the
// same as the cache path. Returns false (0) if cookies cannot be accessed.
///
CEF_EXPORT int cef_set_cookie_path(const cef_string_t* path);
/// ///
// Structure to implement for visiting cookie values. The functions of this // Structure to implement for visiting cookie values. The functions of this

View File

@@ -174,8 +174,7 @@ typedef struct _cef_frame_t {
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self); cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
/// ///
// Returns the globally unique identifier for this frame. This function should // Returns the globally unique identifier for this frame.
// only be called on the UI thread.
/// ///
int64 (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self); int64 (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self);
@@ -186,8 +185,7 @@ typedef struct _cef_frame_t {
struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self); struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self);
/// ///
// Returns the URL currently loaded in this frame. This function should only // Returns the URL currently loaded in this frame.
// be called on the UI thread.
/// ///
// The resulting string must be freed by calling cef_string_userfree_free(). // 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); cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);

View File

@@ -96,7 +96,9 @@ typedef struct _cef_render_handler_t {
// element is the view or the popup widget. |buffer| contains the pixel data // element is the view or the popup widget. |buffer| contains the pixel data
// for the whole image. |dirtyRects| contains the set of rectangles that need // for the whole image. |dirtyRects| contains the set of rectangles that need
// to be repainted. On Windows |buffer| will be width*height*4 bytes in size // to be repainted. On Windows |buffer| will be width*height*4 bytes in size
// and represents a BGRA image with an upper-left origin. // and represents a BGRA image with an upper-left origin. The
// cef_browser_tSettings.animation_frame_rate value controls the rate at which
// this function is called.
/// ///
void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, enum cef_paint_element_type_t type, struct _cef_browser_t* browser, enum cef_paint_element_type_t type,

View File

@@ -139,6 +139,16 @@ typedef struct _cef_request_handler_t {
struct _cef_browser_t* browser, int isProxy, const cef_string_t* host, struct _cef_browser_t* browser, int isProxy, const cef_string_t* host,
int port, const cef_string_t* realm, const cef_string_t* scheme, int port, const cef_string_t* realm, const cef_string_t* scheme,
cef_string_t* username, cef_string_t* password); cef_string_t* username, cef_string_t* password);
///
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
// URL of the top-level frame. Cookies managers can be unique per browser or
// shared across multiple browsers. The global cookie manager will be used if
// this function returns NULL.
///
struct _cef_cookie_manager_t* (CEF_CALLBACK *get_cookie_manager)(
struct _cef_request_handler_t* self, struct _cef_browser_t* browser,
const cef_string_t* main_url);
} cef_request_handler_t; } cef_request_handler_t;

View File

@@ -127,7 +127,8 @@ typedef struct _cef_scheme_handler_factory_t {
/// ///
// Return a new scheme handler instance to handle the request. |browser| will // Return a new scheme handler instance to handle the request. |browser| will
// be the browser window that initiated the request. If the request was // be the browser window that initiated the request. If the request was
// initiated using the cef_web_urlrequest_t API |browser| will be NULL. // initiated using the cef_web_urlrequest_t API |browser| will be NULL. The
// |request| object passed to this function will not contain cookie data.
/// ///
struct _cef_scheme_handler_t* (CEF_CALLBACK *create)( struct _cef_scheme_handler_t* (CEF_CALLBACK *create)(
struct _cef_scheme_handler_factory_t* self, struct _cef_scheme_handler_factory_t* self,

View File

@@ -0,0 +1,110 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Returns the number of installed web plugins. This function must be called on
// the UI thread.
///
CEF_EXPORT size_t cef_get_web_plugin_count();
///
// Returns information for web plugin at the specified zero-based index. This
// function must be called on the UI thread.
///
CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info(int index);
///
// Returns information for web plugin with the specified name. This function
// must be called on the UI thread.
///
CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info_byname(
const cef_string_t* name);
///
// Information about a specific web plugin.
///
typedef struct _cef_web_plugin_info_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the plugin name (i.e. Flash).
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_name)(
struct _cef_web_plugin_info_t* self);
///
// Returns the plugin file path (DLL/bundle/library).
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_path)(
struct _cef_web_plugin_info_t* self);
///
// Returns the version of the plugin (may be OS-specific).
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_version)(
struct _cef_web_plugin_info_t* self);
///
// Returns a description of the plugin from the version information.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_description)(
struct _cef_web_plugin_info_t* self);
} cef_web_plugin_info_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_ZOOM_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_ZOOM_HANDLER_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Implement this structure to customize zoom handling. The functions of this
// structure will be called on the UI thread.
///
typedef struct _cef_zoom_handler_t {
///
// Base structure.
///
cef_base_t base;
///
// Called when the browser wants to retrieve the zoom level for the given
// |url|. Return true (1) if |zoomLevel| has been set to the custom zoom
// level. Return false (0) for the browser's default zoom handling behavior.
///
int (CEF_CALLBACK *on_get_zoom_level)(struct _cef_zoom_handler_t* self,
struct _cef_browser_t* browser, const cef_string_t* url,
double* zoomLevel);
///
// Called when the browser's zoom level has been set to |zoomLevel| for the
// given |url|. Return true (1) to indicate that the new setting has been
// handled. Return false (0) to use the browser's default zoom handling
// behavior.
///
int (CEF_CALLBACK *on_set_zoom_level)(struct _cef_zoom_handler_t* self,
struct _cef_browser_t* browser, const cef_string_t* url,
double zoomLevel);
} cef_zoom_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_ZOOM_HANDLER_CAPI_H_

View File

@@ -294,8 +294,8 @@ class CefBrowser : public virtual CefBase {
// Send a key event to the browser. // Send a key event to the browser.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, virtual void SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool imeChar) =0; int modifiers) =0;
/// ///
// Send a mouse click event to the browser. The |x| and |y| coordinates are // Send a mouse click event to the browser. The |x| and |y| coordinates are
@@ -314,10 +314,11 @@ class CefBrowser : public virtual CefBase {
/// ///
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are // Send a mouse wheel event to the browser. The |x| and |y| coordinates are
// relative to the upper-left corner of the view. // relative to the upper-left corner of the view. The |deltaX| and |deltaY|
// values represent the movement delta in the X and Y directions respectively.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void SendMouseWheelEvent(int x, int y, int delta) =0; virtual void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) =0;
/// ///
// Send a focus event to the browser. // Send a focus event to the browser.

View File

@@ -53,6 +53,7 @@
#include "include/cef_render_handler.h" #include "include/cef_render_handler.h"
#include "include/cef_request_handler.h" #include "include/cef_request_handler.h"
#include "include/cef_v8context_handler.h" #include "include/cef_v8context_handler.h"
#include "include/cef_zoom_handler.h"
/// ///
// Implement this interface to provide handler implementations. // Implement this interface to provide handler implementations.
@@ -171,6 +172,15 @@ class CefClient : public virtual CefBase {
virtual CefRefPtr<CefDragHandler> GetDragHandler() { virtual CefRefPtr<CefDragHandler> GetDragHandler() {
return NULL; return NULL;
} }
///
// Return the handler for zoom events. If no handler is provided the default
// zoom behavior will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefZoomHandler> GetZoomHandler() {
return NULL;
}
}; };
#endif // CEF_INCLUDE_CEF_CLIENT_H_ #endif // CEF_INCLUDE_CEF_CLIENT_H_

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
@@ -39,56 +39,90 @@
#pragma once #pragma once
#include "include/cef_base.h" #include "include/cef_base.h"
#include <vector>
class CefCookieVisitor; class CefCookieVisitor;
///
// Visit all cookies. The returned cookies are ordered by longest path, then by
// earliest creation date. Returns false if cookies cannot be accessed.
///
/*--cef()--*/
bool CefVisitAllCookies(CefRefPtr<CefCookieVisitor> visitor);
/// ///
// Visit a subset of cookies. The results are filtered by the given url scheme, // Class used for managing cookies. The methods of this class may be called on
// host, domain and path. If |includeHttpOnly| is true HTTP-only cookies will // any thread unless otherwise indicated.
// also be included in the results. The returned cookies are ordered by longest
// path, then by earliest creation date. Returns false if cookies cannot be
// accessed.
/// ///
/*--cef()--*/ /*--cef(source=library)--*/
bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly, class CefCookieManager : public virtual CefBase {
CefRefPtr<CefCookieVisitor> visitor); public:
///
// Returns the global cookie manager. By default data will be stored at
// CefSettings.cache_path if specified or in memory otherwise.
///
/*--cef()--*/
static CefRefPtr<CefCookieManager> GetGlobalManager();
/// ///
// Sets a cookie given a valid URL and explicit user-provided cookie attributes. // Creates a new cookie manager. If |path| is empty data will be stored in
// This function expects each attribute to be well-formed. It will check for // memory only. Returns NULL if creation fails.
// disallowed characters (e.g. the ';' character is disallowed within the cookie ///
// value attribute) and will return false without setting the cookie if such /*--cef(optional_param=path)--*/
// characters are found. This method must be called on the IO thread. static CefRefPtr<CefCookieManager> CreateManager(const CefString& path);
///
/*--cef()--*/
bool CefSetCookie(const CefString& url, const CefCookie& cookie);
/// ///
// Delete all cookies that match the specified parameters. If both |url| and // Set the schemes supported by this manager. By default only "http" and
// |cookie_name| are specified all host and domain cookies matching both values // "https" schemes are supported. Must be called before any cookies are
// will be deleted. If only |url| is specified all host cookies (but not domain // accessed.
// cookies) irrespective of path will be deleted. If |url| is empty all cookies ///
// for all hosts and domains will be deleted. Returns false if a non-empty /*--cef()--*/
// invalid URL is specified or if cookies cannot be accessed. This method must virtual void SetSupportedSchemes(const std::vector<CefString>& schemes) =0;
// be called on the IO thread.
///
/*--cef(optional_param=url,optional_param=cookie_name)--*/
bool CefDeleteCookies(const CefString& url, const CefString& cookie_name);
/// ///
// Sets the directory path that will be used for storing cookie data. If |path| // Visit all cookies. The returned cookies are ordered by longest path, then
// is empty data will be stored in memory only. By default the cookie path is // by earliest creation date. Returns false if cookies cannot be accessed.
// the same as the cache path. Returns false if cookies cannot be accessed. ///
/// /*--cef()--*/
/*--cef(optional_param=path)--*/ virtual bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) =0;
bool CefSetCookiePath(const CefString& path);
///
// Visit a subset of cookies. The results are filtered by the given url
// scheme, host, domain and path. If |includeHttpOnly| is true HTTP-only
// cookies will also be included in the results. The returned cookies are
// ordered by longest path, then by earliest creation date. Returns false if
// cookies cannot be accessed.
///
/*--cef()--*/
virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) =0;
///
// Sets a cookie given a valid URL and explicit user-provided cookie
// attributes. This function expects each attribute to be well-formed. It will
// check for disallowed characters (e.g. the ';' character is disallowed
// within the cookie value attribute) and will return false without setting
// the cookie if such characters are found. This method must be called on the
// IO thread.
///
/*--cef()--*/
virtual bool SetCookie(const CefString& url, const CefCookie& cookie) =0;
///
// Delete all cookies that match the specified parameters. If both |url| and
// values |cookie_name| are specified all host and domain cookies matching
// both will be deleted. If only |url| is specified all host cookies (but not
// domain cookies) irrespective of path will be deleted. If |url| is empty all
// cookies for all hosts and domains will be deleted. Returns false if a non-
// empty invalid URL is specified or if cookies cannot be accessed. This
// method must be called on the IO thread.
///
/*--cef(optional_param=url,optional_param=cookie_name)--*/
virtual bool DeleteCookies(const CefString& url,
const CefString& cookie_name) =0;
///
// Sets the directory path that will be used for storing cookie data. If
// |path| is empty data will be stored in memory only. Returns false if
// cookies cannot be accessed.
///
/*--cef(optional_param=path)--*/
virtual bool SetStoragePath(const CefString& path) =0;
};
/// ///

View File

@@ -179,8 +179,7 @@ class CefFrame : public virtual CefBase {
virtual CefString GetName() =0; virtual CefString GetName() =0;
/// ///
// Returns the globally unique identifier for this frame. This method should // Returns the globally unique identifier for this frame.
// only be called on the UI thread.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual int64 GetIdentifier() =0; virtual int64 GetIdentifier() =0;
@@ -193,8 +192,7 @@ class CefFrame : public virtual CefBase {
virtual CefRefPtr<CefFrame> GetParent() =0; virtual CefRefPtr<CefFrame> GetParent() =0;
/// ///
// Returns the URL currently loaded in this frame. This method should only be // Returns the URL currently loaded in this frame.
// called on the UI thread.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefString GetURL() =0; virtual CefString GetURL() =0;

View File

@@ -53,7 +53,7 @@ class CefJSDialogHandler : public virtual CefBase {
// Called to run a JavaScript alert message. Return false to display the // Called to run a JavaScript alert message. Return false to display the
// default alert or true if you displayed a custom alert. // default alert or true if you displayed a custom alert.
/// ///
/*--cef()--*/ /*--cef(optional_param=message)--*/
virtual bool OnJSAlert(CefRefPtr<CefBrowser> browser, virtual bool OnJSAlert(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const CefString& message) { return false; } const CefString& message) { return false; }
@@ -63,7 +63,7 @@ class CefJSDialogHandler : public virtual CefBase {
// default alert or true if you displayed a custom alert. If you handled the // default alert or true if you displayed a custom alert. If you handled the
// alert set |retval| to true if the user accepted the confirmation. // alert set |retval| to true if the user accepted the confirmation.
/// ///
/*--cef()--*/ /*--cef(optional_param=message)--*/
virtual bool OnJSConfirm(CefRefPtr<CefBrowser> browser, virtual bool OnJSConfirm(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const CefString& message, const CefString& message,
@@ -75,7 +75,7 @@ class CefJSDialogHandler : public virtual CefBase {
// the prompt set |retval| to true if the user accepted the prompt and request // the prompt set |retval| to true if the user accepted the prompt and request
// and |result| to the resulting value. // and |result| to the resulting value.
/// ///
/*--cef()--*/ /*--cef(optional_param=message,optional_param=defaultValue)--*/
virtual bool OnJSPrompt(CefRefPtr<CefBrowser> browser, virtual bool OnJSPrompt(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const CefString& message, const CefString& message,

View File

@@ -100,7 +100,9 @@ class CefRenderHandler : public virtual CefBase {
// element is the view or the popup widget. |buffer| contains the pixel data // element is the view or the popup widget. |buffer| contains the pixel data
// for the whole image. |dirtyRects| contains the set of rectangles that need // for the whole image. |dirtyRects| contains the set of rectangles that need
// to be repainted. On Windows |buffer| will be width*height*4 bytes in size // to be repainted. On Windows |buffer| will be width*height*4 bytes in size
// and represents a BGRA image with an upper-left origin. // and represents a BGRA image with an upper-left origin. The
// CefBrowserSettings.animation_frame_rate value controls the rate at which
// this method is called.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual void OnPaint(CefRefPtr<CefBrowser> browser, virtual void OnPaint(CefRefPtr<CefBrowser> browser,

View File

@@ -40,6 +40,7 @@
#include "include/cef_base.h" #include "include/cef_base.h"
#include "include/cef_browser.h" #include "include/cef_browser.h"
#include "include/cef_cookie.h"
#include "include/cef_download_handler.h" #include "include/cef_download_handler.h"
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "include/cef_content_filter.h" #include "include/cef_content_filter.h"
@@ -154,6 +155,17 @@ class CefRequestHandler : public virtual CefBase {
const CefString& scheme, const CefString& scheme,
CefString& username, CefString& username,
CefString& password) { return false; } CefString& password) { return false; }
///
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
// URL of the top-level frame. Cookies managers can be unique per browser or
// shared across multiple browsers. The global cookie manager will be used if
// this method returns NULL.
///
/*--cef()--*/
virtual CefRefPtr<CefCookieManager> GetCookieManager(
CefRefPtr<CefBrowser> browser,
const CefString& main_url) { return NULL; }
}; };
#endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ #endif // CEF_INCLUDE_CEF_REQUEST_HANDLER_H_

View File

@@ -132,7 +132,8 @@ class CefSchemeHandlerFactory : public virtual CefBase {
/// ///
// Return a new scheme handler instance to handle the request. |browser| will // Return a new scheme handler instance to handle the request. |browser| will
// be the browser window that initiated the request. If the request was // be the browser window that initiated the request. If the request was
// initiated using the CefWebURLRequest API |browser| will be NULL. // initiated using the CefWebURLRequest API |browser| will be NULL. The
// |request| object passed to this method will not contain cookie data.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual CefRefPtr<CefSchemeHandler> Create(CefRefPtr<CefBrowser> browser, virtual CefRefPtr<CefSchemeHandler> Create(CefRefPtr<CefBrowser> browser,

97
include/cef_web_plugin.h Normal file
View File

@@ -0,0 +1,97 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#include "include/cef_base.h"
class CefWebPluginInfo;
///
// Returns the number of installed web plugins. This method must be called on
// the UI thread.
///
/*--cef()--*/
size_t CefGetWebPluginCount();
///
// Returns information for web plugin at the specified zero-based index. This
// method must be called on the UI thread.
///
/*--cef()--*/
CefRefPtr<CefWebPluginInfo> CefGetWebPluginInfo(int index);
///
// Returns information for web plugin with the specified name. This method must
// be called on the UI thread.
///
/*--cef(capi_name=cef_get_web_plugin_info_byname)--*/
CefRefPtr<CefWebPluginInfo> CefGetWebPluginInfo(const CefString& name);
///
// Information about a specific web plugin.
///
/*--cef(source=library)--*/
class CefWebPluginInfo : public virtual CefBase {
public:
///
// Returns the plugin name (i.e. Flash).
///
/*--cef()--*/
virtual CefString GetName() =0;
///
// Returns the plugin file path (DLL/bundle/library).
///
/*--cef()--*/
virtual CefString GetPath() =0;
///
// Returns the version of the plugin (may be OS-specific).
///
/*--cef()--*/
virtual CefString GetVersion() =0;
///
// Returns a description of the plugin from the version information.
///
/*--cef()--*/
virtual CefString GetDescription() =0;
};
#endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_

View File

@@ -0,0 +1,72 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_ZOOM_HANDLER_H_
#define CEF_INCLUDE_CEF_ZOOM_HANDLER_H_
#pragma once
#include "include/cef_base.h"
#include "include/cef_browser.h"
///
// Implement this interface to customize zoom handling. The methods of this
// class will be called on the UI thread.
///
/*--cef(source=client)--*/
class CefZoomHandler : public virtual CefBase {
public:
///
// Called when the browser wants to retrieve the zoom level for the given
// |url|. Return true if |zoomLevel| has been set to the custom zoom level.
// Return false for the browser's default zoom handling behavior.
///
/*--cef()--*/
virtual bool OnGetZoomLevel(CefRefPtr<CefBrowser> browser,
const CefString& url,
double& zoomLevel) { return false; }
///
// Called when the browser's zoom level has been set to |zoomLevel| for the
// given |url|. Return true to indicate that the new setting has been handled.
// Return false to use the browser's default zoom handling behavior.
///
/*--cef()--*/
virtual bool OnSetZoomLevel(CefRefPtr<CefBrowser> browser,
const CefString& url,
double zoomLevel) { return false; }
};
#endif // CEF_INCLUDE_CEF_ZOOM_HANDLER_H_

View File

@@ -37,7 +37,9 @@
#include "include/internal/cef_types_linux.h" #include "include/internal/cef_types_linux.h"
#include "include/internal/cef_types_wrappers.h" #include "include/internal/cef_types_wrappers.h"
///
// Atomic increment and decrement. // Atomic increment and decrement.
///
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_add_and_fetch(pDest, 1); return __sync_add_and_fetch(pDest, 1);
} }
@@ -45,7 +47,9 @@ inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_sub_and_fetch(pDest, 1); return __sync_sub_and_fetch(pDest, 1);
} }
///
// Critical section wrapper. // Critical section wrapper.
///
class CefCriticalSection { class CefCriticalSection {
public: public:
CefCriticalSection() { CefCriticalSection() {
@@ -68,10 +72,13 @@ class CefCriticalSection {
pthread_mutexattr_t attr_; pthread_mutexattr_t attr_;
}; };
///
// Handle types. // Handle types.
///
#define CefWindowHandle cef_window_handle_t #define CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t #define CefCursorHandle cef_cursor_handle_t
struct CefWindowInfoTraits { struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type; typedef cef_window_info_t struct_type;
@@ -85,7 +92,9 @@ struct CefWindowInfoTraits {
} }
}; };
///
// Class representing window information. // Class representing window information.
///
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public: public:
typedef CefStructBase<CefWindowInfoTraits> parent; typedef CefStructBase<CefWindowInfoTraits> parent;
@@ -99,6 +108,7 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
} }
}; };
struct CefPrintInfoTraits { struct CefPrintInfoTraits {
typedef cef_print_info_t struct_type; typedef cef_print_info_t struct_type;
@@ -111,9 +121,29 @@ struct CefPrintInfoTraits {
} }
}; };
///
// Class representing print context information. // Class representing print context information.
///
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo; typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
struct CefKeyInfoTraits {
typedef cef_key_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->key = src->key;
}
};
///
// Class representing key information.
///
typedef CefStructBase<CefKeyInfoTraits> CefKeyInfo;
#endif // OS_LINUX #endif // OS_LINUX
#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_ #endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_

View File

@@ -37,7 +37,9 @@
#include "include/internal/cef_types_mac.h" #include "include/internal/cef_types_mac.h"
#include "include/internal/cef_types_wrappers.h" #include "include/internal/cef_types_wrappers.h"
///
// Atomic increment and decrement. // Atomic increment and decrement.
///
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int) inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_add_and_fetch(pDest, 1); return __sync_add_and_fetch(pDest, 1);
} }
@@ -45,11 +47,15 @@ inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_sub_and_fetch(pDest, 1); return __sync_sub_and_fetch(pDest, 1);
} }
///
// Handle types. // Handle types.
///
#define CefWindowHandle cef_window_handle_t #define CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t #define CefCursorHandle cef_cursor_handle_t
///
// Critical section wrapper. // Critical section wrapper.
///
class CefCriticalSection { class CefCriticalSection {
public: public:
CefCriticalSection() { CefCriticalSection() {
@@ -72,6 +78,7 @@ class CefCriticalSection {
pthread_mutexattr_t attr_; pthread_mutexattr_t attr_;
}; };
struct CefWindowInfoTraits { struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type; typedef cef_window_info_t struct_type;
@@ -92,10 +99,14 @@ struct CefWindowInfoTraits {
target->m_nWidth = src->m_nWidth; target->m_nWidth = src->m_nWidth;
target->m_nHeight = src->m_nHeight; target->m_nHeight = src->m_nHeight;
target->m_bHidden = src->m_bHidden; target->m_bHidden = src->m_bHidden;
target->m_bWindowRenderingDisabled = src->m_bWindowRenderingDisabled;
target->m_bTransparentPainting = src->m_bTransparentPainting;
} }
}; };
///
// Class representing window information. // Class representing window information.
///
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> { class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public: public:
typedef CefStructBase<CefWindowInfoTraits> parent; typedef CefStructBase<CefWindowInfoTraits> parent;
@@ -113,8 +124,18 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
m_nHeight = height; m_nHeight = height;
m_bHidden = false; m_bHidden = false;
} }
void SetAsOffScreen(NSView* parent) {
m_bWindowRenderingDisabled = true;
m_ParentView = parent;
}
void SetTransparentPainting(int transparentPainting) {
m_bTransparentPainting = transparentPainting;
}
}; };
struct CefPrintInfoTraits { struct CefPrintInfoTraits {
typedef cef_print_info_t struct_type; typedef cef_print_info_t struct_type;
@@ -127,9 +148,31 @@ struct CefPrintInfoTraits {
} }
}; };
///
// Class representing print context information. // Class representing print context information.
///
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo; typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
struct CefKeyInfoTraits {
typedef cef_key_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->keyCode = src->keyCode;
target->character = src->character;
target->characterNoModifiers = src->characterNoModifiers;
}
};
///
// Class representing key information.
///
typedef CefStructBase<CefKeyInfoTraits> CefKeyInfo;
#endif // OS_MACOSX #endif // OS_MACOSX
#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_ #endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_

View File

@@ -414,7 +414,7 @@ class CefStringBase {
// Clear the string data. // Clear the string data.
/// ///
void clear() { void clear() {
if (!empty()) if (string_)
traits::clear(string_); traits::clear(string_);
} }

View File

@@ -224,6 +224,18 @@ typedef struct _cef_browser_settings_t {
/// ///
bool history_disabled; bool history_disabled;
///
// The number of frames per second (fps) for animation and windowless
// rendering. When window rendering is enabled and the JavaScript
// requestAnimationFrame method is used the browser client area will be
// invalidated at the rate specified. When window rendering is disabled the
// CefRenderHandler::OnPaint() method will be called at the rate specified.
// This value must be between 0 and 90. Specify a value of zero for the
// default frame rate of 30 fps. Changing this value may affect display
// performance and/or CPU usage.
///
int animation_frame_rate;
// The below values map to WebPreferences settings. // The below values map to WebPreferences settings.
/// ///
@@ -862,10 +874,11 @@ enum cef_handler_keyevent_type_t {
// Key event modifiers. // Key event modifiers.
/// ///
enum cef_handler_keyevent_modifiers_t { enum cef_handler_keyevent_modifiers_t {
KEY_SHIFT = 1 << 0, KEY_SHIFT = 1 << 0,
KEY_CTRL = 1 << 1, KEY_CTRL = 1 << 1,
KEY_ALT = 1 << 2, KEY_ALT = 1 << 2,
KEY_META = 1 << 3 KEY_META = 1 << 3,
KEY_KEYPAD = 1 << 4, // Only used on Mac OS-X
}; };
/// ///
@@ -1076,9 +1089,9 @@ enum cef_dom_node_type_t {
// Proxy types. // Proxy types.
/// ///
enum cef_proxy_type_t { enum cef_proxy_type_t {
PROXY_TYPE_DIRECT = 0, CEF_PROXY_TYPE_DIRECT = 0,
PROXY_TYPE_NAMED, CEF_PROXY_TYPE_NAMED,
PROXY_TYPE_PAC_STRING, CEF_PROXY_TYPE_PAC_STRING,
}; };
/// ///

View File

@@ -72,6 +72,13 @@ typedef struct _cef_print_info_t {
double m_Scale; double m_Scale;
} cef_print_info_t; } cef_print_info_t;
///
// Class representing key information.
///
typedef struct _cef_key_info_t {
int key;
} cef_key_info_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -40,15 +40,18 @@
// Window handle. // Window handle.
#ifdef __cplusplus #ifdef __cplusplus
#ifdef __OBJC__ #ifdef __OBJC__
@class NSCursor;
@class NSView; @class NSView;
#else #else
class NSCursor;
class NSView; class NSView;
#endif #endif
#define cef_window_handle_t NSView* #define cef_window_handle_t NSView*
#define cef_cursor_handle_t NSCursor*
#else #else
#define cef_window_handle_t void* #define cef_window_handle_t void*
#endif
#define cef_cursor_handle_t void* #define cef_cursor_handle_t void*
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -76,6 +79,14 @@ typedef struct _cef_window_info_t {
// NSView pointer for the parent view. // NSView pointer for the parent view.
cef_window_handle_t m_ParentView; cef_window_handle_t m_ParentView;
// If window rendering is disabled no browser window will be created. Set
// |m_ParentView| to the window that will act as the parent for popup menus,
// dialog boxes, etc.
int m_bWindowRenderingDisabled;
// Set to true to enable transparent painting.
int m_bTransparentPainting;
// NSView pointer for the new browser view. // NSView pointer for the new browser view.
cef_window_handle_t m_View; cef_window_handle_t m_View;
} cef_window_info_t; } cef_window_info_t;
@@ -87,6 +98,15 @@ typedef struct _cef_print_info_t {
double m_Scale; double m_Scale;
} cef_print_info_t; } cef_print_info_t;
///
// Class representing key information.
///
typedef struct _cef_key_info_t {
int keyCode;
int character;
int characterNoModifiers;
} cef_key_info_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -92,6 +92,15 @@ typedef struct _cef_print_info_t {
double m_Scale; double m_Scale;
} cef_print_info_t; } cef_print_info_t;
///
// Class representing key information.
///
typedef struct _cef_key_info_t {
int key;
BOOL sysChar;
BOOL imeChar;
} cef_key_info_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -331,6 +331,7 @@ struct CefBrowserSettingsTraits {
target->drag_drop_disabled = src->drag_drop_disabled; target->drag_drop_disabled = src->drag_drop_disabled;
target->load_drops_disabled = src->load_drops_disabled; target->load_drops_disabled = src->load_drops_disabled;
target->history_disabled = src->history_disabled; target->history_disabled = src->history_disabled;
target->animation_frame_rate = src->animation_frame_rate;
cef_string_set(src->standard_font_family.str, cef_string_set(src->standard_font_family.str,
src->standard_font_family.length, &target->standard_font_family, copy); src->standard_font_family.length, &target->standard_font_family, copy);
@@ -606,7 +607,7 @@ class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
// Use a direction connection instead of a proxy. // Use a direction connection instead of a proxy.
/// ///
void UseDirect() { void UseDirect() {
proxyType = PROXY_TYPE_DIRECT; proxyType = CEF_PROXY_TYPE_DIRECT;
} }
/// ///
@@ -619,7 +620,7 @@ class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
// "foo1:80;foo2:80". // "foo1:80;foo2:80".
/// ///
void UseNamedProxy(const CefString& proxy_uri_list) { void UseNamedProxy(const CefString& proxy_uri_list) {
proxyType = PROXY_TYPE_NAMED; proxyType = CEF_PROXY_TYPE_NAMED;
(CefString(&proxyList)) = proxy_uri_list; (CefString(&proxyList)) = proxy_uri_list;
} }
@@ -628,13 +629,13 @@ class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
// example, "PROXY foobar:99; SOCKS fml:2; DIRECT". // example, "PROXY foobar:99; SOCKS fml:2; DIRECT".
/// ///
void UsePacString(const CefString& pac_string) { void UsePacString(const CefString& pac_string) {
proxyType = PROXY_TYPE_PAC_STRING; proxyType = CEF_PROXY_TYPE_PAC_STRING;
(CefString(&proxyList)) = pac_string; (CefString(&proxyList)) = pac_string;
} }
bool IsDirect() const { return proxyType == PROXY_TYPE_DIRECT; } bool IsDirect() const { return proxyType == CEF_PROXY_TYPE_DIRECT; }
bool IsNamedProxy() const { return proxyType == PROXY_TYPE_NAMED; } bool IsNamedProxy() const { return proxyType == CEF_PROXY_TYPE_NAMED; }
bool IsPacString() const { return proxyType == PROXY_TYPE_PAC_STRING; } bool IsPacString() const { return proxyType == CEF_PROXY_TYPE_PAC_STRING; }
CefString ProxyList() const { return CefString(&proxyList); } CefString ProxyList() const { return CefString(&proxyList); }
}; };

View File

@@ -71,7 +71,6 @@ class CefCriticalSection {
#define CefWindowHandle cef_window_handle_t #define CefWindowHandle cef_window_handle_t
#define CefCursorHandle cef_cursor_handle_t #define CefCursorHandle cef_cursor_handle_t
struct CefWindowInfoTraits { struct CefWindowInfoTraits {
typedef cef_window_info_t struct_type; typedef cef_window_info_t struct_type;
@@ -162,6 +161,26 @@ struct CefPrintInfoTraits {
/// ///
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo; typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
struct CefKeyInfoTraits {
typedef cef_key_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->key = src->key;
target->sysChar = src->sysChar;
target->imeChar = src->imeChar;
}
};
///
// Class representing key information.
///
typedef CefStructBase<CefKeyInfoTraits> CefKeyInfo;
#endif // OS_WIN #endif // OS_WIN
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_ #endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_

View File

@@ -127,7 +127,9 @@ void BrowserDragDelegate::StartDragging(const WebDropData& drop_data,
// If it is not drag-out, do the drag-and-drop in the current UI thread. // If it is not drag-out, do the drag-and-drop in the current UI thread.
if (drop_data.download_metadata.empty()) { if (drop_data.download_metadata.empty()) {
DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset); DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset);
EndDragging(false); CefThread::PostTask(
CefThread::UI, FROM_HERE,
base::Bind(&BrowserDragDelegate::EndDragging, this, false));
return; return;
} }

View File

@@ -169,7 +169,7 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
can_go_forward_(false), can_go_forward_(false),
has_document_(false), has_document_(false),
is_dropping_(false), is_dropping_(false),
main_frame_(NULL), is_in_onsetfocus_(false),
unique_id_(0) unique_id_(0)
#if defined(OS_WIN) #if defined(OS_WIN)
, opener_was_disabled_by_modal_loop_(false), , opener_was_disabled_by_modal_loop_(false),
@@ -185,6 +185,9 @@ CefBrowserImpl::CefBrowserImpl(const CefWindowInfo& windowInfo,
"FileSystem feature will be disabled."; "FileSystem feature will be disabled.";
DCHECK(file_system_root_.path().empty()); DCHECK(file_system_root_.path().empty());
} }
// Create the singleton main frame reference.
main_frame_ = new CefFrameImpl(this, 0, CefString(), CefString());
} }
void CefBrowserImpl::CloseBrowser() { void CefBrowserImpl::CloseBrowser() {
@@ -205,7 +208,7 @@ void CefBrowserImpl::GoForward() {
} }
void CefBrowserImpl::Reload() { void CefBrowserImpl::Reload() {
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&CefBrowserImpl::UIT_HandleActionView, this, base::Bind(&CefBrowserImpl::UIT_HandleActionView, this,
MENU_ID_NAV_RELOAD)); MENU_ID_NAV_RELOAD));
} }
@@ -224,6 +227,26 @@ void CefBrowserImpl::StopLoad() {
void CefBrowserImpl::SetFocus(bool enable) { void CefBrowserImpl::SetFocus(bool enable) {
if (CefThread::CurrentlyOn(CefThread::UI)) { if (CefThread::CurrentlyOn(CefThread::UI)) {
// If SetFocus() is called from inside the OnSetFocus() callback do not re-
// enter the callback.
if (enable && !is_in_onsetfocus_) {
WebViewHost* host = UIT_GetWebViewHost();
if (host) {
CefRefPtr<CefClient> client = GetClient();
if (client.get()) {
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
if (handler.get()) {
is_in_onsetfocus_ = true;
bool handled = handler->OnSetFocus(this, FOCUS_SOURCE_SYSTEM);
is_in_onsetfocus_ = false;
if (handled)
return;
}
}
}
}
UIT_SetFocus(UIT_GetWebViewHost(), enable); UIT_SetFocus(UIT_GetWebViewHost(), enable);
} else { } else {
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
@@ -231,6 +254,10 @@ void CefBrowserImpl::SetFocus(bool enable) {
} }
} }
CefRefPtr<CefFrame> CefBrowserImpl::GetMainFrame() {
return GetMainCefFrame(0, GURL()).get();
}
CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame() { CefRefPtr<CefFrame> CefBrowserImpl::GetFocusedFrame() {
// Verify that this method is being called on the UI thread. // Verify that this method is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) { if (!CefThread::CurrentlyOn(CefThread::UI)) {
@@ -410,13 +437,13 @@ bool CefBrowserImpl::GetImage(PaintElementType type, int width, int height,
return false; return false;
} }
void CefBrowserImpl::SendKeyEvent(KeyType type, int key, int modifiers, void CefBrowserImpl::SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool sysChar, bool imeChar) { int modifiers) {
// Intentially post event tasks in all cases so that painting tasks can be // Intentially post event tasks in all cases so that painting tasks can be
// handled at sane times. // handled at sane times.
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&CefBrowserImpl::UIT_SendKeyEvent, this, type, key, modifiers, base::Bind(&CefBrowserImpl::UIT_SendKeyEvent, this, type, keyInfo,
sysChar, imeChar)); modifiers));
} }
void CefBrowserImpl::SendMouseClickEvent(int x, int y, MouseButtonType type, void CefBrowserImpl::SendMouseClickEvent(int x, int y, MouseButtonType type,
@@ -436,11 +463,12 @@ void CefBrowserImpl::SendMouseMoveEvent(int x, int y, bool mouseLeave) {
mouseLeave)); mouseLeave));
} }
void CefBrowserImpl::SendMouseWheelEvent(int x, int y, int delta) { void CefBrowserImpl::SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) {
// Intentially post event tasks in all cases so that painting tasks can be // Intentially post event tasks in all cases so that painting tasks can be
// handled at sane times. // handled at sane times.
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&CefBrowserImpl::UIT_SendMouseWheelEvent, this, x, y, delta)); base::Bind(&CefBrowserImpl::UIT_SendMouseWheelEvent, this, x, y, deltaX,
deltaY));
} }
void CefBrowserImpl::SendFocusEvent(bool setFocus) { void CefBrowserImpl::SendFocusEvent(bool setFocus) {
@@ -575,19 +603,6 @@ void CefBrowserImpl::ExecuteJavaScript(CefRefPtr<CefFrame> frame,
scriptUrl, startLine)); scriptUrl, startLine));
} }
int64 CefBrowserImpl::GetIdentifier(CefRefPtr<CefFrame> frame) {
// Verify that this method is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return 0;
}
WebFrame* web_frame = UIT_GetWebFrame(frame);
if (web_frame)
return web_frame->identifier();
return 0;
}
CefRefPtr<CefFrame> CefBrowserImpl::GetParent(CefRefPtr<CefFrame> frame) { CefRefPtr<CefFrame> CefBrowserImpl::GetParent(CefRefPtr<CefFrame> frame) {
// Verify that this method is being called on the UI thread. // Verify that this method is being called on the UI thread.
if (!CefThread::CurrentlyOn(CefThread::UI)) { if (!CefThread::CurrentlyOn(CefThread::UI)) {
@@ -606,77 +621,92 @@ CefRefPtr<CefFrame> CefBrowserImpl::GetParent(CefRefPtr<CefFrame> frame) {
return NULL; return NULL;
} }
CefString CefBrowserImpl::GetURL(CefRefPtr<CefFrame> frame) { CefRefPtr<CefFrameImpl> CefBrowserImpl::GetCefFrame(int64 id) {
// Verify that this method is being called on the UI thread. AutoLock lock_scope(this);
if (!CefThread::CurrentlyOn(CefThread::UI)) { FrameMap::const_iterator it = frames_.find(id);
NOTREACHED() << "called on invalid thread"; if (it != frames_.end())
return CefString(); return it->second;
}
WebFrame* web_frame = UIT_GetWebFrame(frame); return NULL;
if (web_frame)
return std::string(web_frame->document().url().spec());
return CefString();
} }
CefRefPtr<CefFrame> CefBrowserImpl::GetCefFrame(const CefString& name) { CefRefPtr<CefFrameImpl> CefBrowserImpl::GetOrCreateCefFrame(
CefRefPtr<CefFrame> cef_frame; int64 id,
const CefString& name,
const GURL& url) {
CefRefPtr<CefFrameImpl> cef_frame;
if (name.empty()) { if (name.empty()) {
// Use the single main frame reference. // Use the single main frame reference.
cef_frame = GetMainCefFrame(); cef_frame = GetMainCefFrame(id, url);
} else { } else {
// Locate or create the appropriate named reference. // Locate or create the appropriate named reference.
AutoLock lock_scope(this); AutoLock lock_scope(this);
FrameMap::const_iterator it = frames_.find(name); FrameMap::const_iterator it = frames_.find(id);
if (it != frames_.end()) { if (it != frames_.end()) {
cef_frame = it->second; cef_frame = it->second;
cef_frame->set_url(url.spec());
} else { } else {
cef_frame = new CefFrameImpl(this, name); cef_frame = new CefFrameImpl(this, id, name, url.spec());
frames_.insert(std::make_pair(name, cef_frame.get())); frames_.insert(std::make_pair(id, cef_frame.get()));
} }
} }
return cef_frame; return cef_frame;
} }
void CefBrowserImpl::RemoveCefFrame(const CefString& name) { void CefBrowserImpl::RemoveCefFrame(int64 id) {
AutoLock lock_scope(this); AutoLock lock_scope(this);
if (name.empty()) { // Remove the appropriate reference.
// Clear the single main frame reference. FrameMap::iterator it = frames_.find(id);
main_frame_ = NULL; if (it != frames_.end())
} else { frames_.erase(it);
// Remove the appropriate named reference.
FrameMap::iterator it = frames_.find(name);
if (it != frames_.end())
frames_.erase(it);
}
} }
CefRefPtr<CefFrame> CefBrowserImpl::GetMainCefFrame() { CefRefPtr<CefFrameImpl> CefBrowserImpl::GetMainCefFrame(int64 id,
// Return the single main frame reference. const GURL& url) {
AutoLock lock_scope(this); if (id != 0)
if (main_frame_ == NULL) main_frame_->set_id(id);
main_frame_ = new CefFrameImpl(this, CefString());
if (!url.is_empty())
main_frame_->set_url(url.spec());
return main_frame_; return main_frame_;
} }
CefRefPtr<CefFrame> CefBrowserImpl::UIT_GetCefFrame(WebFrame* frame) { CefRefPtr<CefFrame> CefBrowserImpl::UIT_GetCefFrame(WebFrame* frame) {
REQUIRE_UIT(); REQUIRE_UIT();
CefRefPtr<CefFrame> cef_frame; CefRefPtr<CefFrameImpl> cef_frame;
GURL url = frame->document().url();
if (frame->parent() == 0) { if (frame->parent() == 0) {
// Use the single main frame reference. // Use the single main frame reference.
cef_frame = GetMainCefFrame(); cef_frame = GetMainCefFrame(frame->identifier(), url);
} else { } else {
// Locate or create the appropriate named reference. // Locate or create the appropriate reference.
CefString name = string16(frame->name()); CefString name = string16(frame->name());
DCHECK(!name.empty()); DCHECK(!name.empty());
cef_frame = GetCefFrame(name); cef_frame = GetOrCreateCefFrame(frame->identifier(), name, url);
} }
return cef_frame; return cef_frame.get();
}
void CefBrowserImpl::UIT_UpdateCefFrame(WebKit::WebFrame* frame) {
REQUIRE_UIT();
GURL url = frame->document().url();
if (frame->parent() == 0) {
// Update the single main frame reference.
GetMainCefFrame(frame->identifier(), url);
} else {
// Update the appropriate reference if it currently exists.
CefRefPtr<CefFrameImpl> cef_frame = GetCefFrame(frame->identifier());
if (cef_frame.get())
cef_frame->set_url(url.spec());
}
} }
WebFrame* CefBrowserImpl::UIT_GetMainWebFrame() { WebFrame* CefBrowserImpl::UIT_GetMainWebFrame() {
@@ -741,6 +771,9 @@ void CefBrowserImpl::UIT_DestroyBrowser() {
dev_tools_agent_.reset(); dev_tools_agent_.reset();
} }
if (frame_objects_.size() > 0)
frame_objects_.clear();
// Clean up anything associated with the WebViewHost widget. // Clean up anything associated with the WebViewHost widget.
if (webviewhost_.get()) { if (webviewhost_.get()) {
if (webviewhost_->webwidget()) if (webviewhost_->webwidget())
@@ -748,14 +781,29 @@ void CefBrowserImpl::UIT_DestroyBrowser() {
webviewhost_.reset(); webviewhost_.reset();
} }
delegate_.reset(NULL);
popup_delegate_.reset(NULL);
nav_controller_.reset(NULL);
if (paint_delegate_.get())
paint_delegate_.reset(NULL);
// Remove the reference to the window handle. // Remove the reference to the window handle.
UIT_ClearMainWndHandle(); UIT_ClearMainWndHandle();
// Remove the reference added in UIT_CreateBrowser(). main_frame_ = NULL;
Release();
if (request_context_proxy_) {
// Release the proxy on the IO thread.
CefThread::ReleaseSoon(CefThread::IO, FROM_HERE,
request_context_proxy_.release());
}
// Remove the browser from the list maintained by the context. // Remove the browser from the list maintained by the context.
_Context->RemoveBrowser(this); _Context->RemoveBrowser(this);
// Remove the reference added in UIT_CreateBrowser().
Release();
} }
void CefBrowserImpl::UIT_CloseBrowser() { void CefBrowserImpl::UIT_CloseBrowser() {
@@ -989,7 +1037,6 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
return true; return true;
} }
void CefBrowserImpl::UIT_SetSize(PaintElementType type, int width, int height) { void CefBrowserImpl::UIT_SetSize(PaintElementType type, int width, int height) {
if (type == PET_VIEW) { if (type == PET_VIEW) {
WebViewHost* host = UIT_GetWebViewHost(); WebViewHost* host = UIT_GetWebViewHost();
@@ -1008,25 +1055,21 @@ void CefBrowserImpl::UIT_Invalidate(const CefRect& dirtyRect) {
gfx::Rect rect(dirtyRect.x, dirtyRect.y, dirtyRect.width, gfx::Rect rect(dirtyRect.x, dirtyRect.y, dirtyRect.width,
dirtyRect.height); dirtyRect.height);
// Used when window rendering is disabled to send the specified region to
// the paint delegate when WebWidget::Paint() is next called.
host->UpdateRedrawRect(rect);
// Cause WebWidget::Paint() to be called when next appropriate. // Cause WebWidget::Paint() to be called when next appropriate.
host->InvalidateRect(rect); host->InvalidateRect(rect);
} }
} }
void CefBrowserImpl::UIT_SendKeyEvent(KeyType type, int key, int modifiers, void CefBrowserImpl::UIT_SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool sysChar, bool imeChar) { int modifiers) {
REQUIRE_UIT(); REQUIRE_UIT();
if (popuphost_) { if (popuphost_) {
// Send the event to the popup. // Send the event to the popup.
popuphost_->SendKeyEvent(type, key, modifiers, sysChar, imeChar); popuphost_->SendKeyEvent(type, keyInfo, modifiers);
} else { } else {
WebViewHost* host = UIT_GetWebViewHost(); WebViewHost* host = UIT_GetWebViewHost();
if (host) if (host)
host->SendKeyEvent(type, key, modifiers, sysChar, imeChar); host->SendKeyEvent(type, keyInfo, modifiers);
} }
} }
@@ -1057,16 +1100,17 @@ void CefBrowserImpl::UIT_SendMouseMoveEvent(int x, int y, bool mouseLeave) {
} }
} }
void CefBrowserImpl::UIT_SendMouseWheelEvent(int x, int y, int delta) { void CefBrowserImpl::UIT_SendMouseWheelEvent(int x, int y, int deltaX,
int deltaY) {
REQUIRE_UIT(); REQUIRE_UIT();
if (popuphost_ && popup_rect_.Contains(x, y)) { if (popuphost_ && popup_rect_.Contains(x, y)) {
// Send the event to the popup. // Send the event to the popup.
popuphost_->SendMouseWheelEvent(x - popup_rect_.x(), y - popup_rect_.y(), popuphost_->SendMouseWheelEvent(x - popup_rect_.x(), y - popup_rect_.y(),
delta); deltaX, deltaY);
} else { } else {
WebViewHost* host = UIT_GetWebViewHost(); WebViewHost* host = UIT_GetWebViewHost();
if (host) if (host)
host->SendMouseWheelEvent(x, y, delta); host->SendMouseWheelEvent(x, y, deltaX, deltaY);
} }
} }
@@ -1407,8 +1451,16 @@ void CefBrowserImpl::UIT_SetZoomLevel(double zoomLevel) {
REQUIRE_UIT(); REQUIRE_UIT();
WebKit::WebFrame* web_frame = UIT_GetMainWebFrame(); WebKit::WebFrame* web_frame = UIT_GetMainWebFrame();
if (web_frame) { if (web_frame) {
GURL url = web_frame->document().url();
web_frame->view()->setZoomLevel(false, zoomLevel); web_frame->view()->setZoomLevel(false, zoomLevel);
ZoomMap::GetInstance()->set(web_frame->document().url(), zoomLevel); bool didHandleZoom = false;
if (client_.get()) {
CefRefPtr<CefZoomHandler> handler = client_->GetZoomHandler();
if (handler.get())
didHandleZoom = handler->OnSetZoomLevel(this, url.spec(), zoomLevel);
}
if (!didHandleZoom)
ZoomMap::GetInstance()->set(url, zoomLevel);
set_zoom_level(zoomLevel); set_zoom_level(zoomLevel);
} }
} }
@@ -1539,6 +1591,26 @@ bool CefBrowserImpl::has_document() {
return has_document_; return has_document_;
} }
void CefBrowserImpl::set_pending_url(const GURL& url) {
AutoLock lock_scope(this);
pending_url_ = url;
}
GURL CefBrowserImpl::pending_url() {
AutoLock lock_scope(this);
return pending_url_;
}
net::URLRequestContext* CefBrowserImpl::request_context_proxy() {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
if (!request_context_proxy_) {
request_context_proxy_ =
new BrowserRequestContextProxy(_Context->request_context(), this);
}
return request_context_proxy_;
}
void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent) { void CefBrowserImpl::UIT_CreateDevToolsClient(BrowserDevToolsAgent *agent) {
dev_tools_client_.reset(new BrowserDevToolsClient(this, agent)); dev_tools_client_.reset(new BrowserDevToolsClient(this, agent));
} }
@@ -1554,12 +1626,19 @@ void CefBrowserImpl::UIT_DestroyDevToolsClient() {
// CefFrameImpl // CefFrameImpl
CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, const CefString& name) CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser,
: browser_(browser), name_(name) { int64 id,
const CefString& name,
const CefString& url)
: browser_(browser),
name_(name),
id_(id),
url_(url) {
} }
CefFrameImpl::~CefFrameImpl() { CefFrameImpl::~CefFrameImpl() {
browser_->RemoveCefFrame(name_); if (!IsMain())
browser_->RemoveCefFrame(id_);
} }
bool CefFrameImpl::IsFocused() { bool CefFrameImpl::IsFocused() {
@@ -1574,6 +1653,16 @@ bool CefFrameImpl::IsFocused() {
browser_->UIT_GetWebView()->focusedFrame())); browser_->UIT_GetWebView()->focusedFrame()));
} }
int64 CefFrameImpl::GetIdentifier() {
base::AutoLock lock_scope(lock_);
return id_;
}
CefString CefFrameImpl::GetURL() {
base::AutoLock lock_scope(lock_);
return url_;
}
void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) { void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
if (!visitor.get()) { if (!visitor.get()) {
NOTREACHED() << "invalid parameter"; NOTREACHED() << "invalid parameter";
@@ -1600,3 +1689,13 @@ CefRefPtr<CefV8Context> CefFrameImpl::GetV8Context() {
return NULL; return NULL;
} }
} }
void CefFrameImpl::set_id(int64 id) {
base::AutoLock lock_scope(lock_);
id_ = id;
}
void CefFrameImpl::set_url(const CefString& url) {
base::AutoLock lock_scope(lock_);
url_ = url;
}

View File

@@ -20,6 +20,7 @@
#include "libcef/browser_devtools_client.h" #include "libcef/browser_devtools_client.h"
#include "libcef/browser_webview_delegate.h" #include "libcef/browser_webview_delegate.h"
#include "libcef/browser_navigation_controller.h" #include "libcef/browser_navigation_controller.h"
#include "libcef/browser_request_context_proxy.h"
#include "libcef/cef_thread.h" #include "libcef/cef_thread.h"
#include "libcef/tracker.h" #include "libcef/tracker.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@@ -36,6 +37,8 @@ namespace WebKit {
class WebView; class WebView;
} }
class CefFrameImpl;
#define BUFFER_SIZE 32768 #define BUFFER_SIZE 32768
@@ -83,8 +86,7 @@ class CefBrowserImpl : public CefBrowser {
virtual bool IsPopup() OVERRIDE { return is_popup(); } virtual bool IsPopup() OVERRIDE { return is_popup(); }
virtual bool HasDocument() OVERRIDE { return has_document(); } virtual bool HasDocument() OVERRIDE { return has_document(); }
virtual CefRefPtr<CefClient> GetClient() OVERRIDE { return client_; } virtual CefRefPtr<CefClient> GetClient() OVERRIDE { return client_; }
virtual CefRefPtr<CefFrame> GetMainFrame() OVERRIDE virtual CefRefPtr<CefFrame> GetMainFrame() OVERRIDE;
{ return GetMainCefFrame(); }
virtual CefRefPtr<CefFrame> GetFocusedFrame() OVERRIDE; virtual CefRefPtr<CefFrame> GetFocusedFrame() OVERRIDE;
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) OVERRIDE; virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) OVERRIDE;
virtual void GetFrameNames(std::vector<CefString>& names) OVERRIDE; virtual void GetFrameNames(std::vector<CefString>& names) OVERRIDE;
@@ -104,12 +106,13 @@ class CefBrowserImpl : public CefBrowser {
virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE; virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE;
virtual bool GetImage(PaintElementType type, int width, int height, virtual bool GetImage(PaintElementType type, int width, int height,
void* buffer) OVERRIDE; void* buffer) OVERRIDE;
virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, virtual void SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool imeChar) OVERRIDE; int modifiers) OVERRIDE;
virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, virtual void SendMouseClickEvent(int x, int y, MouseButtonType type,
bool mouseUp, int clickCount) OVERRIDE; bool mouseUp, int clickCount) OVERRIDE;
virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE; virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE;
virtual void SendMouseWheelEvent(int x, int y, int delta) OVERRIDE; virtual void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY)
OVERRIDE;
virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendFocusEvent(bool setFocus) OVERRIDE;
virtual void SendCaptureLostEvent() OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE;
@@ -139,24 +142,25 @@ class CefBrowserImpl : public CefBrowser {
const CefString& jsCode, const CefString& jsCode,
const CefString& scriptUrl, const CefString& scriptUrl,
int startLine); int startLine);
int64 GetIdentifier(CefRefPtr<CefFrame> frame);
CefRefPtr<CefFrame> GetParent(CefRefPtr<CefFrame> frame); CefRefPtr<CefFrame> GetParent(CefRefPtr<CefFrame> frame);
CefString GetURL(CefRefPtr<CefFrame> frame);
// CefFrames are light-weight objects managed by the browser and loosely // CefFrames are light-weight objects managed by the browser and loosely
// coupled to a WebFrame object by name. If a CefFrame object does not // coupled to a WebFrame object by id. If a CefFrame object does not already
// already exist for the specified name one will be created. There is no // exist for the specified id one will be created. There is no guarantee that
// guarantee that the same CefFrame object will be returned across different // the same CefFrame object will be returned across different calls to this
// calls to this function. // function.
CefRefPtr<CefFrame> GetCefFrame(const CefString& name); CefRefPtr<CefFrameImpl> GetCefFrame(int64 id);
void RemoveCefFrame(const CefString& name); CefRefPtr<CefFrameImpl> GetOrCreateCefFrame(int64 id, const CefString& name,
CefRefPtr<CefFrame> GetMainCefFrame(); const GURL& url);
void RemoveCefFrame(int64 id);
CefRefPtr<CefFrameImpl> GetMainCefFrame(int64 id, const GURL& url);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD // // ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CefRefPtr<CefFrame> UIT_GetCefFrame(WebKit::WebFrame* frame); CefRefPtr<CefFrame> UIT_GetCefFrame(WebKit::WebFrame* frame);
void UIT_UpdateCefFrame(WebKit::WebFrame* frame);
// Return the main WebFrame object. // Return the main WebFrame object.
WebKit::WebFrame* UIT_GetMainWebFrame(); WebKit::WebFrame* UIT_GetMainWebFrame();
@@ -266,12 +270,11 @@ class CefBrowserImpl : public CefBrowser {
void UIT_SetFocus(WebWidgetHost* host, bool enable); void UIT_SetFocus(WebWidgetHost* host, bool enable);
void UIT_SetSize(PaintElementType type, int width, int height); void UIT_SetSize(PaintElementType type, int width, int height);
void UIT_Invalidate(const CefRect& dirtyRect); void UIT_Invalidate(const CefRect& dirtyRect);
void UIT_SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, void UIT_SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo, int modifiers);
bool imeChar);
void UIT_SendMouseClickEvent(int x, int y, MouseButtonType type, void UIT_SendMouseClickEvent(int x, int y, MouseButtonType type,
bool mouseUp, int clickCount); bool mouseUp, int clickCount);
void UIT_SendMouseMoveEvent(int x, int y, bool mouseLeave); void UIT_SendMouseMoveEvent(int x, int y, bool mouseLeave);
void UIT_SendMouseWheelEvent(int x, int y, int delta); void UIT_SendMouseWheelEvent(int x, int y, int deltaX, int deltaY);
void UIT_SendFocusEvent(bool setFocus); void UIT_SendFocusEvent(bool setFocus);
void UIT_SendCaptureLostEvent(); void UIT_SendCaptureLostEvent();
@@ -335,6 +338,10 @@ class CefBrowserImpl : public CefBrowser {
void set_has_document(bool has_document); void set_has_document(bool has_document);
bool has_document(); bool has_document();
// URL currently being loaded in the main frame.
void set_pending_url(const GURL& url);
GURL pending_url();
void set_is_dropping(bool is_dropping) { is_dropping_ = is_dropping; } void set_is_dropping(bool is_dropping) { is_dropping_ = is_dropping; }
bool is_dropping() { return is_dropping_; } bool is_dropping() { return is_dropping_; }
@@ -349,6 +356,8 @@ class CefBrowserImpl : public CefBrowser {
void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; } void set_popup_rect(const gfx::Rect& rect) { popup_rect_ = rect; }
net::URLRequestContext* request_context_proxy();
static bool ImplementsThreadSafeReferenceCounting() { return true; } static bool ImplementsThreadSafeReferenceCounting() { return true; }
protected: protected:
@@ -375,16 +384,23 @@ class CefBrowserImpl : public CefBrowser {
scoped_ptr<BrowserDevToolsAgent> dev_tools_agent_; scoped_ptr<BrowserDevToolsAgent> dev_tools_agent_;
scoped_ptr<BrowserDevToolsClient> dev_tools_client_; scoped_ptr<BrowserDevToolsClient> dev_tools_client_;
scoped_refptr<BrowserRequestContextProxy> request_context_proxy_;
CefString title_; CefString title_;
double zoom_level_; double zoom_level_;
bool can_go_back_; bool can_go_back_;
bool can_go_forward_; bool can_go_forward_;
bool has_document_; bool has_document_;
GURL pending_url_;
// True if a drop action is occuring. // True if a drop action is occuring.
bool is_dropping_; bool is_dropping_;
// True if currently in the OnSetFocus callback. Only accessed on the UI
// thread.
bool is_in_onsetfocus_;
#if defined(OS_WIN) #if defined(OS_WIN)
// Context object used to manage printing. // Context object used to manage printing.
printing::PrintingContext print_context_; printing::PrintingContext print_context_;
@@ -394,9 +410,12 @@ class CefBrowserImpl : public CefBrowser {
bool internal_modal_message_loop_is_active_; bool internal_modal_message_loop_is_active_;
#endif #endif
typedef std::map<CefString, CefFrame*> FrameMap; // Map of frame id to reference.
typedef std::map<int64, CefFrameImpl*> FrameMap;
FrameMap frames_; FrameMap frames_;
CefFrame* main_frame_;
// Singleton main frame reference.
CefRefPtr<CefFrameImpl> main_frame_;
typedef std::map<WebKit::WebFrame*, CefRefPtr<CefTrackManager> > typedef std::map<WebKit::WebFrame*, CefRefPtr<CefTrackManager> >
FrameObjectMap; FrameObjectMap;
@@ -416,7 +435,10 @@ class CefBrowserImpl : public CefBrowser {
// Implementation of CefFrame. // Implementation of CefFrame.
class CefFrameImpl : public CefFrame { class CefFrameImpl : public CefFrame {
public: public:
CefFrameImpl(CefBrowserImpl* browser, const CefString& name); CefFrameImpl(CefBrowserImpl* browser,
int64 frame_id,
const CefString& name,
const CefString& url);
virtual ~CefFrameImpl(); virtual ~CefFrameImpl();
// CefFrame methods // CefFrame methods
@@ -453,20 +475,26 @@ class CefFrameImpl : public CefFrame {
virtual bool IsMain() OVERRIDE { return name_.empty(); } virtual bool IsMain() OVERRIDE { return name_.empty(); }
virtual bool IsFocused() OVERRIDE; virtual bool IsFocused() OVERRIDE;
virtual CefString GetName() OVERRIDE { return name_; } virtual CefString GetName() OVERRIDE { return name_; }
virtual int64 GetIdentifier() OVERRIDE { virtual int64 GetIdentifier() OVERRIDE;
return browser_->GetIdentifier(this);
}
virtual CefRefPtr<CefFrame> GetParent() OVERRIDE { virtual CefRefPtr<CefFrame> GetParent() OVERRIDE {
return browser_->GetParent(this); return browser_->GetParent(this);
} }
virtual CefString GetURL() OVERRIDE { return browser_->GetURL(this); } virtual CefString GetURL() OVERRIDE;
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE { return browser_.get(); } virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE { return browser_.get(); }
virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE; virtual void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) OVERRIDE;
virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE; virtual CefRefPtr<CefV8Context> GetV8Context() OVERRIDE;
void set_id(int64 id);
void set_url(const CefString& url);
private: private:
CefRefPtr<CefBrowserImpl> browser_; CefRefPtr<CefBrowserImpl> browser_;
CefString name_; CefString name_;
// The below values must be protected by the lock.
base::Lock lock_;
int64 id_;
CefString url_;
IMPLEMENT_REFCOUNTING(CefFrameImpl); IMPLEMENT_REFCOUNTING(CefFrameImpl);
}; };

View File

@@ -92,6 +92,8 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) {
if (!settings_.developer_tools_disabled) if (!settings_.developer_tools_disabled)
dev_tools_agent_->SetWebView(webviewhost_->webview()); dev_tools_agent_->SetWebView(webviewhost_->webview());
webviewhost_->SetFrameRate(settings_.animation_frame_rate);
window_info_.m_Widget = webviewhost_->view_handle(); window_info_.m_Widget = webviewhost_->view_handle();
g_signal_connect(G_OBJECT(window_info_.m_Widget), "destroy", g_signal_connect(G_OBJECT(window_info_.m_Widget), "destroy",
G_CALLBACK(window_destroyed), this); G_CALLBACK(window_destroyed), this);

View File

@@ -29,18 +29,19 @@ CefWindowHandle CefBrowserImpl::GetWindowHandle() {
} }
bool CefBrowserImpl::IsWindowRenderingDisabled() { bool CefBrowserImpl::IsWindowRenderingDisabled() {
// TODO(port): Add support for off-screen rendering. return (window_info_.m_bWindowRenderingDisabled ? true : false);
return false;
} }
gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() { gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() {
REQUIRE_UIT(); REQUIRE_UIT();
return window_info_.m_View; return window_info_.m_bWindowRenderingDisabled ?
window_info_.m_ParentView : window_info_.m_View;
} }
void CefBrowserImpl::UIT_ClearMainWndHandle() { void CefBrowserImpl::UIT_ClearMainWndHandle() {
REQUIRE_UIT(); REQUIRE_UIT();
window_info_.m_View = NULL; if (!window_info_.m_bWindowRenderingDisabled)
window_info_.m_View = NULL;
} }
bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) { bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) {
@@ -61,29 +62,35 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) {
NSView* parentView = window_info_.m_ParentView; NSView* parentView = window_info_.m_ParentView;
gfx::Rect contentRect(window_info_.m_x, window_info_.m_y, gfx::Rect contentRect(window_info_.m_x, window_info_.m_y,
window_info_.m_nWidth, window_info_.m_nHeight); window_info_.m_nWidth, window_info_.m_nHeight);
if (parentView == nil) { if (!window_info_.m_bWindowRenderingDisabled) {
// Create a new window. if (parentView == nil) {
NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; // Create a new window.
NSRect window_rect = {{window_info_.m_x, NSRect screen_rect = [[NSScreen mainScreen] visibleFrame];
screen_rect.size.height - window_info_.m_y}, NSRect window_rect = {{window_info_.m_x,
{window_info_.m_nWidth, window_info_.m_nHeight}}; screen_rect.size.height - window_info_.m_y},
if (window_rect.size.width == 0) {window_info_.m_nWidth, window_info_.m_nHeight}};
window_rect.size.width = 750; if (window_rect.size.width == 0)
if (window_rect.size.height == 0) window_rect.size.width = 750;
window_rect.size.height = 750; if (window_rect.size.height == 0)
contentRect.SetRect(0, 0, window_rect.size.width, window_rect.size.height); window_rect.size.height = 750;
contentRect.SetRect(0, 0, window_rect.size.width,
window_rect.size.height);
newWnd = [[NSWindow alloc] newWnd = [[NSWindow alloc]
initWithContentRect:window_rect initWithContentRect:window_rect
styleMask:(NSTitledWindowMask | styleMask:(NSTitledWindowMask |
NSClosableWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSMiniaturizableWindowMask |
NSResizableWindowMask | NSResizableWindowMask |
NSUnifiedTitleAndToolbarWindowMask ) NSUnifiedTitleAndToolbarWindowMask )
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:NO]; defer:NO];
parentView = [newWnd contentView]; parentView = [newWnd contentView];
window_info_.m_ParentView = parentView; window_info_.m_ParentView = parentView;
}
} else {
// Create a new paint delegate.
paint_delegate_.reset(new PaintDelegate(this));
} }
WebPreferences prefs; WebPreferences prefs;
@@ -92,17 +99,25 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) {
// Create the webview host object // Create the webview host object
webviewhost_.reset( webviewhost_.reset(
WebViewHost::Create(parentView, contentRect, delegate_.get(), WebViewHost::Create(parentView, contentRect, delegate_.get(),
NULL, dev_tools_agent_.get(), prefs)); paint_delegate_.get(), dev_tools_agent_.get(),
prefs));
if (window_info_.m_bTransparentPainting)
webviewhost_->webview()->setIsTransparent(true);
if (!settings_.developer_tools_disabled) if (!settings_.developer_tools_disabled)
dev_tools_agent_->SetWebView(webviewhost_->webview()); dev_tools_agent_->SetWebView(webviewhost_->webview());
webviewhost_->SetFrameRate(settings_.animation_frame_rate);
BrowserWebView* browserView = (BrowserWebView*)webviewhost_->view_handle(); BrowserWebView* browserView = (BrowserWebView*)webviewhost_->view_handle();
browserView.browser = this; browserView.browser = this;
window_info_.m_View = browserView; window_info_.m_View = browserView;
if (!settings_.drag_drop_disabled) if (!window_info_.m_bWindowRenderingDisabled) {
[browserView registerDragDrop]; if (!settings_.drag_drop_disabled)
[browserView registerDragDrop];
}
Unlock(); Unlock();
@@ -130,19 +145,36 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) {
if (!host) if (!host)
return; return;
NSView* view = host->view_handle(); BrowserWebView* browserView = (BrowserWebView*)host->view_handle();
if (!view) if (!browserView)
return; return;
if (enable) if (enable) {
[[view window] makeFirstResponder:view]; // Guard against calling OnSetFocus twice.
browserView.in_setfocus = true;
[[browserView window] makeFirstResponder:browserView];
browserView.in_setfocus = false;
}
} }
bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) { bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame* frame) {
REQUIRE_UIT(); REQUIRE_UIT();
// TODO(port): Add implementation. char sztmp[L_tmpnam+4];
NOTIMPLEMENTED(); if (tmpnam(sztmp)) {
strcat(sztmp, ".txt");
FILE* fp = fopen(sztmp, "wb");
if (fp) {
std::string markup = frame->contentAsMarkup().utf8();
fwrite(markup.c_str(), 1, markup.size(), fp);
fclose(fp);
char szopen[L_tmpnam + 14];
snprintf(szopen, sizeof(szopen), "open -t \"%s\"", sztmp);
return (system(szopen) >= 0);
}
}
return false; return false;
} }

View File

@@ -88,8 +88,15 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
// Clear the user data pointer. // Clear the user data pointer.
ui::SetWindowUserData(hwnd, NULL); ui::SetWindowUserData(hwnd, NULL);
// Destroy the browser. BrowserWebViewDelegate* delegate = browser->UIT_GetWebViewDelegate();
browser->UIT_DestroyBrowser(); if (delegate && delegate->drag_delegate()) {
// Don't destroy the browser while a drag operation is pending. Instead,
// destroy the browser once the drag operation completes.
delegate->set_destroy_on_drag_end(true);
} else {
// Destroy the browser.
browser->UIT_DestroyBrowser();
}
} }
return 0; return 0;
@@ -104,21 +111,8 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
return 0; return 0;
case WM_SETFOCUS: case WM_SETFOCUS:
if (browser) { if (browser)
WebViewHost* host = browser->UIT_GetWebViewHost(); browser->SetFocus(true);
if (host) {
bool handled = false;
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
if (handler.get())
handled = handler->OnSetFocus(browser, FOCUS_SOURCE_SYSTEM);
}
if (!handled)
browser->UIT_SetFocus(host, true);
}
}
return 0; return 0;
case WM_ERASEBKGND: case WM_ERASEBKGND:
@@ -225,6 +219,8 @@ bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) {
if (!settings_.developer_tools_disabled) if (!settings_.developer_tools_disabled)
dev_tools_agent_->SetWebView(webviewhost_->webview()); dev_tools_agent_->SetWebView(webviewhost_->webview());
webviewhost_->SetFrameRate(settings_.animation_frame_rate);
Unlock(); Unlock();
if (!window_info_.m_bWindowRenderingDisabled) { if (!window_info_.m_bWindowRenderingDisabled) {

View File

@@ -57,7 +57,7 @@ BrowserNavigationController::~BrowserNavigationController() {
} }
void BrowserNavigationController::Reset() { void BrowserNavigationController::Reset() {
entries_.clear(); entries_.reset();
DiscardPendingEntry(); DiscardPendingEntry();
last_committed_entry_index_ = -1; last_committed_entry_index_ = -1;
@@ -111,7 +111,8 @@ BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry()
const { const {
if (last_committed_entry_index_ == -1) if (last_committed_entry_index_ == -1)
return NULL; return NULL;
return entries_[last_committed_entry_index_].get(); return const_cast<BrowserNavigationEntry*>(
entries_[last_committed_entry_index_]);
} }
BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const { BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const {
@@ -133,13 +134,14 @@ BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex(
if (index < 0 || index >= GetEntryCount()) if (index < 0 || index >= GetEntryCount())
return NULL; return NULL;
return entries_[index].get(); return const_cast<BrowserNavigationEntry*>(entries_[index]);
} }
BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID( BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID(
int32 page_id) const { int32 page_id) const {
int index = GetEntryIndexWithPageID(page_id); int index = GetEntryIndexWithPageID(page_id);
return (index != -1) ? entries_[index].get() : NULL; return (index != -1) ?
const_cast<BrowserNavigationEntry*>(entries_[index]) : NULL;
} }
void BrowserNavigationController::DidNavigateToEntry( void BrowserNavigationController::DidNavigateToEntry(
@@ -158,7 +160,7 @@ void BrowserNavigationController::DidNavigateToEntry(
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID()); int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ? BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ?
entries_[existing_entry_index].get() : NULL; entries_[existing_entry_index] : NULL;
if (!existing_entry) { if (!existing_entry) {
// No existing entry, then simply ignore this navigation! // No existing entry, then simply ignore this navigation!
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
@@ -191,7 +193,7 @@ void BrowserNavigationController::DidNavigateToEntry(
} }
void BrowserNavigationController::DiscardPendingEntry() { void BrowserNavigationController::DiscardPendingEntry() {
if (pending_entry_index_ == -1) if (pending_entry_index_ == -1 && pending_entry_)
delete pending_entry_; delete pending_entry_;
pending_entry_ = NULL; pending_entry_ = NULL;
pending_entry_index_ = -1; pending_entry_index_ = -1;
@@ -204,19 +206,19 @@ void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
if (settings.history_disabled) { if (settings.history_disabled) {
// History is disabled. Remove any existing entries. // History is disabled. Remove any existing entries.
if (entries_.size() > 0) if (entries_.size() > 0)
entries_.clear(); entries_.reset();
} else { } else {
// Prune any entry which are in front of the current entry. // Prune any entry which are in front of the current entry.
int current_size = static_cast<int>(entries_.size()); int current_size = static_cast<int>(entries_.size());
if (current_size > 0) { if (current_size > 0) {
while (last_committed_entry_index_ < (current_size - 1)) { while (last_committed_entry_index_ < (current_size - 1)) {
entries_.pop_back(); entries_.erase(entries_.end() - 1);
current_size--; current_size--;
} }
} }
} }
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry)); entries_.push_back(entry);
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
UpdateMaxPageID(); UpdateMaxPageID();
} }
@@ -234,7 +236,7 @@ void BrowserNavigationController::NavigateToPendingEntry(bool reload,
// For session history navigations only the pending_entry_index_ is set. // For session history navigations only the pending_entry_index_ is set.
if (!pending_entry_) { if (!pending_entry_) {
DCHECK_NE(pending_entry_index_, -1); DCHECK_NE(pending_entry_index_, -1);
pending_entry_ = entries_[pending_entry_index_].get(); pending_entry_ = entries_[pending_entry_index_];
} }
if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) { if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) {

View File

@@ -11,8 +11,8 @@
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h"
@@ -187,8 +187,7 @@ class BrowserNavigationController {
void UpdateMaxPageID(); void UpdateMaxPageID();
// List of NavigationEntry for this tab // List of NavigationEntry for this tab
typedef std::vector< linked_ptr<BrowserNavigationEntry> > NavigationEntryList; typedef ScopedVector<BrowserNavigationEntry> NavigationEntryList;
typedef NavigationEntryList::iterator NavigationEntryListIterator;
NavigationEntryList entries_; NavigationEntryList entries_;
// An entry we haven't gotten a response for yet. This will be discarded // An entry we haven't gotten a response for yet. This will be discarded
@@ -210,4 +209,3 @@ class BrowserNavigationController {
}; };
#endif // CEF_LIBCEF_BROWSER_NAVIGATION_CONTROLLER_H_ #endif // CEF_LIBCEF_BROWSER_NAVIGATION_CONTROLLER_H_

View File

@@ -147,15 +147,6 @@ void BrowserRequestContext::Init(
const FilePath& cache_path, const FilePath& cache_path,
net::HttpCache::Mode cache_mode, net::HttpCache::Mode cache_mode,
bool no_proxy) { bool no_proxy) {
// Create the |cache_path| directory if necessary.
bool cache_path_valid = false;
if (!cache_path.empty()) {
if (file_util::CreateDirectory(cache_path))
cache_path_valid = true;
else
NOTREACHED() << "The cache_path directory could not be created";
}
SetCookieStoragePath(cache_path); SetCookieStoragePath(cache_path);
storage_.set_origin_bound_cert_service(new net::OriginBoundCertService( storage_.set_origin_bound_cert_service(new net::OriginBoundCertService(
@@ -238,7 +229,7 @@ void BrowserRequestContext::Init(
storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); storage_.set_http_server_properties(new net::HttpServerPropertiesImpl);
net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
cache_path_valid ? net::DISK_CACHE : net::MEMORY_CACHE, cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE,
cache_path, 0, BrowserResourceLoaderBridge::GetCacheThread()); cache_path, 0, BrowserResourceLoaderBridge::GetCacheThread());
net::HttpCache* cache = net::HttpCache* cache =
@@ -307,13 +298,17 @@ void BrowserRequestContext::SetCookieStoragePath(const FilePath& path) {
return; return;
} }
FilePath new_path = path;
scoped_refptr<BrowserPersistentCookieStore> persistent_store; scoped_refptr<BrowserPersistentCookieStore> persistent_store;
if (!path.empty()) { if (!new_path.empty()) {
if (file_util::CreateDirectory(path)) { if (!file_util::PathExists(new_path) &&
const FilePath& cookie_path = path.AppendASCII("Cookies"); !file_util::CreateDirectory(new_path)) {
persistent_store = new BrowserPersistentCookieStore(cookie_path, false); NOTREACHED() << "Failed to create cookie storage directory";
new_path.clear();
} else { } else {
NOTREACHED() << "The cookie storage directory could not be created"; FilePath cookie_path = new_path.Append(FILE_PATH_LITERAL("Cookies"));
persistent_store = new BrowserPersistentCookieStore(cookie_path, false);
} }
} }
@@ -322,7 +317,7 @@ void BrowserRequestContext::SetCookieStoragePath(const FilePath& path) {
// longer referenced. // longer referenced.
storage_.set_cookie_store( storage_.set_cookie_store(
new net::CookieMonster(persistent_store.get(), NULL)); new net::CookieMonster(persistent_store.get(), NULL));
cookie_store_path_ = path; cookie_store_path_ = new_path;
} }
const std::string& BrowserRequestContext::GetUserAgent( const std::string& BrowserRequestContext::GetUserAgent(

View File

@@ -34,7 +34,7 @@ class BrowserRequestContext : public net::URLRequestContext {
net::HttpCache::Mode cache_mode, net::HttpCache::Mode cache_mode,
bool no_proxy); bool no_proxy);
virtual const std::string& GetUserAgent(const GURL& url) const; virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE;
void SetAcceptAllCookies(bool accept_all_cookies); void SetAcceptAllCookies(bool accept_all_cookies);
bool AcceptAllCookies(); bool AcceptAllCookies();

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/browser_request_context_proxy.h"
#include "libcef/browser_impl.h"
#include "libcef/browser_request_context.h"
#include "libcef/cookie_store_proxy.h"
BrowserRequestContextProxy::BrowserRequestContextProxy(
BrowserRequestContext* context,
CefBrowserImpl* browser)
: context_(context),
browser_(browser) {
DCHECK(context_);
DCHECK(browser_);
// Cookie store that proxies to the browser implementation.
set_cookie_store(new CefCookieStoreProxy(browser_));
// All other values refer to the global request context.
set_net_log(context->net_log());
set_host_resolver(context->host_resolver());
set_cert_verifier(context->cert_verifier());
set_origin_bound_cert_service(context->origin_bound_cert_service());
set_fraudulent_certificate_reporter(
context->fraudulent_certificate_reporter());
set_proxy_service(context->proxy_service());
set_ssl_config_service(context->ssl_config_service());
set_http_auth_handler_factory(context->http_auth_handler_factory());
set_http_transaction_factory(context->http_transaction_factory());
set_ftp_transaction_factory(context->ftp_transaction_factory());
set_network_delegate(context->network_delegate());
set_http_server_properties(context->http_server_properties());
set_transport_security_state(context->transport_security_state());
set_accept_charset(context->accept_charset());
set_accept_language(context->accept_language());
set_referrer_charset(context->referrer_charset());
set_job_factory(context->job_factory());
}
const std::string&
BrowserRequestContextProxy::GetUserAgent(const GURL& url) const {
return context_->GetUserAgent(url);
}

View File

@@ -0,0 +1,30 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_
#define CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_
#pragma once
#include <string>
#include "include/cef_base.h"
#include "net/url_request/url_request_context.h"
class BrowserRequestContext;
class CefBrowserImpl;
// A URLRequestContext implementation that proxies cookie requests to the
// client.
class BrowserRequestContextProxy : public net::URLRequestContext {
public:
BrowserRequestContextProxy(BrowserRequestContext* context,
CefBrowserImpl* browser);
virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE;
private:
BrowserRequestContext* context_;
CefRefPtr<CefBrowserImpl> browser_;
};
#endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_PROXY_H_

View File

@@ -20,10 +20,6 @@
// \ -> net::URLRequest // \ -> net::URLRequest
// o-------> SyncRequestProxy (synchronous case) // o-------> SyncRequestProxy (synchronous case)
// -> net::URLRequest // -> net::URLRequest
// SetCookie <------------------------> CookieSetter
// -> net_util::SetCookie
// GetCookies <-----------------------> CookieGetter
// -> net_util::GetCookies
// //
// NOTE: The implementation in this file may be used to have WebKit fetch // NOTE: The implementation in this file may be used to have WebKit fetch
// resources in-process. For example, it is handy for building a single- // resources in-process. For example, it is handy for building a single-
@@ -51,13 +47,11 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/message_loop_proxy.h" #include "base/message_loop_proxy.h"
#include "base/synchronization/waitable_event.h"
#include "base/time.h" #include "base/time.h"
#include "base/timer.h" #include "base/timer.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "net/base/auth.h" #include "net/base/auth.h"
#include "net/base/cookie_store.h"
#include "net/base/file_stream.h" #include "net/base/file_stream.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
@@ -115,7 +109,7 @@ static const int kUpdateUploadProgressIntervalMsec = 100;
class ExtraRequestInfo : public net::URLRequest::UserData { class ExtraRequestInfo : public net::URLRequest::UserData {
public: public:
ExtraRequestInfo(CefBrowser* browser, ResourceType::Type resource_type) ExtraRequestInfo(CefBrowserImpl* browser, ResourceType::Type resource_type)
: browser_(browser), : browser_(browser),
resource_type_(resource_type), resource_type_(resource_type),
allow_download_(resource_type == ResourceType::MAIN_FRAME || allow_download_(resource_type == ResourceType::MAIN_FRAME ||
@@ -125,14 +119,14 @@ class ExtraRequestInfo : public net::URLRequest::UserData {
// The browser pointer is guaranteed to be valid for the lifespan of the // The browser pointer is guaranteed to be valid for the lifespan of the
// request. The pointer will be NULL in cases where the request was // request. The pointer will be NULL in cases where the request was
// initiated via the CefWebURLRequest API instead of by a browser window. // initiated via the CefWebURLRequest API instead of by a browser window.
CefBrowser* browser() const { return browser_; } CefBrowserImpl* browser() const { return browser_; }
// Identifies the type of resource, such as subframe, media, etc. // Identifies the type of resource, such as subframe, media, etc.
ResourceType::Type resource_type() const { return resource_type_; } ResourceType::Type resource_type() const { return resource_type_; }
bool allow_download() const { return allow_download_; } bool allow_download() const { return allow_download_; }
private: private:
CefBrowser* browser_; CefBrowserImpl* browser_;
ResourceType::Type resource_type_; ResourceType::Type resource_type_;
bool allow_download_; bool allow_download_;
}; };
@@ -195,7 +189,7 @@ class RequestProxy : public net::URLRequest::Delegate,
public base::RefCountedThreadSafe<RequestProxy> { public base::RefCountedThreadSafe<RequestProxy> {
public: public:
// Takes ownership of the params. // Takes ownership of the params.
explicit RequestProxy(CefRefPtr<CefBrowser> browser) explicit RequestProxy(CefRefPtr<CefBrowserImpl> browser)
: download_to_file_(false), : download_to_file_(false),
buf_(new net::IOBuffer(kDataSize)), buf_(new net::IOBuffer(kDataSize)),
browser_(browser), browser_(browser),
@@ -292,7 +286,7 @@ class RequestProxy : public net::URLRequest::Delegate,
response->SetStatus(info.headers->response_code()); response->SetStatus(info.headers->response_code());
} }
response->SetMimeType(info.mime_type); response->SetMimeType(info.mime_type);
handler->OnResourceResponse(browser_, url.spec(), response, handler->OnResourceResponse(browser_.get(), url.spec(), response,
content_filter_); content_filter_);
std::string content_disposition; std::string content_disposition;
@@ -305,7 +299,7 @@ class RequestProxy : public net::URLRequest::Delegate,
content_disposition, info.charset, "", info.mime_type, content_disposition, info.charset, "", info.mime_type,
"download"); "download");
CefRefPtr<CefDownloadHandler> dl_handler; CefRefPtr<CefDownloadHandler> dl_handler;
if (handler->GetDownloadHandler(browser_, info.mime_type, if (handler->GetDownloadHandler(browser_.get(), info.mime_type,
filename, info.content_length, filename, info.content_length,
dl_handler)) { dl_handler)) {
download_handler_ = dl_handler; download_handler_ = dl_handler;
@@ -444,7 +438,7 @@ class RequestProxy : public net::URLRequest::Delegate,
// Transfer request headers // Transfer request headers
CefRequest::HeaderMap headerMap; CefRequest::HeaderMap headerMap;
HttpHeaderUtils::ParseHeaders(params->headers, headerMap); HttpHeaderUtils::ParseHeaders(params->headers, headerMap);
headerMap.insert(std::make_pair("Referrer", params->referrer.spec())); headerMap.insert(std::make_pair("Referer", params->referrer.spec()));
requestimpl->SetHeaderMap(headerMap); requestimpl->SetHeaderMap(headerMap);
// Transfer post data, if any // Transfer post data, if any
@@ -462,8 +456,8 @@ class RequestProxy : public net::URLRequest::Delegate,
CefRefPtr<CefStreamReader> resourceStream; CefRefPtr<CefStreamReader> resourceStream;
CefRefPtr<CefResponse> response(new CefResponseImpl()); CefRefPtr<CefResponse> response(new CefResponseImpl());
handled = handler->OnBeforeResourceLoad(browser_, request, redirectUrl, handled = handler->OnBeforeResourceLoad(browser_.get(), request,
resourceStream, response, loadFlags); redirectUrl, resourceStream, response, loadFlags);
if (!handled) { if (!handled) {
// Observe URL from request. // Observe URL from request.
const std::string requestUrl(request->GetURL()); const std::string requestUrl(request->GetURL());
@@ -478,7 +472,7 @@ class RequestProxy : public net::URLRequest::Delegate,
// Observe headers from request. // Observe headers from request.
request->GetHeaderMap(headerMap); request->GetHeaderMap(headerMap);
CefString referrerStr; CefString referrerStr;
referrerStr.FromASCII("Referrer"); referrerStr.FromASCII("Referer");
CefRequest::HeaderMap::iterator referrer = CefRequest::HeaderMap::iterator referrer =
headerMap.find(referrerStr); headerMap.find(referrerStr);
if (referrer == headerMap.end()) { if (referrer == headerMap.end()) {
@@ -539,8 +533,8 @@ class RequestProxy : public net::URLRequest::Delegate,
if (!handled && ResourceType::IsFrame(params->request_type) && if (!handled && ResourceType::IsFrame(params->request_type) &&
!net::URLRequest::IsHandledProtocol(params->url.scheme())) { !net::URLRequest::IsHandledProtocol(params->url.scheme())) {
bool allow_os_execution = false; bool allow_os_execution = false;
handled = handler->OnProtocolExecution(browser_, params->url.spec(), handled = handler->OnProtocolExecution(browser_.get(),
allow_os_execution); params->url.spec(), allow_os_execution);
if (!handled && allow_os_execution && if (!handled && allow_os_execution &&
ExternalProtocolHandler::HandleExternalProtocol(params->url)) { ExternalProtocolHandler::HandleExternalProtocol(params->url)) {
handled = true; handled = true;
@@ -572,7 +566,8 @@ class RequestProxy : public net::URLRequest::Delegate,
request_->SetExtraRequestHeaders(headers); request_->SetExtraRequestHeaders(headers);
request_->set_load_flags(params->load_flags); request_->set_load_flags(params->load_flags);
request_->set_upload(params->upload.get()); request_->set_upload(params->upload.get());
request_->set_context(_Context->request_context()); request_->set_context(browser_.get() ? browser_->request_context_proxy() :
_Context->request_context());
request_->SetUserData(kCefUserData, request_->SetUserData(kCefUserData,
new ExtraRequestInfo(browser_.get(), params->request_type)); new ExtraRequestInfo(browser_.get(), params->request_type));
BrowserAppCacheSystem::SetExtraRequestInfo( BrowserAppCacheSystem::SetExtraRequestInfo(
@@ -758,7 +753,7 @@ class RequestProxy : public net::URLRequest::Delegate,
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler(); CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) { if (handler.get()) {
CefString username, password; CefString username, password;
if (handler->GetAuthCredentials(browser_, if (handler->GetAuthCredentials(browser_.get(),
auth_info->is_proxy, auth_info->is_proxy,
auth_info->challenger.host(), auth_info->challenger.host(),
auth_info->challenger.port(), auth_info->challenger.port(),
@@ -905,7 +900,7 @@ class RequestProxy : public net::URLRequest::Delegate,
// read buffer for async IO // read buffer for async IO
scoped_refptr<net::IOBuffer> buf_; scoped_refptr<net::IOBuffer> buf_;
CefRefPtr<CefBrowser> browser_; CefRefPtr<CefBrowserImpl> browser_;
MessageLoop* owner_loop_; MessageLoop* owner_loop_;
@@ -935,7 +930,7 @@ class RequestProxy : public net::URLRequest::Delegate,
class SyncRequestProxy : public RequestProxy { class SyncRequestProxy : public RequestProxy {
public: public:
explicit SyncRequestProxy(CefRefPtr<CefBrowser> browser, explicit SyncRequestProxy(CefRefPtr<CefBrowserImpl> browser,
ResourceLoaderBridge::SyncLoadResponse* result) ResourceLoaderBridge::SyncLoadResponse* result)
: RequestProxy(browser), result_(result), event_(true, false) { : RequestProxy(browser), result_(result), event_(true, false) {
} }
@@ -1002,7 +997,7 @@ class SyncRequestProxy : public RequestProxy {
class ResourceLoaderBridgeImpl : public ResourceLoaderBridge { class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
public: public:
ResourceLoaderBridgeImpl(CefRefPtr<CefBrowser> browser, ResourceLoaderBridgeImpl(CefRefPtr<CefBrowserImpl> browser,
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
: browser_(browser), : browser_(browser),
params_(new RequestParams), params_(new RequestParams),
@@ -1100,7 +1095,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
virtual void UpdateRoutingId(int new_routing_id) OVERRIDE {} virtual void UpdateRoutingId(int new_routing_id) OVERRIDE {}
private: private:
CefRefPtr<CefBrowser> browser_; CefRefPtr<CefBrowserImpl> browser_;
// Ownership of params_ is transfered to the proxy when the proxy is created. // Ownership of params_ is transfered to the proxy when the proxy is created.
scoped_ptr<RequestParams> params_; scoped_ptr<RequestParams> params_;
@@ -1110,61 +1105,6 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
RequestProxy* proxy_; RequestProxy* proxy_;
}; };
//-----------------------------------------------------------------------------
class CookieSetter : public base::RefCountedThreadSafe<CookieSetter> {
public:
void Set(const GURL& url, const std::string& cookie) {
REQUIRE_IOT();
net::CookieStore* cookie_store =
_Context->request_context()->cookie_store();
if (cookie_store) {
cookie_store->SetCookieWithOptionsAsync(
url, cookie, net::CookieOptions(),
net::CookieStore::SetCookiesCallback());
}
}
private:
friend class base::RefCountedThreadSafe<CookieSetter>;
~CookieSetter() {}
};
class CookieGetter : public base::RefCountedThreadSafe<CookieGetter> {
public:
CookieGetter() : event_(false, false) {
}
void Get(const GURL& url) {
REQUIRE_IOT();
net::CookieStore* cookie_store =
_Context->request_context()->cookie_store();
if (cookie_store) {
cookie_store->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&CookieGetter::OnGetCookies, this));
}
}
std::string GetResult() {
event_.Wait();
return result_;
}
private:
void OnGetCookies(const std::string& cookie_line) {
result_ = cookie_line;
event_.Signal();
}
friend class base::RefCountedThreadSafe<CookieGetter>;
~CookieGetter() {}
base::WaitableEvent event_;
std::string result_;
};
} // anonymous namespace } // anonymous namespace
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1180,37 +1120,7 @@ webkit_glue::ResourceLoaderBridge* BrowserResourceLoaderBridge::Create(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// static // static
void BrowserResourceLoaderBridge::SetCookie(const GURL& url, CefRefPtr<CefBrowserImpl> BrowserResourceLoaderBridge::GetBrowserForRequest(
const GURL& first_party_for_cookies,
const std::string& cookie) {
// Proxy to IO thread to synchronize w/ network loading.
scoped_refptr<CookieSetter> cookie_setter = new CookieSetter();
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&CookieSetter::Set, cookie_setter.get(), url, cookie));
}
// static
std::string BrowserResourceLoaderBridge::GetCookies(
const GURL& url, const GURL& first_party_for_cookies) {
// Proxy to IO thread to synchronize w/ network loading.
scoped_refptr<CookieGetter> cookie_getter = new CookieGetter();
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&CookieGetter::Get, cookie_getter.get(), url));
// Blocks until the result is available.
return cookie_getter->GetResult();
}
// static
void BrowserResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) {
// Proxy to IO thread to synchronize w/ network loading.
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&BrowserRequestContext::SetAcceptAllCookies,
_Context->request_context().get(), accept_all_cookies));
}
// static
CefRefPtr<CefBrowser> BrowserResourceLoaderBridge::GetBrowserForRequest(
net::URLRequest* request) { net::URLRequest* request) {
REQUIRE_IOT(); REQUIRE_IOT();
ExtraRequestInfo* extra_info = ExtraRequestInfo* extra_info =

View File

@@ -14,23 +14,16 @@
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/resource_loader_bridge.h"
class CefBrowser; class CefBrowserImpl;
class GURL; class GURL;
class BrowserResourceLoaderBridge { class BrowserResourceLoaderBridge {
public: public:
// May only be called after Init.
static void SetCookie(const GURL& url,
const GURL& first_party_for_cookies,
const std::string& cookie);
static std::string GetCookies(const GURL& url,
const GURL& first_party_for_cookies);
static void SetAcceptAllCookies(bool accept_all_cookies);
// Return the CefBrowser associated with the specified request. The browser // Return the CefBrowser associated with the specified request. The browser
// will be NULL in cases where the request was initiated using the // will be NULL in cases where the request was initiated using the
// CefWebURLRequest API. // CefWebURLRequest API.
static CefRefPtr<CefBrowser> GetBrowserForRequest(net::URLRequest* request); static CefRefPtr<CefBrowserImpl> GetBrowserForRequest(
net::URLRequest* request);
// Creates a ResourceLoaderBridge instance. // Creates a ResourceLoaderBridge instance.
static webkit_glue::ResourceLoaderBridge* Create( static webkit_glue::ResourceLoaderBridge* Create(

View File

@@ -1,25 +1,139 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2012 the Chromium Embedded Framework authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "libcef/browser_webcookiejar_impl.h" #include "libcef/browser_webcookiejar_impl.h"
#include "libcef/browser_resource_loader_bridge.h"
#include <string>
#include "libcef/browser_resource_loader_bridge.h"
#include "libcef/browser_impl.h"
#include "libcef/cookie_manager_impl.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "base/synchronization/waitable_event.h"
#include "net/base/cookie_store.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
using WebKit::WebString; using WebKit::WebString;
using WebKit::WebURL; using WebKit::WebURL;
namespace {
net::CookieStore* GetCookieStore(CefRefPtr<CefBrowserImpl> browser) {
scoped_refptr<net::CookieStore> cookie_store;
if (browser) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) {
// Get the manager from the handler.
CefRefPtr<CefCookieManager> manager =
handler->GetCookieManager(browser.get(),
browser->pending_url().spec());
if (manager.get()) {
cookie_store =
reinterpret_cast<CefCookieManagerImpl*>(
manager.get())->cookie_monster();
}
}
}
}
if (!cookie_store) {
// Use the global cookie store.
cookie_store = _Context->request_context()->cookie_store();
}
DCHECK(cookie_store);
return cookie_store;
}
class CookieSetter : public base::RefCountedThreadSafe<CookieSetter> {
public:
void Set(CefRefPtr<CefBrowserImpl> browser,
const GURL& url,
const std::string& cookie) {
REQUIRE_IOT();
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore(browser);
cookie_store->SetCookieWithOptionsAsync(
url, cookie, net::CookieOptions(),
net::CookieStore::SetCookiesCallback());
}
private:
friend class base::RefCountedThreadSafe<CookieSetter>;
~CookieSetter() {}
};
class CookieGetter : public base::RefCountedThreadSafe<CookieGetter> {
public:
CookieGetter() : event_(false, false) {
}
void Get(CefRefPtr<CefBrowserImpl> browser, const GURL& url) {
REQUIRE_IOT();
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore(browser);
cookie_store->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&CookieGetter::OnGetCookies, this));
}
std::string GetResult() {
event_.Wait();
return result_;
}
private:
void OnGetCookies(const std::string& cookie_line) {
result_ = cookie_line;
event_.Signal();
}
friend class base::RefCountedThreadSafe<CookieGetter>;
~CookieGetter() {}
base::WaitableEvent event_;
std::string result_;
};
} // namespace
BrowserWebCookieJarImpl::BrowserWebCookieJarImpl()
: browser_(NULL) {
}
BrowserWebCookieJarImpl::BrowserWebCookieJarImpl(CefBrowserImpl* browser)
: browser_(browser) {
}
void BrowserWebCookieJarImpl::setCookie(const WebURL& url, void BrowserWebCookieJarImpl::setCookie(const WebURL& url,
const WebURL& first_party_for_cookies, const WebURL& first_party_for_cookies,
const WebString& value) { const WebString& value) {
BrowserResourceLoaderBridge::SetCookie( GURL gurl = url;
url, first_party_for_cookies, value.utf8()); std::string cookie = value.utf8();
// Proxy to IO thread to synchronize w/ network loading.
scoped_refptr<CookieSetter> cookie_setter = new CookieSetter();
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&CookieSetter::Set, cookie_setter.get(), browser_, gurl, cookie));
} }
WebString BrowserWebCookieJarImpl::cookies( WebString BrowserWebCookieJarImpl::cookies(
const WebURL& url, const WebURL& url,
const WebURL& first_party_for_cookies) { const WebURL& first_party_for_cookies) {
return WebString::fromUTF8( GURL gurl = url;
BrowserResourceLoaderBridge::GetCookies(url, first_party_for_cookies));
// Proxy to IO thread to synchronize w/ network loading.
scoped_refptr<CookieGetter> cookie_getter = new CookieGetter();
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
&CookieGetter::Get, cookie_getter.get(), browser_, gurl));
// Blocks until the result is available.
return WebString::fromUTF8(cookie_getter->GetResult());
} }

View File

@@ -1,4 +1,5 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2012 the Chromium Embedded Framework authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@@ -6,18 +7,30 @@
#define CEF_LIBCEF_BROWSER_WEBCOOKIEJAR_IMPL_H_ #define CEF_LIBCEF_BROWSER_WEBCOOKIEJAR_IMPL_H_
#pragma once #pragma once
// TODO(darin): WebCookieJar.h is missing a WebString.h include!
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookieJar.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookieJar.h"
namespace net {
class CookieStore;
}
class CefBrowserImpl;
// Handles cookie requests from the renderer.
class BrowserWebCookieJarImpl : public WebKit::WebCookieJar { class BrowserWebCookieJarImpl : public WebKit::WebCookieJar {
public: public:
// WebKit::WebCookieJar methods: BrowserWebCookieJarImpl();
explicit BrowserWebCookieJarImpl(CefBrowserImpl* browser);
// WebKit::WebCookieJar methods.
virtual void setCookie( virtual void setCookie(
const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies, const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
const WebKit::WebString& cookie); const WebKit::WebString& cookie);
virtual WebKit::WebString cookies( virtual WebKit::WebString cookies(
const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies); const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
private:
// May be NULL for the global implementation.
CefBrowserImpl* browser_;
}; };
#endif // CEF_LIBCEF_BROWSER_WEBCOOKIEJAR_IMPL_H_ #endif // CEF_LIBCEF_BROWSER_WEBCOOKIEJAR_IMPL_H_

View File

@@ -53,16 +53,17 @@ BrowserWebKitInit::BrowserWebKitInit()
PathService::Get(base::DIR_MODULE, &module_path) && PathService::Get(base::DIR_MODULE, &module_path) &&
media::InitializeMediaLibrary(module_path)); media::InitializeMediaLibrary(module_path));
// Construct and initialize an appcache system for this scope. FilePath appcache_path;
// A new empty temp directory is created to house any cached FilePath cache_path = _Context->cache_path();
// content during the run. Upon exit that directory is deleted. if (!cache_path.empty()) {
// If we can't create a tempdir, we'll use in-memory storage. appcache_path = cache_path.Append(FILE_PATH_LITERAL("AppCache"));
if (!appcache_dir_.CreateUniqueTempDir()) { if (!file_util::PathExists(appcache_path) &&
LOG(WARNING) << "Failed to create a temp dir for the appcache, " !file_util::CreateDirectory(appcache_path)) {
"using in-memory storage."; LOG(WARNING) << "Failed to create appcache storage directory";
DCHECK(appcache_dir_.path().empty()); appcache_path.clear();
}
} }
BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); BrowserAppCacheSystem::InitializeOnUIThread(appcache_path);
WebKit::WebDatabase::setObserver(&database_system_); WebKit::WebDatabase::setObserver(&database_system_);

View File

@@ -106,7 +106,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
webkit_glue::WebClipboardImpl clipboard_; webkit_glue::WebClipboardImpl clipboard_;
SimpleClipboardClient clipboard_client_; SimpleClipboardClient clipboard_client_;
webkit_glue::WebFileUtilitiesImpl file_utilities_; webkit_glue::WebFileUtilitiesImpl file_utilities_;
ScopedTempDir appcache_dir_;
BrowserAppCacheSystem appcache_system_; BrowserAppCacheSystem appcache_system_;
BrowserDatabaseSystem database_system_; BrowserDatabaseSystem database_system_;
BrowserWebCookieJarImpl cookie_jar_; BrowserWebCookieJarImpl cookie_jar_;

View File

@@ -502,20 +502,20 @@ bool BrowserWebViewDelegate::allowScriptExtension(
// WebPluginPageDelegate ----------------------------------------------------- // WebPluginPageDelegate -----------------------------------------------------
WebCookieJar* BrowserWebViewDelegate::GetCookieJar() { WebCookieJar* BrowserWebViewDelegate::GetCookieJar() {
return WebKit::webKitPlatformSupport()->cookieJar(); return &cookie_jar_;
} }
// WebWidgetClient ----------------------------------------------------------- // WebWidgetClient -----------------------------------------------------------
void BrowserWebViewDelegate::didInvalidateRect(const WebRect& rect) { void BrowserWebViewDelegate::didInvalidateRect(const WebRect& rect) {
if (WebWidgetHost* host = GetWidgetHost()) if (WebWidgetHost* host = GetWidgetHost())
host->DidInvalidateRect(rect); host->InvalidateRect(rect);
} }
void BrowserWebViewDelegate::didScrollRect(int dx, int dy, void BrowserWebViewDelegate::didScrollRect(int dx, int dy,
const WebRect& clip_rect) { const WebRect& clip_rect) {
if (WebWidgetHost* host = GetWidgetHost()) if (WebWidgetHost* host = GetWidgetHost())
host->DidScrollRect(dx, dy, clip_rect); host->ScrollRect(dx, dy, clip_rect);
} }
void BrowserWebViewDelegate::scheduleComposite() { void BrowserWebViewDelegate::scheduleComposite() {
@@ -680,6 +680,10 @@ WebApplicationCacheHost* BrowserWebViewDelegate::createApplicationCacheHost(
return BrowserAppCacheSystem::CreateApplicationCacheHost(client); return BrowserAppCacheSystem::CreateApplicationCacheHost(client);
} }
WebKit::WebCookieJar* BrowserWebViewDelegate::cookieJar(WebFrame* frame) {
return &cookie_jar_;
}
void BrowserWebViewDelegate::willClose(WebFrame* frame) { void BrowserWebViewDelegate::willClose(WebFrame* frame) {
browser_->UIT_BeforeFrameClosed(frame); browser_->UIT_BeforeFrameClosed(frame);
} }
@@ -774,6 +778,12 @@ WebURLError BrowserWebViewDelegate::cancelledError(
void BrowserWebViewDelegate::didCreateDataSource( void BrowserWebViewDelegate::didCreateDataSource(
WebFrame* frame, WebDataSource* ds) { WebFrame* frame, WebDataSource* ds) {
ds->setExtraData(pending_extra_data_.release()); ds->setExtraData(pending_extra_data_.release());
if (frame->parent() == 0) {
GURL url = ds->request().url();
if (!url.is_empty())
browser_->set_pending_url(url);
}
} }
void BrowserWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { void BrowserWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) {
@@ -858,8 +868,21 @@ void BrowserWebViewDelegate::didCommitProvisionalLoad(
// Apply zoom settings only on top-level frames. // Apply zoom settings only on top-level frames.
if (is_main_frame) { if (is_main_frame) {
// Restore the zoom value that we have for this URL, if any. // Restore the zoom value that we have for this URL, if any.
GURL url = frame->document().url();
double zoomLevel = 0.0; double zoomLevel = 0.0;
ZoomMap::GetInstance()->get(frame->document().url(), zoomLevel); bool didGetCustomZoom = false;
if (client.get()) {
CefRefPtr<CefZoomHandler> handler = client->GetZoomHandler();
if (handler.get()) {
double newZoomLevel = zoomLevel;
didGetCustomZoom =
handler->OnGetZoomLevel(browser_, url.spec(), newZoomLevel);
if (didGetCustomZoom)
zoomLevel = newZoomLevel;
}
}
if (!didGetCustomZoom)
ZoomMap::GetInstance()->get(url, zoomLevel);
frame->view()->setZoomLevel(false, zoomLevel); frame->view()->setZoomLevel(false, zoomLevel);
browser_->set_zoom_level(zoomLevel); browser_->set_zoom_level(zoomLevel);
} }
@@ -993,13 +1016,17 @@ BrowserWebViewDelegate::BrowserWebViewDelegate(CefBrowserImpl* browser)
browser_(browser), browser_(browser),
page_id_(-1), page_id_(-1),
last_page_id_updated_(-1), last_page_id_updated_(-1),
#if defined(OS_WIN)
destroy_on_drag_end_(false),
#endif
smart_insert_delete_enabled_(true), smart_insert_delete_enabled_(true),
#if defined(OS_WIN) #if defined(OS_WIN)
select_trailing_whitespace_enabled_(true), select_trailing_whitespace_enabled_(true),
#else #else
select_trailing_whitespace_enabled_(false), select_trailing_whitespace_enabled_(false),
#endif #endif
block_redirects_(false) { block_redirects_(false),
cookie_jar_(browser) {
} }
BrowserWebViewDelegate::~BrowserWebViewDelegate() { BrowserWebViewDelegate::~BrowserWebViewDelegate() {
@@ -1166,6 +1193,9 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
entry->SetURL(request.url()); entry->SetURL(request.url());
} }
// Update attributes of the CefFrame if it currently exists.
browser_->UIT_UpdateCefFrame(frame);
bool is_main_frame = (frame->parent() == 0); bool is_main_frame = (frame->parent() == 0);
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
@@ -1208,8 +1238,8 @@ void BrowserWebViewDelegate::UpdateSessionHistory(WebFrame* frame) {
if (page_id_ == -1) if (page_id_ == -1)
return; return;
BrowserNavigationEntry* entry = static_cast<BrowserNavigationEntry*>( BrowserNavigationEntry* entry =
browser_->UIT_GetNavigationController()->GetEntryWithPageID(page_id_)); browser_->UIT_GetNavigationController()->GetEntryWithPageID(page_id_);
if (!entry) if (!entry)
return; return;

View File

@@ -16,6 +16,7 @@
#include <vector> #include <vector>
#include "libcef/browser_navigation_controller.h" #include "libcef/browser_navigation_controller.h"
#include "libcef/browser_webcookiejar_impl.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
@@ -154,6 +155,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client) WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client)
OVERRIDE; OVERRIDE;
virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame*) OVERRIDE;
virtual void willClose(WebKit::WebFrame*) OVERRIDE; virtual void willClose(WebKit::WebFrame*) OVERRIDE;
virtual void loadURLExternally( virtual void loadURLExternally(
WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebFrame*, const WebKit::WebURLRequest&,
@@ -246,7 +248,9 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
BrowserDragDelegate* drag_delegate() { return drag_delegate_.get(); } BrowserDragDelegate* drag_delegate() { return drag_delegate_.get(); }
WebDropTarget* drop_target() { return drop_target_.get(); } WebDropTarget* drop_target() { return drop_target_.get(); }
#endif
void set_destroy_on_drag_end(bool val) { destroy_on_drag_end_ = val; }
#endif // defined(OS_WIN)
void set_pending_extra_data(BrowserExtraData* extra_data) { void set_pending_extra_data(BrowserExtraData* extra_data) {
pending_extra_data_.reset(extra_data); pending_extra_data_.reset(extra_data);
@@ -350,6 +354,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
#if defined(OS_WIN) #if defined(OS_WIN)
// Classes needed by drag and drop. // Classes needed by drag and drop.
scoped_refptr<BrowserDragDelegate> drag_delegate_; scoped_refptr<BrowserDragDelegate> drag_delegate_;
bool destroy_on_drag_end_;
#endif #endif
#if defined(OS_WIN) || defined(OS_LINUX) #if defined(OS_WIN) || defined(OS_LINUX)
scoped_refptr<WebDropTarget> drop_target_; scoped_refptr<WebDropTarget> drop_target_;
@@ -381,6 +386,8 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
std::string edit_command_name_; std::string edit_command_name_;
std::string edit_command_value_; std::string edit_command_value_;
BrowserWebCookieJarImpl cookie_jar_;
DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate); DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate);
}; };

View File

@@ -48,6 +48,7 @@ namespace {
void AddMenuItem(CefRefPtr<CefBrowser> browser, void AddMenuItem(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefMenuHandler> handler, CefRefPtr<CefMenuHandler> handler,
NSMenu* menu, NSMenu* menu,
id target,
cef_menu_id_t menuId, cef_menu_id_t menuId,
const std::string& label, const std::string& label,
bool enabled) { bool enabled) {
@@ -65,7 +66,8 @@ void AddMenuItem(CefRefPtr<CefBrowser> browser,
NSMenuItem* item = NSMenuItem* item =
[[[NSMenuItem alloc] initWithTitle:str [[[NSMenuItem alloc] initWithTitle:str
action:enabled?@selector(menuItemSelected:):nil action:enabled?@selector(menuItemSelected:):nil
keyEquivalent:@""] autorelease]; keyEquivalent:@""] autorelease];
[item setTarget:target];
[item setTag:menuId]; [item setTag:menuId];
[menu addItem:item]; [menu addItem:item];
} }
@@ -77,6 +79,46 @@ void AddMenuSeparator(NSMenu* menu) {
} // namespace } // namespace
@interface BrowserMenuDelegate : NSObject <NSMenuDelegate> {
@private
CefRefPtr<CefBrowserImpl> browser_;
}
- (id)initWithBrowser:(CefBrowserImpl*)browser;
- (void)menuItemSelected:(id)sender;
@end
@implementation BrowserMenuDelegate
- (id)initWithBrowser:(CefBrowserImpl*)browser {
self = [super init];
if (self)
browser_ = browser;
return self;
}
// Called when a context menu item is selected by the user.
- (void)menuItemSelected:(id)sender {
cef_menu_id_t menuId = static_cast<cef_menu_id_t>([sender tag]);
bool handled = false;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefMenuHandler> handler = client->GetMenuHandler();
if (handler.get()) {
// Ask the handler if it wants to handle the action.
handled = handler->OnMenuAction(browser_.get(), menuId);
}
}
if(!handled) {
// Execute the action.
browser_->UIT_HandleAction(menuId, browser_->GetFocusedFrame());
}
}
@end
// WebViewClient -------------------------------------------------------------- // WebViewClient --------------------------------------------------------------
@@ -102,12 +144,21 @@ void BrowserWebViewDelegate::showContextMenu(
if (!host) if (!host)
return; return;
BrowserWebView *view = static_cast<BrowserWebView*>(host->view_handle()); NSView *view = browser_->UIT_GetMainWndHandle();
if (!view) if (!view)
return; return;
NSWindow* window = [view window]; NSWindow* window = [view window];
NSPoint position = [window mouseLocationOutsideOfEventStream];
int screenX = -1;
int screenY = -1;
NSPoint mouse_pt = {data.mousePosition.x, data.mousePosition.y};
if (!browser_->IsWindowRenderingDisabled()) {
mouse_pt = [window mouseLocationOutsideOfEventStream];
NSPoint screen_pt = [window convertBaseToScreen:mouse_pt];
screenX = screen_pt.x;
screenY = screen_pt.y;
}
int edit_flags = 0; int edit_flags = 0;
int type_flags = 0; int type_flags = 0;
@@ -117,7 +168,7 @@ void BrowserWebViewDelegate::showContextMenu(
MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
// Give the client a chance to handle the menu. // Give the client a chance to handle the menu.
if (OnBeforeMenu(data, position.x, position.y, edit_flags, type_flags)) if (OnBeforeMenu(data, mouse_pt.x, mouse_pt.y, edit_flags, type_flags))
return; return;
CefRefPtr<CefClient> client = browser_->GetClient(); CefRefPtr<CefClient> client = browser_->GetClient();
@@ -125,43 +176,57 @@ void BrowserWebViewDelegate::showContextMenu(
if (client.get()) if (client.get())
handler = client->GetMenuHandler(); handler = client->GetMenuHandler();
if (client.get() && browser_->IsWindowRenderingDisabled()) {
// Retrieve the screen coordinates.
CefRefPtr<CefRenderHandler> render_handler = client->GetRenderHandler();
if (!render_handler.get() ||
!render_handler->GetScreenPoint(browser_, mouse_pt.x, mouse_pt.y,
screenX, screenY)) {
return;
}
}
BrowserMenuDelegate* delegate =
[[[BrowserMenuDelegate alloc] initWithBrowser:browser_] autorelease];
// Build the correct default context menu // Build the correct default context menu
if (type_flags & MENUTYPE_EDITABLE) { if (type_flags & MENUTYPE_EDITABLE) {
menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
AddMenuItem(browser_, handler, menu, MENU_ID_UNDO, "Undo", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_UNDO, "Undo",
!!(edit_flags & MENU_CAN_UNDO)); !!(edit_flags & MENU_CAN_UNDO));
AddMenuItem(browser_, handler, menu, MENU_ID_REDO, "Redo", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_REDO, "Redo",
!!(edit_flags & MENU_CAN_REDO)); !!(edit_flags & MENU_CAN_REDO));
AddMenuSeparator(menu); AddMenuSeparator(menu);
AddMenuItem(browser_, handler, menu, MENU_ID_CUT, "Cut", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_CUT, "Cut",
!!(edit_flags & MENU_CAN_CUT)); !!(edit_flags & MENU_CAN_CUT));
AddMenuItem(browser_, handler, menu, MENU_ID_COPY, "Copy", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_COPY, "Copy",
!!(edit_flags & MENU_CAN_COPY)); !!(edit_flags & MENU_CAN_COPY));
AddMenuItem(browser_, handler, menu, MENU_ID_PASTE, "Paste", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_PASTE, "Paste",
!!(edit_flags & MENU_CAN_PASTE)); !!(edit_flags & MENU_CAN_PASTE));
AddMenuItem(browser_, handler, menu, MENU_ID_DELETE, "Delete", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_DELETE, "Delete",
!!(edit_flags & MENU_CAN_DELETE)); !!(edit_flags & MENU_CAN_DELETE));
AddMenuSeparator(menu); AddMenuSeparator(menu);
AddMenuItem(browser_, handler, menu, MENU_ID_SELECTALL, "Select All", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_SELECTALL,
!!(edit_flags & MENU_CAN_SELECT_ALL)); "Select All", !!(edit_flags & MENU_CAN_SELECT_ALL));
} else if(type_flags & MENUTYPE_SELECTION) { } else if(type_flags & MENUTYPE_SELECTION) {
menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
AddMenuItem(browser_, handler, menu, MENU_ID_COPY, "Copy", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_COPY, "Copy",
!!(edit_flags & MENU_CAN_COPY)); !!(edit_flags & MENU_CAN_COPY));
} else if(type_flags & (MENUTYPE_PAGE | MENUTYPE_FRAME)) { } else if(type_flags & (MENUTYPE_PAGE | MENUTYPE_FRAME)) {
menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
AddMenuItem(browser_, handler, menu, MENU_ID_NAV_BACK, "Back", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_NAV_BACK, "Back",
!!(edit_flags & MENU_CAN_GO_BACK)); !!(edit_flags & MENU_CAN_GO_BACK));
AddMenuItem(browser_, handler, menu, MENU_ID_NAV_FORWARD, "Forward", AddMenuItem(browser_, handler, menu, delegate, MENU_ID_NAV_FORWARD,
!!(edit_flags & MENU_CAN_GO_FORWARD)); "Forward", !!(edit_flags & MENU_CAN_GO_FORWARD));
// TODO(port): Enable the below menu items when supported. // TODO(port): Enable the below menu items when supported.
//AddMenuSeparator(menu); //AddMenuSeparator(menu);
//AddMenuItem(browser_, handler, menu, MENU_ID_PRINT, "Print", true); //AddMenuItem(browser_, handler, menu, delegate, MENU_ID_PRINT, "Print",
//AddMenuItem(browser_, handler, menu, MENU_ID_VIEWSOURCE, "View Source", // true);
// true); //AddMenuItem(browser_, handler, menu, delegate, MENU_ID_VIEWSOURCE,
// "View Source", true);
} }
if (!menu) if (!menu)
@@ -169,21 +234,24 @@ void BrowserWebViewDelegate::showContextMenu(
// Synthesize an event for the click, as there is no certainty that // Synthesize an event for the click, as there is no certainty that
// [NSApp currentEvent] will return a valid event. // [NSApp currentEvent] will return a valid event.
NSPoint screen_pt = {screenX, screenY};
NSPoint window_pt = [window convertScreenToBase:screen_pt];
NSEvent* currentEvent = [NSApp currentEvent]; NSEvent* currentEvent = [NSApp currentEvent];
NSTimeInterval eventTime = [currentEvent timestamp]; NSTimeInterval eventTime = [currentEvent timestamp];
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown
location:position location:window_pt
modifierFlags:NSRightMouseDownMask modifierFlags:NSRightMouseDownMask
timestamp:eventTime timestamp:eventTime
windowNumber:[window windowNumber] windowNumber:[window windowNumber]
context:nil context:nil
eventNumber:0 eventNumber:0
clickCount:1 clickCount:1
pressure:1.0]; pressure:1.0];
// Menu selection events go to the BrowserWebView. // Menu selection events go to the BrowserMenuDelegate.
[menu setDelegate:view]; [menu setDelegate:delegate];
// Show the menu. // Show the menu.
[NSMenu popUpContextMenu:menu [NSMenu popUpContextMenu:menu
@@ -194,18 +262,43 @@ void BrowserWebViewDelegate::showContextMenu(
// WebWidgetClient ------------------------------------------------------------ // WebWidgetClient ------------------------------------------------------------
void BrowserWebViewDelegate::show(WebNavigationPolicy policy) { void BrowserWebViewDelegate::show(WebNavigationPolicy policy) {
DCHECK(this != browser_->UIT_GetPopupDelegate());
} }
void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) {
NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor(); NSCursor* ns_cursor = WebCursor(cursor_info).GetNativeCursor();
[ns_cursor set];
if (!browser_->IsWindowRenderingDisabled()) {
[ns_cursor set];
} else {
// Notify the handler of cursor change.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefRenderHandler> handler = client->GetRenderHandler();
if (handler.get())
handler->OnCursorChange(browser_, ns_cursor);
}
}
} }
WebRect BrowserWebViewDelegate::windowRect() { WebRect BrowserWebViewDelegate::windowRect() {
if (WebWidgetHost* host = GetWidgetHost()) { if (WebWidgetHost* host = GetWidgetHost()) {
NSView *view = host->view_handle(); if (!browser_->IsWindowRenderingDisabled()) {
NSRect rect = [view frame]; NSView *view = host->view_handle();
return gfx::Rect(NSRectToCGRect(rect)); NSRect rect = [view frame];
return gfx::Rect(NSRectToCGRect(rect));
} else {
// Retrieve the view rectangle from the handler.
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefRenderHandler> handler = client->GetRenderHandler();
if (handler.get()) {
CefRect rect(0, 0, 0, 0);
if (handler->GetViewRect(browser_, rect))
return WebRect(rect.x, rect.y, rect.width, rect.height);
}
}
}
} }
return WebRect(); return WebRect();
} }
@@ -213,6 +306,8 @@ WebRect BrowserWebViewDelegate::windowRect() {
void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) { void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) {
if (this == browser_->UIT_GetWebViewDelegate()) { if (this == browser_->UIT_GetWebViewDelegate()) {
// TODO(port): Set the window rectangle. // TODO(port): Set the window rectangle.
} else if (this == browser_->UIT_GetPopupDelegate()) {
NOTREACHED();
} }
} }
@@ -257,7 +352,8 @@ void BrowserWebViewDelegate::startDragging(const WebDragData& data,
WebDragOperationsMask mask, WebDragOperationsMask mask,
const WebImage& image, const WebImage& image,
const WebPoint& image_offset) { const WebPoint& image_offset) {
if (browser_->settings().drag_drop_disabled) { if (browser_->settings().drag_drop_disabled ||
browser_->IsWindowRenderingDisabled()) {
browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); browser_->UIT_GetWebView()->dragSourceSystemDragEnded();
return; return;
} }
@@ -303,10 +399,17 @@ void BrowserWebViewDelegate::startDragging(const WebDragData& data,
ns_image = gfx::SkBitmapToNSImageWithColorSpace(bitmap, color_space); ns_image = gfx::SkBitmapToNSImageWithColorSpace(bitmap, color_space);
} }
NSPoint offset = NSPointFromCGPoint(gfx::Point(image_offset).ToCGPoint()); NSPoint offset = NSPointFromCGPoint(gfx::Point(image_offset).ToCGPoint());
// Keep a reference to the NSView so that it won't be destroyed until after
// the drag operation has completed.
[view retain];
[view startDragWithDropData:drop_data [view startDragWithDropData:drop_data
dragOperationMask:static_cast<NSDragOperation>(mask) dragOperationMask:static_cast<NSDragOperation>(mask)
image:ns_image image:ns_image
offset:offset]; offset:offset];
[view release];
} }
void BrowserWebViewDelegate::runModal() { void BrowserWebViewDelegate::runModal() {
@@ -332,15 +435,30 @@ webkit::npapi::WebPluginDelegate* BrowserWebViewDelegate::CreatePluginDelegate(
void BrowserWebViewDelegate::CreatedPluginWindow( void BrowserWebViewDelegate::CreatedPluginWindow(
gfx::PluginWindowHandle handle) { gfx::PluginWindowHandle handle) {
if (browser_->IsWindowRenderingDisabled()) {
WebViewHost* host = browser_->UIT_GetWebViewHost();
if (host)
host->AddWindowedPlugin(handle);
}
} }
void BrowserWebViewDelegate::WillDestroyPluginWindow( void BrowserWebViewDelegate::WillDestroyPluginWindow(
gfx::PluginWindowHandle handle) { gfx::PluginWindowHandle handle) {
if (browser_->IsWindowRenderingDisabled()) {
WebViewHost* host = browser_->UIT_GetWebViewHost();
if (host)
host->RemoveWindowedPlugin(handle);
}
} }
void BrowserWebViewDelegate::DidMovePlugin( void BrowserWebViewDelegate::DidMovePlugin(
const webkit::npapi::WebPluginGeometry& move) { const webkit::npapi::WebPluginGeometry& move) {
// TODO(port): add me once plugins work. if (browser_->IsWindowRenderingDisabled()) {
WebViewHost* host = browser_->UIT_GetWebViewHost();
if (host) {
host->MoveWindowedPlugin(move);
}
}
} }
// Protected methods ---------------------------------------------------------- // Protected methods ----------------------------------------------------------

View File

@@ -448,7 +448,7 @@ void BrowserWebViewDelegate::showContextMenu(
if (client.get() && browser_->IsWindowRenderingDisabled()) { if (client.get() && browser_->IsWindowRenderingDisabled()) {
// Retrieve the screen coordinates. // Retrieve the screen coordinates.
CefRefPtr<CefRenderHandler> render_handler = client->GetRenderHandler(); CefRefPtr<CefRenderHandler> render_handler = client->GetRenderHandler();
if (render_handler.get() && if (!render_handler.get() ||
!render_handler->GetScreenPoint(browser_, mouse_pt.x, mouse_pt.y, !render_handler->GetScreenPoint(browser_, mouse_pt.x, mouse_pt.y,
screenX, screenY)) { screenX, screenY)) {
return; return;
@@ -533,6 +533,9 @@ void BrowserWebViewDelegate::EndDragging() {
if (browser_->UIT_GetWebView()) if (browser_->UIT_GetWebView())
browser_->UIT_GetWebView()->dragSourceSystemDragEnded(); browser_->UIT_GetWebView()->dragSourceSystemDragEnded();
drag_delegate_ = NULL; drag_delegate_ = NULL;
if (destroy_on_drag_end_)
browser_->UIT_DestroyBrowser();
} }
void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe, void BrowserWebViewDelegate::ShowJavaScriptAlert(WebFrame* webframe,

View File

@@ -8,7 +8,10 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "base/mac/cocoa_protocols.h" #import "base/mac/cocoa_protocols.h"
#include "base/string16.h"
#include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_nsobject.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
#include <Vector>
class CefBrowserImpl; class CefBrowserImpl;
@class WebDragSource; @class WebDragSource;
@@ -18,13 +21,45 @@ struct WebDropData;
// A view to wrap the WebCore view and help it live in a Cocoa world. The // A view to wrap the WebCore view and help it live in a Cocoa world. The
// (rough) equivalent of Apple's WebView. // (rough) equivalent of Apple's WebView.
@interface BrowserWebView : NSView <NSMenuDelegate> { @interface BrowserWebView : NSView<NSTextInputClient> {
@private @private
CefBrowserImpl* browser_; // weak CefBrowserImpl* browser_; // weak
NSTrackingArea* trackingArea_; NSTrackingArea* trackingArea_;
bool is_in_setfocus_;
scoped_nsobject<WebDragSource> dragSource_; scoped_nsobject<WebDragSource> dragSource_;
scoped_nsobject<WebDropTarget> dropTarget_; scoped_nsobject<WebDropTarget> dropTarget_;
// Represents the input-method attributes supported by this object.
scoped_nsobject<NSArray> validAttributesForMarkedText_;
// Indicates if we are currently handling a key down event.
BOOL handlingKeyDown_;
// Indicates if there is any marked text.
BOOL hasMarkedText_;
// Indicates if unmarkText is called or not when handling a keyboard
// event.
BOOL unmarkTextCalled_;
// The range of current marked text inside the whole content of the DOM node
// being edited.
// TODO(suzhe): This is currently a fake value, as we do not support accessing
// the whole content yet.
NSRange markedRange_;
// The selected range, cached from a message sent by the renderer.
NSRange selectedRange_;
// Text to be inserted which was generated by handling a key down event.
string16 textToBeInserted_;
// Marked text which was generated by handling a key down event.
string16 markedText_;
// Underline information of the |markedText_|.
std::vector<WebKit::WebCompositionUnderline> underlines_;
} }
- (void)mouseDown:(NSEvent *)theEvent; - (void)mouseDown:(NSEvent *)theEvent;
@@ -45,8 +80,8 @@ struct WebDropData;
- (BOOL)isOpaque; - (BOOL)isOpaque;
- (void)setFrame:(NSRect)frameRect; - (void)setFrame:(NSRect)frameRect;
// Called when a context menu item is selected by the user. // Forward the keyboard event to the editor
- (void)menuItemSelected:(id)sender; - (void)forwardKeyEventToEditor: (NSEvent *)theEvent;
// Register this WebView as a drag/drop target. // Register this WebView as a drag/drop target.
- (void)registerDragDrop; - (void)registerDragDrop;
@@ -58,6 +93,7 @@ struct WebDropData;
offset:(NSPoint)offset; offset:(NSPoint)offset;
@property (nonatomic, assign) CefBrowserImpl* browser; @property (nonatomic, assign) CefBrowserImpl* browser;
@property (nonatomic, assign) bool in_setfocus;
@end @end

View File

@@ -12,15 +12,71 @@
#import "libcef/webwidget_host.h" #import "libcef/webwidget_host.h"
#import "base/memory/scoped_ptr.h" #import "base/memory/scoped_ptr.h"
#import "base/string_util.h"
#import "base/sys_string_conversions.h"
#import "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFactory.h"
#import "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSubstringUtil.h"
#import "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #import "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#import "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #import "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#import "third_party/mozilla/NSPasteboard+Utils.h" #import "third_party/mozilla/NSPasteboard+Utils.h"
#import "third_party/skia/include/core/SkRegion.h" #import "third_party/skia/include/core/SkRegion.h"
#import "ui/gfx/rect.h" #import "ui/gfx/rect.h"
using WebKit::WebColor;
using WebKit::WebCompositionUnderline;
using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory;
using WebKit::WebKeyboardEvent;
using WebKit::WebPoint;
using WebKit::WebRect;
using WebKit::WebString;
using WebKit::WebSubstringUtil;
// This code is copied from
// content/browser/renderer_host/render_widget_host_mac
namespace {
WebColor WebColorFromNSColor(NSColor *color) {
CGFloat r, g, b, a;
[color getRed:&r green:&g blue:&b alpha:&a];
return
std::max(0, std::min(static_cast<int>(lroundf(255.0f * a)), 255)) << 24 |
std::max(0, std::min(static_cast<int>(lroundf(255.0f * r)), 255)) << 16 |
std::max(0, std::min(static_cast<int>(lroundf(255.0f * g)), 255)) << 8 |
std::max(0, std::min(static_cast<int>(lroundf(255.0f * b)), 255));
}
// Extract underline information from an attributed string. Mostly copied from
// third_party/WebKit/Source/WebKit/mac/WebView/WebHTMLView.mm
void ExtractUnderlines(
NSAttributedString* string,
std::vector<WebCompositionUnderline>* underlines) {
int length = [[string string] length];
int i = 0;
while (i < length) {
NSRange range;
NSDictionary* attrs = [string attributesAtIndex:i
longestEffectiveRange:&range
inRange:NSMakeRange(i, length - i)];
if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
WebColor color = SK_ColorBLACK;
if (NSColor *colorAttr =
[attrs objectForKey:NSUnderlineColorAttributeName]) {
color = WebColorFromNSColor(
[colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
}
underlines->push_back(WebCompositionUnderline(
range.location, NSMaxRange(range), color, [style intValue] > 1));
}
i = range.location + range.length;
}
}
} // namespace
@implementation BrowserWebView @implementation BrowserWebView
@synthesize browser = browser_; @synthesize browser = browser_;
@synthesize in_setfocus = is_in_setfocus_;
- (id)initWithFrame:(NSRect)frame { - (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
@@ -139,12 +195,126 @@
browser_->UIT_GetWebViewHost()->MouseEvent(theEvent); browser_->UIT_GetWebViewHost()->MouseEvent(theEvent);
} }
// This code is mostly copied and adapted from
// content/browser/renderer_host/render_widget_host_mac
- (void)keyDown:(NSEvent *)theEvent { - (void)keyDown:(NSEvent *)theEvent {
if (browser_ && browser_->UIT_GetWebView()) if (browser_ && browser_->UIT_GetWebView())
browser_->UIT_GetWebViewHost()->KeyEvent(theEvent); browser_->UIT_GetWebViewHost()->KeyEvent(theEvent);
// Records the current marked text state, so that we can know if the marked
// text was deleted or not after handling the key down event.
BOOL oldHasMarkedText = hasMarkedText_;
// We check if the marked text has one or less characters and a delete key is
// pressed. In such cases, we want to cancel IME composition and delete the
// marked character, so we dispatch the event directly to WebKit.
if (hasMarkedText_ && underlines_.size() <= 1) {
// Check for backspace or delete.
if ([theEvent keyCode] == 0x33 || [theEvent keyCode] == 0x75)
[self forwardKeyEventToEditor: theEvent];
}
textToBeInserted_.clear();
markedText_.clear();
underlines_.clear();
unmarkTextCalled_ = NO;
handlingKeyDown_ = YES;
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
handlingKeyDown_ = NO;
// Only send a corresponding key press event if there is no marked text.
// We also handle keys like backspace or delete, where the length
// of the text to be inserted is 0.
if (!hasMarkedText_ && !oldHasMarkedText &&
!textToBeInserted_.length() <= 1) {
if (textToBeInserted_.length() == 1) {
// If a single character was inserted, then we just send it as a keypress
// event.
WebKeyboardEvent keyboard_event(
WebInputEventFactory::keyboardEvent(theEvent));
keyboard_event.type = WebInputEvent::Char;
keyboard_event.text[0] = textToBeInserted_[0];
keyboard_event.text[1] = 0;
browser_->UIT_GetWebView()->handleInputEvent(keyboard_event);
} else {
[self forwardKeyEventToEditor: theEvent];
}
}
// Calling KeyEvent() could have destroyed the widget.
// We perform a sanity check and return if the widget is NULL.
if (!browser_ || !browser_->UIT_GetWebView())
return;
BOOL textInserted = NO;
if (textToBeInserted_.length() >
((hasMarkedText_ || oldHasMarkedText) ? 0u : 1u)) {
browser_->UIT_GetWebView()->confirmComposition(textToBeInserted_);
textInserted = YES;
}
if (hasMarkedText_ && markedText_.length()) {
browser_->UIT_GetWebView()->setComposition(markedText_, underlines_,
selectedRange_.location,
NSMaxRange(selectedRange_));
} else if (oldHasMarkedText && !hasMarkedText_ && !textInserted) {
if (unmarkTextCalled_) {
browser_->UIT_GetWebView()->confirmComposition();
} else {
// Simulating a cancelComposition
browser_->UIT_GetWebView()->setComposition(EmptyString16(), underlines_,
0, 0);
}
}
}
- (void)forwardKeyEventToEditor: (NSEvent *)theEvent {
if ([theEvent type] != NSKeyDown)
return;
if ([theEvent modifierFlags] & (NSNumericPadKeyMask | NSFunctionKeyMask)) {
// Don't send a Char event for non-char keys like arrows, function keys and
// clear.
switch ([theEvent keyCode]) {
case 81: // =
case 75: // /
case 67: // *
case 78: // -
case 69: // +
case 76: // Enter
case 65: // .
case 82: // 0
case 83: // 1
case 84: // 2
case 85: // 3
case 86: // 4
case 87: // 5
case 88: // 6
case 89: // 7
case 91: // 8
case 92: // 9
break;
default:
return;
}
}
if (browser_ && browser_->UIT_GetWebView()) {
WebKeyboardEvent keyboard_event(
WebInputEventFactory::keyboardEvent(theEvent));
keyboard_event.type = WebInputEvent::Char;
browser_->UIT_GetWebViewHost()->SetLastKeyEvent(keyboard_event);
browser_->UIT_GetWebView()->handleInputEvent(keyboard_event);
}
}
- (void)keyUp:(NSEvent *)theEvent {
if (browser_ && browser_->UIT_GetWebView())
browser_->UIT_GetWebViewHost()->KeyEvent(theEvent);
} }
- (void)keyUp:(NSEvent *)theEvent { - (void)flagsChanged:(NSEvent *)theEvent {
if (browser_ && browser_->UIT_GetWebView()) if (browser_ && browser_->UIT_GetWebView())
browser_->UIT_GetWebViewHost()->KeyEvent(theEvent); browser_->UIT_GetWebViewHost()->KeyEvent(theEvent);
} }
@@ -163,12 +333,14 @@
- (BOOL)becomeFirstResponder { - (BOOL)becomeFirstResponder {
if (browser_ && browser_->UIT_GetWebView()) { if (browser_ && browser_->UIT_GetWebView()) {
CefRefPtr<CefClient> client = browser_->GetClient(); if (!is_in_setfocus_) {
if (client.get()) { CefRefPtr<CefClient> client = browser_->GetClient();
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler(); if (client.get()) {
if (handler.get() && CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
handler->OnSetFocus(browser_, FOCUS_SOURCE_SYSTEM)) { if (handler.get() &&
return NO; handler->OnSetFocus(browser_, FOCUS_SOURCE_SYSTEM)) {
return NO;
}
} }
} }
@@ -192,7 +364,8 @@
[super setFrame:frameRect]; [super setFrame:frameRect];
if (browser_ && browser_->UIT_GetWebView()) { if (browser_ && browser_->UIT_GetWebView()) {
const NSRect bounds = [self bounds]; const NSRect bounds = [self bounds];
browser_->UIT_GetWebViewHost()->Resize(gfx::Rect(NSRectToCGRect(bounds))); browser_->UIT_GetWebViewHost()->SetSize(bounds.size.width,
bounds.size.height);
} }
} }
@@ -231,25 +404,6 @@
browser_->GetFocusedFrame()->SelectAll(); browser_->GetFocusedFrame()->SelectAll();
} }
- (void)menuItemSelected:(id)sender {
cef_menu_id_t menuId = static_cast<cef_menu_id_t>([sender tag]);
bool handled = false;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefMenuHandler> handler = client->GetMenuHandler();
if (handler.get()) {
// Ask the handler if it wants to handle the action.
handled = handler->OnMenuAction(browser_, menuId);
}
}
if(!handled) {
// Execute the action.
browser_->UIT_HandleAction(menuId, browser_->GetFocusedFrame());
}
}
- (void)registerDragDrop { - (void)registerDragDrop {
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]); dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);
@@ -264,12 +418,12 @@
image:(NSImage*)image image:(NSImage*)image
offset:(NSPoint)offset { offset:(NSPoint)offset {
dragSource_.reset([[WebDragSource alloc] dragSource_.reset([[WebDragSource alloc]
initWithWebView:self initWithWebView:self
dropData:&dropData dropData:&dropData
image:image image:image
offset:offset offset:offset
pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
dragOperationMask:operationMask]); dragOperationMask:operationMask]);
[dragSource_ startDrag]; [dragSource_ startDrag];
} }
@@ -339,4 +493,167 @@
return [dropTarget_ performDragOperation:sender view:self]; return [dropTarget_ performDragOperation:sender view:self];
} }
// NSTextInputClient methods
// This code is mostly copied and adapted from
// content/browser/renderer_host/render_widget_host_mac
extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
}
- (NSArray *)validAttributesForMarkedText {
if (!validAttributesForMarkedText_) {
validAttributesForMarkedText_.reset([[NSArray alloc] initWithObjects:
NSUnderlineStyleAttributeName,
NSUnderlineColorAttributeName,
NSMarkedClauseSegmentAttributeName,
NSTextInputReplacementRangeAttributeName,
nil]);
}
return validAttributesForMarkedText_.get();
}
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint {
DCHECK([self window]);
// |thePoint| is in screen coordinates, but needs to be converted to WebKit
// coordinates (upper left origin). Scroll offsets will be taken care of in
// the renderer.
thePoint = [[self window] convertScreenToBase:thePoint];
thePoint = [self convertPoint:thePoint fromView:nil];
thePoint.y = NSHeight([self frame]) - thePoint.y;
WebPoint point(thePoint.x, thePoint.y);
return (NSUInteger)browser_->UIT_GetWebView()->focusedFrame()->
characterIndexForPoint(point);
}
- (NSRect)firstRectForCharacterRange:(NSRange)theRange
actualRange:(NSRangePointer) actualRange {
if (actualRange)
*actualRange = theRange;
if (!browser_ || !browser_->UIT_GetWebView() ||
!browser_->UIT_GetWebView()->focusedFrame()) {
return NSMakeRect(0, 0, 0, 0);
}
WebRect webRect;
browser_->UIT_GetWebView()->focusedFrame()->firstRectForCharacterRange(
theRange.location, theRange.length, webRect);
NSRect rect = NSMakeRect(webRect.x, webRect.y, webRect.width, webRect.height);
// The returned rectangle is in WebKit coordinates (upper left origin), so
// flip the coordinate system and then convert it into screen coordinates for
// return.
NSRect viewFrame = [self frame];
rect.origin.y = NSHeight(viewFrame) - rect.origin.y;
rect.origin.y -= rect.size.height;
rect = [self convertRectToBase:rect];
rect.origin = [[self window] convertBaseToScreen:rect.origin];
return rect;
}
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)theRange
actualRange:(NSRangePointer) actualRange {
if (actualRange)
*actualRange = theRange;
if (!browser_ || !browser_->UIT_GetWebView() ||
!browser_->UIT_GetWebView()->focusedFrame()) {
return nil;
}
return WebSubstringUtil::attributedSubstringInRange(
browser_->UIT_GetWebView()->focusedFrame(),
theRange.location,
theRange.length);
}
- (void)doCommandBySelector:(SEL)selector {
}
- (NSRange)markedRange {
return hasMarkedText_ ? markedRange_ : NSMakeRange(NSNotFound, 0);
}
- (NSRange)selectedRange {
return selectedRange_;
}
- (NSInteger)conversationIdentifier {
return reinterpret_cast<NSInteger>(self);
}
- (BOOL)hasMarkedText {
return hasMarkedText_;
}
- (void)unmarkText {
hasMarkedText_ = NO;
markedText_.clear();
underlines_.clear();
if (!handlingKeyDown_) {
if (browser_ && browser_->UIT_GetWebView())
browser_->UIT_GetWebView()->confirmComposition();
} else {
unmarkTextCalled_ = YES;
}
}
- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange
replacementRange: (NSRange) replacementRange {
// An input method updates the composition string.
// We send the given text and range to the renderer so it can update the
// composition node of WebKit.
BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
NSString* im_text = isAttributedString ? [string string] : string;
int length = [im_text length];
// |markedRange_| will get set on a callback from ImeSetComposition().
selectedRange_ = newSelRange;
markedText_ = base::SysNSStringToUTF16(im_text);
hasMarkedText_ = (length > 0);
underlines_.clear();
if (isAttributedString) {
ExtractUnderlines(string, &underlines_);
} else {
// Use a thin black underline by default.
underlines_.push_back(
WebCompositionUnderline(0, length, SK_ColorBLACK, false));
}
// If we are handling a key down event, then SetComposition() will be
// called in keyEvent: method.
// Input methods of Mac use setMarkedText calls with an empty text to cancel
// an ongoing composition. So, we should check whether or not the given text
// is empty to update the input method state. (Our input method backend can
// automatically cancels an ongoing composition when we send an empty text.
// So, it is OK to send an empty text to the renderer.)
if (!handlingKeyDown_) {
if (browser_ && browser_->UIT_GetWebView()) {
const WebString markedText(markedText_);
browser_->UIT_GetWebView()->setComposition(markedText,
underlines_,
newSelRange.location,
NSMaxRange(newSelRange));
}
}
}
- (void)insertText:(id)string replacementRange: (NSRange) replacementRange {
BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
NSString* im_text = isAttributedString ? [string string] : string;
if (handlingKeyDown_) {
textToBeInserted_.append(base::SysNSStringToUTF16(im_text));
} else {
browser_->UIT_GetWebViewHost()->webwidget()->confirmComposition(
base::SysNSStringToUTF16(im_text));
}
// Inserting text will delete all marked text automatically.
hasMarkedText_ = NO;
}
@end @end

View File

@@ -172,6 +172,12 @@ bool CefContext::Initialize(const CefSettings& settings,
application_ = application; application_ = application;
cache_path_ = FilePath(CefString(&settings.cache_path)); cache_path_ = FilePath(CefString(&settings.cache_path));
if (!cache_path_.empty() &&
!file_util::PathExists(cache_path_) &&
!file_util::CreateDirectory(cache_path_)) {
NOTREACHED() << "Failed to create cache_path directory";
cache_path_.clear();
}
#if defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_MACOSX) || defined(OS_WIN)
// We want to be sure to init NSPR on the main thread. // We want to be sure to init NSPR on the main thread.
@@ -402,6 +408,7 @@ base::StringPiece CefContext::GetDataResource(int resource_id) const {
} }
} }
value = broken_image_data; value = broken_image_data;
break;
} }
case IDR_TEXTAREA_RESIZER: { case IDR_TEXTAREA_RESIZER: {
// Use webkit's text area resizer image. // Use webkit's text area resizer image.
@@ -415,6 +422,7 @@ base::StringPiece CefContext::GetDataResource(int resource_id) const {
} }
} }
value = resize_corner_data; value = resize_corner_data;
break;
} }
default: default:

View File

@@ -76,9 +76,7 @@ class CefContext : public CefBase {
void set_request_context(BrowserRequestContext* request_context) { void set_request_context(BrowserRequestContext* request_context) {
request_context_ = request_context; request_context_ = request_context;
} }
scoped_refptr<BrowserRequestContext> request_context() { BrowserRequestContext* request_context() { return request_context_; }
return request_context_;
}
// The DOMStorageContext object is managed by CefProcessUIThread. // The DOMStorageContext object is managed by CefProcessUIThread.
void set_storage_context(DOMStorageContext* storage_context) { void set_storage_context(DOMStorageContext* storage_context) {

View File

@@ -1,232 +0,0 @@
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "include/cef_cookie.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "libcef/cef_time_util.h"
#include "base/bind.h"
#include "net/base/cookie_monster.h"
namespace {
// Callback class for visiting cookies.
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
public:
explicit VisitCookiesCallback(CefRefPtr<CefCookieVisitor> visitor)
: visitor_(visitor) {
}
void Run(const net::CookieList& list) {
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
int total = list.size(), count = 0;
net::CookieList::const_iterator it = list.begin();
for (; it != list.end(); ++it, ++count) {
CefCookie cookie;
const net::CookieMonster::CanonicalCookie& cc = *(it);
CefString(&cookie.name).FromString(cc.Name());
CefString(&cookie.value).FromString(cc.Value());
CefString(&cookie.domain).FromString(cc.Domain());
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.DoesExpire();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
bool deleteCookie = false;
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
if (deleteCookie) {
cookie_monster->DeleteCanonicalCookieAsync(cc,
net::CookieMonster::DeleteCookieCallback());
}
if (!keepLooping)
break;
}
}
private:
CefRefPtr<CefCookieVisitor> visitor_;
};
void IOT_VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) {
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesAsync(
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_VisitUrlCookies(const GURL& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) {
REQUIRE_IOT();
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return;
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(visitor));
cookie_monster->GetAllCookiesForURLWithOptionsAsync(url, options,
base::Bind(&VisitCookiesCallback::Run, callback.get()));
}
void IOT_SetCookiePath(const CefString& path) {
REQUIRE_IOT();
FilePath cookie_path;
if (!path.empty())
cookie_path = FilePath(path);
_Context->request_context()->SetCookieStoragePath(cookie_path);
}
} // namespace
bool CefVisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
return CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(IOT_VisitAllCookies, visitor));
}
bool CefVisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
return CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(IOT_VisitUrlCookies, gurl, includeHttpOnly, visitor));
}
bool CefSetCookie(const CefString& url, const CefCookie& cookie) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString();
std::string domain = CefString(&cookie.domain).ToString();
std::string path = CefString(&cookie.path).ToString();
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
cookie_monster->SetCookieWithDetailsAsync(gurl, name, value, domain, path,
expiration_time, cookie.secure, cookie.httponly,
net::CookieStore::SetCookiesCallback());
return true;
}
bool CefDeleteCookies(const CefString& url, const CefString& cookie_name) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
net::CookieMonster* cookie_monster = static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
if (!cookie_monster)
return false;
if (url.empty()) {
// Delete all cookies.
cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
return true;
}
std::string urlStr = url;
GURL gurl = GURL(urlStr);
if (!gurl.is_valid())
return false;
if (cookie_name.empty()) {
// Delete all matching host cookies.
cookie_monster->DeleteAllForHostAsync(gurl,
net::CookieMonster::DeleteCallback());
} else {
// Delete all matching host and domain cookies.
cookie_monster->DeleteCookieAsync(gurl, cookie_name, base::Closure());
}
return true;
}
bool CefSetCookiePath(const CefString& path) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return false;
}
if (CefThread::CurrentlyOn(CefThread::IO)) {
IOT_SetCookiePath(path);
} else {
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&IOT_SetCookiePath, path));
}
return true;
}

View File

@@ -0,0 +1,281 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/cookie_manager_impl.h"
#include <string>
#include "libcef/browser_persistent_cookie_store.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "libcef/cef_time_util.h"
#include "base/bind.h"
#include "base/logging.h"
namespace {
// Callback class for visiting cookies.
class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
public:
explicit VisitCookiesCallback(net::CookieMonster* cookie_monster,
CefRefPtr<CefCookieVisitor> visitor)
: cookie_monster_(cookie_monster),
visitor_(visitor) {
}
void Run(const net::CookieList& list) {
REQUIRE_IOT();
int total = list.size(), count = 0;
net::CookieList::const_iterator it = list.begin();
for (; it != list.end(); ++it, ++count) {
CefCookie cookie;
const net::CookieMonster::CanonicalCookie& cc = *(it);
CefString(&cookie.name).FromString(cc.Name());
CefString(&cookie.value).FromString(cc.Value());
CefString(&cookie.domain).FromString(cc.Domain());
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.has_expires = cc.DoesExpire();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
bool deleteCookie = false;
bool keepLooping = visitor_->Visit(cookie, count, total, deleteCookie);
if (deleteCookie) {
cookie_monster_->DeleteCanonicalCookieAsync(cc,
net::CookieMonster::DeleteCookieCallback());
}
if (!keepLooping)
break;
}
}
private:
scoped_refptr<net::CookieMonster> cookie_monster_;
CefRefPtr<CefCookieVisitor> visitor_;
};
} // namespace
CefCookieManagerImpl::CefCookieManagerImpl(bool is_global)
: is_global_(is_global) {
if (is_global) {
cookie_monster_ =
static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
DCHECK(cookie_monster_);
}
}
CefCookieManagerImpl::~CefCookieManagerImpl() {
}
void CefCookieManagerImpl::SetSupportedSchemes(
const std::vector<CefString>& schemes) {
if (CefThread::CurrentlyOn(CefThread::IO)) {
if (schemes.empty())
return;
std::set<std::string> scheme_set;
std::vector<CefString>::const_iterator it = schemes.begin();
for (; it != schemes.end(); ++it)
scheme_set.insert(*it);
const char** arr = new const char*[scheme_set.size()];
std::set<std::string>::const_iterator it2 = scheme_set.begin();
for (int i = 0; it2 != scheme_set.end(); ++it2, ++i)
arr[i] = it2->c_str();
cookie_monster_->SetCookieableSchemes(arr, scheme_set.size());
delete [] arr;
} else {
// Execute on the IO thread.
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(&CefCookieManagerImpl::SetSupportedSchemes,
this, schemes));
}
}
bool CefCookieManagerImpl::VisitAllCookies(
CefRefPtr<CefCookieVisitor> visitor) {
if (CefThread::CurrentlyOn(CefThread::IO)) {
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(cookie_monster_, visitor));
cookie_monster_->GetAllCookiesAsync(
base::Bind(&VisitCookiesCallback::Run, callback.get()));
} else {
// Execute on the IO thread.
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(base::IgnoreResult(&CefCookieManagerImpl::VisitAllCookies),
this, visitor));
}
return true;
}
bool CefCookieManagerImpl::VisitUrlCookies(
const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) {
if (CefThread::CurrentlyOn(CefThread::IO)) {
net::CookieOptions options;
if (includeHttpOnly)
options.set_include_httponly();
scoped_refptr<VisitCookiesCallback> callback(
new VisitCookiesCallback(cookie_monster_, visitor));
GURL gurl = GURL(url.ToString());
cookie_monster_->GetAllCookiesForURLWithOptionsAsync(gurl, options,
base::Bind(&VisitCookiesCallback::Run, callback.get()));
} else {
// Execute on the IO thread.
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(base::IgnoreResult(&CefCookieManagerImpl::VisitUrlCookies),
this, url, includeHttpOnly, visitor));
}
return true;
}
bool CefCookieManagerImpl::SetCookie(const CefString& url,
const CefCookie& cookie) {
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
GURL gurl = GURL(url.ToString());
if (!gurl.is_valid())
return false;
std::string name = CefString(&cookie.name).ToString();
std::string value = CefString(&cookie.value).ToString();
std::string domain = CefString(&cookie.domain).ToString();
std::string path = CefString(&cookie.path).ToString();
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
cookie_monster_->SetCookieWithDetailsAsync(gurl, name, value, domain, path,
expiration_time, cookie.secure, cookie.httponly,
net::CookieStore::SetCookiesCallback());
return true;
}
bool CefCookieManagerImpl::DeleteCookies(const CefString& url,
const CefString& cookie_name) {
// Verify that this function is being called on the IO thread.
if (!CefThread::CurrentlyOn(CefThread::IO)) {
NOTREACHED() << "called on invalid thread";
return false;
}
if (url.empty()) {
// Delete all cookies.
cookie_monster_->DeleteAllAsync(net::CookieMonster::DeleteCallback());
return true;
}
GURL gurl = GURL(url.ToString());
if (!gurl.is_valid())
return false;
if (cookie_name.empty()) {
// Delete all matching host cookies.
cookie_monster_->DeleteAllForHostAsync(gurl,
net::CookieMonster::DeleteCallback());
} else {
// Delete all matching host and domain cookies.
cookie_monster_->DeleteCookieAsync(gurl, cookie_name, base::Closure());
}
return true;
}
bool CefCookieManagerImpl::SetStoragePath(const CefString& path) {
if (CefThread::CurrentlyOn(CefThread::IO)) {
FilePath new_path;
if (!path.empty())
new_path = FilePath(path);
if (is_global_) {
// Global path changes are handled by the request context.
_Context->request_context()->SetCookieStoragePath(new_path);
cookie_monster_ =
static_cast<net::CookieMonster*>(
_Context->request_context()->cookie_store());
return true;
}
if (cookie_monster_ && ((storage_path_.empty() && path.empty()) ||
storage_path_ == new_path)) {
// The path has not changed so don't do anything.
return true;
}
scoped_refptr<BrowserPersistentCookieStore> persistent_store;
if (!new_path.empty()) {
if (!file_util::PathExists(new_path) &&
!file_util::CreateDirectory(new_path)) {
NOTREACHED() << "Failed to create cookie storage directory";
new_path.clear();
} else {
FilePath cookie_path = new_path.Append(FILE_PATH_LITERAL("Cookies"));
persistent_store = new BrowserPersistentCookieStore(cookie_path, false);
}
}
// Set the new cookie store that will be used for all new requests. The old
// cookie store, if any, will be automatically flushed and closed when no
// longer referenced.
cookie_monster_ = new net::CookieMonster(persistent_store.get(), NULL);
storage_path_ = new_path;
} else {
// Execute on the IO thread.
CefThread::PostTask(CefThread::IO, FROM_HERE,
base::Bind(base::IgnoreResult(&CefCookieManagerImpl::SetStoragePath),
this, path));
}
return true;
}
// CefCookieManager methods ----------------------------------------------------
// static
CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager() {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return NULL;
}
return new CefCookieManagerImpl(true);
}
// static
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
const CefString& path) {
// Verify that the context is in a valid state.
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return NULL;
}
CefRefPtr<CefCookieManager> manager(new CefCookieManagerImpl(false));
manager->SetStoragePath(path);
return manager;
}

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_COOKIE_IMPL_H_
#define CEF_LIBCEF_COOKIE_IMPL_H_
#include "include/cef_cookie.h"
#include "base/file_path.h"
#include "net/base/cookie_monster.h"
// Implementation of the CefCookieManager interface.
class CefCookieManagerImpl : public CefCookieManager {
public:
CefCookieManagerImpl(bool is_global);
~CefCookieManagerImpl();
// CefCookieManager methods.
virtual void SetSupportedSchemes(const std::vector<CefString>& schemes)
OVERRIDE;
virtual bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
virtual bool SetCookie(const CefString& url,
const CefCookie& cookie) OVERRIDE;
virtual bool DeleteCookies(const CefString& url,
const CefString& cookie_name) OVERRIDE;
virtual bool SetStoragePath(const CefString& path) OVERRIDE;
net::CookieMonster* cookie_monster() { return cookie_monster_; }
private:
scoped_refptr<net::CookieMonster> cookie_monster_;
bool is_global_;
FilePath storage_path_;
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);
};
#endif // CEF_LIBCEF_COOKIE_IMPL_H_

View File

@@ -0,0 +1,92 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "libcef/cookie_store_proxy.h"
#include <string>
#include "libcef/browser_impl.h"
#include "libcef/cef_context.h"
#include "libcef/cookie_manager_impl.h"
#include "base/logging.h"
CefCookieStoreProxy::CefCookieStoreProxy(CefBrowserImpl* browser)
: browser_(browser) {
DCHECK(browser_);
}
void CefCookieStoreProxy::SetCookieWithOptionsAsync(
const GURL& url,
const std::string& cookie_line,
const net::CookieOptions& options,
const SetCookiesCallback& callback) {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->SetCookieWithOptionsAsync(url, cookie_line, options, callback);
}
void CefCookieStoreProxy::GetCookiesWithOptionsAsync(
const GURL& url, const net::CookieOptions& options,
const GetCookiesCallback& callback) {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->GetCookiesWithOptionsAsync(url, options, callback);
}
void CefCookieStoreProxy::GetCookiesWithInfoAsync(
const GURL& url,
const net::CookieOptions& options,
const GetCookieInfoCallback& callback) {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->GetCookiesWithInfoAsync(url, options, callback);
}
void CefCookieStoreProxy::DeleteCookieAsync(
const GURL& url,
const std::string& cookie_name,
const base::Closure& callback) {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->DeleteCookieAsync(url, cookie_name, callback);
}
void CefCookieStoreProxy::DeleteAllCreatedBetweenAsync(
const base::Time& delete_begin,
const base::Time& delete_end,
const DeleteCallback& callback) {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
cookie_store->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
callback);
}
net::CookieMonster* CefCookieStoreProxy::GetCookieMonster() {
scoped_refptr<net::CookieStore> cookie_store = GetCookieStore();
return cookie_store->GetCookieMonster();
}
net::CookieStore* CefCookieStoreProxy::GetCookieStore() {
scoped_refptr<net::CookieStore> cookie_store;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
if (handler.get()) {
// Get the manager from the handler.
CefRefPtr<CefCookieManager> manager =
handler->GetCookieManager(browser_, browser_->pending_url().spec());
if (manager.get()) {
cookie_store =
reinterpret_cast<CefCookieManagerImpl*>(
manager.get())->cookie_monster();
}
}
}
if (!cookie_store) {
// Use the global cookie store.
cookie_store = _Context->request_context()->cookie_store();
}
DCHECK(cookie_store);
return cookie_store;
}

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef CEF_LIBCEF_COOKIE_STORE_PROXY_H_
#define CEF_LIBCEF_COOKIE_STORE_PROXY_H_
#pragma once
#include "net/base/cookie_store.h"
class CefBrowserImpl;
// Handles cookie requests from the network stack.
class CefCookieStoreProxy : public net::CookieStore {
public:
explicit CefCookieStoreProxy(CefBrowserImpl* browser);
// net::CookieStore methods.
virtual void SetCookieWithOptionsAsync(
const GURL& url,
const std::string& cookie_line,
const net::CookieOptions& options,
const SetCookiesCallback& callback) OVERRIDE;
virtual void GetCookiesWithOptionsAsync(
const GURL& url, const net::CookieOptions& options,
const GetCookiesCallback& callback) OVERRIDE;
void GetCookiesWithInfoAsync(
const GURL& url,
const net::CookieOptions& options,
const GetCookieInfoCallback& callback) OVERRIDE;
virtual void DeleteCookieAsync(const GURL& url,
const std::string& cookie_name,
const base::Closure& callback) OVERRIDE;
virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
const base::Time& delete_end,
const DeleteCallback& callback)
OVERRIDE;
virtual net::CookieMonster* GetCookieMonster() OVERRIDE;
private:
net::CookieStore* GetCookieStore();
CefBrowserImpl* browser_;
};
#endif // CEF_LIBCEF_COOKIE_STORE_PROXY_H_

View File

@@ -11,6 +11,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/threading/non_thread_safe.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
@@ -42,7 +43,8 @@ namespace {
// Wrapper implementation for WebDOMEventListener. // Wrapper implementation for WebDOMEventListener.
class CefDOMEventListenerWrapper : public WebDOMEventListener, class CefDOMEventListenerWrapper : public WebDOMEventListener,
public CefTrackNode { public CefTrackNode,
public base::NonThreadSafe {
public: public:
CefDOMEventListenerWrapper(CefBrowserImpl* browser, WebFrame* frame, CefDOMEventListenerWrapper(CefBrowserImpl* browser, WebFrame* frame,
CefRefPtr<CefDOMEventListener> listener) CefRefPtr<CefDOMEventListener> listener)
@@ -53,7 +55,6 @@ class CefDOMEventListenerWrapper : public WebDOMEventListener,
browser->UIT_AddFrameObject(frame, this); browser->UIT_AddFrameObject(frame, this);
} }
virtual ~CefDOMEventListenerWrapper() { virtual ~CefDOMEventListenerWrapper() {
REQUIRE_UIT();
} }
virtual void handleEvent(const WebDOMEvent& event) { virtual void handleEvent(const WebDOMEvent& event) {

View File

@@ -33,9 +33,35 @@ void ExternalPopupMenu::show(const WebKit::WebRect& bounds) {
CefBrowserImpl* browser = delegate_->GetBrowser(); CefBrowserImpl* browser = delegate_->GetBrowser();
NSView* view = nil;
NSRect view_rect;
if (!browser->IsWindowRenderingDisabled()) {
view = browser->UIT_GetWebViewWndHandle();
view_rect = [view bounds];
} else {
view = browser->UIT_GetMainWndHandle();
if (view != nil) {
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
// Retrieve the view rect.
CefRect rect;
CefRefPtr<CefRenderHandler> render_handler = client->GetRenderHandler();
if (render_handler.get() &&
render_handler->GetViewRect(browser, rect)) {
view_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height);
}
}
}
}
if (view == nil || view_rect.size.width == 0 || view_rect.size.height == 0) {
popup_menu_client_->didCancel();
delegate_->ClosePopupMenu();
return;
}
// Set up the menu position. // Set up the menu position.
NSView* web_view = browser->UIT_GetWebViewWndHandle();
NSRect view_rect = [web_view bounds];
int y_offset = bounds.y + bounds.height; int y_offset = bounds.y + bounds.height;
NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset, NSRect position = NSMakeRect(bounds.x, view_rect.size.height - y_offset,
bounds.width, bounds.height); bounds.width, bounds.height);
@@ -46,7 +72,7 @@ void ExternalPopupMenu::show(const WebKit::WebRect& bounds) {
fontSize:font_size fontSize:font_size
rightAligned:right_aligned]); rightAligned:right_aligned]);
[menu_runner runMenuInView:browser->UIT_GetWebViewWndHandle() [menu_runner runMenuInView:view
withBounds:position withBounds:position
initialIndex:selected_index]; initialIndex:selected_index];

View File

@@ -3,6 +3,10 @@
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "libcef/request_impl.h" #include "libcef/request_impl.h"
#include <string>
#include <vector>
#include "libcef/http_header_utils.h" #include "libcef/http_header_utils.h"
#include "base/logging.h" #include "base/logging.h"
@@ -80,9 +84,23 @@ void CefRequestImpl::Set(net::URLRequest* request) {
url_ = request->url().spec(); url_ = request->url().spec();
method_ = request->method(); method_ = request->method();
net::HttpRequestHeaders headers = request->extra_request_headers();
// Ensure that we do not send username and password fields in the referrer.
GURL referrer(request->GetSanitizedReferrer());
// Strip Referer from request_info_.extra_headers to prevent, e.g., plugins
// from overriding headers that are controlled using other means. Otherwise a
// plugin could set a referrer although sending the referrer is inhibited.
headers.RemoveHeader(net::HttpRequestHeaders::kReferer);
// Our consumer should have made sure that this is a safe referrer. See for
// instance WebCore::FrameLoader::HideReferrer.
if (referrer.is_valid())
headers.SetHeader(net::HttpRequestHeaders::kReferer, referrer.spec());
// Transfer request headers // Transfer request headers
GetHeaderMap(request->extra_request_headers(), headermap_); GetHeaderMap(headers, headermap_);
headermap_.insert(std::make_pair(L"Referrer", request->referrer()));
// Transfer post data, if any // Transfer post data, if any
net::UploadData* data = request->get_upload(); net::UploadData* data = request->get_upload();

View File

@@ -5,9 +5,9 @@
#include <map> #include <map>
#include "include/cef_browser.h"
#include "include/cef_scheme.h" #include "include/cef_scheme.h"
#include "libcef/browser_devtools_scheme_handler.h" #include "libcef/browser_devtools_scheme_handler.h"
#include "libcef/browser_impl.h"
#include "libcef/browser_resource_loader_bridge.h" #include "libcef/browser_resource_loader_bridge.h"
#include "libcef/cef_context.h" #include "libcef/cef_context.h"
#include "libcef/cef_thread.h" #include "libcef/cef_thread.h"
@@ -22,6 +22,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "googleurl/src/url_util.h" #include "googleurl/src/url_util.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/cookie_monster.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/upload_data.h" #include "net/base/upload_data.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
@@ -107,7 +108,9 @@ class CefUrlRequestJob : public net::URLRequestJob {
CefRefPtr<CefSchemeHandler> handler) CefRefPtr<CefSchemeHandler> handler)
: net::URLRequestJob(request), : net::URLRequestJob(request),
handler_(handler), handler_(handler),
remaining_bytes_(0) { remaining_bytes_(0),
response_cookies_save_index_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
} }
virtual ~CefUrlRequestJob() { virtual ~CefUrlRequestJob() {
@@ -116,22 +119,132 @@ class CefUrlRequestJob : public net::URLRequestJob {
virtual void Start() OVERRIDE { virtual void Start() OVERRIDE {
REQUIRE_IOT(); REQUIRE_IOT();
cef_request_ = CefRequest::CreateRequest();
// Populate the request data.
static_cast<CefRequestImpl*>(cef_request_.get())->Set(request_);
// Add default headers if not already specified.
const net::URLRequestContext* context = request_->context();
if (context) {
CefRequest::HeaderMap::const_iterator it;
CefRequest::HeaderMap headerMap;
cef_request_->GetHeaderMap(headerMap);
bool changed = false;
if (!context->accept_language().empty()) {
it = headerMap.find(net::HttpRequestHeaders::kAcceptLanguage);
if (it == headerMap.end()) {
headerMap.insert(
std::make_pair(net::HttpRequestHeaders::kAcceptLanguage,
context->accept_language()));
}
changed = true;
}
if (!context->accept_charset().empty()) {
it = headerMap.find(net::HttpRequestHeaders::kAcceptCharset);
if (it == headerMap.end()) {
headerMap.insert(
std::make_pair(net::HttpRequestHeaders::kAcceptCharset,
context->accept_charset()));
}
changed = true;
}
it = headerMap.find(net::HttpRequestHeaders::kUserAgent);
if (it == headerMap.end()) {
headerMap.insert(
std::make_pair(net::HttpRequestHeaders::kUserAgent,
context->GetUserAgent(request_->url())));
changed = true;
}
if (changed)
cef_request_->SetHeaderMap(headerMap);
}
AddCookieHeaderAndStart();
}
void AddCookieHeaderAndStart() {
// No matter what, we want to report our status as IO pending since we will
// be notifying our consumer asynchronously via OnStartCompleted.
SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
// If the request was destroyed, then there is no more work to do.
if (!request_)
return;
net::CookieStore* cookie_store =
request_->context()->cookie_store();
if (cookie_store) {
net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
if (cookie_monster) {
cookie_monster->GetAllCookiesForURLAsync(
request_->url(),
base::Bind(&CefUrlRequestJob::CheckCookiePolicyAndLoad,
weak_factory_.GetWeakPtr()));
} else {
DoLoadCookies();
}
} else {
DoStartTransaction();
}
}
void DoLoadCookies() {
net::CookieOptions options;
options.set_include_httponly();
request_->context()->cookie_store()->GetCookiesWithInfoAsync(
request_->url(), options,
base::Bind(&CefUrlRequestJob::OnCookiesLoaded,
weak_factory_.GetWeakPtr()));
}
void CheckCookiePolicyAndLoad(
const net::CookieList& cookie_list) {
if (CanGetCookies(cookie_list))
DoLoadCookies();
else
DoStartTransaction();
}
void OnCookiesLoaded(
const std::string& cookie_line,
const std::vector<net::CookieStore::CookieInfo>& cookie_infos) {
if (!cookie_line.empty()) {
CefRequest::HeaderMap headerMap;
cef_request_->GetHeaderMap(headerMap);
headerMap.insert(
std::make_pair(net::HttpRequestHeaders::kCookie, cookie_line));
cef_request_->SetHeaderMap(headerMap);
}
DoStartTransaction();
}
void DoStartTransaction() {
// We may have been canceled while retrieving cookies.
if (GetStatus().is_success()) {
StartTransaction();
} else {
NotifyCanceled();
}
}
void StartTransaction() {
if (!callback_) if (!callback_)
callback_ = new Callback(this); callback_ = new Callback(this);
CefRefPtr<CefRequest> req(CefRequest::CreateRequest()); // Protect against deletion of this object.
base::WeakPtr<CefUrlRequestJob> weak_ptr(weak_factory_.GetWeakPtr());
// Populate the request data.
static_cast<CefRequestImpl*>(req.get())->Set(request());
// Handler can decide whether to process the request. // Handler can decide whether to process the request.
bool rv = handler_->ProcessRequest(req, callback_.get()); bool rv = handler_->ProcessRequest(cef_request_, callback_.get());
if (!rv) { if (weak_ptr.get() && !rv) {
// Cancel the request. // Cancel the request.
NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, ERR_ABORTED)); NotifyCanceled();
} }
return;
} }
virtual void Kill() OVERRIDE { virtual void Kill() OVERRIDE {
@@ -193,11 +306,7 @@ class CefUrlRequestJob : public net::URLRequestJob {
virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE {
REQUIRE_IOT(); REQUIRE_IOT();
if (response_.get()) { info->headers = GetResponseHeaders();
CefResponseImpl* responseImpl =
static_cast<CefResponseImpl*>(response_.get());
info->headers = responseImpl->GetResponseHeaders();
}
} }
virtual bool IsRedirectResponse(GURL* location, int* http_status_code) virtual bool IsRedirectResponse(GURL* location, int* http_status_code)
@@ -265,7 +374,81 @@ class CefUrlRequestJob : public net::URLRequestJob {
set_expected_content_size(remaining_bytes_); set_expected_content_size(remaining_bytes_);
// Continue processing the request. // Continue processing the request.
NotifyHeadersComplete(); SaveCookiesAndNotifyHeadersComplete();
}
net::HttpResponseHeaders* GetResponseHeaders() {
DCHECK(response_);
if (!response_headers_.get()) {
CefResponseImpl* responseImpl =
static_cast<CefResponseImpl*>(response_.get());
response_headers_ = responseImpl->GetResponseHeaders();
}
return response_headers_;
}
void SaveCookiesAndNotifyHeadersComplete() {
response_cookies_.clear();
response_cookies_save_index_ = 0;
FetchResponseCookies(&response_cookies_);
// Now, loop over the response cookies, and attempt to persist each.
SaveNextCookie();
}
void SaveNextCookie() {
if (response_cookies_save_index_ == response_cookies_.size()) {
response_cookies_.clear();
response_cookies_save_index_ = 0;
SetStatus(URLRequestStatus()); // Clear the IO_PENDING status
NotifyHeadersComplete();
return;
}
// No matter what, we want to report our status as IO pending since we will
// be notifying our consumer asynchronously via OnStartCompleted.
SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
net::CookieOptions options;
options.set_include_httponly();
if (CanSetCookie(
response_cookies_[response_cookies_save_index_], &options)) {
request_->context()->cookie_store()->SetCookieWithOptionsAsync(
request_->url(), response_cookies_[response_cookies_save_index_],
options, base::Bind(&CefUrlRequestJob::OnCookieSaved,
weak_factory_.GetWeakPtr()));
return;
}
CookieHandled();
}
void OnCookieSaved(bool cookie_status) {
CookieHandled();
}
void CookieHandled() {
response_cookies_save_index_++;
// We may have been canceled within OnSetCookie.
if (GetStatus().is_success()) {
SaveNextCookie();
} else {
NotifyCanceled();
}
}
void FetchResponseCookies(
std::vector<std::string>* cookies) {
const std::string name = "Set-Cookie";
std::string value;
void* iter = NULL;
net::HttpResponseHeaders* headers = GetResponseHeaders();
while (headers->EnumerateHeader(&iter, name, &value)) {
if (!value.empty())
cookies->push_back(value);
}
} }
// Client callback for asynchronous response continuation. // Client callback for asynchronous response continuation.
@@ -307,9 +490,14 @@ class CefUrlRequestJob : public net::URLRequestJob {
dest_ = NULL; dest_ = NULL;
dest_size_ = 0; dest_size_ = 0;
} else {
// All done.
job_->NotifyDone(URLRequestStatus());
} }
} else { } else if (!job_->GetStatus().is_io_pending()) {
// All done. // Failed due to an error.
NOTREACHED() <<
"ReadRawData returned false without setting IO as pending";
job_->NotifyDone(URLRequestStatus()); job_->NotifyDone(URLRequestStatus());
} }
} }
@@ -355,7 +543,12 @@ class CefUrlRequestJob : public net::URLRequestJob {
GURL redirect_url_; GURL redirect_url_;
int64 remaining_bytes_; int64 remaining_bytes_;
CefRefPtr<CefRequest> cef_request_;
CefRefPtr<Callback> callback_; CefRefPtr<Callback> callback_;
scoped_refptr<net::HttpResponseHeaders> response_headers_;
std::vector<std::string> response_cookies_;
size_t response_cookies_save_index_;
base::WeakPtrFactory<CefUrlRequestJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CefUrlRequestJob); DISALLOW_COPY_AND_ASSIGN(CefUrlRequestJob);
}; };
@@ -539,10 +732,10 @@ class CefUrlRequestManager {
// Call the handler factory to create the handler for the request. // Call the handler factory to create the handler for the request.
CefRefPtr<CefRequest> requestPtr(new CefRequestImpl()); CefRefPtr<CefRequest> requestPtr(new CefRequestImpl());
static_cast<CefRequestImpl*>(requestPtr.get())->Set(request); static_cast<CefRequestImpl*>(requestPtr.get())->Set(request);
CefRefPtr<CefBrowser> browser = CefRefPtr<CefBrowserImpl> browser =
BrowserResourceLoaderBridge::GetBrowserForRequest(request); BrowserResourceLoaderBridge::GetBrowserForRequest(request);
CefRefPtr<CefSchemeHandler> handler = CefRefPtr<CefSchemeHandler> handler =
factory->Create(browser, scheme, requestPtr); factory->Create(browser.get(), scheme, requestPtr);
if (handler.get()) if (handler.get())
job = new CefUrlRequestJob(request, handler); job = new CefUrlRequestJob(request, handler);
} }

View File

@@ -140,6 +140,8 @@ void GetCefString(v8::Handle<v8::String> str, CefString& out) {
#if defined(CEF_STRING_TYPE_WIDE) #if defined(CEF_STRING_TYPE_WIDE)
// Allocate enough space for a worst-case conversion. // Allocate enough space for a worst-case conversion.
int len = str->Utf8Length(); int len = str->Utf8Length();
if (len == 0)
return;
char* buf = new char[len + 1]; char* buf = new char[len + 1];
str->WriteUtf8(buf, len + 1); str->WriteUtf8(buf, len + 1);
@@ -151,11 +153,15 @@ void GetCefString(v8::Handle<v8::String> str, CefString& out) {
#else // !defined(CEF_STRING_TYPE_WIDE) #else // !defined(CEF_STRING_TYPE_WIDE)
#if defined(CEF_STRING_TYPE_UTF16) #if defined(CEF_STRING_TYPE_UTF16)
int len = str->Length(); int len = str->Length();
if (len == 0)
return;
char16* buf = new char16[len + 1]; char16* buf = new char16[len + 1];
str->Write(reinterpret_cast<uint16_t*>(buf), 0, len + 1); str->Write(reinterpret_cast<uint16_t*>(buf), 0, len + 1);
#else #else
// Allocate enough space for a worst-case conversion. // Allocate enough space for a worst-case conversion.
int len = str->Utf8Length(); int len = str->Utf8Length();
if (len == 0)
return;
char* buf = new char[len + 1]; char* buf = new char[len + 1];
str->WriteUtf8(buf, len + 1); str->WriteUtf8(buf, len + 1);
#endif #endif

View File

@@ -98,7 +98,7 @@ void WebDragSource::StartDragging(const WebDropData& drop_data,
const SkBitmap& bitmap = image.getSkBitmap(); const SkBitmap& bitmap = image.getSkBitmap();
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
gtk_drag_set_icon_pixbuf(context, pixbuf, image_offset.x, image_offset.y); gtk_drag_set_icon_pixbuf(context, pixbuf, image_offset.x, image_offset.y);
gdk_pixbuf_unref(pixbuf); g_object_unref(pixbuf);
} else { } else {
gtk_drag_set_icon_default(context); gtk_drag_set_icon_default(context);
} }

105
libcef/web_plugin_impl.cc Normal file
View File

@@ -0,0 +1,105 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef_web_plugin.h"
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "base/file_path.h"
#include "base/string_util.h"
#include "webkit/plugins/npapi/plugin_list.h"
namespace {
class CefWebPluginInfoImpl : public CefWebPluginInfo {
public:
explicit CefWebPluginInfoImpl(const webkit::WebPluginInfo& plugin_info)
: plugin_info_(plugin_info) {
}
virtual CefString GetName() OVERRIDE {
return plugin_info_.name;
}
virtual CefString GetPath() OVERRIDE {
return plugin_info_.path.value();
}
virtual CefString GetVersion() OVERRIDE {
return plugin_info_.version;
}
virtual CefString GetDescription() OVERRIDE {
return plugin_info_.desc;
}
private:
webkit::WebPluginInfo plugin_info_;
IMPLEMENT_REFCOUNTING(CefWebPluginInfoImpl);
};
} // namespace
size_t CefGetWebPluginCount() {
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return 0;
}
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return 0;
}
std::vector<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
return plugins.size();
}
CefRefPtr<CefWebPluginInfo> CefGetWebPluginInfo(int index) {
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return 0;
}
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return 0;
}
std::vector<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
if (index < 0 || index >= static_cast<int>(plugins.size()))
return NULL;
return new CefWebPluginInfoImpl(plugins[index]);
}
CefRefPtr<CefWebPluginInfo> CefGetWebPluginInfo(const CefString& name) {
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return 0;
}
if (!CefThread::CurrentlyOn(CefThread::UI)) {
NOTREACHED() << "called on invalid thread";
return 0;
}
std::vector<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
std::string nameStr = name;
StringToLowerASCII(&nameStr);
std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
for (; it != plugins.end(); ++it) {
if (LowerCaseEqualsASCII(it->name, nameStr.c_str()))
return new CefWebPluginInfoImpl(*it);
}
return NULL;
}

View File

@@ -3,6 +3,7 @@
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "libcef/webview_host.h" #include "libcef/webview_host.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
WebViewHost::WebViewHost(BrowserWebViewDelegate* delegate) WebViewHost::WebViewHost(BrowserWebViewDelegate* delegate)
: delegate_(delegate) { : delegate_(delegate) {
@@ -12,3 +13,7 @@ WebViewHost::WebViewHost(BrowserWebViewDelegate* delegate)
WebViewHost::~WebViewHost() { WebViewHost::~WebViewHost() {
} }
#endif #endif
bool WebViewHost::IsTransparent() {
return static_cast<WebKit::WebView*>(webwidget_)->isTransparent();
}

View File

@@ -58,6 +58,8 @@ class WebViewHost : public WebWidgetHost {
virtual void SetFocus(bool enable); virtual void SetFocus(bool enable);
#endif #endif
virtual bool IsTransparent();
protected: protected:
explicit WebViewHost(BrowserWebViewDelegate* delegate); explicit WebViewHost(BrowserWebViewDelegate* delegate);

View File

@@ -35,10 +35,15 @@ WebViewHost* WebViewHost::Create(NSView* parent_view,
WebViewHost* host = new WebViewHost(delegate); WebViewHost* host = new WebViewHost(delegate);
NSRect content_rect = {{rect.x(), rect.y()}, {rect.width(), rect.height()}}; NSRect content_rect = {{rect.x(), rect.y()}, {rect.width(), rect.height()}};
host->view_ = [[BrowserWebView alloc] initWithFrame:content_rect]; if (!paint_delegate) {
[host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; host->view_ = [[BrowserWebView alloc] initWithFrame:content_rect];
[parent_view addSubview:host->view_]; [host->view_ setAutoresizingMask:(NSViewWidthSizable |
[host->view_ release]; NSViewHeightSizable)];
[parent_view addSubview:host->view_];
[host->view_ release];
} else {
host->paint_delegate_ = paint_delegate;
}
#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) #if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT)
host->webwidget_ = WebView::create(delegate, NULL); host->webwidget_ = WebView::create(delegate, NULL);

View File

@@ -6,59 +6,79 @@
#include "libcef/cef_thread.h" #include "libcef/cef_thread.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
#include "webkit/glue/webkit_glue.h"
using webkit::npapi::WebPluginGeometry; using webkit::npapi::WebPluginGeometry;
using WebKit::WebSize; using WebKit::WebSize;
const int WebWidgetHost::kDefaultFrameRate = 30;
const int WebWidgetHost::kMaxFrameRate = 90;
void WebWidgetHost::ScheduleComposite() { void WebWidgetHost::InvalidateRect(const gfx::Rect& rect) {
if (has_invalidate_task_) if (rect.IsEmpty())
return; return;
has_invalidate_task_ = true; int width, height;
GetSize(width, height);
const gfx::Rect client_rect(width, height);
// Try to paint at 60fps. const gfx::Rect rect_in_client = client_rect.Intersect(rect);
static int64 kDesiredRate = 16; if (rect_in_client.IsEmpty())
return;
base::TimeDelta delta = base::TimeTicks::Now() - paint_last_call_; UpdatePaintRect(rect_in_client);
int64 actualRate = delta.InMilliseconds();
if (actualRate >= kDesiredRate) { if (view_)
// Can't keep up so run as fast as possible. InvalidateWindowRect(rect_in_client);
MessageLoop::current()->PostTask(FROM_HERE, else
base::Bind(&WebWidgetHost::Invalidate, weak_factory_.GetWeakPtr())); ScheduleTimer();
} else { }
// Maintain the desired rate.
MessageLoop::current()->PostDelayedTask(FROM_HERE, void WebWidgetHost::ScheduleComposite() {
base::Bind(&WebWidgetHost::Invalidate, weak_factory_.GetWeakPtr()), ScheduleTimer();
kDesiredRate - actualRate);
}
} }
void WebWidgetHost::ScheduleAnimation() { void WebWidgetHost::ScheduleAnimation() {
ScheduleComposite(); ScheduleTimer();
} }
void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { bool WebWidgetHost::GetImage(int width, int height, void* rgba_buffer) {
#if defined(OS_WIN) || defined(OS_MACOSX) if (!canvas_.get())
paint_rgn_.op(rect.x(), rect.y(), rect.right(), rect.bottom(), return false;
SkRegion::kUnion_Op);
#else
// TODO(cef): Update all ports to use regions instead of rectangles.
paint_rect_ = paint_rect_.Union(rect);
#endif
}
void WebWidgetHost::UpdateRedrawRect(const gfx::Rect& rect) { const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false);
if (!view_) DCHECK(bitmap.config() == SkBitmap::kARGB_8888_Config);
redraw_rect_ = redraw_rect_.Union(rect);
if (width == canvas_->getDevice()->width() &&
height == canvas_->getDevice()->height()) {
// The specified width and height values are the same as the canvas size.
// Return the existing canvas contents.
const void* pixels = bitmap.getPixels();
memcpy(rgba_buffer, pixels, width * height * 4);
return true;
}
// Create a new canvas of the requested size.
scoped_ptr<skia::PlatformCanvas> new_canvas(
new skia::PlatformCanvas(width, height, true));
new_canvas->writePixels(bitmap, 0, 0);
const SkBitmap& new_bitmap = new_canvas->getDevice()->accessBitmap(false);
DCHECK(new_bitmap.config() == SkBitmap::kARGB_8888_Config);
// Return the new canvas contents.
const void* pixels = new_bitmap.getPixels();
memcpy(rgba_buffer, pixels, width * height * 4);
return true;
} }
void WebWidgetHost::SetSize(int width, int height) { void WebWidgetHost::SetSize(int width, int height) {
webwidget_->resize(WebSize(width, height)); webwidget_->resize(WebSize(width, height));
DidInvalidateRect(gfx::Rect(0, 0, width, height)); InvalidateRect(gfx::Rect(0, 0, width, height));
EnsureTooltip(); EnsureTooltip();
} }
@@ -105,22 +125,103 @@ gfx::PluginWindowHandle WebWidgetHost::GetWindowedPluginAt(int x, int y) {
return gfx::kNullPluginWindow; return gfx::kNullPluginWindow;
} }
void WebWidgetHost::DoPaint() { void WebWidgetHost::SetFrameRate(int frames_per_second) {
// TODO(cef): The below code is cross-platform but the IsIdle() method if (frames_per_second <= 0)
// currently requires patches to Chromium. Since this code is only executed frames_per_second = kDefaultFrameRate;
// on Windows it's been stuck behind an #ifdef for now to avoid having to if (frames_per_second > kMaxFrameRate)
// patch Chromium code on other platforms. frames_per_second = kMaxFrameRate;
#if defined(OS_WIN)
if (MessageLoop::current()->IsIdle()) { frame_delay_ = 1000 / frames_per_second;
has_update_task_ = false; }
// Paint to the delegate.
Paint(); void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
} else { #if defined(OS_WIN) || defined(OS_MACOSX)
// Try again later. paint_rgn_.op(rect.x(), rect.y(), rect.right(), rect.bottom(),
CefThread::PostTask(CefThread::UI, FROM_HERE, SkRegion::kUnion_Op);
base::Bind(&WebWidgetHost::DoPaint, weak_factory_.GetWeakPtr()));
}
#else #else
NOTIMPLEMENTED(); // TODO(cef): Update all ports to use regions instead of rectangles.
paint_rect_ = paint_rect_.Union(rect);
#endif #endif
} }
void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
#ifndef NDEBUG
DCHECK(!painting_);
#endif
DCHECK(canvas_.get());
if (rect.IsEmpty())
return;
if (IsTransparent()) {
// When using transparency mode clear the rectangle before painting.
SkPaint clearpaint;
clearpaint.setARGB(0, 0, 0, 0);
clearpaint.setXfermodeMode(SkXfermode::kClear_Mode);
SkRect skrc;
skrc.set(rect.x(), rect.y(), rect.right(), rect.bottom());
canvas_->drawRect(skrc, clearpaint);
}
set_painting(true);
webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect);
set_painting(false);
}
void WebWidgetHost::ScheduleTimer() {
if (timer_.IsRunning())
return;
// This method may be called multiple times while the timer callback is
// executing. If so re-execute this method a single time after the callback
// has completed.
if (timer_executing_) {
if (!timer_wanted_)
timer_wanted_ = true;
return;
}
// Maintain the desired rate.
base::TimeDelta delta = base::TimeTicks::Now() - timer_last_;
int64 actualRate = delta.InMilliseconds();
if (actualRate >= frame_delay_)
delta = base::TimeDelta::FromMilliseconds(1);
else
delta = base::TimeDelta::FromMilliseconds(frame_delay_ - actualRate);
timer_.Start(
FROM_HERE,
delta,
this,
&WebWidgetHost::DoTimer);
}
void WebWidgetHost::DoTimer() {
timer_executing_ = true;
if (view_) {
// Window rendering is enabled and we've received a requestAnimationFrame
// or similar call. Trigger the OS to invalidate/repaint the client area at
// the requested frequency.
InvalidateWindow();
} else {
// Window rendering is disabled. Generate OnPaint() calls at the requested
// frequency.
#if defined(OS_MACOSX)
SkRegion region;
Paint(region);
#else
Paint();
#endif
}
timer_executing_ = false;
timer_last_ = base::TimeTicks::Now();
if (timer_wanted_) {
timer_wanted_ = false;
ScheduleTimer();
}
}

View File

@@ -15,8 +15,8 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time.h" #include "base/time.h"
#include "base/timer.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
@@ -30,7 +30,7 @@
#include "ui/base/win/ime_input.h" #include "ui/base/win/ime_input.h"
#endif #endif
#if defined(TOOLKIT_USES_GTK) #if defined(TOOLKIT_GTK)
#include <gtk/gtk.h> // NOLINT(build/include_order) #include <gtk/gtk.h> // NOLINT(build/include_order)
#endif #endif
@@ -76,8 +76,9 @@ class WebWidgetHost {
gfx::NativeView view_handle() const { return view_; } gfx::NativeView view_handle() const { return view_; }
WebKit::WebWidget* webwidget() const { return webwidget_; } WebKit::WebWidget* webwidget() const { return webwidget_; }
void DidInvalidateRect(const gfx::Rect& rect); void InvalidateRect(const gfx::Rect& rect);
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
void ScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
// Called for accelerated content like WebGL. // Called for accelerated content like WebGL.
void ScheduleComposite(); void ScheduleComposite();
@@ -85,28 +86,15 @@ class WebWidgetHost {
// Called for requestAnimationFrame animations. // Called for requestAnimationFrame animations.
void ScheduleAnimation(); void ScheduleAnimation();
// Invalidate the complete client area. This is called at a reasonable frame
// rate by the Schedule*() methods.
void Invalidate();
#if defined(OS_WIN) #if defined(OS_WIN)
void SetCursor(HCURSOR cursor); void SetCursor(HCURSOR cursor);
#endif #endif
// Update the region that will be painted to the canvas by WebKit the next
// time that Paint() is called.
void UpdatePaintRect(const gfx::Rect& rect);
// Update the region that will be drawn to the device the next time Paint()
// is called. This is only used when window rendering is disabled.
void UpdateRedrawRect(const gfx::Rect& rect);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void Paint(SkRegion& update_rgn); void Paint(SkRegion& update_rgn);
#else #else
void Paint(); void Paint();
#endif #endif
void InvalidateRect(const gfx::Rect& rect);
bool GetImage(int width, int height, void* buffer); bool GetImage(int width, int height, void* buffer);
@@ -118,17 +106,18 @@ class WebWidgetHost {
WebKit::WebScreenInfo GetScreenInfo(); WebKit::WebScreenInfo GetScreenInfo();
WebKit::WebKeyboardEvent GetLastKeyEvent() const { return last_key_event_; } WebKit::WebKeyboardEvent GetLastKeyEvent() const { return last_key_event_; }
void PaintRect(const gfx::Rect& rect); void SetLastKeyEvent(WebKit::WebKeyboardEvent keyEvent)
{ last_key_event_ = keyEvent; }
void SetTooltipText(const CefString& tooltip_text); void SetTooltipText(const CefString& tooltip_text);
void SendKeyEvent(cef_key_type_t type, int key, int modifiers, bool sysChar, void SendKeyEvent(cef_key_type_t type, const cef_key_info_t& keyInfo,
bool imeChar); int modifiers);
void SendMouseClickEvent(int x, int y, cef_mouse_button_type_t type, void SendMouseClickEvent(int x, int y, cef_mouse_button_type_t type,
bool mouseUp, int clickCount); bool mouseUp, int clickCount);
void SendMouseMoveEvent(int x, int y, bool mouseLeave); void SendMouseMoveEvent(int x, int y, bool mouseLeave);
void SendMouseWheelEvent(int x, int y, int delta); void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY);
void SendFocusEvent(bool setFocus); void SendFocusEvent(bool setFocus);
void SendCaptureLostEvent(); void SendCaptureLostEvent();
@@ -139,9 +128,9 @@ class WebWidgetHost {
void MoveWindowedPlugin(const webkit::npapi::WebPluginGeometry& geometry); void MoveWindowedPlugin(const webkit::npapi::WebPluginGeometry& geometry);
gfx::PluginWindowHandle GetWindowedPluginAt(int x, int y); gfx::PluginWindowHandle GetWindowedPluginAt(int x, int y);
// If window rendering is disabled paint messages are generated after all void SetFrameRate(int frames_per_second);
// other pending messages have been processed.
void DoPaint(); virtual bool IsTransparent() { return false; }
void set_popup(bool popup) { popup_ = popup; } void set_popup(bool popup) { popup_ = popup; }
bool popup() { return popup_; } bool popup() { return popup_; }
@@ -151,11 +140,26 @@ class WebWidgetHost {
protected: protected:
WebWidgetHost(); WebWidgetHost();
// Update the region that will be painted to the canvas by WebKit the next
// time that Paint() is called.
void UpdatePaintRect(const gfx::Rect& rect);
void PaintRect(const gfx::Rect& rect);
// Trigger the OS to invalidate/repaint the window.
void InvalidateWindow();
void InvalidateWindowRect(const gfx::Rect& rect);
// When window rendering is enabled this method invalidates the client area to
// trigger repaint via the OS. When window rendering is disabled this method
// is used to generate CefRenderHandler::OnPaint() calls.
void ScheduleTimer();
void DoTimer();
#if defined(OS_WIN) #if defined(OS_WIN)
// Per-class wndproc. Returns true if the event should be swallowed. // Per-class wndproc. Returns true if the event should be swallowed.
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam); virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
void Resize(LPARAM lparam);
virtual void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam); virtual void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
void WheelEvent(WPARAM wparam, LPARAM lparam); void WheelEvent(WPARAM wparam, LPARAM lparam);
virtual void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam); virtual void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
@@ -173,20 +177,18 @@ class WebWidgetHost {
LRESULT OnImeEndComposition(UINT message, WPARAM wparam, LPARAM lparam, LRESULT OnImeEndComposition(UINT message, WPARAM wparam, LPARAM lparam,
BOOL& handled); BOOL& handled);
void OnInputLangChange(DWORD character_set, HKL input_language_id); void OnInputLangChange(DWORD character_set, HKL input_language_id);
void ImeUpdateTextInputState(WebKit::WebTextInputType type, void UpdateImeInputState();
const gfx::Rect& caret_rect); void ToggleImeTimer();
void UpdateInputMethod();
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// These need to be called from a non-subclass, so they need to be public. // These need to be called from a non-subclass, so they need to be public.
public: public:
void Resize(const gfx::Rect& rect);
virtual void MouseEvent(NSEvent* event); virtual void MouseEvent(NSEvent* event);
void WheelEvent(NSEvent* event); void WheelEvent(NSEvent* event);
virtual void KeyEvent(NSEvent* event); virtual void KeyEvent(NSEvent* event);
virtual void SetFocus(bool enable); virtual void SetFocus(bool enable);
protected: protected:
#elif defined(TOOLKIT_USES_GTK) #elif defined(TOOLKIT_GTK)
public: public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -200,7 +202,6 @@ class WebWidgetHost {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static gfx::NativeView CreateWidget(gfx::NativeView parent_view, static gfx::NativeView CreateWidget(gfx::NativeView parent_view,
WebWidgetHost* host); WebWidgetHost* host);
void Resize(const gfx::Size& size);
virtual void KeyEvent(GdkEventKey* event); virtual void KeyEvent(GdkEventKey* event);
#endif #endif
@@ -237,23 +238,18 @@ class WebWidgetHost {
gfx::Rect paint_rect_; gfx::Rect paint_rect_;
#endif #endif
// True if an update task is pending when window rendering is disabled. base::OneShotTimer<WebWidgetHost> timer_;
bool has_update_task_; base::TimeTicks timer_last_;
bool timer_executing_;
bool timer_wanted_;
// True if an invalidate task is pending due to the Schedule*() methods. int64 frame_delay_;
bool has_invalidate_task_;
#if defined(OS_WIN) #if defined(OS_WIN)
// True if an update input method task is pending due to DidInvalidateRect(). // Used to call UpdateImeInputState() while IME is active.
bool has_update_input_method_task_; base::RepeatingTimer<WebWidgetHost> ime_timer_;
#endif #endif
// When the Paint() method last completed.
base::TimeTicks paint_last_call_;
// Redraw rectangle requested by an explicit call to CefBrowser::Invalidate().
gfx::Rect redraw_rect_;
// The map of windowed plugins that need to be drawn when window rendering is // The map of windowed plugins that need to be drawn when window rendering is
// disabled. // disabled.
typedef std::map<gfx::PluginWindowHandle, webkit::npapi::WebPluginGeometry> typedef std::map<gfx::PluginWindowHandle, webkit::npapi::WebPluginGeometry>
@@ -269,25 +265,20 @@ class WebWidgetHost {
// Wrapper class for IME input. // Wrapper class for IME input.
ui::ImeInput ime_input_; ui::ImeInput ime_input_;
// Represents whether or not this browser process is receiving status // Represents whether or not this browser process is receiving status messages
// messages about the focused edit control from a renderer process. // about the focused edit control from a renderer process.
bool ime_notification_; bool ime_notification_;
// Represents whether or not the IME of a browser process is active. // Stores the current text input type.
bool input_method_is_active_;
// Stores the current text input type received by ImeUpdateTextInputState()
// method.
WebKit::WebTextInputType text_input_type_; WebKit::WebTextInputType text_input_type_;
// Stores the current caret bounds of input focus. // Stores the current caret bounds of input focus.
WebKit::WebRect caret_bounds_; WebKit::WebRect caret_bounds_;
#endif #endif // OS_WIN
#if defined(TOOLKIT_USES_GTK) #if defined(OS_MACOSX)
// Since GtkWindow resize is asynchronous, we have to stash the dimensions, int mouse_modifiers_;
// so that the backing store doesn't have to wait for sizing to take place. WebKit::WebMouseEvent::Button mouse_button_down_;
gfx::Size logical_size_;
#endif #endif
WebKit::WebKeyboardEvent last_key_event_; WebKit::WebKeyboardEvent last_key_event_;
@@ -295,8 +286,8 @@ class WebWidgetHost {
bool painting_; bool painting_;
bool layouting_; bool layouting_;
private: static const int kDefaultFrameRate;
base::WeakPtrFactory<WebWidgetHost> weak_factory_; static const int kMaxFrameRate;
}; };
#endif // CEF_LIBCEF_WEBWIDGET_HOST_H_ #endif // CEF_LIBCEF_WEBWIDGET_HOST_H_

View File

@@ -128,14 +128,14 @@ class WebWidgetHostGtkWidget {
static void HandleSizeAllocate(GtkWidget* widget, static void HandleSizeAllocate(GtkWidget* widget,
GtkAllocation* allocation, GtkAllocation* allocation,
WebWidgetHost* host) { WebWidgetHost* host) {
host->Resize(WebSize(allocation->width, allocation->height)); host->SetSize(allocation->width, allocation->height);
} }
// Size, position, or stacking of the GdkWindow changed. // Size, position, or stacking of the GdkWindow changed.
static gboolean HandleConfigure(GtkWidget* widget, static gboolean HandleConfigure(GtkWidget* widget,
GdkEventConfigure* config, GdkEventConfigure* config,
WebWidgetHost* host) { WebWidgetHost* host) {
host->Resize(WebSize(config->width, config->height)); host->SetSize(config->width, config->height);
return FALSE; return FALSE;
} }
@@ -146,7 +146,7 @@ class WebWidgetHostGtkWidget {
// See comments above about what g_handling_expose is for. // See comments above about what g_handling_expose is for.
g_handling_expose = true; g_handling_expose = true;
gfx::Rect rect(expose->area); gfx::Rect rect(expose->area);
host->UpdatePaintRect(rect); host->InvalidateRect(rect);
host->Paint(); host->Paint();
g_handling_expose = false; g_handling_expose = false;
return FALSE; return FALSE;
@@ -273,34 +273,10 @@ WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view,
return host; return host;
} }
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { void WebWidgetHost::ScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
UpdatePaintRect(damaged_rect);
if (!g_handling_expose) {
gtk_widget_queue_draw_area(GTK_WIDGET(view_), damaged_rect.x(),
damaged_rect.y(), damaged_rect.width(), damaged_rect.height());
}
}
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
// This is used for optimizing painting when the renderer is scrolled. We're // This is used for optimizing painting when the renderer is scrolled. We're
// currently not doing any optimizations so just invalidate the region. // currently not doing any optimizations so just invalidate the region.
DidInvalidateRect(clip_rect); InvalidateRect(clip_rect);
}
void WebWidgetHost::Invalidate() {
int width = logical_size_.width();
int height = logical_size_.height();
GdkRectangle grect = {
0,
0,
width,
height
};
GdkWindow* window = view_->window;
gdk_window_invalidate_rect(window, &grect, 0);
} }
WebWidgetHost::WebWidgetHost() WebWidgetHost::WebWidgetHost()
@@ -310,9 +286,9 @@ WebWidgetHost::WebWidgetHost()
canvas_w_(0), canvas_w_(0),
canvas_h_(0), canvas_h_(0),
popup_(false), popup_(false),
has_update_task_(false), timer_executing_(false),
has_invalidate_task_(false), timer_wanted_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { frame_delay_(1000 / kDefaultFrameRate) {
set_painting(false); set_painting(false);
} }
@@ -326,14 +302,24 @@ WebWidgetHost::~WebWidgetHost() {
// webwidget_->close(); // webwidget_->close();
} }
void WebWidgetHost::Resize(const gfx::Size &newsize) { void WebWidgetHost::InvalidateWindow() {
logical_size_ = newsize; int width, height;
SetSize(newsize.width(), newsize.height()); GetSize(width, height);
const gfx::Rect client_rect(width, height);
InvalidateWindowRect(client_rect);
}
void WebWidgetHost::InvalidateWindowRect(const gfx::Rect& rect) {
DCHECK(view_);
if (!g_handling_expose) {
gtk_widget_queue_draw_area(GTK_WIDGET(view_), rect.x(),
rect.y(), rect.width(), rect.height());
}
} }
void WebWidgetHost::Paint() { void WebWidgetHost::Paint() {
int width = logical_size_.width(); int width, height;
int height = logical_size_.height(); GetSize(width, height);
gfx::Rect client_rect(width, height); gfx::Rect client_rect(width, height);
// Number of pixels that the canvas is allowed to differ from the client area. // Number of pixels that the canvas is allowed to differ from the client area.
@@ -403,45 +389,21 @@ void WebWidgetHost::Paint() {
cairo_destroy(cairo_drawable); cairo_destroy(cairo_drawable);
gdk_window_end_paint(window); gdk_window_end_paint(window);
// Used with scheduled invalidation to maintain a consistent frame rate.
paint_last_call_ = base::TimeTicks::Now();
if (has_invalidate_task_)
has_invalidate_task_ = false;
} }
void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) { void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) {
// TODO(port): Implement this method as part of tooltip support. // TODO(port): Implement this method as part of tooltip support.
} }
void WebWidgetHost::InvalidateRect(const gfx::Rect& rect) {
// TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED();
}
bool WebWidgetHost::GetImage(int width, int height, void* rgba_buffer) {
if (!canvas_.get())
return false;
// TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED();
return false;
}
WebScreenInfo WebWidgetHost::GetScreenInfo() { WebScreenInfo WebWidgetHost::GetScreenInfo() {
Display* display = GtkWidgetGetDisplay(view_); Display* display = GtkWidgetGetDisplay(view_);
int screen_num = GtkWidgetGetScreenNum(view_); int screen_num = GtkWidgetGetScreenNum(view_);
return WebScreenInfoFactory::screenInfo(display, screen_num); return WebScreenInfoFactory::screenInfo(display, screen_num);
} }
void WebWidgetHost::PaintRect(const gfx::Rect& rect) { void WebWidgetHost::SendKeyEvent(cef_key_type_t type,
set_painting(true); const cef_key_info_t& keyInfo,
webwidget_->paint(canvas_.get(), rect); int modifiers) {
set_painting(false);
}
void WebWidgetHost::SendKeyEvent(cef_key_type_t type, int key, int modifiers,
bool sysChar, bool imeChar) {
// TODO(port): Implement this method as part of off-screen rendering support. // TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
@@ -458,7 +420,7 @@ void WebWidgetHost::SendMouseMoveEvent(int x, int y, bool mouseLeave) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void WebWidgetHost::SendMouseWheelEvent(int x, int y, int delta) { void WebWidgetHost::SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) {
// TODO(port): Implement this method as part of off-screen rendering support. // TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }

View File

@@ -3,7 +3,18 @@
// found in the LICENSE file. // found in the LICENSE file.
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "base/compiler_specific.h"
#include "third_party/WebKit/Source/WebCore/config.h"
MSVC_PUSH_WARNING_LEVEL(0);
#include "KeyEventCocoa.h" // NOLINT(build/include)
MSVC_POP_WARNING();
#undef LOG
#import "libcef/webwidget_host.h" #import "libcef/webwidget_host.h"
#include "libcef/cef_thread.h"
#include "base/bind.h"
#import "base/logging.h" #import "base/logging.h"
#import "skia/ext/platform_canvas.h" #import "skia/ext/platform_canvas.h"
#import "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFactory.h" #import "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFactory.h"
@@ -15,8 +26,8 @@
#import "third_party/skia/include/core/SkRegion.h" #import "third_party/skia/include/core/SkRegion.h"
#import "ui/gfx/rect.h" #import "ui/gfx/rect.h"
#import "ui/gfx/size.h" #import "ui/gfx/size.h"
#import "webkit/glue/webkit_glue.h"
using webkit::npapi::WebPluginGeometry;
using WebKit::WebInputEvent; using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory; using WebKit::WebInputEventFactory;
using WebKit::WebKeyboardEvent; using WebKit::WebKeyboardEvent;
@@ -46,14 +57,19 @@ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view,
PaintDelegate* paint_delegate) { PaintDelegate* paint_delegate) {
WebWidgetHost* host = new WebWidgetHost(); WebWidgetHost* host = new WebWidgetHost();
const NSRect bounds = [parent_view bounds]; if (!paint_delegate) {
host->view_ = [[NSView alloc] initWithFrame:bounds]; const NSRect bounds = [parent_view bounds];
[parent_view addSubview:host->view_]; host->view_ = [[NSView alloc] initWithFrame:bounds];
[parent_view addSubview:host->view_];
host->webwidget_ = WebPopupMenu::create(client);
host->webwidget_->resize(WebSize(NSWidth(bounds), NSHeight(bounds)));
} else {
host->paint_delegate_ = paint_delegate;
host->view_ = nil;
host->webwidget_ = WebPopupMenu::create(client);
}
host->painting_ = false;
host->layouting_ = false;
host->webwidget_ = WebPopupMenu::create(client);
host->webwidget_->resize(WebSize(NSWidth(bounds), NSHeight(bounds)));
return host; return host;
} }
@@ -64,31 +80,24 @@ WebWidgetHost::WebWidgetHost()
canvas_w_(0), canvas_w_(0),
canvas_h_(0), canvas_h_(0),
popup_(false), popup_(false),
has_update_task_(false), timer_executing_(false),
has_invalidate_task_(false), timer_wanted_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { frame_delay_(1000 / kDefaultFrameRate),
mouse_modifiers_(0),
painting_(false),
layouting_(false) {
set_painting(false); set_painting(false);
} }
WebWidgetHost::~WebWidgetHost() { WebWidgetHost::~WebWidgetHost() {
} }
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { void WebWidgetHost::ScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
const gfx::Rect client_rect(NSRectToCGRect([view_ bounds]));
const gfx::Rect damaged_rect_in_client = client_rect.Intersect(damaged_rect);
if (!damaged_rect_in_client.IsEmpty()) {
UpdatePaintRect(damaged_rect_in_client);
NSRect cocoa_rect = NSRectFromCGRect(damaged_rect_in_client.ToCGRect());
cocoa_rect.origin.y = client_rect.height() - NSMaxY(cocoa_rect);
[view_ setNeedsDisplayInRect:cocoa_rect];
}
}
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
DCHECK(dx || dy); DCHECK(dx || dy);
const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); int width, height;
GetSize(width, height);
const gfx::Rect client_rect(width, height);
gfx::Rect rect = clip_rect.Intersect(client_rect); gfx::Rect rect = clip_rect.Intersect(client_rect);
const int x = rect.x(); const int x = rect.x();
@@ -106,8 +115,9 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
// needs to be laid out; calling scrollRect:by: in this situation leads to // needs to be laid out; calling scrollRect:by: in this situation leads to
// unwanted behavior. Finally, scrolling the rectangle by more than the size // unwanted behavior. Finally, scrolling the rectangle by more than the size
// of the view means we can just invalidate the entire scroll rect. // of the view means we can just invalidate the entire scroll rect.
if (![view_ canDraw] || painting_ || layouting_ || Dx >= w || Dy >= h) { if (!view_ || [view_ canDraw] || painting_ || layouting_ || Dx >= w ||
DidInvalidateRect(clip_rect); Dy >= h) {
InvalidateRect(clip_rect);
return; return;
} }
@@ -131,7 +141,7 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
// to the screen buffer. // to the screen buffer.
rect = gfx::Rect(dx>=0? x: r - Dx, dy>=0? y: b - Dy, rect = gfx::Rect(dx>=0? x: r - Dx, dy>=0? y: b - Dy,
dx>0? Dx: w, dy>0? Dy: h); dx>0? Dx: w, dy>0? Dy: h);
DidInvalidateRect(rect); InvalidateRect(rect);
// If any part of the scrolled rect was marked as dirty make sure to redraw // If any part of the scrolled rect was marked as dirty make sure to redraw
// it in the new scrolled-to location. Otherwise we can end up with artifacts // it in the new scrolled-to location. Otherwise we can end up with artifacts
@@ -140,40 +150,54 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
SkRegion moved_paint_rgn(paint_rgn_); SkRegion moved_paint_rgn(paint_rgn_);
moved_paint_rgn.translate(dx, dy); moved_paint_rgn.translate(dx, dy);
moved_paint_rgn.op(convertToSkiaRect(client_rect), SkRegion::kIntersect_Op); moved_paint_rgn.op(convertToSkiaRect(client_rect), SkRegion::kIntersect_Op);
DidInvalidateRect(convertFromSkiaRect(moved_paint_rgn.getBounds())); InvalidateRect(convertFromSkiaRect(moved_paint_rgn.getBounds()));
} }
void WebWidgetHost::Paint(SkRegion& update_rgn) { void WebWidgetHost::Paint(SkRegion& update_rgn) {
gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); int width, height;
GetSize(width, height);
gfx::Rect client_rect(width, height);
// Union the rectangle that WebKit think needs repainting with the rectangle SkRegion damaged_rgn;
// of the view that must be painted now. In most situations this will not
// affect the painted rectangle. In some situations we could end up re-
// painting areas that are already in the canvas and only dirty in the view
// itself. However, if we don't do this we can get artifacts when scrolling
// because contents of the canvas are no longer correct after scrolling only
// in the view.
paint_rgn_.op(update_rgn, SkRegion::kUnion_Op);
// When we are not using accelerated compositing the canvas area is allowed if (view_) {
// to differ in size from the client by a certain number of pixels (128 in // Union the rectangle that WebKit think needs repainting with the rectangle
// this case). When accelerated compositing is in effect the size must match // of the view that must be painted now. In most situations this will not
// exactly. // affect the painted rectangle. In some situations we could end up re-
const int extra_w = (webwidget_->isAcceleratedCompositingActive()? 0: 128); // painting areas that are already in the canvas and only dirty in the view
const int extra_h = (webwidget_->isAcceleratedCompositingActive()? 0: 128); // itself. However, if we don't do this we can get artifacts when scrolling
const int min_w = client_rect.width(); // because contents of the canvas are no longer correct after scrolling only
const int min_h = client_rect.height(); // in the view.
const int max_w = client_rect.width() + extra_w * 2; paint_rgn_.op(update_rgn, SkRegion::kUnion_Op);
const int max_h = client_rect.height() + extra_h * 2;
const bool too_small = (canvas_w_ < min_w || canvas_h_ < min_h); // When we are not using accelerated compositing the canvas area is allowed
const bool too_large = (canvas_w_ > max_w || canvas_h_ > max_h); // to differ in size from the client by a certain number of pixels (128 in
// this case). When accelerated compositing is in effect the size must match
// exactly.
const int extra_w = (webwidget_->isAcceleratedCompositingActive()? 0: 128);
const int extra_h = (webwidget_->isAcceleratedCompositingActive()? 0: 128);
const int min_w = client_rect.width();
const int min_h = client_rect.height();
const int max_w = client_rect.width() + extra_w * 2;
const int max_h = client_rect.height() + extra_h * 2;
if (!canvas_.get() || too_small || too_large) { const bool too_small = (canvas_w_ < min_w || canvas_h_ < min_h);
canvas_w_ = client_rect.width() + extra_w; const bool too_large = (canvas_w_ > max_w || canvas_h_ > max_h);
canvas_h_ = client_rect.height() + extra_h;
canvas_.reset(new skia::PlatformCanvas(canvas_w_, canvas_h_, true)); if (!canvas_.get() || too_small || too_large) {
canvas_w_ = client_rect.width() + extra_w;
canvas_h_ = client_rect.height() + extra_h;
canvas_.reset(new skia::PlatformCanvas(canvas_w_, canvas_h_, true));
paint_rgn_.setRect(convertToSkiaRect(client_rect));
}
} else if (!canvas_.get() || canvas_w_ != client_rect.width() ||
canvas_h_ != client_rect.height()) {
paint_rgn_.setRect(convertToSkiaRect(client_rect)); paint_rgn_.setRect(convertToSkiaRect(client_rect));
// The canvas must be the exact size of the client area.
canvas_w_ = client_rect.width();
canvas_h_ = client_rect.height();
canvas_.reset(new skia::PlatformCanvas(canvas_w_, canvas_h_, true));
} }
webwidget_->animate(0.0); webwidget_->animate(0.0);
@@ -202,66 +226,83 @@ void WebWidgetHost::Paint(SkRegion& update_rgn) {
draw_rgn.swap(paint_rgn_); draw_rgn.swap(paint_rgn_);
SkRegion::Cliperator iterator(draw_rgn, convertToSkiaRect(client_rect)); SkRegion::Cliperator iterator(draw_rgn, convertToSkiaRect(client_rect));
for (; !iterator.done(); iterator.next()) for (; !iterator.done(); iterator.next()) {
PaintRect(convertFromSkiaRect(iterator.rect())); const SkIRect& r = iterator.rect();
PaintRect(convertFromSkiaRect(r));
// If any more rectangles were made dirty during the paint operation, make if (!view_)
// sure they are copied to the window buffer, by including the paint region. damaged_rgn.op(r, SkRegion::kUnion_Op);
// If nothing needs additional painting, this is a no-op. }
update_rgn.op(paint_rgn_, SkRegion::kUnion_Op);
if (view_) {
// If any more rectangles were made dirty during the paint operation, make
// sure they are copied to the window buffer, by including the paint
// region. If nothing needs additional painting, this is a no-op.
update_rgn.op(paint_rgn_, SkRegion::kUnion_Op);
}
}
if (!view_ && plugin_map_.size() > 0) {
// Flash seems to stop calling NPN_InvalidateRect, which means we stop
// painting. If we've got a plugin make sure we paint its rect each time.
PluginMap::const_iterator it = plugin_map_.begin();
for (; it != plugin_map_.end(); ++it) {
if (it->second.visible &&
client_rect.Intersects(it->second.window_rect)) {
const WebPluginGeometry* geom = &it->second;
damaged_rgn.op(convertToSkiaRect(geom->window_rect),
SkRegion::kUnion_Op);
}
}
} }
// Set the context back to our view and copy the bitmap that we just painted if (view_) {
// into to the view. Only the regions that were updated are copied. // Set the context back to our view and copy the bitmap that we just painted
[NSGraphicsContext restoreGraphicsState]; // into to the view. Only the regions that were updated are copied.
NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; [NSGraphicsContext restoreGraphicsState];
CGContextRef context = static_cast<CGContextRef>([view_context graphicsPort]); NSGraphicsContext* view_context = [NSGraphicsContext currentContext];
CGContextRef context =
static_cast<CGContextRef>([view_context graphicsPort]);
SkRegion::Cliperator iterator(update_rgn, convertToSkiaRect(client_rect)); SkRegion::Cliperator iterator(update_rgn, convertToSkiaRect(client_rect));
for (; !iterator.done(); iterator.next()) { for (; !iterator.done(); iterator.next()) {
const SkIRect& r = iterator.rect(); const SkIRect& r = iterator.rect();
CGRect copy_rect = { { r.x(), r.y() }, { r.width(), r.height() } }; CGRect copy_rect = { { r.x(), r.y() }, { r.width(), r.height() } };
const float x = r.x(); const float x = r.x();
const float y = client_rect.height() - r.bottom(); const float y = client_rect.height() - r.bottom();
skia::DrawToNativeContext(canvas_.get(), context, x, y, &copy_rect); skia::DrawToNativeContext(canvas_.get(), context, x, y, &copy_rect);
}
} else {
if (damaged_rgn.isEmpty())
return;
// Paint to the delegate.
DCHECK(paint_delegate_);
const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false);
DCHECK(bitmap.config() == SkBitmap::kARGB_8888_Config);
const void* pixels = bitmap.getPixels();
std::vector<CefRect> damaged_rects;
SkRegion::Cliperator iterator(damaged_rgn, convertToSkiaRect(client_rect));
for (; !iterator.done(); iterator.next()) {
const SkIRect& r = iterator.rect();
damaged_rects.push_back(
CefRect(r.left(), r.top(), r.width(), r.height()));
}
paint_delegate_->Paint(popup_, damaged_rects, pixels);
} }
// Used with scheduled invalidation to maintain a consistent frame rate.
paint_last_call_ = base::TimeTicks::Now();
if (has_invalidate_task_)
has_invalidate_task_ = false;
}
void WebWidgetHost::Invalidate() {
[view_ setNeedsDisplay:YES];
} }
void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) { void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) {
// TODO(port): Implement this method as part of tooltip support. // TODO(port): Implement this method as part of tooltip support.
} }
void WebWidgetHost::InvalidateRect(const gfx::Rect& rect) {
// TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED();
}
bool WebWidgetHost::GetImage(int width, int height, void* rgba_buffer) {
if (!canvas_.get())
return false;
// TODO(port): Implement this method as part of off-screen rendering support.
NOTIMPLEMENTED();
return false;
}
WebScreenInfo WebWidgetHost::GetScreenInfo() { WebScreenInfo WebWidgetHost::GetScreenInfo() {
return WebScreenInfoFactory::screenInfo(view_); return WebScreenInfoFactory::screenInfo(view_);
} }
void WebWidgetHost::Resize(const gfx::Rect& rect) {
SetSize(rect.width(), rect.height());
}
void WebWidgetHost::MouseEvent(NSEvent *event) { void WebWidgetHost::MouseEvent(NSEvent *event) {
const WebMouseEvent& web_event = WebInputEventFactory::mouseEvent( const WebMouseEvent& web_event = WebInputEventFactory::mouseEvent(
event, view_); event, view_);
@@ -277,93 +318,217 @@ void WebWidgetHost::KeyEvent(NSEvent *event) {
WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event)); WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event));
last_key_event_ = keyboard_event; last_key_event_ = keyboard_event;
webwidget_->handleInputEvent(keyboard_event); webwidget_->handleInputEvent(keyboard_event);
if ([event type] != NSKeyDown)
return;
if ([event modifierFlags] & (NSNumericPadKeyMask | NSFunctionKeyMask)) {
// Don't send a Char event for non-char keys like arrows, function keys and
// clear.
switch ([event keyCode]) {
case 81: // =
case 75: // /
case 67: // *
case 78: // -
case 69: // +
case 76: // Enter
case 65: // .
case 82: // 0
case 83: // 1
case 84: // 2
case 85: // 3
case 86: // 4
case 87: // 5
case 88: // 6
case 89: // 7
case 91: // 8
case 92: // 9
break;
default:
return;
}
}
// Send a Char event here to emulate the keyboard events.
// TODO(hbono): Bug 20852 <http://crbug.com/20852> implement the NSTextInput
// protocol and remove this code.
keyboard_event.type = WebInputEvent::Char;
last_key_event_ = keyboard_event;
webwidget_->handleInputEvent(keyboard_event);
} }
void WebWidgetHost::SetFocus(bool enable) { void WebWidgetHost::SetFocus(bool enable) {
webwidget_->setFocus(enable); webwidget_->setFocus(enable);
} }
void WebWidgetHost::PaintRect(const gfx::Rect& rect) { void WebWidgetHost::SendKeyEvent(cef_key_type_t type,
#ifndef NDEBUG const cef_key_info_t& keyInfo,
DCHECK(!painting_); int modifiers) {
#endif WebKeyboardEvent event;
DCHECK(canvas_.get());
if (!rect.IsEmpty()) { switch (type) {
set_painting(true); case KT_KEYUP:
webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); default:
set_painting(false); event.type = WebInputEvent::KeyUp;
break;
case KT_KEYDOWN:
event.type = WebInputEvent::RawKeyDown;
break;
case KT_CHAR:
event.type = WebInputEvent::Char;
break;
} }
} event.timeStampSeconds = TickCount();
void WebWidgetHost::SendKeyEvent(cef_key_type_t type, int key, int modifiers, if (modifiers & KEY_SHIFT)
bool sysChar, bool imeChar) { event.modifiers |= WebInputEvent::ShiftKey;
// TODO(port): Implement this method as part of off-screen rendering support. if (modifiers & KEY_ALT)
NOTIMPLEMENTED(); event.modifiers |= WebInputEvent::AltKey;
if (modifiers & KEY_CTRL)
event.modifiers |= WebInputEvent::ControlKey;
if (modifiers & KEY_META)
event.modifiers |= WebInputEvent::MetaKey;
if (modifiers & KEY_KEYPAD)
event.modifiers |= WebInputEvent::IsKeyPad;
// There are several kinds of characters for which we produce key code from
// char code:
// 1. Roman letters. Windows keyboard layouts affect both virtual key codes
// and character codes for these, so e.g. 'A' gets the same keyCode on
// QWERTY, AZERTY or Dvorak layouts.
// 2. Keys for which there is no known Mac virtual key codes, like
// PrintScreen.
// 3. Certain punctuation keys. On Windows, these are also remapped depending
// on current keyboard layout, but see comment in
// windowsKeyCodeForCharCode().
if (type == KT_KEYUP || type == KT_KEYDOWN) {
if (keyInfo.character != 0) {
// Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified
// characters first.
event.windowsKeyCode =
WebCore::windowsKeyCodeForCharCode(keyInfo.character);
}
if (event.windowsKeyCode == 0 && keyInfo.characterNoModifiers != 0) {
// Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on
// keyInfo.keyCode below.
event.windowsKeyCode =
WebCore::windowsKeyCodeForCharCode(keyInfo.characterNoModifiers);
}
}
if (event.windowsKeyCode == 0) {
// Map Mac virtual key code directly to Windows one for any keys not handled
// above. E.g. the key next to Caps Lock has the same Event.keyCode on U.S.
// keyboard ('A') and on Russian keyboard (CYRILLIC LETTER EF).
event.windowsKeyCode = WebCore::windowsKeyCodeForKeyCode(keyInfo.keyCode);
}
event.nativeKeyCode = keyInfo.keyCode;
int textChar = keyInfo.character;
int unmodifiedChar = keyInfo.characterNoModifiers;
// Always use 13 for Enter/Return -- we don't want to use AppKit's
// different character for Enter.
if (event.windowsKeyCode == '\r') {
textChar = '\r';
unmodifiedChar = '\r';
}
// The adjustments below are only needed in backward compatibility mode,
// but we cannot tell what mode we are in from here.
// Turn 0x7F into 8, because backspace needs to always be 8.
if (textChar == '\x7F')
textChar = '\x8';
if (unmodifiedChar == '\x7F')
unmodifiedChar = '\x8';
// Always use 9 for tab -- we don't want to use AppKit's different character
// for shift-tab.
if (event.windowsKeyCode == 9) {
textChar = '\x9';
unmodifiedChar = '\x9';
}
event.text[0] = textChar;
event.unmodifiedText[0] = unmodifiedChar;
event.setKeyIdentifierFromWindowsKeyCode();
event.isSystemKey = !!(modifiers & KEY_META);
last_key_event_ = event;
webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::SendMouseClickEvent(int x, int y, void WebWidgetHost::SendMouseClickEvent(int x, int y,
cef_mouse_button_type_t type, cef_mouse_button_type_t type,
bool mouseUp, int clickCount) { bool mouseUp, int clickCount) {
// TODO(port): Implement this method as part of off-screen rendering support. WebMouseEvent event;
NOTIMPLEMENTED();
switch(type) {
case MBT_LEFT:
event.button = WebMouseEvent::ButtonLeft;
event.modifiers |= WebInputEvent::LeftButtonDown;
break;
case MBT_MIDDLE:
event.button = WebMouseEvent::ButtonMiddle;
event.modifiers |= WebInputEvent::MiddleButtonDown;
break;
case MBT_RIGHT:
event.button = WebMouseEvent::ButtonRight;
event.modifiers |= WebInputEvent::RightButtonDown;
break;
}
if (mouseUp)
event.type = WebInputEvent::MouseUp;
else
event.type = WebInputEvent::MouseDown;
event.clickCount = clickCount;
event.timeStampSeconds = TickCount();
event.x = x;
event.y = y;
event.windowX = event.x;
event.windowY = event.y;
if (mouseUp) {
mouse_button_down_ = WebMouseEvent::ButtonNone;
mouse_modifiers_ &= ~event.modifiers;
} else {
mouse_modifiers_ |= event.modifiers;
mouse_button_down_ = event.button;
}
event.modifiers = mouse_modifiers_;
webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::SendMouseMoveEvent(int x, int y, bool mouseLeave) { void WebWidgetHost::SendMouseMoveEvent(int x, int y, bool mouseLeave) {
// TODO(port): Implement this method as part of off-screen rendering support. WebMouseEvent event;
NOTIMPLEMENTED();
event.type = WebInputEvent::MouseMove;
event.timeStampSeconds = TickCount();
event.button = mouse_button_down_;
event.x = x;
event.y = y;
event.windowX = event.x;
event.windowY = event.y;
event.modifiers = mouse_modifiers_;
webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::SendMouseWheelEvent(int x, int y, int delta) { void WebWidgetHost::SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) {
// TODO(port): Implement this method as part of off-screen rendering support. WebMouseWheelEvent event;
NOTIMPLEMENTED();
// Conversion between wheel delta amounts and number of pixels to scroll.
static const double scrollbarPixelsPerCocoaTick = 40.0;
event.type = WebInputEvent::MouseWheel;
event.timeStampSeconds = TickCount();
event.button = WebMouseEvent::ButtonNone;
event.deltaX = static_cast<float>(deltaX);
event.deltaY = static_cast<float>(deltaY);
event.wheelTicksX = static_cast<float>(deltaX/scrollbarPixelsPerCocoaTick);
event.wheelTicksY = static_cast<float>(deltaY/scrollbarPixelsPerCocoaTick);
event.hasPreciseScrollingDeltas = true;
event.x = x;
event.y = y;
event.windowX = event.x;
event.windowY = event.y;
webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::SendFocusEvent(bool setFocus) { void WebWidgetHost::SendFocusEvent(bool setFocus) {
// TODO(port): Implement this method as part of off-screen rendering support. SetFocus(setFocus);
NOTIMPLEMENTED();
} }
void WebWidgetHost::SendCaptureLostEvent() { void WebWidgetHost::SendCaptureLostEvent() {
// TODO(port): Implement this method as part of off-screen rendering support. }
NOTIMPLEMENTED();
void WebWidgetHost::InvalidateWindow() {
DCHECK(view_);
[view_ setNeedsDisplay:YES];
}
void WebWidgetHost::InvalidateWindowRect(const gfx::Rect& rect) {
DCHECK(view_);
int width, height;
GetSize(width, height);
const gfx::Rect client_rect(width, height);
NSRect cocoa_rect = NSRectFromCGRect(rect.ToCGRect());
cocoa_rect.origin.y = client_rect.height() - NSMaxY(cocoa_rect);
[view_ setNeedsDisplayInRect:cocoa_rect];
} }
void WebWidgetHost::EnsureTooltip() { void WebWidgetHost::EnsureTooltip() {

View File

@@ -7,6 +7,7 @@
#include <commctrl.h> #include <commctrl.h>
#include "libcef/webwidget_host.h" #include "libcef/webwidget_host.h"
#include "libcef/browser_impl.h"
#include "libcef/cef_thread.h" #include "libcef/cef_thread.h"
#include "base/bind.h" #include "base/bind.h"
@@ -19,7 +20,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h" #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h" #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h"
#include "third_party/skia/include/core/SkRegion.h" #include "third_party/skia/include/core/SkRegion.h"
@@ -29,6 +29,9 @@
#include "ui/gfx/gdi_util.h" #include "ui/gfx/gdi_util.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
using webkit::npapi::WebPluginGeometry; using webkit::npapi::WebPluginGeometry;
using WebKit::WebInputEvent; using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory; using WebKit::WebInputEventFactory;
@@ -98,7 +101,6 @@ WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
0, 0, 0, 0, 0, 0, 0, 0,
parent_view, NULL, GetModuleHandle(NULL), parent_view, NULL, GetModuleHandle(NULL),
NULL); NULL);
ui::SetWindowUserData(host->view_, host); ui::SetWindowUserData(host->view_, host);
} else { } else {
host->paint_delegate_ = paint_delegate; host->paint_delegate_ = paint_delegate;
@@ -131,9 +133,12 @@ LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
// during painting. // during painting.
return 0; return 0;
case WM_SIZE: case WM_SIZE: {
host->Resize(lparam); int width = LOWORD(lparam);
int height = HIWORD(lparam);
host->SetSize(width, height);
return 0; return 0;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
@@ -158,7 +163,7 @@ LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
{ {
// Only send mouse wheel events if the cursor is over the window. // Only send mouse wheel events if the cursor is over the window.
POINT mousePt = { LOWORD(lparam), HIWORD(lparam) }; POINT mousePt = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
RECT wndRect; RECT wndRect;
GetWindowRect(hwnd, &wndRect); GetWindowRect(hwnd, &wndRect);
if (PtInRect(&wndRect, mousePt)) if (PtInRect(&wndRect, mousePt))
@@ -263,37 +268,18 @@ LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
return DefWindowProc(hwnd, message, wparam, lparam); return DefWindowProc(hwnd, message, wparam, lparam);
} }
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { void WebWidgetHost::ScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
// If this invalidate overlaps with a pending scroll then we have to downgrade
// to invalidating the scroll rect.
UpdatePaintRect(damaged_rect);
InvalidateRect(damaged_rect);
if (!popup_ && view_ && webwidget_ && input_method_is_active_ &&
!has_update_input_method_task_) {
has_update_input_method_task_ = true;
// Call UpdateInputMethod() approximately every 100ms.
CefThread::PostDelayedTask(CefThread::UI, FROM_HERE,
base::Bind(&WebWidgetHost::UpdateInputMethod,
weak_factory_.GetWeakPtr()),
100);
}
}
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
DCHECK(dx || dy); DCHECK(dx || dy);
// Invalidate and re-paint the entire scroll rect if: // Invalidate and re-paint the entire scroll rect if:
// 1. We're in a state where we cannot draw into the view right now, or // 1. Window rendering is disabled, or
// 2. The rect is being scrolled by more than the size of the view, or // 2. We're in a state where we cannot draw into the view right now, or
// 3. The scroll rect intersects the current paint region. // 3. The rect is being scrolled by more than the size of the view, or
if (!canvas_.get() || layouting_ || painting_ || // 4. The scroll rect intersects the current paint region.
if (!view_ || !canvas_.get() || layouting_ || painting_ ||
abs(dx) >= clip_rect.width() || abs(dy) >= clip_rect.height() || abs(dx) >= clip_rect.width() || abs(dy) >= clip_rect.height() ||
paint_rgn_.intersects(convertToSkiaRect(clip_rect))) { paint_rgn_.intersects(convertToSkiaRect(clip_rect))) {
DidInvalidateRect(clip_rect); InvalidateRect(clip_rect);
return; return;
} }
@@ -309,14 +295,8 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
// Invalidate the scroll rect. It will be drawn from the canvas bitmap on the // Invalidate the scroll rect. It will be drawn from the canvas bitmap on the
// next WM_PAINT call. // next WM_PAINT call.
InvalidateRect(clip_rect); RECT r = clip_rect.ToRECT();
} ::InvalidateRect(view_, &r, FALSE);
void WebWidgetHost::Invalidate() {
if (!webwidget_)
return;
WebSize size = webwidget_->size();
InvalidateRect(gfx::Rect(0, 0, size.width, size.height));
} }
void WebWidgetHost::SetCursor(HCURSOR cursor) { void WebWidgetHost::SetCursor(HCURSOR cursor) {
@@ -333,26 +313,40 @@ WebWidgetHost::WebWidgetHost()
canvas_w_(0), canvas_w_(0),
canvas_h_(0), canvas_h_(0),
popup_(false), popup_(false),
timer_executing_(false),
timer_wanted_(false),
track_mouse_leave_(false), track_mouse_leave_(false),
has_update_task_(false), frame_delay_(1000 / kDefaultFrameRate),
has_invalidate_task_(false),
has_update_input_method_task_(false),
tooltip_view_(NULL), tooltip_view_(NULL),
tooltip_showing_(false), tooltip_showing_(false),
ime_notification_(false), ime_notification_(false),
input_method_is_active_(false),
layouting_(false), layouting_(false),
text_input_type_(WebKit::WebTextInputTypeNone), text_input_type_(WebKit::WebTextInputTypeNone) {
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
set_painting(false); set_painting(false);
} }
WebWidgetHost::~WebWidgetHost() { WebWidgetHost::~WebWidgetHost() {
if (view_)
ui::SetWindowUserData(view_, 0);
TrackMouseLeave(false); TrackMouseLeave(false);
ResetTooltip(); ResetTooltip();
if (view_) {
ui::SetWindowUserData(view_, 0);
view_ = NULL;
}
}
void WebWidgetHost::InvalidateWindow() {
int width, height;
GetSize(width, height);
const gfx::Rect client_rect(width, height);
InvalidateWindowRect(client_rect);
}
void WebWidgetHost::InvalidateWindowRect(const gfx::Rect& rect) {
DCHECK(view_);
RECT r = rect.ToRECT();
::InvalidateRect(view_, &r, FALSE);
} }
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
@@ -375,12 +369,6 @@ void WebWidgetHost::Paint() {
// Damaged rectangle used for drawing when window rendering is disabled. // Damaged rectangle used for drawing when window rendering is disabled.
SkRegion damaged_rgn; SkRegion damaged_rgn;
if (!view_ && !redraw_rect_.IsEmpty()) {
// At a minimum we need to send the delegate the rectangle that was
// requested by calling CefBrowser::InvalidateRect().
damaged_rgn.setRect(convertToSkiaRect(redraw_rect_));
redraw_rect_ = gfx::Rect();
}
if (view_ && !webwidget_->isAcceleratedCompositingActive()) { if (view_ && !webwidget_->isAcceleratedCompositingActive()) {
// Number of pixels that the canvas is allowed to differ from the client // Number of pixels that the canvas is allowed to differ from the client
@@ -508,6 +496,9 @@ void WebWidgetHost::Paint() {
// Draw children // Draw children
UpdateWindow(view_); UpdateWindow(view_);
} else { } else {
if (damaged_rgn.isEmpty())
return;
// Paint to the delegate. // Paint to the delegate.
DCHECK(paint_delegate_); DCHECK(paint_delegate_);
const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false); const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false);
@@ -524,67 +515,12 @@ void WebWidgetHost::Paint() {
paint_delegate_->Paint(popup_, damaged_rects, pixels); paint_delegate_->Paint(popup_, damaged_rects, pixels);
} }
// Used with scheduled invalidation to maintain a consistent frame rate.
paint_last_call_ = base::TimeTicks::Now();
if (has_invalidate_task_)
has_invalidate_task_ = false;
}
void WebWidgetHost::InvalidateRect(const gfx::Rect& rect) {
if (rect.IsEmpty())
return;
if (view_) {
// Let the window handle painting.
RECT r = rect.ToRECT();
::InvalidateRect(view_, &r, FALSE);
} else {
// Don't post a paint task if this invalidation occurred during layout or if
// a paint task is already pending. Paint() will be called by DoPaint().
if (!layouting_ && !has_update_task_) {
has_update_task_ = true;
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&WebWidgetHost::DoPaint, weak_factory_.GetWeakPtr()));
}
}
}
bool WebWidgetHost::GetImage(int width, int height, void* buffer) {
const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false);
DCHECK(bitmap.config() == SkBitmap::kARGB_8888_Config);
if (width == canvas_->getDevice()->width() &&
height == canvas_->getDevice()->height()) {
// The specified width and height values are the same as the canvas size.
// Return the existing canvas contents.
const void* pixels = bitmap.getPixels();
memcpy(buffer, pixels, width * height * 4);
return true;
}
// Create a new canvas of the requested size.
scoped_ptr<skia::PlatformCanvas> new_canvas(
new skia::PlatformCanvas(width, height, true));
new_canvas->writePixels(bitmap, 0, 0);
const SkBitmap& new_bitmap = new_canvas->getDevice()->accessBitmap(false);
DCHECK(new_bitmap.config() == SkBitmap::kARGB_8888_Config);
// Return the new canvas contents.
const void* pixels = new_bitmap.getPixels();
memcpy(buffer, pixels, width * height * 4);
return true;
} }
WebScreenInfo WebWidgetHost::GetScreenInfo() { WebScreenInfo WebWidgetHost::GetScreenInfo() {
return WebScreenInfoFactory::screenInfo(view_); return WebScreenInfoFactory::screenInfo(view_);
} }
void WebWidgetHost::Resize(LPARAM lparam) {
SetSize(LOWORD(lparam), HIWORD(lparam));
}
void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
const WebMouseEvent& event = WebInputEventFactory::mouseEvent( const WebMouseEvent& event = WebInputEventFactory::mouseEvent(
view_, message, wparam, lparam); view_, message, wparam, lparam);
@@ -598,11 +534,24 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
case WebInputEvent::MouseDown: case WebInputEvent::MouseDown:
if (!popup()) { if (!popup()) {
SetCapture(view_); SetCapture(view_);
// This mimics a temporary workaround in RenderWidgetHostViewWin
// for bug 765011 to get focus when the mouse is clicked. This if (::GetFocus() != view_) {
// happens after the mouse down event is sent to the renderer // Set focus to this window.
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN. HWND parent_hwnd = ::GetParent(view_);
::SetFocus(view_); if (parent_hwnd) {
CefRefPtr<CefBrowserImpl> browser =
static_cast<CefBrowserImpl*>(
ui::GetWindowUserData(parent_hwnd));
if (browser.get()) {
// This mimics a temporary workaround in RenderWidgetHostViewWin
// for bug 765011 to get focus when the mouse is clicked. This
// happens after the mouse down event is sent to the renderer
// because normally Windows does a WM_SETFOCUS after
// WM_LBUTTONDOWN.
browser->SetFocus(true);
}
}
}
} }
break; break;
case WebInputEvent::MouseUp: case WebInputEvent::MouseUp:
@@ -740,52 +689,31 @@ void WebWidgetHost::TrackMouseLeave(bool track) {
TrackMouseEvent(&tme); TrackMouseEvent(&tme);
} }
void WebWidgetHost::PaintRect(const gfx::Rect& rect) { void WebWidgetHost::SendKeyEvent(cef_key_type_t type,
#ifndef NDEBUG const cef_key_info_t& keyInfo,
DCHECK(!painting_); int modifiers) {
#endif
DCHECK(canvas_.get());
if (!popup() && ((WebKit::WebView*)webwidget_)->isTransparent()) {
// When using transparency mode clear the rectangle before painting.
SkPaint clearpaint;
clearpaint.setARGB(0, 0, 0, 0);
clearpaint.setXfermodeMode(SkXfermode::kClear_Mode);
SkRect skrc;
skrc.set(rect.x(), rect.y(), rect.right(), rect.bottom());
canvas_->drawRect(skrc, clearpaint);
}
set_painting(true);
webwidget_->paint(canvas_.get(), rect);
set_painting(false);
}
void WebWidgetHost::SendKeyEvent(cef_key_type_t type, int key, int modifiers,
bool sysChar, bool imeChar) {
UINT message = 0; UINT message = 0;
WPARAM wparam = key; WPARAM wparam = keyInfo.key;
LPARAM lparam = modifiers; LPARAM lparam = modifiers;
if (type == KT_KEYUP) { if (type == KT_KEYUP) {
if (sysChar) if (keyInfo.sysChar)
message = WM_SYSKEYUP; message = WM_SYSKEYUP;
else if (imeChar) else if (keyInfo.imeChar)
message = WM_IME_KEYUP; message = WM_IME_KEYUP;
else else
message = WM_KEYUP; message = WM_KEYUP;
} else if (type == KT_KEYDOWN) { } else if (type == KT_KEYDOWN) {
if (sysChar) if (keyInfo.sysChar)
message = WM_SYSKEYDOWN; message = WM_SYSKEYDOWN;
else if (imeChar) else if (keyInfo.imeChar)
message = WM_IME_KEYDOWN; message = WM_IME_KEYDOWN;
else else
message = WM_KEYDOWN; message = WM_KEYDOWN;
} else if (type == KT_CHAR) { } else if (type == KT_CHAR) {
if (sysChar) if (keyInfo.sysChar)
message = WM_SYSCHAR; message = WM_SYSCHAR;
else if (imeChar) else if (keyInfo.imeChar)
message = WM_IME_CHAR; message = WM_IME_CHAR;
else else
message = WM_CHAR; message = WM_CHAR;
@@ -888,8 +816,8 @@ void WebWidgetHost::SendMouseMoveEvent(int x, int y, bool mouseLeave) {
} }
} }
void WebWidgetHost::SendMouseWheelEvent(int x, int y, int delta) { void WebWidgetHost::SendMouseWheelEvent(int x, int y, int deltaX, int deltaY) {
WPARAM wparam = MAKEWPARAM(0, delta); WPARAM wparam = MAKEWPARAM(0, deltaY);
LPARAM lparam = MAKELPARAM(x, y); LPARAM lparam = MAKELPARAM(x, y);
if (GetKeyState(VK_CONTROL) & 0x8000) if (GetKeyState(VK_CONTROL) & 0x8000)
@@ -926,26 +854,22 @@ LRESULT WebWidgetHost::OnImeSetContext(UINT message, WPARAM wparam,
if (!webwidget_) if (!webwidget_)
return 0; return 0;
// We need status messages about the focused input control from a // We need to start the IME timer when:
// renderer process when:
// * the current input context has IMEs, and; // * the current input context has IMEs, and;
// * an application is activated. // * an application is activated.
// This seems to tell we should also check if the current input context has // This seems to indicate that we should also check if the current input
// IMEs before sending a request, however, this WM_IME_SETCONTEXT is // context has IMEs before starting the timer, however, this WM_IME_SETCONTEXT
// fortunately sent to an application only while the input context has IMEs. // is fortunately sent to an application only while the input context has
// Therefore, we just start/stop status messages according to the activation // IMEs. Therefore, we just start/stop the timer according to the activation
// status of this application without checks. // status of this application without checks.
bool activated = (wparam == TRUE); ime_notification_ = (wparam == TRUE);
if (webwidget_) {
input_method_is_active_ = activated;
ime_notification_ = activated;
}
if (ime_notification_) if (ime_notification_)
ime_input_.CreateImeWindow(view_); ime_input_.CreateImeWindow(view_);
ime_input_.CleanupComposition(view_); ime_input_.CleanupComposition(view_);
ime_input_.SetImeWindowStyle(view_, message, wparam, lparam, &handled); ime_input_.SetImeWindowStyle(view_, message, wparam, lparam, &handled);
ToggleImeTimer();
return 0; return 0;
} }
@@ -979,7 +903,7 @@ LRESULT WebWidgetHost::OnImeComposition(UINT message, WPARAM wparam,
ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff);
// Retrieve the result string and its attributes of the ongoing composition // Retrieve the result string and its attributes of the ongoing composition
// and send it to a renderer process. // and send to WebKit.
ui::CompositionText composition; ui::CompositionText composition;
if (ime_input_.GetResult(view_, lparam, &composition.text)) { if (ime_input_.GetResult(view_, lparam, &composition.text)) {
webwidget_->setComposition(composition.text, webwidget_->setComposition(composition.text,
@@ -993,14 +917,12 @@ LRESULT WebWidgetHost::OnImeComposition(UINT message, WPARAM wparam,
// by the start of another composition. // by the start of another composition.
} }
// Retrieve the composition string and its attributes of the ongoing // Retrieve the composition string and its attributes of the ongoing
// composition and send it to a renderer process. // composition and send to WebKit.
if (ime_input_.GetComposition(view_, lparam, &composition)) { if (ime_input_.GetComposition(view_, lparam, &composition)) {
// TODO(suzhe): due to a bug of webkit, we can't use selection range with // TODO(suzhe): due to a bug of webkit, we can't use selection range with
// composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788
composition.selection = ui::Range(composition.selection.end()); composition.selection = ui::Range(composition.selection.end());
// TODO(suzhe): convert both renderer_host and renderer to use
// ui::CompositionText.
const std::vector<WebKit::WebCompositionUnderline>& underlines = const std::vector<WebKit::WebCompositionUnderline>& underlines =
reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>(
composition.underlines); composition.underlines);
@@ -1022,8 +944,8 @@ LRESULT WebWidgetHost::OnImeEndComposition(UINT message, WPARAM wparam,
if (ime_input_.is_composing()) { if (ime_input_.is_composing()) {
// A composition has been ended while there is an ongoing composition, // A composition has been ended while there is an ongoing composition,
// i.e. the ongoing composition has been canceled. // i.e. the ongoing composition has been canceled.
// We need to reset the composition status both of the ImeInput object and // Reset the composition status of both of the ImeInput object and the
// of the renderer process. // window.
ime_input_.CancelIME(view_); ime_input_.CancelIME(view_);
ime_input_.ResetComposition(view_); ime_input_.ResetComposition(view_);
} }
@@ -1035,44 +957,32 @@ LRESULT WebWidgetHost::OnImeEndComposition(UINT message, WPARAM wparam,
void WebWidgetHost::OnInputLangChange(DWORD character_set, void WebWidgetHost::OnInputLangChange(DWORD character_set,
HKL input_language_id) { HKL input_language_id) {
if (!webwidget_)
return;
// Send the given Locale ID to the ImeInput object and retrieves whether // Send the given Locale ID to the ImeInput object and retrieves whether
// or not the current input context has IMEs. // or not the current input context has IMEs. Toggle the timer based on
// If the current input context has IMEs, a browser process has to send a // whether the current input context has IMEs.
// request to a renderer process that it needs status messages about
// the focused edit control from the renderer process.
// On the other hand, if the current input context does not have IMEs, the
// browser process also has to send a request to the renderer process that
// it does not need the status messages any longer.
// To minimize the number of this notification request, we should check if
// the browser process is actually retrieving the status messages (this
// state is stored in ime_notification_) and send a request only if the
// browser process has to update this status, its details are listed below:
// * If a browser process is not retrieving the status messages,
// (i.e. ime_notification_ == false),
// send this request only if the input context does have IMEs,
// (i.e. ime_status == true);
// When it successfully sends the request, toggle its notification status,
// (i.e.ime_notification_ = !ime_notification_ = true).
// * If a browser process is retrieving the status messages
// (i.e. ime_notification_ == true),
// send this request only if the input context does not have IMEs,
// (i.e. ime_status == false).
// When it successfully sends the request, toggle its notification status,
// (i.e.ime_notification_ = !ime_notification_ = false).
// To analyze the above actions, we can optimize them into the ones
// listed below:
// 1 Sending a request only if ime_status_ != ime_notification_, and;
// 2 Copying ime_status to ime_notification_ if it sends the request
// successfully (because Action 1 shows ime_status = !ime_notification_.)
bool ime_status = ime_input_.SetInputLanguage(); bool ime_status = ime_input_.SetInputLanguage();
if (ime_status != ime_notification_ && webwidget_) { if (ime_status != ime_notification_) {
input_method_is_active_ = ime_status;
ime_notification_ = ime_status; ime_notification_ = ime_status;
ToggleImeTimer();
} }
} }
void WebWidgetHost::ImeUpdateTextInputState(WebKit::WebTextInputType type, void WebWidgetHost::UpdateImeInputState() {
const gfx::Rect& caret_rect) { if (!webwidget_ || !ime_notification_) {
ToggleImeTimer();
return;
}
WebKit::WebTextInputType type = webwidget_->textInputType();
WebKit::WebRect caret_bounds;
WebKit::WebRect startRect, endRect;
if (webwidget_->selectionBounds(startRect, endRect))
caret_bounds = endRect;
if (text_input_type_ != type) { if (text_input_type_ != type) {
text_input_type_ = type; text_input_type_ = type;
if (type == WebKit::WebTextInputTypeText) if (type == WebKit::WebTextInputTypeText)
@@ -1081,31 +991,24 @@ void WebWidgetHost::ImeUpdateTextInputState(WebKit::WebTextInputType type,
ime_input_.DisableIME(view_); ime_input_.DisableIME(view_);
} }
// Only update caret position if the input method is enabled. // Only update caret position if the input method is enabled and the caret
if (type == WebKit::WebTextInputTypeText) // position has changed.
ime_input_.UpdateCaretRect(view_, caret_rect); if (type == WebKit::WebTextInputTypeText && caret_bounds != caret_bounds_) {
} caret_bounds_ = caret_bounds;
ime_input_.UpdateCaretRect(view_, caret_bounds);
void WebWidgetHost::UpdateInputMethod() { }
REQUIRE_UIT(); }
has_update_input_method_task_ = false; void WebWidgetHost::ToggleImeTimer() {
if (view_ && !popup_ && ime_notification_ && webwidget_) {
if (!input_method_is_active_ || !webwidget_) if (!ime_timer_.IsRunning()) {
return; ime_timer_.Start(
FROM_HERE,
WebKit::WebTextInputType new_type = webwidget_->textInputType(); base::TimeDelta::FromMilliseconds(200),
WebKit::WebRect new_caret_bounds; this,
&WebWidgetHost::UpdateImeInputState);
WebKit::WebRect startRect, endRect; }
if (webwidget_->selectionBounds(startRect, endRect)) } else if (ime_timer_.IsRunning()) {
new_caret_bounds = endRect; ime_timer_.Stop();
// Only sends text input type and caret bounds to the browser process if they
// are changed.
if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds) {
text_input_type_ = new_type;
caret_bounds_ = new_caret_bounds;
ImeUpdateTextInputState(new_type, new_caret_bounds);
} }
} }

View File

@@ -606,21 +606,28 @@ int CEF_CALLBACK browser_get_image(struct _cef_browser_t* self,
} }
void CEF_CALLBACK browser_send_key_event(struct _cef_browser_t* self, void CEF_CALLBACK browser_send_key_event(struct _cef_browser_t* self,
enum cef_key_type_t type, int key, int modifiers, int sysChar, enum cef_key_type_t type, const struct _cef_key_info_t* keyInfo,
int imeChar) { int modifiers) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self); DCHECK(self);
if (!self) if (!self)
return; return;
// Verify param: keyInfo; type: struct_byref_const
DCHECK(keyInfo);
if (!keyInfo)
return;
// Translate param: keyInfo; type: struct_byref_const
CefKeyInfo keyInfoObj;
if (keyInfo)
keyInfoObj.Set(*keyInfo, false);
// Execute // Execute
CefBrowserCppToC::Get(self)->SendKeyEvent( CefBrowserCppToC::Get(self)->SendKeyEvent(
type, type,
key, keyInfoObj,
modifiers, modifiers);
sysChar?true:false,
imeChar?true:false);
} }
void CEF_CALLBACK browser_send_mouse_click_event(struct _cef_browser_t* self, void CEF_CALLBACK browser_send_mouse_click_event(struct _cef_browser_t* self,
@@ -657,7 +664,7 @@ void CEF_CALLBACK browser_send_mouse_move_event(struct _cef_browser_t* self,
} }
void CEF_CALLBACK browser_send_mouse_wheel_event(struct _cef_browser_t* self, void CEF_CALLBACK browser_send_mouse_wheel_event(struct _cef_browser_t* self,
int x, int y, int delta) { int x, int y, int deltaX, int deltaY) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self); DCHECK(self);
@@ -668,7 +675,8 @@ void CEF_CALLBACK browser_send_mouse_wheel_event(struct _cef_browser_t* self,
CefBrowserCppToC::Get(self)->SendMouseWheelEvent( CefBrowserCppToC::Get(self)->SendMouseWheelEvent(
x, x,
y, y,
delta); deltaX,
deltaY);
} }
void CEF_CALLBACK browser_send_focus_event(struct _cef_browser_t* self, void CEF_CALLBACK browser_send_focus_event(struct _cef_browser_t* self,

View File

@@ -25,6 +25,7 @@
#include "libcef_dll/cpptoc/render_handler_cpptoc.h" #include "libcef_dll/cpptoc/render_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h" #include "libcef_dll/cpptoc/request_handler_cpptoc.h"
#include "libcef_dll/cpptoc/v8context_handler_cpptoc.h" #include "libcef_dll/cpptoc/v8context_handler_cpptoc.h"
#include "libcef_dll/cpptoc/zoom_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
@@ -253,6 +254,22 @@ struct _cef_drag_handler_t* CEF_CALLBACK client_get_drag_handler(
return CefDragHandlerCppToC::Wrap(_retval); return CefDragHandlerCppToC::Wrap(_retval);
} }
struct _cef_zoom_handler_t* CEF_CALLBACK client_get_zoom_handler(
struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefZoomHandler> _retval = CefClientCppToC::Get(
self)->GetZoomHandler();
// Return type: refptr_same
return CefZoomHandlerCppToC::Wrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
@@ -272,6 +289,7 @@ CefClientCppToC::CefClientCppToC(CefClient* cls)
struct_.struct_.get_v8context_handler = client_get_v8context_handler; struct_.struct_.get_v8context_handler = client_get_v8context_handler;
struct_.struct_.get_render_handler = client_get_render_handler; struct_.struct_.get_render_handler = client_get_render_handler;
struct_.struct_.get_drag_handler = client_get_drag_handler; struct_.struct_.get_drag_handler = client_get_drag_handler;
struct_.struct_.get_zoom_handler = client_get_zoom_handler;
} }
#ifndef NDEBUG #ifndef NDEBUG

View File

@@ -0,0 +1,200 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefCookieManager> _retval = CefCookieManager::GetGlobalManager();
// Return type: refptr_same
return CefCookieManagerCppToC::Wrap(_retval);
}
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
const cef_string_t* path) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: path
// Execute
CefRefPtr<CefCookieManager> _retval = CefCookieManager::CreateManager(
CefString(path));
// Return type: refptr_same
return CefCookieManagerCppToC::Wrap(_retval);
}
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK cookie_manager_set_supported_schemes(
struct _cef_cookie_manager_t* self, cef_string_list_t schemes) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: schemes; type: string_vec_byref_const
DCHECK(schemes);
if (!schemes)
return;
// Translate param: schemes; type: string_vec_byref_const
std::vector<CefString> schemesList;
transfer_string_list_contents(schemes, schemesList);
// Execute
CefCookieManagerCppToC::Get(self)->SetSupportedSchemes(
schemesList);
}
int CEF_CALLBACK cookie_manager_visit_all_cookies(
struct _cef_cookie_manager_t* self,
struct _cef_cookie_visitor_t* visitor) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: visitor; type: refptr_diff
DCHECK(visitor);
if (!visitor)
return 0;
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->VisitAllCookies(
CefCookieVisitorCToCpp::Wrap(visitor));
// Return type: bool
return _retval;
}
int CEF_CALLBACK cookie_manager_visit_url_cookies(
struct _cef_cookie_manager_t* self, const cef_string_t* url,
int includeHttpOnly, struct _cef_cookie_visitor_t* visitor) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: url; type: string_byref_const
DCHECK(url);
if (!url)
return 0;
// Verify param: visitor; type: refptr_diff
DCHECK(visitor);
if (!visitor)
return 0;
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->VisitUrlCookies(
CefString(url),
includeHttpOnly?true:false,
CefCookieVisitorCToCpp::Wrap(visitor));
// Return type: bool
return _retval;
}
int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self,
const cef_string_t* url, const struct _cef_cookie_t* cookie) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: url; type: string_byref_const
DCHECK(url);
if (!url)
return 0;
// Verify param: cookie; type: struct_byref_const
DCHECK(cookie);
if (!cookie)
return 0;
// Translate param: cookie; type: struct_byref_const
CefCookie cookieObj;
if (cookie)
cookieObj.Set(*cookie, false);
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->SetCookie(
CefString(url),
cookieObj);
// Return type: bool
return _retval;
}
int CEF_CALLBACK cookie_manager_delete_cookies(
struct _cef_cookie_manager_t* self, const cef_string_t* url,
const cef_string_t* cookie_name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Unverified params: url, cookie_name
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->DeleteCookies(
CefString(url),
CefString(cookie_name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK cookie_manager_set_storage_path(
struct _cef_cookie_manager_t* self, const cef_string_t* path) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Unverified params: path
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->SetStoragePath(
CefString(path));
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefCookieManagerCppToC::CefCookieManagerCppToC(CefCookieManager* cls)
: CefCppToC<CefCookieManagerCppToC, CefCookieManager, cef_cookie_manager_t>(
cls) {
struct_.struct_.set_supported_schemes = cookie_manager_set_supported_schemes;
struct_.struct_.visit_all_cookies = cookie_manager_visit_all_cookies;
struct_.struct_.visit_url_cookies = cookie_manager_visit_url_cookies;
struct_.struct_.set_cookie = cookie_manager_set_cookie;
struct_.struct_.delete_cookies = cookie_manager_delete_cookies;
struct_.struct_.set_storage_path = cookie_manager_set_storage_path;
}
#ifndef NDEBUG
template<> long CefCppToC<CefCookieManagerCppToC, CefCookieManager,
cef_cookie_manager_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_cookie.h"
#include "include/capi/cef_cookie_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefCookieManagerCppToC
: public CefCppToC<CefCookieManagerCppToC, CefCookieManager,
cef_cookie_manager_t> {
public:
explicit CefCookieManagerCppToC(CefCookieManager* cls);
virtual ~CefCookieManagerCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_COOKIE_MANAGER_CPPTOC_H_

View File

@@ -33,10 +33,7 @@ int CEF_CALLBACK jsdialog_handler_on_jsalert(
DCHECK(frame); DCHECK(frame);
if (!frame) if (!frame)
return 0; return 0;
// Verify param: message; type: string_byref_const // Unverified params: message
DCHECK(message);
if (!message)
return 0;
// Execute // Execute
bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSAlert( bool _retval = CefJSDialogHandlerCppToC::Get(self)->OnJSAlert(
@@ -64,14 +61,11 @@ int CEF_CALLBACK jsdialog_handler_on_jsconfirm(
DCHECK(frame); DCHECK(frame);
if (!frame) if (!frame)
return 0; return 0;
// Verify param: message; type: string_byref_const
DCHECK(message);
if (!message)
return 0;
// Verify param: retval; type: bool_byref // Verify param: retval; type: bool_byref
DCHECK(retval); DCHECK(retval);
if (!retval) if (!retval)
return 0; return 0;
// Unverified params: message
// Translate param: retval; type: bool_byref // Translate param: retval; type: bool_byref
bool retvalBool = (retval && *retval)?true:false; bool retvalBool = (retval && *retval)?true:false;
@@ -108,14 +102,6 @@ int CEF_CALLBACK jsdialog_handler_on_jsprompt(
DCHECK(frame); DCHECK(frame);
if (!frame) if (!frame)
return 0; return 0;
// Verify param: message; type: string_byref_const
DCHECK(message);
if (!message)
return 0;
// Verify param: defaultValue; type: string_byref_const
DCHECK(defaultValue);
if (!defaultValue)
return 0;
// Verify param: retval; type: bool_byref // Verify param: retval; type: bool_byref
DCHECK(retval); DCHECK(retval);
if (!retval) if (!retval)
@@ -124,6 +110,7 @@ int CEF_CALLBACK jsdialog_handler_on_jsprompt(
DCHECK(result); DCHECK(result);
if (!result) if (!result)
return 0; return 0;
// Unverified params: message, defaultValue
// Translate param: retval; type: bool_byref // Translate param: retval; type: bool_byref
bool retvalBool = (retval && *retval)?true:false; bool retvalBool = (retval && *retval)?true:false;

View File

@@ -14,6 +14,7 @@
#include "libcef_dll/cpptoc/download_handler_cpptoc.h" #include "libcef_dll/cpptoc/download_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h" #include "libcef_dll/cpptoc/request_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/request_ctocpp.h" #include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/ctocpp/response_ctocpp.h" #include "libcef_dll/ctocpp/response_ctocpp.h"
@@ -347,6 +348,33 @@ int CEF_CALLBACK request_handler_get_auth_credentials(
return _retval; return _retval;
} }
cef_cookie_manager_t* CEF_CALLBACK request_handler_get_cookie_manager(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* main_url) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return NULL;
// Verify param: main_url; type: string_byref_const
DCHECK(main_url);
if (!main_url)
return NULL;
// Execute
CefRefPtr<CefCookieManager> _retval = CefRequestHandlerCppToC::Get(
self)->GetCookieManager(
CefBrowserCToCpp::Wrap(browser),
CefString(main_url));
// Return type: refptr_diff
return CefCookieManagerCToCpp::Unwrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
@@ -361,6 +389,7 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls)
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution; struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
struct_.struct_.get_download_handler = request_handler_get_download_handler; struct_.struct_.get_download_handler = request_handler_get_download_handler;
struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials; struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials;
struct_.struct_.get_cookie_manager = request_handler_get_cookie_manager;
} }
#ifndef NDEBUG #ifndef NDEBUG

View File

@@ -0,0 +1,94 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_name(
struct _cef_web_plugin_info_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_path(
struct _cef_web_plugin_info_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetPath();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_version(
struct _cef_web_plugin_info_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetVersion();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_description(
struct _cef_web_plugin_info_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetDescription();
// Return type: string
return _retval.DetachToUserFree();
}
// CONSTRUCTOR - Do not edit by hand.
CefWebPluginInfoCppToC::CefWebPluginInfoCppToC(CefWebPluginInfo* cls)
: CefCppToC<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t>(cls) {
struct_.struct_.get_name = web_plugin_info_get_name;
struct_.struct_.get_path = web_plugin_info_get_path;
struct_.struct_.get_version = web_plugin_info_get_version;
struct_.struct_.get_description = web_plugin_info_get_description;
}
#ifndef NDEBUG
template<> long CefCppToC<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefWebPluginInfoCppToC
: public CefCppToC<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t> {
public:
explicit CefWebPluginInfoCppToC(CefWebPluginInfo* cls);
virtual ~CefWebPluginInfoCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_

View File

@@ -0,0 +1,97 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/zoom_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK zoom_handler_on_get_zoom_level(
struct _cef_zoom_handler_t* self, cef_browser_t* browser,
const cef_string_t* url, double* zoomLevel) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: url; type: string_byref_const
DCHECK(url);
if (!url)
return 0;
// Verify param: zoomLevel; type: simple_byref
DCHECK(zoomLevel);
if (!zoomLevel)
return 0;
// Translate param: zoomLevel; type: simple_byref
double zoomLevelVal = zoomLevel?*zoomLevel:0;
// Execute
bool _retval = CefZoomHandlerCppToC::Get(self)->OnGetZoomLevel(
CefBrowserCToCpp::Wrap(browser),
CefString(url),
zoomLevelVal);
// Restore param: zoomLevel; type: simple_byref
if (zoomLevel)
*zoomLevel = zoomLevelVal;
// Return type: bool
return _retval;
}
int CEF_CALLBACK zoom_handler_on_set_zoom_level(
struct _cef_zoom_handler_t* self, cef_browser_t* browser,
const cef_string_t* url, double zoomLevel) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: url; type: string_byref_const
DCHECK(url);
if (!url)
return 0;
// Execute
bool _retval = CefZoomHandlerCppToC::Get(self)->OnSetZoomLevel(
CefBrowserCToCpp::Wrap(browser),
CefString(url),
zoomLevel);
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefZoomHandlerCppToC::CefZoomHandlerCppToC(CefZoomHandler* cls)
: CefCppToC<CefZoomHandlerCppToC, CefZoomHandler, cef_zoom_handler_t>(cls) {
struct_.struct_.on_get_zoom_level = zoom_handler_on_get_zoom_level;
struct_.struct_.on_set_zoom_level = zoom_handler_on_set_zoom_level;
}
#ifndef NDEBUG
template<> long CefCppToC<CefZoomHandlerCppToC, CefZoomHandler,
cef_zoom_handler_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_ZOOM_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_ZOOM_HANDLER_CPPTOC_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_zoom_handler.h"
#include "include/capi/cef_zoom_handler_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefZoomHandlerCppToC
: public CefCppToC<CefZoomHandlerCppToC, CefZoomHandler,
cef_zoom_handler_t> {
public:
explicit CefZoomHandlerCppToC(CefZoomHandler* cls);
virtual ~CefZoomHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_ZOOM_HANDLER_CPPTOC_H_

View File

@@ -491,8 +491,8 @@ bool CefBrowserCToCpp::GetImage(PaintElementType type, int width, int height,
return _retval?true:false; return _retval?true:false;
} }
void CefBrowserCToCpp::SendKeyEvent(KeyType type, int key, int modifiers, void CefBrowserCToCpp::SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool sysChar, bool imeChar) { int modifiers) {
if (CEF_MEMBER_MISSING(struct_, send_key_event)) if (CEF_MEMBER_MISSING(struct_, send_key_event))
return; return;
@@ -501,10 +501,8 @@ void CefBrowserCToCpp::SendKeyEvent(KeyType type, int key, int modifiers,
// Execute // Execute
struct_->send_key_event(struct_, struct_->send_key_event(struct_,
type, type,
key, &keyInfo,
modifiers, modifiers);
sysChar,
imeChar);
} }
void CefBrowserCToCpp::SendMouseClickEvent(int x, int y, MouseButtonType type, void CefBrowserCToCpp::SendMouseClickEvent(int x, int y, MouseButtonType type,
@@ -536,7 +534,8 @@ void CefBrowserCToCpp::SendMouseMoveEvent(int x, int y, bool mouseLeave) {
mouseLeave); mouseLeave);
} }
void CefBrowserCToCpp::SendMouseWheelEvent(int x, int y, int delta) { void CefBrowserCToCpp::SendMouseWheelEvent(int x, int y, int deltaX,
int deltaY) {
if (CEF_MEMBER_MISSING(struct_, send_mouse_wheel_event)) if (CEF_MEMBER_MISSING(struct_, send_mouse_wheel_event))
return; return;
@@ -546,7 +545,8 @@ void CefBrowserCToCpp::SendMouseWheelEvent(int x, int y, int delta) {
struct_->send_mouse_wheel_event(struct_, struct_->send_mouse_wheel_event(struct_,
x, x,
y, y,
delta); deltaX,
deltaY);
} }
void CefBrowserCToCpp::SendFocusEvent(bool setFocus) { void CefBrowserCToCpp::SendFocusEvent(bool setFocus) {

View File

@@ -70,12 +70,13 @@ class CefBrowserCToCpp
virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE; virtual void Invalidate(const CefRect& dirtyRect) OVERRIDE;
virtual bool GetImage(PaintElementType type, int width, int height, virtual bool GetImage(PaintElementType type, int width, int height,
void* buffer) OVERRIDE; void* buffer) OVERRIDE;
virtual void SendKeyEvent(KeyType type, int key, int modifiers, bool sysChar, virtual void SendKeyEvent(KeyType type, const CefKeyInfo& keyInfo,
bool imeChar) OVERRIDE; int modifiers) OVERRIDE;
virtual void SendMouseClickEvent(int x, int y, MouseButtonType type, virtual void SendMouseClickEvent(int x, int y, MouseButtonType type,
bool mouseUp, int clickCount) OVERRIDE; bool mouseUp, int clickCount) OVERRIDE;
virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE; virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave) OVERRIDE;
virtual void SendMouseWheelEvent(int x, int y, int delta) OVERRIDE; virtual void SendMouseWheelEvent(int x, int y, int deltaX,
int deltaY) OVERRIDE;
virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendFocusEvent(bool setFocus) OVERRIDE;
virtual void SendCaptureLostEvent() OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE;
}; };

View File

@@ -25,6 +25,7 @@
#include "libcef_dll/ctocpp/render_handler_ctocpp.h" #include "libcef_dll/ctocpp/render_handler_ctocpp.h"
#include "libcef_dll/ctocpp/request_handler_ctocpp.h" #include "libcef_dll/ctocpp/request_handler_ctocpp.h"
#include "libcef_dll/ctocpp/v8context_handler_ctocpp.h" #include "libcef_dll/ctocpp/v8context_handler_ctocpp.h"
#include "libcef_dll/ctocpp/zoom_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand. // VIRTUAL METHODS - Body may be edited by hand.
@@ -211,6 +212,19 @@ CefRefPtr<CefDragHandler> CefClientCToCpp::GetDragHandler() {
return CefDragHandlerCToCpp::Wrap(_retval); return CefDragHandlerCToCpp::Wrap(_retval);
} }
CefRefPtr<CefZoomHandler> CefClientCToCpp::GetZoomHandler() {
if (CEF_MEMBER_MISSING(struct_, get_zoom_handler))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_zoom_handler_t* _retval = struct_->get_zoom_handler(struct_);
// Return type: refptr_same
return CefZoomHandlerCToCpp::Wrap(_retval);
}
#ifndef NDEBUG #ifndef NDEBUG
template<> long CefCToCpp<CefClientCToCpp, CefClient, template<> long CefCToCpp<CefClientCToCpp, CefClient,

View File

@@ -46,6 +46,7 @@ class CefClientCToCpp
virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE; virtual CefRefPtr<CefV8ContextHandler> GetV8ContextHandler() OVERRIDE;
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE; virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE;
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE; virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE;
virtual CefRefPtr<CefZoomHandler> GetZoomHandler() OVERRIDE;
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED

View File

@@ -0,0 +1,175 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// STATIC METHODS - Body may be edited by hand.
CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_cookie_manager_t* _retval = cef_cookie_manager_get_global_manager();
// Return type: refptr_same
return CefCookieManagerCToCpp::Wrap(_retval);
}
CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
const CefString& path) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: path
// Execute
cef_cookie_manager_t* _retval = cef_cookie_manager_create_manager(
path.GetStruct());
// Return type: refptr_same
return CefCookieManagerCToCpp::Wrap(_retval);
}
// VIRTUAL METHODS - Body may be edited by hand.
void CefCookieManagerCToCpp::SetSupportedSchemes(
const std::vector<CefString>& schemes) {
if (CEF_MEMBER_MISSING(struct_, set_supported_schemes))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: schemes; type: string_vec_byref_const
cef_string_list_t schemesList = cef_string_list_alloc();
DCHECK(schemesList);
if (schemesList)
transfer_string_list_contents(schemes, schemesList);
// Execute
struct_->set_supported_schemes(struct_,
schemesList);
// Restore param:schemes; type: string_vec_byref_const
if (schemesList)
cef_string_list_free(schemesList);
}
bool CefCookieManagerCToCpp::VisitAllCookies(
CefRefPtr<CefCookieVisitor> visitor) {
if (CEF_MEMBER_MISSING(struct_, visit_all_cookies))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: visitor; type: refptr_diff
DCHECK(visitor.get());
if (!visitor.get())
return false;
// Execute
int _retval = struct_->visit_all_cookies(struct_,
CefCookieVisitorCppToC::Wrap(visitor));
// Return type: bool
return _retval?true:false;
}
bool CefCookieManagerCToCpp::VisitUrlCookies(const CefString& url,
bool includeHttpOnly, CefRefPtr<CefCookieVisitor> visitor) {
if (CEF_MEMBER_MISSING(struct_, visit_url_cookies))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: url; type: string_byref_const
DCHECK(!url.empty());
if (url.empty())
return false;
// Verify param: visitor; type: refptr_diff
DCHECK(visitor.get());
if (!visitor.get())
return false;
// Execute
int _retval = struct_->visit_url_cookies(struct_,
url.GetStruct(),
includeHttpOnly,
CefCookieVisitorCppToC::Wrap(visitor));
// Return type: bool
return _retval?true:false;
}
bool CefCookieManagerCToCpp::SetCookie(const CefString& url,
const CefCookie& cookie) {
if (CEF_MEMBER_MISSING(struct_, set_cookie))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: url; type: string_byref_const
DCHECK(!url.empty());
if (url.empty())
return false;
// Execute
int _retval = struct_->set_cookie(struct_,
url.GetStruct(),
&cookie);
// Return type: bool
return _retval?true:false;
}
bool CefCookieManagerCToCpp::DeleteCookies(const CefString& url,
const CefString& cookie_name) {
if (CEF_MEMBER_MISSING(struct_, delete_cookies))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: url, cookie_name
// Execute
int _retval = struct_->delete_cookies(struct_,
url.GetStruct(),
cookie_name.GetStruct());
// Return type: bool
return _retval?true:false;
}
bool CefCookieManagerCToCpp::SetStoragePath(const CefString& path) {
if (CEF_MEMBER_MISSING(struct_, set_storage_path))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: path
// Execute
int _retval = struct_->set_storage_path(struct_,
path.GetStruct());
// Return type: bool
return _retval?true:false;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefCookieManagerCToCpp, CefCookieManager,
cef_cookie_manager_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,52 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include <vector>
#include "include/cef_cookie.h"
#include "include/capi/cef_cookie_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefCookieManagerCToCpp
: public CefCToCpp<CefCookieManagerCToCpp, CefCookieManager,
cef_cookie_manager_t> {
public:
explicit CefCookieManagerCToCpp(cef_cookie_manager_t* str)
: CefCToCpp<CefCookieManagerCToCpp, CefCookieManager,
cef_cookie_manager_t>(str) {}
virtual ~CefCookieManagerCToCpp() {}
// CefCookieManager methods
virtual void SetSupportedSchemes(
const std::vector<CefString>& schemes) OVERRIDE;
virtual bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly,
CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
virtual bool SetCookie(const CefString& url,
const CefCookie& cookie) OVERRIDE;
virtual bool DeleteCookies(const CefString& url,
const CefString& cookie_name) OVERRIDE;
virtual bool SetStoragePath(const CefString& path) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_

View File

@@ -32,10 +32,7 @@ bool CefJSDialogHandlerCToCpp::OnJSAlert(CefRefPtr<CefBrowser> browser,
DCHECK(frame.get()); DCHECK(frame.get());
if (!frame.get()) if (!frame.get())
return false; return false;
// Verify param: message; type: string_byref_const // Unverified params: message
DCHECK(!message.empty());
if (message.empty())
return false;
// Execute // Execute
int _retval = struct_->on_jsalert(struct_, int _retval = struct_->on_jsalert(struct_,
@@ -62,10 +59,7 @@ bool CefJSDialogHandlerCToCpp::OnJSConfirm(CefRefPtr<CefBrowser> browser,
DCHECK(frame.get()); DCHECK(frame.get());
if (!frame.get()) if (!frame.get())
return false; return false;
// Verify param: message; type: string_byref_const // Unverified params: message
DCHECK(!message.empty());
if (message.empty())
return false;
// Translate param: retval; type: bool_byref // Translate param: retval; type: bool_byref
int retvalInt = retval; int retvalInt = retval;
@@ -100,14 +94,7 @@ bool CefJSDialogHandlerCToCpp::OnJSPrompt(CefRefPtr<CefBrowser> browser,
DCHECK(frame.get()); DCHECK(frame.get());
if (!frame.get()) if (!frame.get())
return false; return false;
// Verify param: message; type: string_byref_const // Unverified params: message, defaultValue
DCHECK(!message.empty());
if (message.empty())
return false;
// Verify param: defaultValue; type: string_byref_const
DCHECK(!defaultValue.empty());
if (defaultValue.empty())
return false;
// Translate param: retval; type: bool_byref // Translate param: retval; type: bool_byref
int retvalInt = retval; int retvalInt = retval;

View File

@@ -11,6 +11,7 @@
// //
#include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h" #include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/response_cpptoc.h" #include "libcef_dll/cpptoc/response_cpptoc.h"
@@ -289,6 +290,31 @@ bool CefRequestHandlerCToCpp::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
return _retval?true:false; return _retval?true:false;
} }
CefRefPtr<CefCookieManager> CefRequestHandlerCToCpp::GetCookieManager(
CefRefPtr<CefBrowser> browser, const CefString& main_url) {
if (CEF_MEMBER_MISSING(struct_, get_cookie_manager))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return NULL;
// Verify param: main_url; type: string_byref_const
DCHECK(!main_url.empty());
if (main_url.empty())
return NULL;
// Execute
cef_cookie_manager_t* _retval = struct_->get_cookie_manager(struct_,
CefBrowserCppToC::Wrap(browser),
main_url.GetStruct());
// Return type: refptr_diff
return CefCookieManagerCppToC::Unwrap(_retval);
}
#ifndef NDEBUG #ifndef NDEBUG
template<> long CefCToCpp<CefRequestHandlerCToCpp, CefRequestHandler, template<> long CefCToCpp<CefRequestHandlerCToCpp, CefRequestHandler,

View File

@@ -55,6 +55,8 @@ class CefRequestHandlerCToCpp
const CefString& host, int port, const CefString& realm, const CefString& host, int port, const CefString& realm,
const CefString& scheme, CefString& username, const CefString& scheme, CefString& username,
CefString& password) OVERRIDE; CefString& password) OVERRIDE;
virtual CefRefPtr<CefCookieManager> GetCookieManager(
CefRefPtr<CefBrowser> browser, const CefString& main_url) OVERRIDE;
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED

View File

@@ -0,0 +1,83 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefString CefWebPluginInfoCToCpp::GetName() {
if (CEF_MEMBER_MISSING(struct_, get_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefWebPluginInfoCToCpp::GetPath() {
if (CEF_MEMBER_MISSING(struct_, get_path))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_path(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefWebPluginInfoCToCpp::GetVersion() {
if (CEF_MEMBER_MISSING(struct_, get_version))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_version(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefWebPluginInfoCToCpp::GetDescription() {
if (CEF_MEMBER_MISSING(struct_, get_description))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_description(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefWebPluginInfoCToCpp
: public CefCToCpp<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t> {
public:
explicit CefWebPluginInfoCToCpp(cef_web_plugin_info_t* str)
: CefCToCpp<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t>(str) {}
virtual ~CefWebPluginInfoCToCpp() {}
// CefWebPluginInfo methods
virtual CefString GetName() OVERRIDE;
virtual CefString GetPath() OVERRIDE;
virtual CefString GetVersion() OVERRIDE;
virtual CefString GetDescription() OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_

Some files were not shown because too many files have changed in this diff Show More