diff options
author | Paul Rouget <me@paulrouget.com> | 2018-01-31 05:15:12 +0100 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2018-01-31 06:36:21 +0100 |
commit | 2282292fa4e4ab876b2f8df50a9b5f40fb619dbc (patch) | |
tree | a9ba2e0c0cd6c0deeb0017db87868bf945366012 | |
parent | e94a25949c924e086e38ef6bdbdc935734415b26 (diff) | |
download | servo-2282292fa4e4ab876b2f8df50a9b5f40fb619dbc.tar.gz servo-2282292fa4e4ab876b2f8df50a9b5f40fb619dbc.zip |
Drop CEF support
106 files changed, 151 insertions, 38350 deletions
diff --git a/Cargo.lock b/Cargo.lock index a1beb83faf1..4378641ecea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -745,31 +745,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "embedding" -version = "0.0.1" -dependencies = [ - "cocoa 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "compositing 0.0.1", - "devtools 0.0.1", - "euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "glutin_app 0.0.1", - "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "libservo 0.0.1", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "msg 0.0.1", - "net_traits 0.0.1", - "objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "script_traits 0.0.1", - "servo_config 0.0.1", - "servo_geometry 0.0.1", - "servo_url 0.0.1", - "style_traits 0.0.1", - "webrender_api 0.57.0 (git+https://github.com/servo/webrender)", - "x11 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "encoding_rs" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1078,34 +1053,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "glutin_app" -version = "0.0.1" -dependencies = [ - "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "compositing 0.0.1", - "euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "libservo 0.0.1", - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "msg 0.0.1", - "net_traits 0.0.1", - "osmesa-src 17.3.1-devel (git+https://github.com/servo/osmesa-src)", - "osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "script_traits 0.0.1", - "servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "servo-glutin 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "servo_config 0.0.1", - "servo_geometry 0.0.1", - "servo_url 0.0.1", - "style_traits 0.0.1", - "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_api 0.57.0 (git+https://github.com/servo/webrender)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "glx" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2622,11 +2569,30 @@ version = "0.0.1" dependencies = [ "android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "browserhtml 0.1.17 (git+https://github.com/browserhtml/browserhtml?branch=crate)", - "glutin_app 0.0.1", + "compositing 0.0.1", + "euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "libservo 0.0.1", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "msg 0.0.1", + "net_traits 0.0.1", + "osmesa-src 17.3.1-devel (git+https://github.com/servo/osmesa-src)", + "osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "script_traits 0.0.1", + "servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "servo-glutin 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_config 0.0.1", + "servo_geometry 0.0.1", + "servo_url 0.0.1", "sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "style_traits 0.0.1", + "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webrender_api 0.57.0 (git+https://github.com/servo/webrender)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 2.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6c492634dd2..d42024cc101 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,6 @@ members = [ "ports/geckolib", "ports/geckolib/tests", - - "ports/cef", ] default-members = [ "ports/servo", diff --git a/docs/ORGANIZATION.md b/docs/ORGANIZATION.md index 9a37472a062..8aa97f69eb6 100644 --- a/docs/ORGANIZATION.md +++ b/docs/ORGANIZATION.md @@ -59,8 +59,6 @@ * mach * A command-line tool to help with developer tasks. * ports - * cef - * Embedding implementation for the Chrome Embedding Framework (CEF) API. * geckolib * A static library to be linked into Gecko for the Stylo project. * glutin diff --git a/etc/ci/buildbot_steps.yml b/etc/ci/buildbot_steps.yml index 37380ca5349..786c9ea8e4b 100644 --- a/etc/ci/buildbot_steps.yml +++ b/etc/ci/buildbot_steps.yml @@ -46,7 +46,6 @@ mac-dev-unit: - env PKG_CONFIG_PATH=/usr/local/opt/zlib/lib/pkgconfig ./mach build --dev - env PKG_CONFIG_PATH=/usr/local/opt/zlib/lib/pkgconfig ./mach test-unit - ./mach package --dev - - env PKG_CONFIG_PATH=/usr/local/opt/zlib/lib/pkgconfig ./mach build-cef - ./mach build-geckolib - bash ./etc/ci/lockfile_changed.sh - bash ./etc/ci/manifest_changed.sh @@ -108,7 +107,6 @@ linux-dev: - ./mach build --dev - ./mach test-unit - ./mach package --dev - - ./mach build-cef - ./mach build --dev --no-default-features --features default-except-unstable - ./mach build-geckolib - ./mach test-stylo diff --git a/etc/ci/check_no_panic.sh b/etc/ci/check_no_panic.sh index 251d61591d0..c020b350e8f 100755 --- a/etc/ci/check_no_panic.sh +++ b/etc/ci/check_no_panic.sh @@ -17,8 +17,8 @@ cd "$(git rev-parse --show-toplevel)" PATHS=( "components/compositing/compositor.rs" "components/constellation/" - "ports/glutin/lib.rs" - "ports/glutin/window.rs" + "ports/servo/glutin_app/mod.rs" + "ports/servo/glutin_app/window.rs" ) # Make sure the paths exist diff --git a/etc/ci/taskcluster-test.sh b/etc/ci/taskcluster-test.sh index 9bad1e7aa80..0ef6863004f 100755 --- a/etc/ci/taskcluster-test.sh +++ b/etc/ci/taskcluster-test.sh @@ -14,7 +14,6 @@ set -o pipefail env CC=gcc-5 CXX=g++-5 ./mach build --dev env ./mach test-unit env ./mach package --dev -env ./mach build-cef env ./mach build --dev --no-default-features --features default-except-unstable ./mach build-geckolib ./mach test-stylo diff --git a/ports/cef/Cargo.toml b/ports/cef/Cargo.toml deleted file mode 100644 index f24a98d2bab..00000000000 --- a/ports/cef/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "embedding" -version = "0.0.1" -authors = ["The Servo Project Developers"] - -[lib] -name = "embedding" -path = "lib.rs" -crate-type = ["dylib"] - -[profile.release] -opt-level = 3 -# Uncomment to profile on Linux: -# debug = true -# lto = false - -[features] -debugmozjs = ["libservo/debugmozjs"] -default = ["unstable", "default-except-unstable"] -default-except-unstable = [] -unstable = ["libservo/unstable"] - -[dependencies] -compositing = {path = "../../components/compositing"} -devtools = {path = "../../components/devtools"} -euclid = "0.16" -gleam = "0.4" -glutin_app = {path = "../glutin"} -libc = "0.2" -libservo = {path = "../../components/servo"} -log = {version = "0.3.5", features = ["release_max_level_info"]} -msg = {path = "../../components/msg"} -net_traits = {path = "../../components/net_traits"} -script_traits = {path = "../../components/script_traits"} -servo_config = {path = "../../components/config"} -servo_geometry = {path = "../../components/geometry"} -servo_url = {path = "../../components/url"} -style_traits = {path = "../../components/style_traits"} -webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} - -[target.'cfg(target_os="macos")'.dependencies] -objc = "0.2" -cocoa = "0.14" - -[target.'cfg(target_os="linux")'.dependencies] -x11 = "2.3" diff --git a/ports/cef/README.md b/ports/cef/README.md deleted file mode 100644 index 0a0991072dd..00000000000 --- a/ports/cef/README.md +++ /dev/null @@ -1,11 +0,0 @@ -How to test: - -1. Build Servo's embedding crate (```./mach build-cef [--release]```) -2. Build ECEF (https://github.com/zmike/ecef) -3. See ECEF README -4. Enjoy CEF-powered crashes - -Notes: -* The contents of `interfaces/` are entirely autogenerated. To - regenerate, see https://github.com/zmike/cef-rebase/blob/master/README.md for full instructions - diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs deleted file mode 100644 index fbeb81bfce7..00000000000 --- a/ports/cef/browser.rs +++ /dev/null @@ -1,330 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use browser_host::{ServoCefBrowserHost, ServoCefBrowserHostExtensions}; -use eutil::Downcast; -use frame::{ServoCefFrame, ServoCefFrameExtensions}; -use interfaces::{CefBrowser, CefBrowserHost, CefClient, CefFrame, CefRequestContext}; -use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t}; -use interfaces::{cef_request_context_t}; -use msg::constellation_msg::TraversalDirection; -use servo::{BrowserId, Servo}; -use servo::ipc_channel::ipc; -use servo::servo_url::ServoUrl; -use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t}; -use window; -use wrappers::CefWrap; - -use compositing::windowing::WindowEvent; -use glutin_app; -use libc::c_int; -use std::cell::{Cell, RefCell}; -use std::ptr; -use std::rc::Rc; -use std::sync::atomic::{AtomicIsize, Ordering}; -use std::thread; - -thread_local!(pub static ID_COUNTER: AtomicIsize = AtomicIsize::new(0)); -thread_local!(pub static BROWSERS: RefCell<Vec<CefBrowser>> = RefCell::new(vec!())); - -pub enum ServoBrowser { - Invalid, - OnScreen(Servo<glutin_app::window::Window>, BrowserId), - OffScreen(Servo<window::Window>, BrowserId), -} - -impl ServoBrowser { - fn handle_event(&mut self, event: WindowEvent) { - match *self { - ServoBrowser::OnScreen(ref mut browser, _) => { browser.handle_events(vec![event]); } - ServoBrowser::OffScreen(ref mut browser, _) => { browser.handle_events(vec![event]); } - ServoBrowser::Invalid => {} - } - } - - pub fn pinch_zoom_level(&self) -> f32 { - match *self { - ServoBrowser::OnScreen(ref browser, _) => browser.pinch_zoom_level(), - ServoBrowser::OffScreen(ref browser, _) => browser.pinch_zoom_level(), - ServoBrowser::Invalid => 1.0, - } - } - - pub fn get_browser_id(&self) -> BrowserId { - match *self { - ServoBrowser::Invalid => unreachable!(), - ServoBrowser::OnScreen(_, id) => id, - ServoBrowser::OffScreen(_, id) => id, - } - } -} - -cef_class_impl! { - ServoCefBrowser : CefBrowser, cef_browser_t { - fn get_host(&this,) -> *mut cef_browser_host_t {{ - this.downcast().host.clone() - }} - - fn can_go_back(&this,) -> c_int {{ - this.downcast().back.get() as c_int - }} - - fn can_go_forward(&this,) -> c_int {{ - this.downcast().forward.get() as c_int - }} - - fn is_loading(&this,) -> c_int {{ - this.downcast().loading.get() as c_int - }} - - fn go_back(&this,) -> () {{ - this.send_window_event(WindowEvent::Navigation(this.get_browser_id(), TraversalDirection::Back(1))); - }} - - fn go_forward(&this,) -> () {{ - this.send_window_event(WindowEvent::Navigation(this.get_browser_id(), TraversalDirection::Forward(1))); - }} - - // Returns the main (top-level) frame for the browser window. - fn get_main_frame(&this,) -> *mut cef_frame_t {{ - this.downcast().frame.clone() - }} - - fn get_identifier(&this,) -> c_int {{ - this.downcast().id as c_int - }} - } -} - -pub struct ServoCefBrowser { - /// A reference to the browser's primary frame. - pub frame: CefFrame, - /// A reference to the browser's host. - pub host: CefBrowserHost, - /// A reference to the browser client. - pub client: CefClient, - /// the glutin window when using windowed rendering - pub window: Option<Rc<glutin_app::window::Window>>, - /// Whether the on-created callback has fired yet. - pub callback_executed: Cell<bool>, - /// whether the browser can navigate back - pub back: Cell<bool>, - /// whether the browser can navigate forward - pub forward: Cell<bool>, - /// whether the browser is loading - pub loading: Cell<bool>, - /// a vec of favicon urls for the current page - pub favicons: RefCell<Vec<String>>, - /// the display system window handle: only to be used with host.get_window_handle() - window_handle: cef_window_handle_t, - - id: isize, - servo_browser: RefCell<ServoBrowser>, - message_queue: RefCell<Vec<WindowEvent>>, -} - -impl ServoCefBrowser { - pub fn new(window_info: &cef_window_info_t, client: CefClient, target_url: ServoUrl) -> ServoCefBrowser { - let frame = ServoCefFrame::new().as_cef_interface(); - let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface(); - let mut window_handle: cef_window_handle_t = get_null_window_handle(); - - let (glutin_window, servo_browser) = if window_info.windowless_rendering_enabled == 0 { - let parent_window = glutin_app::WindowID::new(window_info.parent_window as *mut _); - let glutin_window = glutin_app::create_window(Some(parent_window)); - let mut servo_browser = Servo::new(glutin_window.clone()); - let (sender, receiver) = ipc::channel().unwrap(); - servo_browser.handle_events(vec![WindowEvent::NewBrowser(target_url, sender)]); - let browser_id = receiver.recv().unwrap(); - servo_browser.handle_events(vec![WindowEvent::SelectBrowser(browser_id)]); - window_handle = glutin_window.platform_window().window as cef_window_handle_t; - (Some(glutin_window), ServoBrowser::OnScreen(servo_browser, browser_id)) - } else { - (None, ServoBrowser::Invalid) - }; - - let id = ID_COUNTER.with(|counter| { - counter.fetch_add(1, Ordering::SeqCst) - }); - - ServoCefBrowser { - frame: frame, - host: host, - client: client, - window: glutin_window, - callback_executed: Cell::new(false), - servo_browser: RefCell::new(servo_browser), - message_queue: RefCell::new(vec!()), - id: id, - back: Cell::new(false), - forward: Cell::new(false), - loading: Cell::new(false), - favicons: RefCell::new(vec!()), - window_handle: window_handle, - } - } -} - -pub trait ServoCefBrowserExtensions { - fn init(&self, window_info: &cef_window_info_t); - fn get_browser_id(&self) -> BrowserId; - fn send_window_event(&self, event: WindowEvent); - fn pinch_zoom_level(&self) -> f32; -} - -impl ServoCefBrowserExtensions for CefBrowser { - fn init(&self, window_info: &cef_window_info_t) { - if window_info.windowless_rendering_enabled != 0 { - let window = window::Window::new(window_info.width, window_info.height); - window.set_browser(self.clone()); - let home_url = ServoUrl::parse("about:blank").unwrap(); - let mut servo_browser = Servo::new(window.clone()); - let (sender, receiver) = ipc::channel().unwrap(); - servo_browser.handle_events(vec![WindowEvent::NewBrowser(home_url, sender)]); - let browser_id = receiver.recv().unwrap(); - servo_browser.handle_events(vec![WindowEvent::SelectBrowser(browser_id)]); - *self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser, browser_id); - } - - self.downcast().host.set_browser((*self).clone()); - self.downcast().frame.set_browser((*self).clone()); - if window_info.windowless_rendering_enabled == 0 { - self.downcast().host.initialize_compositing(); - } - } - - fn get_browser_id(&self) -> BrowserId { - self.downcast().servo_browser.borrow().get_browser_id() - } - - fn send_window_event(&self, event: WindowEvent) { - let browser = self.downcast(); - - if let Ok(mut servo_browser) = browser.servo_browser.try_borrow_mut() { - servo_browser.handle_event(event); - while let Some(event) = browser.message_queue.borrow_mut().pop() { - servo_browser.handle_event(event); - } - } else { - // If we fail to borrow mutably, this means we're trying to send an - // event while processing another one. This will cause general badness, - // we just queue up that event instead of immediately processing it. - browser.message_queue.borrow_mut().push(event); - } - } - - fn pinch_zoom_level(&self) -> f32 { - self.downcast().servo_browser.borrow().pinch_zoom_level() - } -} - -#[cfg(target_os="macos")] -pub fn get_null_window_handle() -> cef_window_handle_t { - ptr::null_mut() -} -#[cfg(target_os="linux")] -pub fn get_null_window_handle() -> cef_window_handle_t { - 0 -} - -pub fn update() { - BROWSERS.with(|browsers| { - for browser in &*browsers.borrow() { - if browser.downcast().callback_executed.get() == false { - browser_callback_after_created(browser.clone()); - } - let mut events = match browser.downcast().window { - Some(ref win) => win.wait_events(), - None => vec![WindowEvent::Idle] - }; - loop { - match events.pop() { - Some(event) => browser.send_window_event(event), - None => break - } - } - } - }); -} - -pub fn close(browser: CefBrowser) { - BROWSERS.with(|browsers| { - let mut browsers = browsers.borrow_mut(); - browsers.iter() - .position(|&ref n| n.downcast().id == browser.downcast().id) - .map(|e| browsers.remove(e)); - }); -} - -pub fn get_window(browser: &CefBrowser) -> cef_window_handle_t { - browser.downcast().window_handle -} - -pub fn browser_callback_after_created(browser: CefBrowser) { - if browser.downcast().client.is_null_cef_object() { - return - } - let client = browser.downcast().client.clone(); - let life_span_handler = client.get_life_span_handler(); - if life_span_handler.is_not_null_cef_object() { - life_span_handler.on_after_created(browser.clone()); - } - browser.downcast().callback_executed.set(true); - browser.downcast().frame.load(); - browser.downcast().host.was_resized(); -} - -fn browser_host_create(window_info: &cef_window_info_t, - client: CefClient, - url: *const cef_string_t, - callback_executed: bool) - -> CefBrowser { - let url_string = if url != ptr::null() { - unsafe { String::from_utf16(CefWrap::to_rust(url)).ok() } - } else { - None - }; - let target_url = url_string - .and_then(|val| ServoUrl::parse(&val).ok()) - .or(ServoUrl::parse("about:blank").ok()) - .unwrap(); - let browser = ServoCefBrowser::new(window_info, client, target_url).as_cef_interface(); - browser.init(window_info); - if callback_executed { - browser_callback_after_created(browser.clone()); - } - BROWSERS.with(|browsers| { - browsers.borrow_mut().push(browser.clone()); - }); - browser -} - -cef_static_method_impls! { - fn cef_browser_host_create_browser(window_info: *const cef_window_info_t, - client: *mut cef_client_t, - url: *const cef_string_t, - _browser_settings: *const cef_browser_settings_t, - _request_context: *mut cef_request_context_t) - -> c_int {{ - let client: CefClient = client; - let _browser_settings: &cef_browser_settings_t = _browser_settings; - let _request_context: CefRequestContext = _request_context; - browser_host_create(window_info, client, url, false); - thread::Builder::new().name("async_browser_creation".to_owned()).spawn(move || { - window::app_wakeup(); - }).expect("Thread spawning failed"); - 1i32 - }} - fn cef_browser_host_create_browser_sync(window_info: *const cef_window_info_t, - client: *mut cef_client_t, - url: *const cef_string_t, - _browser_settings: *const cef_browser_settings_t, - _request_context: *mut cef_request_context_t) - -> *mut cef_browser_t {{ - let client: CefClient = client; - let _browser_settings: &cef_browser_settings_t = _browser_settings; - let _request_context: CefRequestContext = _request_context; - browser_host_create(window_info, client, url, true) - }} -} diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs deleted file mode 100644 index 1cb640c63bd..00000000000 --- a/ports/cef/browser_host.rs +++ /dev/null @@ -1,532 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use browser::{self, ServoCefBrowserExtensions}; -use eutil::Downcast; -use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_t, cef_browser_host_t, cef_client_t}; -use types::cef_event_flags_t::{EVENTFLAG_ALT_DOWN, EVENTFLAG_CONTROL_DOWN, EVENTFLAG_SHIFT_DOWN}; -use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN}; -use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t}; -use webrender_api::ScrollLocation; -use wrappers::CefWrap; - -use compositing::windowing::{WindowEvent, MouseWindowEvent}; -use euclid::{TypedPoint2D, TypedVector2D}; -use libc::{c_double, c_int}; -use msg::constellation_msg::{self, KeyModifiers, KeyState}; -use script_traits::{MouseButton, TouchEventType}; -use std::cell::{Cell, RefCell}; -use std::char; - -pub struct ServoCefBrowserHost { - /// A reference to the browser. - pub browser: RefCell<Option<CefBrowser>>, - /// A reference to the client. - pub client: CefClient, - /// flag for return value of prepare_for_composite - pub composite_ok: Cell<bool>, -} - -// From blink ui/events/keycodes/keyboard_codes_posix.h. -#[allow(dead_code)] -#[allow(non_snake_case)] -mod KeyboardCode { - pub const VKEY_BACK : u8 = 0x08; - pub const VKEY_TAB : u8 = 0x09; - pub const VKEY_BACKTAB : u8 = 0x0A; - pub const VKEY_CLEAR : u8 = 0x0C; - pub const VKEY_RETURN : u8 = 0x0D; - pub const VKEY_SHIFT : u8 = 0x10; - pub const VKEY_CONTROL : u8 = 0x11; - pub const VKEY_MENU : u8 = 0x12; - pub const VKEY_PAUSE : u8 = 0x13; - pub const VKEY_CAPITAL : u8 = 0x14; - pub const VKEY_KANA : u8 = 0x15; - //VKEY_HANGUL = 0x15, - pub const VKEY_JUNJA : u8 = 0x17; - pub const VKEY_FINAL : u8 = 0x18; - pub const VKEY_HANJA : u8 = 0x19; - //VKEY_KANJI = 0x19, - pub const VKEY_ESCAPE : u8 = 0x1B; - pub const VKEY_CONVERT : u8 = 0x1C; - pub const VKEY_NONCONVERT : u8 = 0x1D; - pub const VKEY_ACCEPT : u8 = 0x1E; - pub const VKEY_MODECHANGE : u8 = 0x1F; - pub const VKEY_SPACE : u8 = 0x20; - pub const VKEY_PRIOR : u8 = 0x21; - pub const VKEY_NEXT : u8 = 0x22; - pub const VKEY_END : u8 = 0x23; - pub const VKEY_HOME : u8 = 0x24; - pub const VKEY_LEFT : u8 = 0x25; - pub const VKEY_UP : u8 = 0x26; - pub const VKEY_RIGHT : u8 = 0x27; - pub const VKEY_DOWN : u8 = 0x28; - pub const VKEY_SELECT : u8 = 0x29; - pub const VKEY_PRINT : u8 = 0x2A; - pub const VKEY_EXECUTE : u8 = 0x2B; - pub const VKEY_SNAPSHOT : u8 = 0x2C; - pub const VKEY_INSERT : u8 = 0x2D; - pub const VKEY_DELETE : u8 = 0x2E; - pub const VKEY_HELP : u8 = 0x2F; - pub const VKEY_0 : u8 = 0x30; - pub const VKEY_1 : u8 = 0x31; - pub const VKEY_2 : u8 = 0x32; - pub const VKEY_3 : u8 = 0x33; - pub const VKEY_4 : u8 = 0x34; - pub const VKEY_5 : u8 = 0x35; - pub const VKEY_6 : u8 = 0x36; - pub const VKEY_7 : u8 = 0x37; - pub const VKEY_8 : u8 = 0x38; - pub const VKEY_9 : u8 = 0x39; - pub const VKEY_A : u8 = 0x41; - pub const VKEY_B : u8 = 0x42; - pub const VKEY_C : u8 = 0x43; - pub const VKEY_D : u8 = 0x44; - pub const VKEY_E : u8 = 0x45; - pub const VKEY_F : u8 = 0x46; - pub const VKEY_G : u8 = 0x47; - pub const VKEY_H : u8 = 0x48; - pub const VKEY_I : u8 = 0x49; - pub const VKEY_J : u8 = 0x4A; - pub const VKEY_K : u8 = 0x4B; - pub const VKEY_L : u8 = 0x4C; - pub const VKEY_M : u8 = 0x4D; - pub const VKEY_N : u8 = 0x4E; - pub const VKEY_O : u8 = 0x4F; - pub const VKEY_P : u8 = 0x50; - pub const VKEY_Q : u8 = 0x51; - pub const VKEY_R : u8 = 0x52; - pub const VKEY_S : u8 = 0x53; - pub const VKEY_T : u8 = 0x54; - pub const VKEY_U : u8 = 0x55; - pub const VKEY_V : u8 = 0x56; - pub const VKEY_W : u8 = 0x57; - pub const VKEY_X : u8 = 0x58; - pub const VKEY_Y : u8 = 0x59; - pub const VKEY_Z : u8 = 0x5A; - pub const VKEY_LWIN : u8 = 0x5B; - pub const VKEY_RWIN : u8 = 0x5C; - pub const VKEY_APPS : u8 = 0x5D; - pub const VKEY_SLEEP : u8 = 0x5F; - pub const VKEY_NUMPAD0 : u8 = 0x60; - pub const VKEY_NUMPAD1 : u8 = 0x61; - pub const VKEY_NUMPAD2 : u8 = 0x62; - pub const VKEY_NUMPAD3 : u8 = 0x63; - pub const VKEY_NUMPAD4 : u8 = 0x64; - pub const VKEY_NUMPAD5 : u8 = 0x65; - pub const VKEY_NUMPAD6 : u8 = 0x66; - pub const VKEY_NUMPAD7 : u8 = 0x67; - pub const VKEY_NUMPAD8 : u8 = 0x68; - pub const VKEY_NUMPAD9 : u8 = 0x69; - pub const VKEY_MULTIPLY : u8 = 0x6A; - pub const VKEY_ADD : u8 = 0x6B; - pub const VKEY_SEPARATOR : u8 = 0x6C; - pub const VKEY_SUBTRACT : u8 = 0x6D; - pub const VKEY_DECIMAL : u8 = 0x6E; - pub const VKEY_DIVIDE : u8 = 0x6F; - pub const VKEY_F1 : u8 = 0x70; - pub const VKEY_F2 : u8 = 0x71; - pub const VKEY_F3 : u8 = 0x72; - pub const VKEY_F4 : u8 = 0x73; - pub const VKEY_F5 : u8 = 0x74; - pub const VKEY_F6 : u8 = 0x75; - pub const VKEY_F7 : u8 = 0x76; - pub const VKEY_F8 : u8 = 0x77; - pub const VKEY_F9 : u8 = 0x78; - pub const VKEY_F10 : u8 = 0x79; - pub const VKEY_F11 : u8 = 0x7A; - pub const VKEY_F12 : u8 = 0x7B; - pub const VKEY_F13 : u8 = 0x7C; - pub const VKEY_F14 : u8 = 0x7D; - pub const VKEY_F15 : u8 = 0x7E; - pub const VKEY_F16 : u8 = 0x7F; - pub const VKEY_F17 : u8 = 0x80; - pub const VKEY_F18 : u8 = 0x81; - pub const VKEY_F19 : u8 = 0x82; - pub const VKEY_F20 : u8 = 0x83; - pub const VKEY_F21 : u8 = 0x84; - pub const VKEY_F22 : u8 = 0x85; - pub const VKEY_F23 : u8 = 0x86; - pub const VKEY_F24 : u8 = 0x87; - pub const VKEY_NUMLOCK : u8 = 0x90; - pub const VKEY_SCROLL : u8 = 0x91; - pub const VKEY_LSHIFT : u8 = 0xA0; - pub const VKEY_RSHIFT : u8 = 0xA1; - pub const VKEY_LCONTROL : u8 = 0xA2; - pub const VKEY_RCONTROL : u8 = 0xA3; - pub const VKEY_LMENU : u8 = 0xA4; - pub const VKEY_RMENU : u8 = 0xA5; - pub const VKEY_BROWSER_BACK : u8 = 0xA6; - pub const VKEY_BROWSER_FORWARD : u8 = 0xA7; - pub const VKEY_BROWSER_REFRESH : u8 = 0xA8; - pub const VKEY_BROWSER_STOP : u8 = 0xA9; - pub const VKEY_BROWSER_SEARCH : u8 = 0xAA; - pub const VKEY_BROWSER_FAVORITES : u8 = 0xAB; - pub const VKEY_BROWSER_HOME : u8 = 0xAC; - pub const VKEY_VOLUME_MUTE : u8 = 0xAD; - pub const VKEY_VOLUME_DOWN : u8 = 0xAE; - pub const VKEY_VOLUME_UP : u8 = 0xAF; - pub const VKEY_MEDIA_NEXT_TRACK : u8 = 0xB0; - pub const VKEY_MEDIA_PREV_TRACK : u8 = 0xB1; - pub const VKEY_MEDIA_STOP : u8 = 0xB2; - pub const VKEY_MEDIA_PLAY_PAUSE : u8 = 0xB3; - pub const VKEY_MEDIA_LAUNCH_MAIL : u8 = 0xB4; - pub const VKEY_MEDIA_LAUNCH_MEDIA_SELECT : u8 = 0xB5; - pub const VKEY_MEDIA_LAUNCH_APP1 : u8 = 0xB6; - pub const VKEY_MEDIA_LAUNCH_APP2 : u8 = 0xB7; - pub const VKEY_OEM_1 : u8 = 0xBA; - pub const VKEY_OEM_PLUS : u8 = 0xBB; - pub const VKEY_OEM_COMMA : u8 = 0xBC; - pub const VKEY_OEM_MINUS : u8 = 0xBD; - pub const VKEY_OEM_PERIOD : u8 = 0xBE; - pub const VKEY_OEM_2 : u8 = 0xBF; - pub const VKEY_OEM_3 : u8 = 0xC0; - pub const VKEY_OEM_4 : u8 = 0xDB; - pub const VKEY_OEM_5 : u8 = 0xDC; - pub const VKEY_OEM_6 : u8 = 0xDD; - pub const VKEY_OEM_7 : u8 = 0xDE; - pub const VKEY_OEM_8 : u8 = 0xDF; - pub const VKEY_OEM_102 : u8 = 0xE2; - pub const VKEY_OEM_103 : u8 = 0xE3; // GTV KEYCODE_MEDIA_REWIND - pub const VKEY_OEM_104 : u8 = 0xE4; // GTV KEYCODE_MEDIA_FAST_FORWARD - pub const VKEY_PROCESSKEY : u8 = 0xE5; - pub const VKEY_PACKET : u8 = 0xE7; - pub const VKEY_DBE_SBCSCHAR : u8 = 0xF3; - pub const VKEY_DBE_DBCSCHAR : u8 = 0xF4; - pub const VKEY_ATTN : u8 = 0xF6; - pub const VKEY_CRSEL : u8 = 0xF7; - pub const VKEY_EXSEL : u8 = 0xF8; - pub const VKEY_EREOF : u8 = 0xF9; - pub const VKEY_PLAY : u8 = 0xFA; - pub const VKEY_ZOOM : u8 = 0xFB; - pub const VKEY_NONAME : u8 = 0xFC; - pub const VKEY_PA1 : u8 = 0xFD; - pub const VKEY_OEM_CLEAR : u8 = 0xFE; - pub const VKEY_UNKNOWN : u8 = 0x0; - - // POSIX specific VKEYs. Note that as of Windows SDK 7.1, 0x97-9F, 0xD8-DA, - // and 0xE8 are unassigned. - pub const VKEY_WLAN : u8 = 0x97; - pub const VKEY_POWER : u8 = 0x98; - pub const VKEY_BRIGHTNESS_DOWN : u8 = 0xD8; - pub const VKEY_BRIGHTNESS_UP : u8 = 0xD9; - pub const VKEY_KBD_BRIGHTNESS_DOWN : u8 = 0xDA; - pub const VKEY_KBD_BRIGHTNESS_UP : u8 = 0xE8; - - // Windows does not have a specific key code for AltGr. We use the unused 0xE1 - // (VK_OEM_AX) code to represent AltGr, matching the behaviour of Firefox on - // Linux. - pub const VKEY_ALTGR : u8 = 0xE1; - // Windows does not have a specific key code for Compose. We use the unused - // 0xE6 (VK_ICO_CLEAR) code to represent Compose. - pub const VKEY_COMPOSE : u8 = 0xE6; -} - -// this is way too much work to do 100% correctly right now. -// see xkb_keyboard_layout_engine.cc -> XkbKeyboardLayoutEngine::Lookup in chromium for details -fn get_key_msg(keycode: c_int, character: u16) -> Option<constellation_msg::Key> { - match keycode as u8 { - KeyboardCode::VKEY_BACK => Some(constellation_msg::Key::Backspace), - KeyboardCode::VKEY_RIGHT => Some(constellation_msg::Key::Right), - KeyboardCode::VKEY_LEFT => Some(constellation_msg::Key::Left), - KeyboardCode::VKEY_UP => Some(constellation_msg::Key::Up), - KeyboardCode::VKEY_DOWN => Some(constellation_msg::Key::Down), - KeyboardCode::VKEY_RSHIFT => Some(constellation_msg::Key::RightShift), - KeyboardCode::VKEY_SHIFT | KeyboardCode::VKEY_LSHIFT => Some(constellation_msg::Key::LeftShift), - KeyboardCode::VKEY_RCONTROL => Some(constellation_msg::Key::RightControl), - KeyboardCode::VKEY_CONTROL | KeyboardCode::VKEY_LCONTROL => Some(constellation_msg::Key::LeftControl), - KeyboardCode::VKEY_LWIN => Some(constellation_msg::Key::LeftSuper), - KeyboardCode::VKEY_RWIN => Some(constellation_msg::Key::RightSuper), - KeyboardCode::VKEY_MENU => Some(constellation_msg::Key::LeftAlt), - KeyboardCode::VKEY_APPS => Some(constellation_msg::Key::Menu), - KeyboardCode::VKEY_ALTGR => Some(constellation_msg::Key::RightAlt), //not sure if correct... - KeyboardCode::VKEY_ESCAPE => Some(constellation_msg::Key::Escape), - KeyboardCode::VKEY_INSERT => Some(constellation_msg::Key::Insert), - KeyboardCode::VKEY_DELETE => Some(constellation_msg::Key::Delete), - KeyboardCode::VKEY_NEXT => Some(constellation_msg::Key::PageUp), - KeyboardCode::VKEY_PRIOR => Some(constellation_msg::Key::PageDown), - KeyboardCode::VKEY_HOME => Some(constellation_msg::Key::Home), - KeyboardCode::VKEY_END => Some(constellation_msg::Key::End), - KeyboardCode::VKEY_CAPITAL => Some(constellation_msg::Key::CapsLock), - KeyboardCode::VKEY_F1 => Some(constellation_msg::Key::F1), - KeyboardCode::VKEY_F2 => Some(constellation_msg::Key::F2), - KeyboardCode::VKEY_F3 => Some(constellation_msg::Key::F3), - KeyboardCode::VKEY_F4 => Some(constellation_msg::Key::F4), - KeyboardCode::VKEY_F5 => Some(constellation_msg::Key::F5), - KeyboardCode::VKEY_F6 => Some(constellation_msg::Key::F6), - KeyboardCode::VKEY_F7 => Some(constellation_msg::Key::F7), - KeyboardCode::VKEY_F8 => Some(constellation_msg::Key::F8), - KeyboardCode::VKEY_F9 => Some(constellation_msg::Key::F9), - KeyboardCode::VKEY_F10 => Some(constellation_msg::Key::F10), - KeyboardCode::VKEY_F11 => Some(constellation_msg::Key::F11), - KeyboardCode::VKEY_F12 => Some(constellation_msg::Key::F12), - KeyboardCode::VKEY_F13 => Some(constellation_msg::Key::F13), - KeyboardCode::VKEY_F14 => Some(constellation_msg::Key::F14), - KeyboardCode::VKEY_F15 => Some(constellation_msg::Key::F15), - KeyboardCode::VKEY_F16 => Some(constellation_msg::Key::F16), - KeyboardCode::VKEY_F17 => Some(constellation_msg::Key::F17), - KeyboardCode::VKEY_F18 => Some(constellation_msg::Key::F18), - KeyboardCode::VKEY_F19 => Some(constellation_msg::Key::F19), - KeyboardCode::VKEY_F20 => Some(constellation_msg::Key::F20), - KeyboardCode::VKEY_F21 => Some(constellation_msg::Key::F21), - KeyboardCode::VKEY_F22 => Some(constellation_msg::Key::F22), - KeyboardCode::VKEY_F23 => Some(constellation_msg::Key::F23), - KeyboardCode::VKEY_F24 => Some(constellation_msg::Key::F24), - KeyboardCode::VKEY_NUMPAD0 => Some(constellation_msg::Key::Kp0), - KeyboardCode::VKEY_NUMPAD1 => Some(constellation_msg::Key::Kp1), - KeyboardCode::VKEY_NUMPAD2 => Some(constellation_msg::Key::Kp2), - KeyboardCode::VKEY_NUMPAD3 => Some(constellation_msg::Key::Kp3), - KeyboardCode::VKEY_NUMPAD4 => Some(constellation_msg::Key::Kp4), - KeyboardCode::VKEY_NUMPAD5 => Some(constellation_msg::Key::Kp5), - KeyboardCode::VKEY_NUMPAD6 => Some(constellation_msg::Key::Kp6), - KeyboardCode::VKEY_NUMPAD7 => Some(constellation_msg::Key::Kp7), - KeyboardCode::VKEY_NUMPAD8 => Some(constellation_msg::Key::Kp8), - KeyboardCode::VKEY_NUMPAD9 => Some(constellation_msg::Key::Kp9), - KeyboardCode::VKEY_DECIMAL => Some(constellation_msg::Key::KpDecimal), - KeyboardCode::VKEY_DIVIDE => Some(constellation_msg::Key::KpDivide), - KeyboardCode::VKEY_MULTIPLY => Some(constellation_msg::Key::KpMultiply), - KeyboardCode::VKEY_SUBTRACT => Some(constellation_msg::Key::KpSubtract), - KeyboardCode::VKEY_ADD => Some(constellation_msg::Key::KpAdd), - KeyboardCode::VKEY_NUMLOCK => Some(constellation_msg::Key::NumLock), - KeyboardCode::VKEY_PRINT => Some(constellation_msg::Key::PrintScreen), - KeyboardCode::VKEY_PAUSE => Some(constellation_msg::Key::Pause), - //VKEY_BACK - _ => { match character as u8 { - b'[' => Some(constellation_msg::Key::LeftBracket), - b']' => Some(constellation_msg::Key::RightBracket), - b'=' => Some(constellation_msg::Key::Equal), - b';' => Some(constellation_msg::Key::Semicolon), - b'/' => Some(constellation_msg::Key::Slash), - b'.' => Some(constellation_msg::Key::Period), - b'-' => Some(constellation_msg::Key::Minus), - b',' => Some(constellation_msg::Key::Comma), - b'\'' => Some(constellation_msg::Key::Apostrophe), - b'\\' => Some(constellation_msg::Key::Backslash), - b'`' => Some(constellation_msg::Key::GraveAccent), - b'\t' => Some(constellation_msg::Key::Tab), - b'a' | b'A' => Some(constellation_msg::Key::A), - b'b' | b'B' => Some(constellation_msg::Key::B), - b'c' | b'C' => Some(constellation_msg::Key::C), - b'd' | b'D' => Some(constellation_msg::Key::D), - b'e' | b'E' => Some(constellation_msg::Key::E), - b'f' | b'F' => Some(constellation_msg::Key::F), - b'g' | b'G' => Some(constellation_msg::Key::G), - b'h' | b'H' => Some(constellation_msg::Key::H), - b'i' | b'I' => Some(constellation_msg::Key::I), - b'j' | b'J' => Some(constellation_msg::Key::J), - b'k' | b'K' => Some(constellation_msg::Key::K), - b'l' | b'L' => Some(constellation_msg::Key::L), - b'm' | b'M' => Some(constellation_msg::Key::M), - b'n' | b'N' => Some(constellation_msg::Key::N), - b'o' | b'O' => Some(constellation_msg::Key::O), - b'p' | b'P' => Some(constellation_msg::Key::P), - b'q' | b'Q' => Some(constellation_msg::Key::Q), - b'r' | b'R' => Some(constellation_msg::Key::R), - b's' | b'S' => Some(constellation_msg::Key::S), - b't' | b'T' => Some(constellation_msg::Key::T), - b'u' | b'U' => Some(constellation_msg::Key::U), - b'v' | b'V' => Some(constellation_msg::Key::V), - b'w' | b'W' => Some(constellation_msg::Key::W), - b'x' | b'X' => Some(constellation_msg::Key::X), - b'y' | b'Y' => Some(constellation_msg::Key::Y), - b'z' | b'Z' => Some(constellation_msg::Key::Z), - b'0' => Some(constellation_msg::Key::Num0), - b'1' => Some(constellation_msg::Key::Num1), - b'2' => Some(constellation_msg::Key::Num2), - b'3' => Some(constellation_msg::Key::Num3), - b'4' => Some(constellation_msg::Key::Num4), - b'5' => Some(constellation_msg::Key::Num5), - b'6' => Some(constellation_msg::Key::Num6), - b'7' => Some(constellation_msg::Key::Num7), - b'8' => Some(constellation_msg::Key::Num8), - b'9' => Some(constellation_msg::Key::Num9), - b'\n' | b'\r' => Some(constellation_msg::Key::Enter), - b' ' => Some(constellation_msg::Key::Space), - _ => None - } - } - } -} - -// unhandled -//pub enum Key { - //World1, - //World2, - //ScrollLock, - //KpEnter, - //KpEqual, - //RightAlt, -//} - -full_cef_class_impl! { - ServoCefBrowserHost : CefBrowserHost, cef_browser_host_t { - fn get_client(&this,) -> *mut cef_client_t {{ - this.downcast().client.clone() - }} - fn get_browser(&this,) -> *mut cef_browser_t {{ - let browser = this.downcast().browser.borrow_mut(); - browser.clone().unwrap() - }} - - fn was_resized(&this,) -> () {{ - let mut rect = cef_rect_t::zero(); - if cfg!(target_os="macos") { - if check_ptr_exist!(this.get_client(), get_render_handler) && - check_ptr_exist!(this.get_client().get_render_handler(), get_backing_rect) { - this.get_client() - .get_render_handler() - .get_backing_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect); - } - } else if check_ptr_exist!(this.get_client(), get_render_handler) && - check_ptr_exist!(this.get_client().get_render_handler(), get_view_rect) { - this.get_client() - .get_render_handler() - .get_view_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect); - } - this.downcast().send_window_event(WindowEvent::Resize); - }} - - fn close_browser(&this, _force: c_int [c_int],) -> () {{ - browser::close(this.downcast().browser.borrow_mut().take().unwrap()); - }} - - fn send_focus_event(&this, focus: c_int [c_int],) -> () {{ - let focus: c_int = focus; - if focus != 0 { - this.downcast().send_window_event(WindowEvent::Refresh); - } - }} - - fn send_key_event(&this, event: *const cef_key_event [&cef_key_event],) -> () {{ - let event: &cef_key_event = event; - let key = match get_key_msg((*event).windows_key_code, (*event).character) { - Some(keycode) => keycode, - None => { - error!("Unhandled keycode({}) passed!", (*event).windows_key_code); - return; - } - }; - let key_state = match (*event).t { - // in tests with cef-real, this event had no effect - KEYEVENT_RAWKEYDOWN => return, - KEYEVENT_KEYDOWN => KeyState::Pressed, - KEYEVENT_CHAR => KeyState::Repeated, - KEYEVENT_KEYUP => KeyState::Released, - }; - let mut key_modifiers = KeyModifiers::empty(); - if (*event).modifiers & EVENTFLAG_SHIFT_DOWN as u32 != 0 { - key_modifiers = key_modifiers | constellation_msg::KeyModifiers::SHIFT; - } - if (*event).modifiers & EVENTFLAG_CONTROL_DOWN as u32 != 0 { - key_modifiers = key_modifiers | constellation_msg::KeyModifiers::CONTROL; - } - if (*event).modifiers & EVENTFLAG_ALT_DOWN as u32 != 0 { - key_modifiers = key_modifiers | constellation_msg::KeyModifiers::ALT; - } - let ch = char::from_u32((*event).character as u32); - this.downcast().send_window_event(WindowEvent::KeyEvent(ch, key, key_state, key_modifiers)) - }} - - fn send_mouse_click_event(&this, - event: *const cef_mouse_event [&cef_mouse_event], - mouse_button_type: cef_mouse_button_type_t [cef_mouse_button_type_t], - mouse_up: c_int [c_int], - _click_count: c_int [c_int],) - -> () {{ - let event: &cef_mouse_event = event; - let mouse_button_type: cef_mouse_button_type_t = mouse_button_type; - let mouse_up: c_int = mouse_up; - let button_type = match mouse_button_type { - cef_mouse_button_type_t::MBT_LEFT => MouseButton::Left, - cef_mouse_button_type_t::MBT_MIDDLE => MouseButton::Middle, - cef_mouse_button_type_t::MBT_RIGHT => MouseButton::Right, - }; - let point = TypedPoint2D::new((*event).x as f32, (*event).y as f32); - if mouse_up != 0 { - this.downcast().send_window_event(WindowEvent::MouseWindowEventClass( - MouseWindowEvent::Click(button_type, point))) - } else { - this.downcast().send_window_event(WindowEvent::MouseWindowEventClass( - MouseWindowEvent::MouseUp(button_type, point))) - } - }} - - fn send_mouse_move_event(&this, event: *const cef_mouse_event [&cef_mouse_event], - _mouse_exited: c_int [c_int],) - -> () {{ - let event: &cef_mouse_event = event; - let point = TypedPoint2D::new((*event).x as f32, (*event).y as f32); - this.downcast().send_window_event(WindowEvent::MouseWindowMoveEventClass(point)) - }} - - fn send_mouse_wheel_event(&this, - event: *const cef_mouse_event [&cef_mouse_event], - delta_x: c_int [c_int], - delta_y: c_int [c_int],) - -> () {{ - let event: &cef_mouse_event = event; - let delta_x: c_int = delta_x; - let delta_y: c_int = delta_y; - let delta = TypedVector2D::new(delta_x as f32, delta_y as f32); - let origin = TypedPoint2D::new((*event).x as i32, (*event).y as i32); - this.downcast().send_window_event(WindowEvent::Scroll(ScrollLocation::Delta(delta), - origin, - TouchEventType::Move)) - }} - - fn get_zoom_level(&this,) -> c_double {{ - this.downcast().pinch_zoom_level() as c_double - }} - - fn set_zoom_level(&this, new_zoom_level: c_double [c_double],) -> () {{ - let new_zoom_level: c_double = new_zoom_level; - let old_zoom_level = this.get_zoom_level(); - this.downcast().send_window_event(WindowEvent::PinchZoom((new_zoom_level / old_zoom_level) as f32)) - }} - - fn initialize_compositing(&_this,) -> () {{ - }} - - fn composite(&this,) -> () {{ - this.downcast().composite_ok.set(true); - this.downcast().send_window_event(WindowEvent::Refresh); - this.downcast().composite_ok.set(false); - }} - - fn get_window_handle(&this,) -> cef_window_handle_t {{ - let t = this.downcast(); - let browser = t.browser.borrow(); - browser::get_window(&browser.as_ref().unwrap()) as cef_window_handle_t - }} - } -} - -impl ServoCefBrowserHost { - pub fn new(client: CefClient) -> ServoCefBrowserHost { - ServoCefBrowserHost { - browser: RefCell::new(None), - client: client, - composite_ok: Cell::new(false), - } - } - - fn send_window_event(&self, event: WindowEvent) { - self.browser.borrow_mut().as_mut().unwrap().send_window_event(event); - } - - fn pinch_zoom_level(&self) -> f32 { - self.browser.borrow_mut().as_mut().unwrap().pinch_zoom_level() - } -} - -pub trait ServoCefBrowserHostExtensions { - fn set_browser(&self, browser: CefBrowser); -} - -impl ServoCefBrowserHostExtensions for CefBrowserHost { - fn set_browser(&self, browser: CefBrowser) { - *self.downcast().browser.borrow_mut() = Some(browser) - } -} - diff --git a/ports/cef/command_line.rs b/ports/cef/command_line.rs deleted file mode 100644 index bf010075cdc..00000000000 --- a/ports/cef/command_line.rs +++ /dev/null @@ -1,106 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::cef_command_line_t; - -use libc::{calloc, c_int, c_char, size_t}; -use std::ffi; -use std::mem; -use std::slice; -use std::str; -use string as cef_string; -use string::cef_string_utf16_set; -use types::{cef_string_t, cef_string_userfree_t, cef_string_utf16_t}; - -type command_line_t = command_line; -struct command_line { - pub cl: cef_command_line_t, - pub argc: c_int, - pub argv: Vec<String>, -} - -static mut GLOBAL_CMDLINE: Option<*mut command_line_t> = None; - -fn command_line_new() -> *mut command_line_t { - unsafe { - let cl = calloc(1, mem::size_of::<command_line>() as size_t) as *mut command_line_t; - (*cl).cl.base.size = mem::size_of::<cef_command_line_t>() as size_t; - cl - } -} - -pub fn command_line_init(argc: c_int, argv: *const *const u8) { - unsafe { - let args = slice::from_raw_parts(argv, argc as usize); - let a = args.iter().map(|&arg| { - let slice = ffi::CStr::from_ptr(arg as *const c_char); - str::from_utf8(slice.to_bytes()).unwrap().to_owned() - }).collect(); - let cl = command_line_new(); - (*cl).argc = argc; - (*cl).argv = a; - (*cl).cl.get_switch_value = Some(command_line_get_switch_value as extern "C" fn(*mut cef_command_line_t, *const cef_string_t) -> cef_string_userfree_t); - GLOBAL_CMDLINE = Some(cl); - } -} - -#[no_mangle] -pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, name: *const cef_string_t) -> cef_string_userfree_t { - if cmd.is_null() || name.is_null() { - return cef_string::empty_utf16_userfree_string() - } - unsafe { - //technically cef_string_t can be any type of character size - //but the default cef callback uses utf16, so I'm jumping on board the SS Copy - let cl: *mut command_line_t = mem::transmute(cmd); - let cs: *const cef_string_utf16_t = mem::transmute(name); - let buf = (*cs).str as *const _; - let slice = slice::from_raw_parts(buf, (*cs).length as usize); - let opt = String::from_utf16(slice).unwrap(); - //debug!("opt: {}", opt); - for s in &(*cl).argv { - let o = s.trim_left_matches('-'); - //debug!("arg: {}", o); - if o.starts_with(&opt) { - let mut string = mem::uninitialized(); - let arg = o[opt.len() + 1..].as_bytes(); - let c_str = ffi::CString::new(arg).unwrap(); - cef_string_utf16_set(c_str.as_bytes().as_ptr() as *const _, - arg.len() as size_t, - &mut string, - 1); - return cef_string::string_to_userfree_string(string) - } - } - } - return cef_string::empty_utf16_userfree_string() -} - -#[no_mangle] -pub extern "C" fn cef_command_line_create() -> *mut cef_command_line_t { - unsafe { - let cl = command_line_new(); - (*cl).cl.get_switch_value = Some(command_line_get_switch_value as extern "C" fn(*mut cef_command_line_t, *const cef_string_t) -> cef_string_userfree_t); - mem::transmute(cl) - } -} - -#[no_mangle] -pub extern "C" fn cef_command_line_get_global() -> *mut cef_command_line_t { - unsafe { - match GLOBAL_CMDLINE { - Some(scl) => { - mem::transmute(scl) - }, - None => { - 0 as *mut cef_command_line_t - } - } - } -} - -cef_stub_static_method_impls! { - fn cef_command_line_create_command_line() -> *mut cef_command_line_t - fn cef_command_line_get_global_command_line() -> *mut cef_command_line_t -} diff --git a/ports/cef/cookie.rs b/ports/cef/cookie.rs deleted file mode 100644 index a710b70833c..00000000000 --- a/ports/cef/cookie.rs +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_completion_callback_t, cef_cookie_manager_t}; -use types::cef_string_t; - -use libc::c_int; - -cef_stub_static_method_impls! { - fn cef_cookie_manager_get_global_manager(callback: *mut cef_completion_callback_t) -> *mut cef_cookie_manager_t - fn cef_cookie_manager_create_manager(path: *const cef_string_t, - persist_session_cookies: c_int, - callback: *mut cef_completion_callback_t) - -> *mut cef_cookie_manager_t -} - diff --git a/ports/cef/core.rs b/ports/cef/core.rs deleted file mode 100644 index c3bef096f85..00000000000 --- a/ports/cef/core.rs +++ /dev/null @@ -1,127 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use command_line::command_line_init; -use interfaces::cef_app_t; -use types::{cef_main_args_t, cef_settings_t}; -use window::init_window; - -use browser; -use libc::{c_char, c_int, c_void}; -use servo_config::opts; -use std::ffi; -use std::str; - -//static HOME_URL: &'static str = "http://s27.postimg.org/vqbtrolyr/servo.jpg"; - -static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0"; -#[cfg(target_os="windows")] -static CEF_API_HASH_PLATFORM: &'static [u8] = b"5c7f3e50ff5265985d11dc1a466513e25748bedd\0"; -#[cfg(target_os="macos")] -static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650b251bf3d\0"; -#[cfg(target_os="linux")] -static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0"; - -pub static mut CEF_APP: *mut cef_app_t = 0 as *mut cef_app_t; - - -#[no_mangle] -pub extern "C" fn cef_initialize(args: *const cef_main_args_t, - settings: *mut cef_settings_t, - application: *mut cef_app_t, - _windows_sandbox_info: *const c_void) - -> c_int { - if args.is_null() { - return 0; - } - unsafe { - if !CEF_APP.is_null() { - panic!("Attempting to call cef_initialize() multiple times!"); - } - } - - unsafe { - command_line_init((*args).argc, (*args).argv); - - if !application.is_null() { - (*application).get_browser_process_handler.map(|cb| { - let handler = cb(application); - if !handler.is_null() { - (*handler).on_context_initialized.map(|hcb| hcb(handler)); - } - }); - CEF_APP = application; - } - } - - let mut temp_opts = opts::default_opts(); - temp_opts.headless = false; - temp_opts.hard_fail = false; - temp_opts.enable_text_antialiasing = true; - temp_opts.enable_canvas_antialiasing = true; - temp_opts.url = None; - opts::set_defaults(temp_opts); - - if unsafe { (*settings).windowless_rendering_enabled != 0 } { - init_window(); - } - - return 1 -} - -#[no_mangle] -pub extern "C" fn cef_shutdown() { -} - -#[no_mangle] -pub extern "C" fn cef_run_message_loop() { - // GWTODO: Support blocking message loop - // again. Although, will it ever actually - // be used or will everything use the - // cef_do_message_loop_work function below - // as our current miniservo apps do? - unimplemented!() -} - -#[no_mangle] -pub extern "C" fn cef_do_message_loop_work() { - browser::update(); -} - -#[no_mangle] -pub extern "C" fn cef_quit_message_loop() { -} - -#[no_mangle] -pub extern "C" fn cef_execute_process(_args: *const cef_main_args_t, - _app: *mut cef_app_t, - _windows_sandbox_info: *mut c_void) - -> c_int { - -1 -} - -#[no_mangle] -pub extern "C" fn cef_api_hash(entry: c_int) -> *const c_char { - if entry == 0 { - &CEF_API_HASH_PLATFORM[0] as *const u8 as *const c_char - } else { - &CEF_API_HASH_UNIVERSAL[0] as *const u8 as *const c_char - } -} - -#[no_mangle] -pub extern "C" fn cef_log(_file: *const c_char, - _line: c_int, - _severity: c_int, - message: *const c_char) { - unsafe { - let slice = ffi::CStr::from_ptr(message); - println!("{}", str::from_utf8(slice.to_bytes()).unwrap()) - } -} - -#[no_mangle] -pub extern "C" fn cef_get_min_log_level() -> c_int { - 0 -} diff --git a/ports/cef/drag_data.rs b/ports/cef/drag_data.rs deleted file mode 100644 index f7660a6b5ca..00000000000 --- a/ports/cef/drag_data.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_drag_data_t}; - -cef_stub_static_method_impls! { - fn cef_drag_data_create() -> *mut cef_drag_data_t -} - diff --git a/ports/cef/eutil.rs b/ports/cef/eutil.rs deleted file mode 100644 index 06591618332..00000000000 --- a/ports/cef/eutil.rs +++ /dev/null @@ -1,83 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use types::cef_base_t; - -use libc::{self, c_int, c_void, size_t}; -use std::mem; -use std::slice; -use std::str; - -/// Allows you to downcast a CEF interface to a CEF class instance. -/// -/// FIXME(pcwalton): This is currently unsafe. I think the right way to make this safe is to (a) -/// forbid more than one Rust implementation of a given interface (easy to do by manufacturing an -/// impl that will conflict if there is more than one) and then (b) add a dynamic check to make -/// sure the `release` for the object is equal to `servo_release`. -pub trait Downcast<Class> { - fn downcast(&self) -> &Class; -} - -pub fn slice_to_str<F>(s: *const u8, l: usize, f: F) -> c_int where F: FnOnce(&str) -> c_int { - unsafe { - let s = slice::from_raw_parts(s, l); - str::from_utf8(s).map(f).unwrap_or(0) - } -} - -/// Creates a new raw CEF object of the given type and sets up its reference counting machinery. -/// All fields are initialized to zero. It is the caller's responsibility to ensure that the given -/// type is a CEF type with `cef_base_t` as its first member. -pub unsafe fn create_cef_object<Base,Extra>(size: size_t) -> *mut Base { - let object = libc::calloc(1, mem::size_of::<Base>() + mem::size_of::<Extra>()) as - *mut cef_base_t; - (*object).size = size; - (*object).add_ref = Some(servo_add_ref as extern "C" fn(*mut cef_base_t) -> c_int); - (*object).release = Some(servo_release as extern "C" fn(*mut cef_base_t) -> c_int); - *ref_count(object) = 1; - object as *mut Base -} - -/// Returns a pointer to the Servo-specific reference count for the given object. This only works -/// on objects that Servo created! -unsafe fn ref_count(object: *mut cef_base_t) -> *mut usize { - // The reference count should be the first field of the extra data. - (object as *mut u8).offset((*object).size as isize) as *mut usize -} - -/// Increments the reference count on a CEF object. This only works on objects that Servo created! -extern "C" fn servo_add_ref(object: *mut cef_base_t) -> c_int { - unsafe { - let count = ref_count(object); - *count += 1; - *count as c_int - } -} - -/// Decrements the reference count on a CEF object. If zero, frees it. This only works on objects -/// that Servo created! -extern "C" fn servo_release(object: *mut cef_base_t) -> c_int { - unsafe { - let count = ref_count(object); - *count -= 1; - let new_count = *count; - if new_count == 0 { - servo_free(object); - } - (new_count == 0) as c_int - } -} - -unsafe fn servo_free(object: *mut cef_base_t) { - libc::free(object as *mut c_void); -} - -pub unsafe fn add_ref(c_object: *mut cef_base_t) { - ((*c_object).add_ref.unwrap())(c_object); -} - -#[no_mangle] -pub extern "C" fn servo_test() -> c_int { - 1 -} diff --git a/ports/cef/frame.rs b/ports/cef/frame.rs deleted file mode 100644 index 387d515faba..00000000000 --- a/ports/cef/frame.rs +++ /dev/null @@ -1,72 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use browser::ServoCefBrowserExtensions; -use eutil::Downcast; -use interfaces::{CefBrowser, CefFrame, CefStringVisitor, cef_frame_t, cef_string_visitor_t}; -use types::{cef_string_t, cef_string_userfree_t}; - -use compositing::windowing::WindowEvent; -use servo::servo_url::ServoUrl; -use std::cell::RefCell; - -pub struct ServoCefFrame { - pub url: RefCell<String>, - pub title: RefCell<Vec<u16>>, - - /// A reference to the browser. - pub browser: RefCell<Option<CefBrowser>>, -} - -impl ServoCefFrame { - pub fn new() -> ServoCefFrame { - ServoCefFrame { - url: RefCell::new(String::new()), - title: RefCell::new(vec![]), - browser: RefCell::new(None), - } - } -} - -full_cef_class_impl! { - ServoCefFrame : CefFrame, cef_frame_t { - fn load_url(&this, url: *const cef_string_t [&[u16]],) -> () {{ - let this = this.downcast(); - let url = String::from_utf16(url).unwrap(); - *this.url.borrow_mut() = url.clone(); - let id = this.browser.borrow().as_ref().unwrap().get_browser_id(); - let url = ServoUrl::parse(&url).or(ServoUrl::parse("about:blank")).unwrap(); - let event = WindowEvent::LoadUrl(id, url); - this.browser.borrow_mut().as_mut().unwrap().send_window_event(event); - }} - fn get_url(&this,) -> cef_string_userfree_t {{ - // FIXME(https://github.com/rust-lang/rust/issues/23338) - let url = this.downcast().url.borrow(); - (*url).clone() - }} - fn get_text(&this, visitor: *mut cef_string_visitor_t [CefStringVisitor],) -> () {{ - let this = this.downcast(); - let str = &*this.title.borrow(); - visitor.visit(str) - }} - } -} - -pub trait ServoCefFrameExtensions { - fn set_browser(&self, browser: CefBrowser); - fn load(&self); -} - -impl ServoCefFrameExtensions for CefFrame { - fn set_browser(&self, browser: CefBrowser) { - *self.downcast().browser.borrow_mut() = Some(browser) - } - fn load(&self) { - let id = self.downcast().browser.borrow().as_ref().unwrap().get_browser_id(); - let url = self.downcast().url.borrow(); - let url = ServoUrl::parse(&*url).or(ServoUrl::parse("about:blank")).unwrap(); - let event = WindowEvent::LoadUrl(id, url); - self.downcast().browser.borrow_mut().as_mut().unwrap().send_window_event(event); - } -} diff --git a/ports/cef/interfaces/cef_app.rs b/ports/cef/interfaces/cef_app.rs deleted file mode 100644 index b12b22304dd..00000000000 --- a/ports/cef/interfaces/cef_app.rs +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to provide handler implementations. Methods will be -// called by the process and/or thread indicated. -// -#[repr(C)] -pub struct _cef_app_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Provides an opportunity to view and/or modify command-line arguments before - // processing by CEF and Chromium. The |process_type| value will be NULL for - // the browser process. Do not keep a reference to the cef_command_line_t - // object passed to this function. The CefSettings.command_line_args_disabled - // value can be used to start with an NULL command-line object. Any values - // specified in CefSettings that equate to command-line arguments will be set - // before this function is called. Be cautious when using this function to - // modify command-line arguments for non-browser processes as this may result - // in undefined behavior including crashes. - // - pub on_before_command_line_processing: Option<extern "C" fn( - this: *mut cef_app_t, process_type: *const types::cef_string_t, - command_line: *mut interfaces::cef_command_line_t) -> ()>, - - // - // Provides an opportunity to register custom schemes. Do not keep a reference - // to the |registrar| object. This function is called on the main thread for - // each process and the registered schemes should be the same across all - // processes. - // - pub on_register_custom_schemes: Option<extern "C" fn(this: *mut cef_app_t, - registrar: *mut interfaces::cef_scheme_registrar_t) -> ()>, - - // - // Return the handler for resource bundle events. If - // CefSettings.pack_loading_disabled is true (1) a handler must be returned. - // If no handler is returned resources will be loaded from pack files. This - // function is called by the browser and render processes on multiple threads. - // - pub get_resource_bundle_handler: Option<extern "C" fn( - this: *mut cef_app_t) -> *mut interfaces::cef_resource_bundle_handler_t>, - - // - // Return the handler for functionality specific to the browser process. This - // function is called on multiple threads in the browser process. - // - pub get_browser_process_handler: Option<extern "C" fn( - this: *mut cef_app_t) -> *mut interfaces::cef_browser_process_handler_t>, - - // - // Return the handler for functionality specific to the render process. This - // function is called on the render process main thread. - // - pub get_render_process_handler: Option<extern "C" fn( - this: *mut cef_app_t) -> *mut interfaces::cef_render_process_handler_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_app_t = _cef_app_t; - - -// -// Implement this structure to provide handler implementations. Methods will be -// called by the process and/or thread indicated. -// -pub struct CefApp { - c_object: *mut cef_app_t, -} - -impl Clone for CefApp { - fn clone(&self) -> CefApp{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefApp { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefApp { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefApp { - pub unsafe fn from_c_object(c_object: *mut cef_app_t) -> CefApp { - CefApp { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_app_t) -> CefApp { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefApp { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_app_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_app_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Provides an opportunity to view and/or modify command-line arguments before - // processing by CEF and Chromium. The |process_type| value will be NULL for - // the browser process. Do not keep a reference to the cef_command_line_t - // object passed to this function. The CefSettings.command_line_args_disabled - // value can be used to start with an NULL command-line object. Any values - // specified in CefSettings that equate to command-line arguments will be set - // before this function is called. Be cautious when using this function to - // modify command-line arguments for non-browser processes as this may result - // in undefined behavior including crashes. - // - pub fn on_before_command_line_processing(&self, process_type: &[u16], - command_line: interfaces::CefCommandLine) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_command_line_processing.unwrap())( - self.c_object, - CefWrap::to_c(process_type), - CefWrap::to_c(command_line))) - } - } - - // - // Provides an opportunity to register custom schemes. Do not keep a reference - // to the |registrar| object. This function is called on the main thread for - // each process and the registered schemes should be the same across all - // processes. - // - pub fn on_register_custom_schemes(&self, - registrar: interfaces::CefSchemeRegistrar) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_register_custom_schemes.unwrap())( - self.c_object, - CefWrap::to_c(registrar))) - } - } - - // - // Return the handler for resource bundle events. If - // CefSettings.pack_loading_disabled is true (1) a handler must be returned. - // If no handler is returned resources will be loaded from pack files. This - // function is called by the browser and render processes on multiple threads. - // - pub fn get_resource_bundle_handler( - &self) -> interfaces::CefResourceBundleHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_resource_bundle_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for functionality specific to the browser process. This - // function is called on multiple threads in the browser process. - // - pub fn get_browser_process_handler( - &self) -> interfaces::CefBrowserProcessHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_browser_process_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for functionality specific to the render process. This - // function is called on the render process main thread. - // - pub fn get_render_process_handler( - &self) -> interfaces::CefRenderProcessHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_render_process_handler.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_app_t> for CefApp { - fn to_c(rust_object: CefApp) -> *mut cef_app_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_app_t) -> CefApp { - CefApp::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_app_t> for Option<CefApp> { - fn to_c(rust_object: Option<CefApp>) -> *mut cef_app_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_app_t) -> Option<CefApp> { - if c_object.is_null() { - None - } else { - Some(CefApp::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_auth_callback.rs b/ports/cef/interfaces/cef_auth_callback.rs deleted file mode 100644 index 1b735fc2abd..00000000000 --- a/ports/cef/interfaces/cef_auth_callback.rs +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure used for asynchronous continuation of authentication -// requests. -// -#[repr(C)] -pub struct _cef_auth_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue the authentication request. - // - pub cont: Option<extern "C" fn(this: *mut cef_auth_callback_t, - username: *const types::cef_string_t, - password: *const types::cef_string_t) -> ()>, - - // - // Cancel the authentication request. - // - pub cancel: Option<extern "C" fn(this: *mut cef_auth_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_auth_callback_t = _cef_auth_callback_t; - - -// -// Callback structure used for asynchronous continuation of authentication -// requests. -// -pub struct CefAuthCallback { - c_object: *mut cef_auth_callback_t, -} - -impl Clone for CefAuthCallback { - fn clone(&self) -> CefAuthCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefAuthCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefAuthCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefAuthCallback { - pub unsafe fn from_c_object(c_object: *mut cef_auth_callback_t) -> CefAuthCallback { - CefAuthCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_auth_callback_t) -> CefAuthCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefAuthCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_auth_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_auth_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue the authentication request. - // - pub fn cont(&self, username: &[u16], password: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(username), - CefWrap::to_c(password))) - } - } - - // - // Cancel the authentication request. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_auth_callback_t> for CefAuthCallback { - fn to_c(rust_object: CefAuthCallback) -> *mut cef_auth_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_auth_callback_t) -> CefAuthCallback { - CefAuthCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_auth_callback_t> for Option<CefAuthCallback> { - fn to_c(rust_object: Option<CefAuthCallback>) -> *mut cef_auth_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_auth_callback_t) -> Option<CefAuthCallback> { - if c_object.is_null() { - None - } else { - Some(CefAuthCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_browser.rs b/ports/cef/interfaces/cef_browser.rs deleted file mode 100644 index 8ba378bf3b5..00000000000 --- a/ports/cef/interfaces/cef_browser.rs +++ /dev/null @@ -1,2472 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent a browser window. When used in the browser -// process the functions of this structure may be called on any thread unless -// otherwise indicated in the comments. When used in the render process the -// functions of this structure may only be called on the main thread. -// -#[repr(C)] -pub struct _cef_browser_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the browser host object. This function can only be called in the - // browser process. - // - pub get_host: Option<extern "C" fn( - this: *mut cef_browser_t) -> *mut interfaces::cef_browser_host_t>, - - // - // Returns true (1) if the browser can navigate backwards. - // - pub can_go_back: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::c_int>, - - // - // Navigate backwards. - // - pub go_back: Option<extern "C" fn(this: *mut cef_browser_t) -> ()>, - - // - // Returns true (1) if the browser can navigate forwards. - // - pub can_go_forward: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::c_int>, - - // - // Navigate forwards. - // - pub go_forward: Option<extern "C" fn(this: *mut cef_browser_t) -> ()>, - - // - // Returns true (1) if the browser is currently loading. - // - pub is_loading: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::c_int>, - - // - // Reload the current page. - // - pub reload: Option<extern "C" fn(this: *mut cef_browser_t) -> ()>, - - // - // Reload the current page ignoring any cached data. - // - pub reload_ignore_cache: Option<extern "C" fn(this: *mut cef_browser_t) -> ( - )>, - - // - // Stop loading the page. - // - pub stop_load: Option<extern "C" fn(this: *mut cef_browser_t) -> ()>, - - // - // Returns the globally unique identifier for this browser. - // - pub get_identifier: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::c_int>, - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_browser_t, - that: *mut interfaces::cef_browser_t) -> libc::c_int>, - - // - // Returns true (1) if the window is a popup window. - // - pub is_popup: Option<extern "C" fn(this: *mut cef_browser_t) -> libc::c_int>, - - // - // Returns true (1) if a document has been loaded in the browser. - // - pub has_document: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::c_int>, - - // - // Returns the main (top-level) frame for the browser window. - // - pub get_main_frame: Option<extern "C" fn( - this: *mut cef_browser_t) -> *mut interfaces::cef_frame_t>, - - // - // Returns the focused frame for the browser window. - // - pub get_focused_frame: Option<extern "C" fn( - this: *mut cef_browser_t) -> *mut interfaces::cef_frame_t>, - - // - // Returns the frame with the specified identifier, or NULL if not found. - // - pub get_frame_byident: Option<extern "C" fn(this: *mut cef_browser_t, - identifier: i64) -> *mut interfaces::cef_frame_t>, - - // - // Returns the frame with the specified name, or NULL if not found. - // - pub get_frame: Option<extern "C" fn(this: *mut cef_browser_t, - name: *const types::cef_string_t) -> *mut interfaces::cef_frame_t>, - - // - // Returns the number of frames that currently exist. - // - pub get_frame_count: Option<extern "C" fn( - this: *mut cef_browser_t) -> libc::size_t>, - - // - // Returns the identifiers of all existing frames. - // - pub get_frame_identifiers: Option<extern "C" fn(this: *mut cef_browser_t, - identifiers_count: *mut libc::size_t, identifiers: *mut i64) -> ()>, - - // - // Returns the names of all existing frames. - // - pub get_frame_names: Option<extern "C" fn(this: *mut cef_browser_t, - names: &types::cef_string_list_t) -> ()>, - - // - // Send a message to the specified |target_process|. Returns true (1) if the - // message was sent successfully. - // - pub send_process_message: Option<extern "C" fn(this: *mut cef_browser_t, - target_process: interfaces::cef_process_id_t, - message: *mut interfaces::cef_process_message_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_browser_t = _cef_browser_t; - - -// -// Structure used to represent a browser window. When used in the browser -// process the functions of this structure may be called on any thread unless -// otherwise indicated in the comments. When used in the render process the -// functions of this structure may only be called on the main thread. -// -pub struct CefBrowser { - c_object: *mut cef_browser_t, -} - -impl Clone for CefBrowser { - fn clone(&self) -> CefBrowser{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefBrowser { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefBrowser { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefBrowser { - pub unsafe fn from_c_object(c_object: *mut cef_browser_t) -> CefBrowser { - CefBrowser { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_t) -> CefBrowser { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefBrowser { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_browser_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_browser_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the browser host object. This function can only be called in the - // browser process. - // - pub fn get_host(&self) -> interfaces::CefBrowserHost { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_host.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the browser can navigate backwards. - // - pub fn can_go_back(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).can_go_back.unwrap())( - self.c_object)) - } - } - - // - // Navigate backwards. - // - pub fn go_back(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).go_back.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the browser can navigate forwards. - // - pub fn can_go_forward(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).can_go_forward.unwrap())( - self.c_object)) - } - } - - // - // Navigate forwards. - // - pub fn go_forward(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).go_forward.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the browser is currently loading. - // - pub fn is_loading(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_loading.unwrap())( - self.c_object)) - } - } - - // - // Reload the current page. - // - pub fn reload(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).reload.unwrap())( - self.c_object)) - } - } - - // - // Reload the current page ignoring any cached data. - // - pub fn reload_ignore_cache(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).reload_ignore_cache.unwrap())( - self.c_object)) - } - } - - // - // Stop loading the page. - // - pub fn stop_load(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).stop_load.unwrap())( - self.c_object)) - } - } - - // - // Returns the globally unique identifier for this browser. - // - pub fn get_identifier(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_identifier.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub fn is_same(&self, that: interfaces::CefBrowser) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if the window is a popup window. - // - pub fn is_popup(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_popup.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if a document has been loaded in the browser. - // - pub fn has_document(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_document.unwrap())( - self.c_object)) - } - } - - // - // Returns the main (top-level) frame for the browser window. - // - pub fn get_main_frame(&self) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_main_frame.unwrap())( - self.c_object)) - } - } - - // - // Returns the focused frame for the browser window. - // - pub fn get_focused_frame(&self) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_focused_frame.unwrap())( - self.c_object)) - } - } - - // - // Returns the frame with the specified identifier, or NULL if not found. - // - pub fn get_frame_byident(&self, identifier: i64) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_byident.unwrap())( - self.c_object, - CefWrap::to_c(identifier))) - } - } - - // - // Returns the frame with the specified name, or NULL if not found. - // - pub fn get_frame(&self, name: &[u16]) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Returns the number of frames that currently exist. - // - pub fn get_frame_count(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_count.unwrap())( - self.c_object)) - } - } - - // - // Returns the identifiers of all existing frames. - // - pub fn get_frame_identifiers(&self, identifiers_count: *mut libc::size_t, - identifiers: *mut i64) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_identifiers.unwrap())( - self.c_object, - CefWrap::to_c(identifiers_count), - CefWrap::to_c(identifiers))) - } - } - - // - // Returns the names of all existing frames. - // - pub fn get_frame_names(&self, names: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_names.unwrap())( - self.c_object, - CefWrap::to_c(names))) - } - } - - // - // Send a message to the specified |target_process|. Returns true (1) if the - // message was sent successfully. - // - pub fn send_process_message(&self, target_process: interfaces::CefProcessId, - message: interfaces::CefProcessMessage) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_process_message.unwrap())( - self.c_object, - CefWrap::to_c(target_process), - CefWrap::to_c(message))) - } - } -} - -impl CefWrap<*mut cef_browser_t> for CefBrowser { - fn to_c(rust_object: CefBrowser) -> *mut cef_browser_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_browser_t) -> CefBrowser { - CefBrowser::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_browser_t> for Option<CefBrowser> { - fn to_c(rust_object: Option<CefBrowser>) -> *mut cef_browser_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_browser_t) -> Option<CefBrowser> { - if c_object.is_null() { - None - } else { - Some(CefBrowser::from_c_object_addref(c_object)) - } - } -} - - -// -// Callback structure for cef_browser_host_t::RunFileDialog. The functions of -// this structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_run_file_dialog_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called asynchronously after the file dialog is dismissed. - // |selected_accept_filter| is the 0-based index of the value selected from - // the accept filters array passed to cef_browser_host_t::RunFileDialog. - // |file_paths| will be a single value or a list of values depending on the - // dialog mode. If the selection was cancelled |file_paths| will be NULL. - // - pub on_file_dialog_dismissed: Option<extern "C" fn( - this: *mut cef_run_file_dialog_callback_t, - selected_accept_filter: libc::c_int, - file_paths: &types::cef_string_list_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_run_file_dialog_callback_t = _cef_run_file_dialog_callback_t; - - -// -// Callback structure for cef_browser_host_t::RunFileDialog. The functions of -// this structure will be called on the browser process UI thread. -// -pub struct CefRunFileDialogCallback { - c_object: *mut cef_run_file_dialog_callback_t, -} - -impl Clone for CefRunFileDialogCallback { - fn clone(&self) -> CefRunFileDialogCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRunFileDialogCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRunFileDialogCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRunFileDialogCallback { - pub unsafe fn from_c_object(c_object: *mut cef_run_file_dialog_callback_t) -> CefRunFileDialogCallback { - CefRunFileDialogCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_run_file_dialog_callback_t) -> CefRunFileDialogCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRunFileDialogCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_run_file_dialog_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_run_file_dialog_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called asynchronously after the file dialog is dismissed. - // |selected_accept_filter| is the 0-based index of the value selected from - // the accept filters array passed to cef_browser_host_t::RunFileDialog. - // |file_paths| will be a single value or a list of values depending on the - // dialog mode. If the selection was cancelled |file_paths| will be NULL. - // - pub fn on_file_dialog_dismissed(&self, selected_accept_filter: libc::c_int, - file_paths: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_file_dialog_dismissed.unwrap())( - self.c_object, - CefWrap::to_c(selected_accept_filter), - CefWrap::to_c(file_paths))) - } - } -} - -impl CefWrap<*mut cef_run_file_dialog_callback_t> for CefRunFileDialogCallback { - fn to_c(rust_object: CefRunFileDialogCallback) -> *mut cef_run_file_dialog_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_run_file_dialog_callback_t) -> CefRunFileDialogCallback { - CefRunFileDialogCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_run_file_dialog_callback_t> for Option<CefRunFileDialogCallback> { - fn to_c(rust_object: Option<CefRunFileDialogCallback>) -> *mut cef_run_file_dialog_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_run_file_dialog_callback_t) -> Option<CefRunFileDialogCallback> { - if c_object.is_null() { - None - } else { - Some(CefRunFileDialogCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Callback structure for cef_browser_host_t::GetNavigationEntries. The -// functions of this structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_navigation_entry_visitor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be executed. Do not keep a reference to |entry| outside of - // this callback. Return true (1) to continue visiting entries or false (0) to - // stop. |current| is true (1) if this entry is the currently loaded - // navigation entry. |index| is the 0-based index of this entry and |total| is - // the total number of entries. - // - pub visit: Option<extern "C" fn(this: *mut cef_navigation_entry_visitor_t, - entry: *mut interfaces::cef_navigation_entry_t, current: libc::c_int, - index: libc::c_int, total: libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_navigation_entry_visitor_t = _cef_navigation_entry_visitor_t; - - -// -// Callback structure for cef_browser_host_t::GetNavigationEntries. The -// functions of this structure will be called on the browser process UI thread. -// -pub struct CefNavigationEntryVisitor { - c_object: *mut cef_navigation_entry_visitor_t, -} - -impl Clone for CefNavigationEntryVisitor { - fn clone(&self) -> CefNavigationEntryVisitor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefNavigationEntryVisitor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefNavigationEntryVisitor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefNavigationEntryVisitor { - pub unsafe fn from_c_object(c_object: *mut cef_navigation_entry_visitor_t) -> CefNavigationEntryVisitor { - CefNavigationEntryVisitor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_navigation_entry_visitor_t) -> CefNavigationEntryVisitor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefNavigationEntryVisitor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_navigation_entry_visitor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_navigation_entry_visitor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be executed. Do not keep a reference to |entry| outside of - // this callback. Return true (1) to continue visiting entries or false (0) to - // stop. |current| is true (1) if this entry is the currently loaded - // navigation entry. |index| is the 0-based index of this entry and |total| is - // the total number of entries. - // - pub fn visit(&self, entry: interfaces::CefNavigationEntry, - current: libc::c_int, index: libc::c_int, - total: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit.unwrap())( - self.c_object, - CefWrap::to_c(entry), - CefWrap::to_c(current), - CefWrap::to_c(index), - CefWrap::to_c(total))) - } - } -} - -impl CefWrap<*mut cef_navigation_entry_visitor_t> for CefNavigationEntryVisitor { - fn to_c(rust_object: CefNavigationEntryVisitor) -> *mut cef_navigation_entry_visitor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_navigation_entry_visitor_t) -> CefNavigationEntryVisitor { - CefNavigationEntryVisitor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_navigation_entry_visitor_t> for Option<CefNavigationEntryVisitor> { - fn to_c(rust_object: Option<CefNavigationEntryVisitor>) -> *mut cef_navigation_entry_visitor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_navigation_entry_visitor_t) -> Option<CefNavigationEntryVisitor> { - if c_object.is_null() { - None - } else { - Some(CefNavigationEntryVisitor::from_c_object_addref(c_object)) - } - } -} - - -// -// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this -// structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_pdf_print_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be executed when the PDF printing has completed. |path| is - // the output path. |ok| will be true (1) if the printing completed - // successfully or false (0) otherwise. - // - pub on_pdf_print_finished: Option<extern "C" fn( - this: *mut cef_pdf_print_callback_t, path: *const types::cef_string_t, - ok: libc::c_int) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_pdf_print_callback_t = _cef_pdf_print_callback_t; - - -// -// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this -// structure will be called on the browser process UI thread. -// -pub struct CefPdfPrintCallback { - c_object: *mut cef_pdf_print_callback_t, -} - -impl Clone for CefPdfPrintCallback { - fn clone(&self) -> CefPdfPrintCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPdfPrintCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPdfPrintCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPdfPrintCallback { - pub unsafe fn from_c_object(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback { - CefPdfPrintCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPdfPrintCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_pdf_print_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_pdf_print_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be executed when the PDF printing has completed. |path| is - // the output path. |ok| will be true (1) if the printing completed - // successfully or false (0) otherwise. - // - pub fn on_pdf_print_finished(&self, path: &[u16], ok: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_pdf_print_finished.unwrap())( - self.c_object, - CefWrap::to_c(path), - CefWrap::to_c(ok))) - } - } -} - -impl CefWrap<*mut cef_pdf_print_callback_t> for CefPdfPrintCallback { - fn to_c(rust_object: CefPdfPrintCallback) -> *mut cef_pdf_print_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback { - CefPdfPrintCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_pdf_print_callback_t> for Option<CefPdfPrintCallback> { - fn to_c(rust_object: Option<CefPdfPrintCallback>) -> *mut cef_pdf_print_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> Option<CefPdfPrintCallback> { - if c_object.is_null() { - None - } else { - Some(CefPdfPrintCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to represent the browser process aspects of a browser window. -// The functions of this structure can only be called in the browser process. -// They may be called on any thread in that process unless otherwise indicated -// in the comments. -// -#[repr(C)] -pub struct _cef_browser_host_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the hosted browser object. - // - pub get_browser: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> *mut interfaces::cef_browser_t>, - - // - // Request that the browser close. The JavaScript 'onbeforeunload' event will - // be fired. If |force_close| is false (0) the event handler, if any, will be - // allowed to prompt the user and the user can optionally cancel the close. If - // |force_close| is true (1) the prompt will not be displayed and the close - // will proceed. Results in a call to cef_life_span_handler_t::do_close() if - // the event handler allows the close or if |force_close| is true (1). See - // cef_life_span_handler_t::do_close() documentation for additional usage - // information. - // - pub close_browser: Option<extern "C" fn(this: *mut cef_browser_host_t, - force_close: libc::c_int) -> ()>, - - // - // Set whether the browser is focused. - // - pub set_focus: Option<extern "C" fn(this: *mut cef_browser_host_t, - focus: libc::c_int) -> ()>, - - // - // Set whether the window containing the browser is visible - // (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X. - // - pub set_window_visibility: Option<extern "C" fn(this: *mut cef_browser_host_t, - visible: libc::c_int) -> ()>, - - // - // Retrieve the window handle for this browser. - // - pub get_window_handle: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> types::cef_window_handle_t>, - - // - // Retrieve the window handle of the browser that opened this browser. Will - // return NULL for non-popup windows. This function can be used in combination - // with custom handling of modal windows. - // - pub get_opener_window_handle: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> types::cef_window_handle_t>, - - // - // Returns the client for this browser. - // - pub get_client: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> *mut interfaces::cef_client_t>, - - // - // Returns the request context for this browser. - // - pub get_request_context: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> *mut interfaces::cef_request_context_t>, - - // - // Get the current zoom level. The default zoom level is 0.0. This function - // can only be called on the UI thread. - // - pub get_zoom_level: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> libc::c_double>, - - // - // Change the zoom level to the specified value. Specify 0.0 to reset the zoom - // level. If called on the UI thread the change will be applied immediately. - // Otherwise, the change will be applied asynchronously on the UI thread. - // - pub set_zoom_level: Option<extern "C" fn(this: *mut cef_browser_host_t, - zoomLevel: libc::c_double) -> ()>, - - // - // Call to run a file chooser dialog. Only a single file chooser dialog may be - // pending at any given time. |mode| represents the type of dialog to display. - // |title| to the title to be used for the dialog and may be NULL to show the - // default title ("Open" or "Save" depending on the mode). |default_file_path| - // is the path with optional directory and/or file name component that will be - // initially selected in the dialog. |accept_filters| are used to restrict the - // selectable file types and may any combination of (a) valid lower-cased MIME - // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. - // ".txt" or ".png"), or (c) combined description and file extension delimited - // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). - // |selected_accept_filter| is the 0-based index of the filter that will be - // selected by default. |callback| will be executed after the dialog is - // dismissed or immediately if another dialog is already pending. The dialog - // will be initiated asynchronously on the UI thread. - // - pub run_file_dialog: Option<extern "C" fn(this: *mut cef_browser_host_t, - mode: types::cef_file_dialog_mode_t, title: *const types::cef_string_t, - default_file_path: *const types::cef_string_t, - accept_filters: &types::cef_string_list_t, - selected_accept_filter: libc::c_int, - callback: *mut interfaces::cef_run_file_dialog_callback_t) -> ()>, - - // - // Download the file at |url| using cef_download_handler_t. - // - pub start_download: Option<extern "C" fn(this: *mut cef_browser_host_t, - url: *const types::cef_string_t) -> ()>, - - // - // Print the current browser contents. - // - pub print: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>, - - // - // Print the current browser contents to the PDF file specified by |path| and - // execute |callback| on completion. The caller is responsible for deleting - // |path| when done. For PDF printing to work on Linux you must implement the - // cef_print_handler_t::GetPdfPaperSize function. - // - pub print_to_pdf: Option<extern "C" fn(this: *mut cef_browser_host_t, - path: *const types::cef_string_t, - settings: *const interfaces::cef_pdf_print_settings_t, - callback: *mut interfaces::cef_pdf_print_callback_t) -> ()>, - - // - // Search for |searchText|. |identifier| can be used to have multiple searches - // running simultaniously. |forward| indicates whether to search forward or - // backward within the page. |matchCase| indicates whether the search should - // be case-sensitive. |findNext| indicates whether this is the first request - // or a follow-up. The cef_find_handler_t instance, if any, returned via - // cef_client_t::GetFindHandler will be called to report find results. - // - pub find: Option<extern "C" fn(this: *mut cef_browser_host_t, - identifier: libc::c_int, searchText: *const types::cef_string_t, - forward: libc::c_int, matchCase: libc::c_int, findNext: libc::c_int) -> ( - )>, - - // - // Cancel all searches that are currently going on. - // - pub stop_finding: Option<extern "C" fn(this: *mut cef_browser_host_t, - clearSelection: libc::c_int) -> ()>, - - // - // Open developer tools in its own window. If |inspect_element_at| is non- - // NULL the element at the specified (x,y) location will be inspected. - // - pub show_dev_tools: Option<extern "C" fn(this: *mut cef_browser_host_t, - windowInfo: *const interfaces::cef_window_info_t, - client: *mut interfaces::cef_client_t, - settings: *const interfaces::cef_browser_settings_t, - inspect_element_at: *const types::cef_point_t) -> ()>, - - // - // Explicitly close the developer tools window if one exists for this browser - // instance. - // - pub close_dev_tools: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ( - )>, - - // - // Retrieve a snapshot of current navigation entries as values sent to the - // specified visitor. If |current_only| is true (1) only the current - // navigation entry will be sent, otherwise all navigation entries will be - // sent. - // - // - pub get_navigation_entries: Option<extern "C" fn( - this: *mut cef_browser_host_t, - visitor: *mut interfaces::cef_navigation_entry_visitor_t, - current_only: libc::c_int) -> ()>, - - // - // Set whether mouse cursor change is disabled. - // - pub set_mouse_cursor_change_disabled: Option<extern "C" fn( - this: *mut cef_browser_host_t, disabled: libc::c_int) -> ()>, - - // - // Returns true (1) if mouse cursor change is disabled. - // - pub is_mouse_cursor_change_disabled: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> libc::c_int>, - - // - // If a misspelled word is currently selected in an editable node calling this - // function will replace it with the specified |word|. - // - pub replace_misspelling: Option<extern "C" fn(this: *mut cef_browser_host_t, - word: *const types::cef_string_t) -> ()>, - - // - // Add the specified |word| to the spelling dictionary. - // - pub add_word_to_dictionary: Option<extern "C" fn( - this: *mut cef_browser_host_t, word: *const types::cef_string_t) -> ()>, - - // - // Returns true (1) if window rendering is disabled. - // - pub is_window_rendering_disabled: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> libc::c_int>, - - // - // Notify the browser that the widget has been resized. The browser will first - // call cef_render_handler_t::GetViewRect to get the new size and then call - // cef_render_handler_t::OnPaint asynchronously with the updated regions. This - // function is only used when window rendering is disabled. - // - pub was_resized: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>, - - // - // Notify the browser that it has been hidden or shown. Layouting and - // cef_render_handler_t::OnPaint notification will stop when the browser is - // hidden. This function is only used when window rendering is disabled. - // - pub was_hidden: Option<extern "C" fn(this: *mut cef_browser_host_t, - hidden: libc::c_int) -> ()>, - - // - // Send a notification to the browser that the screen info has changed. The - // browser will then call cef_render_handler_t::GetScreenInfo to update the - // screen information with the new values. This simulates moving the webview - // window from one display to another, or changing the properties of the - // current display. This function is only used when window rendering is - // disabled. - // - pub notify_screen_info_changed: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // Invalidate the view. The browser will call cef_render_handler_t::OnPaint - // asynchronously. This function is only used when window rendering is - // disabled. - // - pub invalidate: Option<extern "C" fn(this: *mut cef_browser_host_t, - ty: types::cef_paint_element_type_t) -> ()>, - - // - // Send a key event to the browser. - // - pub send_key_event: Option<extern "C" fn(this: *mut cef_browser_host_t, - event: *const interfaces::cef_key_event_t) -> ()>, - - // - // Send a mouse click event to the browser. The |x| and |y| coordinates are - // relative to the upper-left corner of the view. - // - pub send_mouse_click_event: Option<extern "C" fn( - this: *mut cef_browser_host_t, - event: *const interfaces::cef_mouse_event_t, - ty: types::cef_mouse_button_type_t, mouseUp: libc::c_int, - clickCount: libc::c_int) -> ()>, - - // - // Send a mouse move event to the browser. The |x| and |y| coordinates are - // relative to the upper-left corner of the view. - // - pub send_mouse_move_event: Option<extern "C" fn(this: *mut cef_browser_host_t, - event: *const interfaces::cef_mouse_event_t, - mouseLeave: libc::c_int) -> ()>, - - // - // Send a mouse wheel event to the browser. The |x| and |y| coordinates are - // 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. - // In order to scroll inside select popups with window rendering disabled - // cef_render_handler_t::GetScreenPoint should be implemented properly. - // - pub send_mouse_wheel_event: Option<extern "C" fn( - this: *mut cef_browser_host_t, - event: *const interfaces::cef_mouse_event_t, deltaX: libc::c_int, - deltaY: libc::c_int) -> ()>, - - // - // Send a focus event to the browser. - // - pub send_focus_event: Option<extern "C" fn(this: *mut cef_browser_host_t, - setFocus: libc::c_int) -> ()>, - - // - // Send a capture lost event to the browser. - // - pub send_capture_lost_event: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // Notify the browser that the window hosting it is about to be moved or - // resized. This function is only used on Windows and Linux. - // - pub notify_move_or_resize_started: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // Returns the maximum rate in frames per second (fps) that - // cef_render_handler_t:: OnPaint will be called for a windowless browser. The - // actual fps may be lower if the browser cannot generate frames at the - // requested rate. The minimum value is 1 and the maximum value is 60 (default - // 30). This function can only be called on the UI thread. - // - pub get_windowless_frame_rate: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> libc::c_int>, - - // - // Set the maximum rate in frames per second (fps) that cef_render_handler_t:: - // OnPaint will be called for a windowless browser. The actual fps may be - // lower if the browser cannot generate frames at the requested rate. The - // minimum value is 1 and the maximum value is 60 (default 30). Can also be - // set at browser creation via cef_browser_tSettings.windowless_frame_rate. - // - pub set_windowless_frame_rate: Option<extern "C" fn( - this: *mut cef_browser_host_t, frame_rate: libc::c_int) -> ()>, - - // - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. - // - pub get_nstext_input_context: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> types::cef_text_input_context_t>, - - // - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. - // - pub handle_key_event_before_text_input_client: Option<extern "C" fn( - this: *mut cef_browser_host_t, keyEvent: types::cef_event_handle_t) -> ( - )>, - - // - // Performs any additional actions after NSTextInputClient handles the event. - // - pub handle_key_event_after_text_input_client: Option<extern "C" fn( - this: *mut cef_browser_host_t, keyEvent: types::cef_event_handle_t) -> ( - )>, - - // - // Call this function when the user drags the mouse into the web view (before - // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data| - // should not contain file contents as this type of data is not allowed to be - // dragged into the web view. File contents can be removed using - // cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from - // cef_render_handler_t::StartDragging). This function is only used when - // window rendering is disabled. - // - pub drag_target_drag_enter: Option<extern "C" fn( - this: *mut cef_browser_host_t, - drag_data: *mut interfaces::cef_drag_data_t, - event: *const interfaces::cef_mouse_event_t, - allowed_ops: types::cef_drag_operations_mask_t) -> ()>, - - // - // Call this function each time the mouse is moved across the web view during - // a drag operation (after calling DragTargetDragEnter and before calling - // DragTargetDragLeave/DragTargetDrop). This function is only used when window - // rendering is disabled. - // - pub drag_target_drag_over: Option<extern "C" fn(this: *mut cef_browser_host_t, - event: *const interfaces::cef_mouse_event_t, - allowed_ops: types::cef_drag_operations_mask_t) -> ()>, - - // - // Call this function when the user drags the mouse out of the web view (after - // calling DragTargetDragEnter). This function is only used when window - // rendering is disabled. - // - pub drag_target_drag_leave: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // Call this function when the user completes the drag operation by dropping - // the object onto the web view (after calling DragTargetDragEnter). The - // object being dropped is |drag_data|, given as an argument to the previous - // DragTargetDragEnter call. This function is only used when window rendering - // is disabled. - // - pub drag_target_drop: Option<extern "C" fn(this: *mut cef_browser_host_t, - event: *const interfaces::cef_mouse_event_t) -> ()>, - - // - // Call this function when the drag operation started by a - // cef_render_handler_t::StartDragging call has ended either in a drop or by - // being cancelled. |x| and |y| are mouse coordinates relative to the upper- - // left corner of the view. If the web view is both the drag source and the - // drag target then all DragTarget* functions should be called before - // DragSource* mthods. This function is only used when window rendering is - // disabled. - // - pub drag_source_ended_at: Option<extern "C" fn(this: *mut cef_browser_host_t, - x: libc::c_int, y: libc::c_int, - op: types::cef_drag_operations_mask_t) -> ()>, - - // - // Call this function when the drag operation started by a - // cef_render_handler_t::StartDragging call has completed. This function may - // be called immediately without first calling DragSourceEndedAt to cancel a - // drag operation. If the web view is both the drag source and the drag target - // then all DragTarget* functions should be called before DragSource* mthods. - // This function is only used when window rendering is disabled. - // - pub drag_source_system_drag_ended: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // Instructs the browser to perform an accelerated composite. The appropriate - // Direct3D or OpenGL state must have been set up before calling this - // function. - // - pub composite: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>, - - // - // Instructs the browser to initialize accelerated compositing. The - // appropriate Direct3D or OpenGL state must have been set up before calling - // this function. - // - pub initialize_compositing: Option<extern "C" fn( - this: *mut cef_browser_host_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_browser_host_t = _cef_browser_host_t; - - -// -// Structure used to represent the browser process aspects of a browser window. -// The functions of this structure can only be called in the browser process. -// They may be called on any thread in that process unless otherwise indicated -// in the comments. -// -pub struct CefBrowserHost { - c_object: *mut cef_browser_host_t, -} - -impl Clone for CefBrowserHost { - fn clone(&self) -> CefBrowserHost{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefBrowserHost { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefBrowserHost { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefBrowserHost { - pub unsafe fn from_c_object(c_object: *mut cef_browser_host_t) -> CefBrowserHost { - CefBrowserHost { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_host_t) -> CefBrowserHost { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefBrowserHost { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_browser_host_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_browser_host_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the hosted browser object. - // - pub fn get_browser(&self) -> interfaces::CefBrowser { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_browser.unwrap())( - self.c_object)) - } - } - - // - // Request that the browser close. The JavaScript 'onbeforeunload' event will - // be fired. If |force_close| is false (0) the event handler, if any, will be - // allowed to prompt the user and the user can optionally cancel the close. If - // |force_close| is true (1) the prompt will not be displayed and the close - // will proceed. Results in a call to cef_life_span_handler_t::do_close() if - // the event handler allows the close or if |force_close| is true (1). See - // cef_life_span_handler_t::do_close() documentation for additional usage - // information. - // - pub fn close_browser(&self, force_close: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).close_browser.unwrap())( - self.c_object, - CefWrap::to_c(force_close))) - } - } - - // - // Set whether the browser is focused. - // - pub fn set_focus(&self, focus: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_focus.unwrap())( - self.c_object, - CefWrap::to_c(focus))) - } - } - - // - // Set whether the window containing the browser is visible - // (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X. - // - pub fn set_window_visibility(&self, visible: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_window_visibility.unwrap())( - self.c_object, - CefWrap::to_c(visible))) - } - } - - // - // Retrieve the window handle for this browser. - // - pub fn get_window_handle(&self) -> types::cef_window_handle_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_window_handle.unwrap())( - self.c_object)) - } - } - - // - // Retrieve the window handle of the browser that opened this browser. Will - // return NULL for non-popup windows. This function can be used in combination - // with custom handling of modal windows. - // - pub fn get_opener_window_handle(&self) -> types::cef_window_handle_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_opener_window_handle.unwrap())( - self.c_object)) - } - } - - // - // Returns the client for this browser. - // - pub fn get_client(&self) -> interfaces::CefClient { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_client.unwrap())( - self.c_object)) - } - } - - // - // Returns the request context for this browser. - // - pub fn get_request_context(&self) -> interfaces::CefRequestContext { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_request_context.unwrap())( - self.c_object)) - } - } - - // - // Get the current zoom level. The default zoom level is 0.0. This function - // can only be called on the UI thread. - // - pub fn get_zoom_level(&self) -> libc::c_double { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_zoom_level.unwrap())( - self.c_object)) - } - } - - // - // Change the zoom level to the specified value. Specify 0.0 to reset the zoom - // level. If called on the UI thread the change will be applied immediately. - // Otherwise, the change will be applied asynchronously on the UI thread. - // - pub fn set_zoom_level(&self, zoomLevel: libc::c_double) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_zoom_level.unwrap())( - self.c_object, - CefWrap::to_c(zoomLevel))) - } - } - - // - // Call to run a file chooser dialog. Only a single file chooser dialog may be - // pending at any given time. |mode| represents the type of dialog to display. - // |title| to the title to be used for the dialog and may be NULL to show the - // default title ("Open" or "Save" depending on the mode). |default_file_path| - // is the path with optional directory and/or file name component that will be - // initially selected in the dialog. |accept_filters| are used to restrict the - // selectable file types and may any combination of (a) valid lower-cased MIME - // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. - // ".txt" or ".png"), or (c) combined description and file extension delimited - // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). - // |selected_accept_filter| is the 0-based index of the filter that will be - // selected by default. |callback| will be executed after the dialog is - // dismissed or immediately if another dialog is already pending. The dialog - // will be initiated asynchronously on the UI thread. - // - pub fn run_file_dialog(&self, mode: types::cef_file_dialog_mode_t, - title: &[u16], default_file_path: &[u16], accept_filters: &Vec<String>, - selected_accept_filter: libc::c_int, - callback: interfaces::CefRunFileDialogCallback) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).run_file_dialog.unwrap())( - self.c_object, - CefWrap::to_c(mode), - CefWrap::to_c(title), - CefWrap::to_c(default_file_path), - CefWrap::to_c(accept_filters), - CefWrap::to_c(selected_accept_filter), - CefWrap::to_c(callback))) - } - } - - // - // Download the file at |url| using cef_download_handler_t. - // - pub fn start_download(&self, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).start_download.unwrap())( - self.c_object, - CefWrap::to_c(url))) - } - } - - // - // Print the current browser contents. - // - pub fn print(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).print.unwrap())( - self.c_object)) - } - } - - // - // Print the current browser contents to the PDF file specified by |path| and - // execute |callback| on completion. The caller is responsible for deleting - // |path| when done. For PDF printing to work on Linux you must implement the - // cef_print_handler_t::GetPdfPaperSize function. - // - pub fn print_to_pdf(&self, path: &[u16], - settings: &interfaces::CefPdfPrintSettings, - callback: interfaces::CefPdfPrintCallback) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).print_to_pdf.unwrap())( - self.c_object, - CefWrap::to_c(path), - CefWrap::to_c(settings), - CefWrap::to_c(callback))) - } - } - - // - // Search for |searchText|. |identifier| can be used to have multiple searches - // running simultaniously. |forward| indicates whether to search forward or - // backward within the page. |matchCase| indicates whether the search should - // be case-sensitive. |findNext| indicates whether this is the first request - // or a follow-up. The cef_find_handler_t instance, if any, returned via - // cef_client_t::GetFindHandler will be called to report find results. - // - pub fn find(&self, identifier: libc::c_int, searchText: &[u16], - forward: libc::c_int, matchCase: libc::c_int, findNext: libc::c_int) -> ( - ) { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).find.unwrap())( - self.c_object, - CefWrap::to_c(identifier), - CefWrap::to_c(searchText), - CefWrap::to_c(forward), - CefWrap::to_c(matchCase), - CefWrap::to_c(findNext))) - } - } - - // - // Cancel all searches that are currently going on. - // - pub fn stop_finding(&self, clearSelection: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).stop_finding.unwrap())( - self.c_object, - CefWrap::to_c(clearSelection))) - } - } - - // - // Open developer tools in its own window. If |inspect_element_at| is non- - // NULL the element at the specified (x,y) location will be inspected. - // - pub fn show_dev_tools(&self, windowInfo: &interfaces::CefWindowInfo, - client: interfaces::CefClient, settings: &interfaces::CefBrowserSettings, - inspect_element_at: &types::cef_point_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).show_dev_tools.unwrap())( - self.c_object, - CefWrap::to_c(windowInfo), - CefWrap::to_c(client), - CefWrap::to_c(settings), - CefWrap::to_c(inspect_element_at))) - } - } - - // - // Explicitly close the developer tools window if one exists for this browser - // instance. - // - pub fn close_dev_tools(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).close_dev_tools.unwrap())( - self.c_object)) - } - } - - // - // Retrieve a snapshot of current navigation entries as values sent to the - // specified visitor. If |current_only| is true (1) only the current - // navigation entry will be sent, otherwise all navigation entries will be - // sent. - // - // - pub fn get_navigation_entries(&self, - visitor: interfaces::CefNavigationEntryVisitor, - current_only: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_navigation_entries.unwrap())( - self.c_object, - CefWrap::to_c(visitor), - CefWrap::to_c(current_only))) - } - } - - // - // Set whether mouse cursor change is disabled. - // - pub fn set_mouse_cursor_change_disabled(&self, disabled: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_mouse_cursor_change_disabled.unwrap())( - self.c_object, - CefWrap::to_c(disabled))) - } - } - - // - // Returns true (1) if mouse cursor change is disabled. - // - pub fn is_mouse_cursor_change_disabled(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_mouse_cursor_change_disabled.unwrap())( - self.c_object)) - } - } - - // - // If a misspelled word is currently selected in an editable node calling this - // function will replace it with the specified |word|. - // - pub fn replace_misspelling(&self, word: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).replace_misspelling.unwrap())( - self.c_object, - CefWrap::to_c(word))) - } - } - - // - // Add the specified |word| to the spelling dictionary. - // - pub fn add_word_to_dictionary(&self, word: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_word_to_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(word))) - } - } - - // - // Returns true (1) if window rendering is disabled. - // - pub fn is_window_rendering_disabled(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_window_rendering_disabled.unwrap())( - self.c_object)) - } - } - - // - // Notify the browser that the widget has been resized. The browser will first - // call cef_render_handler_t::GetViewRect to get the new size and then call - // cef_render_handler_t::OnPaint asynchronously with the updated regions. This - // function is only used when window rendering is disabled. - // - pub fn was_resized(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).was_resized.unwrap())( - self.c_object)) - } - } - - // - // Notify the browser that it has been hidden or shown. Layouting and - // cef_render_handler_t::OnPaint notification will stop when the browser is - // hidden. This function is only used when window rendering is disabled. - // - pub fn was_hidden(&self, hidden: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).was_hidden.unwrap())( - self.c_object, - CefWrap::to_c(hidden))) - } - } - - // - // Send a notification to the browser that the screen info has changed. The - // browser will then call cef_render_handler_t::GetScreenInfo to update the - // screen information with the new values. This simulates moving the webview - // window from one display to another, or changing the properties of the - // current display. This function is only used when window rendering is - // disabled. - // - pub fn notify_screen_info_changed(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).notify_screen_info_changed.unwrap())( - self.c_object)) - } - } - - // - // Invalidate the view. The browser will call cef_render_handler_t::OnPaint - // asynchronously. This function is only used when window rendering is - // disabled. - // - pub fn invalidate(&self, ty: types::cef_paint_element_type_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).invalidate.unwrap())( - self.c_object, - CefWrap::to_c(ty))) - } - } - - // - // Send a key event to the browser. - // - pub fn send_key_event(&self, event: &interfaces::CefKeyEvent) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_key_event.unwrap())( - self.c_object, - CefWrap::to_c(event))) - } - } - - // - // Send a mouse click event to the browser. The |x| and |y| coordinates are - // relative to the upper-left corner of the view. - // - pub fn send_mouse_click_event(&self, event: &interfaces::CefMouseEvent, - ty: types::cef_mouse_button_type_t, mouseUp: libc::c_int, - clickCount: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_mouse_click_event.unwrap())( - self.c_object, - CefWrap::to_c(event), - CefWrap::to_c(ty), - CefWrap::to_c(mouseUp), - CefWrap::to_c(clickCount))) - } - } - - // - // Send a mouse move event to the browser. The |x| and |y| coordinates are - // relative to the upper-left corner of the view. - // - pub fn send_mouse_move_event(&self, event: &interfaces::CefMouseEvent, - mouseLeave: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_mouse_move_event.unwrap())( - self.c_object, - CefWrap::to_c(event), - CefWrap::to_c(mouseLeave))) - } - } - - // - // Send a mouse wheel event to the browser. The |x| and |y| coordinates are - // 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. - // In order to scroll inside select popups with window rendering disabled - // cef_render_handler_t::GetScreenPoint should be implemented properly. - // - pub fn send_mouse_wheel_event(&self, event: &interfaces::CefMouseEvent, - deltaX: libc::c_int, deltaY: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_mouse_wheel_event.unwrap())( - self.c_object, - CefWrap::to_c(event), - CefWrap::to_c(deltaX), - CefWrap::to_c(deltaY))) - } - } - - // - // Send a focus event to the browser. - // - pub fn send_focus_event(&self, setFocus: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_focus_event.unwrap())( - self.c_object, - CefWrap::to_c(setFocus))) - } - } - - // - // Send a capture lost event to the browser. - // - pub fn send_capture_lost_event(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).send_capture_lost_event.unwrap())( - self.c_object)) - } - } - - // - // Notify the browser that the window hosting it is about to be moved or - // resized. This function is only used on Windows and Linux. - // - pub fn notify_move_or_resize_started(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).notify_move_or_resize_started.unwrap())( - self.c_object)) - } - } - - // - // Returns the maximum rate in frames per second (fps) that - // cef_render_handler_t:: OnPaint will be called for a windowless browser. The - // actual fps may be lower if the browser cannot generate frames at the - // requested rate. The minimum value is 1 and the maximum value is 60 (default - // 30). This function can only be called on the UI thread. - // - pub fn get_windowless_frame_rate(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_windowless_frame_rate.unwrap())( - self.c_object)) - } - } - - // - // Set the maximum rate in frames per second (fps) that cef_render_handler_t:: - // OnPaint will be called for a windowless browser. The actual fps may be - // lower if the browser cannot generate frames at the requested rate. The - // minimum value is 1 and the maximum value is 60 (default 30). Can also be - // set at browser creation via cef_browser_tSettings.windowless_frame_rate. - // - pub fn set_windowless_frame_rate(&self, frame_rate: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_windowless_frame_rate.unwrap())( - self.c_object, - CefWrap::to_c(frame_rate))) - } - } - - // - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. - // - pub fn get_nstext_input_context(&self) -> types::cef_text_input_context_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_nstext_input_context.unwrap())( - self.c_object)) - } - } - - // - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. - // - pub fn handle_key_event_before_text_input_client(&self, - keyEvent: types::cef_event_handle_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).handle_key_event_before_text_input_client.unwrap())( - self.c_object, - CefWrap::to_c(keyEvent))) - } - } - - // - // Performs any additional actions after NSTextInputClient handles the event. - // - pub fn handle_key_event_after_text_input_client(&self, - keyEvent: types::cef_event_handle_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).handle_key_event_after_text_input_client.unwrap())( - self.c_object, - CefWrap::to_c(keyEvent))) - } - } - - // - // Call this function when the user drags the mouse into the web view (before - // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data| - // should not contain file contents as this type of data is not allowed to be - // dragged into the web view. File contents can be removed using - // cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from - // cef_render_handler_t::StartDragging). This function is only used when - // window rendering is disabled. - // - pub fn drag_target_drag_enter(&self, drag_data: interfaces::CefDragData, - event: &interfaces::CefMouseEvent, - allowed_ops: types::cef_drag_operations_mask_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_target_drag_enter.unwrap())( - self.c_object, - CefWrap::to_c(drag_data), - CefWrap::to_c(event), - CefWrap::to_c(allowed_ops))) - } - } - - // - // Call this function each time the mouse is moved across the web view during - // a drag operation (after calling DragTargetDragEnter and before calling - // DragTargetDragLeave/DragTargetDrop). This function is only used when window - // rendering is disabled. - // - pub fn drag_target_drag_over(&self, event: &interfaces::CefMouseEvent, - allowed_ops: types::cef_drag_operations_mask_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_target_drag_over.unwrap())( - self.c_object, - CefWrap::to_c(event), - CefWrap::to_c(allowed_ops))) - } - } - - // - // Call this function when the user drags the mouse out of the web view (after - // calling DragTargetDragEnter). This function is only used when window - // rendering is disabled. - // - pub fn drag_target_drag_leave(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_target_drag_leave.unwrap())( - self.c_object)) - } - } - - // - // Call this function when the user completes the drag operation by dropping - // the object onto the web view (after calling DragTargetDragEnter). The - // object being dropped is |drag_data|, given as an argument to the previous - // DragTargetDragEnter call. This function is only used when window rendering - // is disabled. - // - pub fn drag_target_drop(&self, event: &interfaces::CefMouseEvent) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_target_drop.unwrap())( - self.c_object, - CefWrap::to_c(event))) - } - } - - // - // Call this function when the drag operation started by a - // cef_render_handler_t::StartDragging call has ended either in a drop or by - // being cancelled. |x| and |y| are mouse coordinates relative to the upper- - // left corner of the view. If the web view is both the drag source and the - // drag target then all DragTarget* functions should be called before - // DragSource* mthods. This function is only used when window rendering is - // disabled. - // - pub fn drag_source_ended_at(&self, x: libc::c_int, y: libc::c_int, - op: types::cef_drag_operations_mask_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_source_ended_at.unwrap())( - self.c_object, - CefWrap::to_c(x), - CefWrap::to_c(y), - CefWrap::to_c(op))) - } - } - - // - // Call this function when the drag operation started by a - // cef_render_handler_t::StartDragging call has completed. This function may - // be called immediately without first calling DragSourceEndedAt to cancel a - // drag operation. If the web view is both the drag source and the drag target - // then all DragTarget* functions should be called before DragSource* mthods. - // This function is only used when window rendering is disabled. - // - pub fn drag_source_system_drag_ended(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).drag_source_system_drag_ended.unwrap())( - self.c_object)) - } - } - - // - // Instructs the browser to perform an accelerated composite. The appropriate - // Direct3D or OpenGL state must have been set up before calling this - // function. - // - pub fn composite(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).composite.unwrap())( - self.c_object)) - } - } - - // - // Instructs the browser to initialize accelerated compositing. The - // appropriate Direct3D or OpenGL state must have been set up before calling - // this function. - // - pub fn initialize_compositing(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).initialize_compositing.unwrap())( - self.c_object)) - } - } - - // - // Create a new browser window using the window parameters specified by - // |windowInfo|. All values will be copied internally and the actual window - // will be created on the UI thread. If |request_context| is NULL the global - // request context will be used. This function can be called on any browser - // process thread and will not block. - // - pub fn create_browser(windowInfo: &interfaces::CefWindowInfo, - client: interfaces::CefClient, url: &[u16], - settings: &interfaces::CefBrowserSettings, - request_context: interfaces::CefRequestContext) -> libc::c_int { - unsafe { - CefWrap::to_rust( - ::browser::cef_browser_host_create_browser( - CefWrap::to_c(windowInfo), - CefWrap::to_c(client), - CefWrap::to_c(url), - CefWrap::to_c(settings), - CefWrap::to_c(request_context))) - } - } - - // - // Create a new browser window using the window parameters specified by - // |windowInfo|. If |request_context| is NULL the global request context will - // be used. This function can only be called on the browser process UI thread. - // - pub fn create_browser_sync(windowInfo: &interfaces::CefWindowInfo, - client: interfaces::CefClient, url: &[u16], - settings: &interfaces::CefBrowserSettings, - request_context: interfaces::CefRequestContext) -> interfaces::CefBrowser { - unsafe { - CefWrap::to_rust( - ::browser::cef_browser_host_create_browser_sync( - CefWrap::to_c(windowInfo), - CefWrap::to_c(client), - CefWrap::to_c(url), - CefWrap::to_c(settings), - CefWrap::to_c(request_context))) - } - } -} - -impl CefWrap<*mut cef_browser_host_t> for CefBrowserHost { - fn to_c(rust_object: CefBrowserHost) -> *mut cef_browser_host_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_browser_host_t) -> CefBrowserHost { - CefBrowserHost::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_browser_host_t> for Option<CefBrowserHost> { - fn to_c(rust_object: Option<CefBrowserHost>) -> *mut cef_browser_host_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_browser_host_t) -> Option<CefBrowserHost> { - if c_object.is_null() { - None - } else { - Some(CefBrowserHost::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_browser_process_handler.rs b/ports/cef/interfaces/cef_browser_process_handler.rs deleted file mode 100644 index eb58d839d45..00000000000 --- a/ports/cef/interfaces/cef_browser_process_handler.rs +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to implement browser process callbacks. The functions of this -// structure will be called on the browser process main thread unless otherwise -// indicated. -// -#[repr(C)] -pub struct _cef_browser_process_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called on the browser process UI thread immediately after the CEF context - // has been initialized. - // - pub on_context_initialized: Option<extern "C" fn( - this: *mut cef_browser_process_handler_t) -> ()>, - - // - // Called before a child process is launched. Will be called on the browser - // process UI thread when launching a render process and on the browser - // process IO thread when launching a GPU or plugin process. Provides an - // opportunity to modify the child process command line. Do not keep a - // reference to |command_line| outside of this function. - // - pub on_before_child_process_launch: Option<extern "C" fn( - this: *mut cef_browser_process_handler_t, - command_line: *mut interfaces::cef_command_line_t) -> ()>, - - // - // Called on the browser process IO thread after the main thread has been - // created for a new render process. Provides an opportunity to specify extra - // information that will be passed to - // cef_render_process_handler_t::on_render_thread_created() in the render - // process. Do not keep a reference to |extra_info| outside of this function. - // - pub on_render_process_thread_created: Option<extern "C" fn( - this: *mut cef_browser_process_handler_t, - extra_info: *mut interfaces::cef_list_value_t) -> ()>, - - // - // Return the handler for printing on Linux. If a print handler is not - // provided then printing will not be supported on the Linux platform. - // - pub get_print_handler: Option<extern "C" fn( - this: *mut cef_browser_process_handler_t) -> *mut interfaces::cef_print_handler_t>, - - // - // Called when the application should call cef_do_message_loop_work(). May be - // called from a thread. - // - pub on_work_available: Option<extern "C" fn( - this: *mut cef_browser_process_handler_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_browser_process_handler_t = _cef_browser_process_handler_t; - - -// -// Structure used to implement browser process callbacks. The functions of this -// structure will be called on the browser process main thread unless otherwise -// indicated. -// -pub struct CefBrowserProcessHandler { - c_object: *mut cef_browser_process_handler_t, -} - -impl Clone for CefBrowserProcessHandler { - fn clone(&self) -> CefBrowserProcessHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefBrowserProcessHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefBrowserProcessHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefBrowserProcessHandler { - pub unsafe fn from_c_object(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler { - CefBrowserProcessHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefBrowserProcessHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_browser_process_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_browser_process_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called on the browser process UI thread immediately after the CEF context - // has been initialized. - // - pub fn on_context_initialized(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_context_initialized.unwrap())( - self.c_object)) - } - } - - // - // Called before a child process is launched. Will be called on the browser - // process UI thread when launching a render process and on the browser - // process IO thread when launching a GPU or plugin process. Provides an - // opportunity to modify the child process command line. Do not keep a - // reference to |command_line| outside of this function. - // - pub fn on_before_child_process_launch(&self, - command_line: interfaces::CefCommandLine) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_child_process_launch.unwrap())( - self.c_object, - CefWrap::to_c(command_line))) - } - } - - // - // Called on the browser process IO thread after the main thread has been - // created for a new render process. Provides an opportunity to specify extra - // information that will be passed to - // cef_render_process_handler_t::on_render_thread_created() in the render - // process. Do not keep a reference to |extra_info| outside of this function. - // - pub fn on_render_process_thread_created(&self, - extra_info: interfaces::CefListValue) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_render_process_thread_created.unwrap())( - self.c_object, - CefWrap::to_c(extra_info))) - } - } - - // - // Return the handler for printing on Linux. If a print handler is not - // provided then printing will not be supported on the Linux platform. - // - pub fn get_print_handler(&self) -> interfaces::CefPrintHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_print_handler.unwrap())( - self.c_object)) - } - } - - // - // Called when the application should call cef_do_message_loop_work(). May be - // called from a thread. - // - pub fn on_work_available(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_work_available.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_browser_process_handler_t> for CefBrowserProcessHandler { - fn to_c(rust_object: CefBrowserProcessHandler) -> *mut cef_browser_process_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler { - CefBrowserProcessHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_browser_process_handler_t> for Option<CefBrowserProcessHandler> { - fn to_c(rust_object: Option<CefBrowserProcessHandler>) -> *mut cef_browser_process_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_browser_process_handler_t) -> Option<CefBrowserProcessHandler> { - if c_object.is_null() { - None - } else { - Some(CefBrowserProcessHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_callback.rs b/ports/cef/interfaces/cef_callback.rs deleted file mode 100644 index cec3bc49143..00000000000 --- a/ports/cef/interfaces/cef_callback.rs +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Generic callback structure used for asynchronous continuation. -// -#[repr(C)] -pub struct _cef_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue processing. - // - pub cont: Option<extern "C" fn(this: *mut cef_callback_t) -> ()>, - - // - // Cancel processing. - // - pub cancel: Option<extern "C" fn(this: *mut cef_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_callback_t = _cef_callback_t; - - -// -// Generic callback structure used for asynchronous continuation. -// -pub struct CefCallback { - c_object: *mut cef_callback_t, -} - -impl Clone for CefCallback { - fn clone(&self) -> CefCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefCallback { - pub unsafe fn from_c_object(c_object: *mut cef_callback_t) -> CefCallback { - CefCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_callback_t) -> CefCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue processing. - // - pub fn cont(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object)) - } - } - - // - // Cancel processing. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_callback_t> for CefCallback { - fn to_c(rust_object: CefCallback) -> *mut cef_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_callback_t) -> CefCallback { - CefCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_callback_t> for Option<CefCallback> { - fn to_c(rust_object: Option<CefCallback>) -> *mut cef_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_callback_t) -> Option<CefCallback> { - if c_object.is_null() { - None - } else { - Some(CefCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Generic callback structure used for asynchronous completion. -// -#[repr(C)] -pub struct _cef_completion_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called once the task is complete. - // - pub on_complete: Option<extern "C" fn( - this: *mut cef_completion_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_completion_callback_t = _cef_completion_callback_t; - - -// -// Generic callback structure used for asynchronous completion. -// -pub struct CefCompletionCallback { - c_object: *mut cef_completion_callback_t, -} - -impl Clone for CefCompletionCallback { - fn clone(&self) -> CefCompletionCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefCompletionCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefCompletionCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefCompletionCallback { - pub unsafe fn from_c_object(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback { - CefCompletionCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefCompletionCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_completion_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_completion_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called once the task is complete. - // - pub fn on_complete(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_complete.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_completion_callback_t> for CefCompletionCallback { - fn to_c(rust_object: CefCompletionCallback) -> *mut cef_completion_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback { - CefCompletionCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_completion_callback_t> for Option<CefCompletionCallback> { - fn to_c(rust_object: Option<CefCompletionCallback>) -> *mut cef_completion_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_completion_callback_t) -> Option<CefCompletionCallback> { - if c_object.is_null() { - None - } else { - Some(CefCompletionCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_client.rs b/ports/cef/interfaces/cef_client.rs deleted file mode 100644 index 5c03330bde4..00000000000 --- a/ports/cef/interfaces/cef_client.rs +++ /dev/null @@ -1,484 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to provide handler implementations. -// -#[repr(C)] -pub struct _cef_client_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Return the handler for context menus. If no handler is provided the default - // implementation will be used. - // - pub get_context_menu_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_context_menu_handler_t>, - - // - // Return the handler for dialogs. If no handler is provided the default - // implementation will be used. - // - pub get_dialog_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_dialog_handler_t>, - - // - // Return the handler for browser display state events. - // - pub get_display_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_display_handler_t>, - - // - // Return the handler for download events. If no handler is returned downloads - // will not be allowed. - // - pub get_download_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_download_handler_t>, - - // - // Return the handler for drag events. - // - pub get_drag_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_drag_handler_t>, - - // - // Return the handler for find result events. - // - pub get_find_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_find_handler_t>, - - // - // Return the handler for focus events. - // - pub get_focus_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_focus_handler_t>, - - // - // Return the handler for geolocation permissions requests. If no handler is - // provided geolocation access will be denied by default. - // - pub get_geolocation_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_geolocation_handler_t>, - - // - // Return the handler for JavaScript dialogs. If no handler is provided the - // default implementation will be used. - // - pub get_jsdialog_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_jsdialog_handler_t>, - - // - // Return the handler for keyboard events. - // - pub get_keyboard_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_keyboard_handler_t>, - - // - // Return the handler for browser life span events. - // - pub get_life_span_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_life_span_handler_t>, - - // - // Return the handler for browser load status events. - // - pub get_load_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_load_handler_t>, - - // - // Return the handler for off-screen rendering events. - // - pub get_render_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_render_handler_t>, - - // - // Return the handler for browser request events. - // - pub get_request_handler: Option<extern "C" fn( - this: *mut cef_client_t) -> *mut interfaces::cef_request_handler_t>, - - // - // Called when a new message is received from a different process. Return true - // (1) if the message was handled or false (0) otherwise. Do not keep a - // reference to or attempt to access the message outside of this callback. - // - pub on_process_message_received: Option<extern "C" fn(this: *mut cef_client_t, - browser: *mut interfaces::cef_browser_t, - source_process: interfaces::cef_process_id_t, - message: *mut interfaces::cef_process_message_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_client_t = _cef_client_t; - - -// -// Implement this structure to provide handler implementations. -// -pub struct CefClient { - c_object: *mut cef_client_t, -} - -impl Clone for CefClient { - fn clone(&self) -> CefClient{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefClient { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefClient { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefClient { - pub unsafe fn from_c_object(c_object: *mut cef_client_t) -> CefClient { - CefClient { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_client_t) -> CefClient { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefClient { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_client_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_client_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Return the handler for context menus. If no handler is provided the default - // implementation will be used. - // - pub fn get_context_menu_handler(&self) -> interfaces::CefContextMenuHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_context_menu_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for dialogs. If no handler is provided the default - // implementation will be used. - // - pub fn get_dialog_handler(&self) -> interfaces::CefDialogHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dialog_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for browser display state events. - // - pub fn get_display_handler(&self) -> interfaces::CefDisplayHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_display_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for download events. If no handler is returned downloads - // will not be allowed. - // - pub fn get_download_handler(&self) -> interfaces::CefDownloadHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_download_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for drag events. - // - pub fn get_drag_handler(&self) -> interfaces::CefDragHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_drag_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for find result events. - // - pub fn get_find_handler(&self) -> interfaces::CefFindHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_find_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for focus events. - // - pub fn get_focus_handler(&self) -> interfaces::CefFocusHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_focus_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for geolocation permissions requests. If no handler is - // provided geolocation access will be denied by default. - // - pub fn get_geolocation_handler(&self) -> interfaces::CefGeolocationHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_geolocation_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for JavaScript dialogs. If no handler is provided the - // default implementation will be used. - // - pub fn get_jsdialog_handler(&self) -> interfaces::CefJSDialogHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_jsdialog_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for keyboard events. - // - pub fn get_keyboard_handler(&self) -> interfaces::CefKeyboardHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_keyboard_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for browser life span events. - // - pub fn get_life_span_handler(&self) -> interfaces::CefLifeSpanHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_life_span_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for browser load status events. - // - pub fn get_load_handler(&self) -> interfaces::CefLoadHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_load_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for off-screen rendering events. - // - pub fn get_render_handler(&self) -> interfaces::CefRenderHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_render_handler.unwrap())( - self.c_object)) - } - } - - // - // Return the handler for browser request events. - // - pub fn get_request_handler(&self) -> interfaces::CefRequestHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_request_handler.unwrap())( - self.c_object)) - } - } - - // - // Called when a new message is received from a different process. Return true - // (1) if the message was handled or false (0) otherwise. Do not keep a - // reference to or attempt to access the message outside of this callback. - // - pub fn on_process_message_received(&self, browser: interfaces::CefBrowser, - source_process: interfaces::CefProcessId, - message: interfaces::CefProcessMessage) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_process_message_received.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(source_process), - CefWrap::to_c(message))) - } - } -} - -impl CefWrap<*mut cef_client_t> for CefClient { - fn to_c(rust_object: CefClient) -> *mut cef_client_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_client_t) -> CefClient { - CefClient::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_client_t> for Option<CefClient> { - fn to_c(rust_object: Option<CefClient>) -> *mut cef_client_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_client_t) -> Option<CefClient> { - if c_object.is_null() { - None - } else { - Some(CefClient::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_command_line.rs b/ports/cef/interfaces/cef_command_line.rs deleted file mode 100644 index 489af9f5ceb..00000000000 --- a/ports/cef/interfaces/cef_command_line.rs +++ /dev/null @@ -1,644 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to create and/or parse command line arguments. Arguments with -// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches -// will always precede any arguments without switch prefixes. Switches can -// optionally have a value specified using the '=' delimiter (e.g. -// "-switch=value"). An argument of "--" will terminate switch parsing with all -// subsequent tokens, regardless of prefix, being interpreted as non-switch -// arguments. Switch names are considered case-insensitive. This structure can -// be used before cef_initialize() is called. -// -#[repr(C)] -pub struct _cef_command_line_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_command_line_t) -> libc::c_int>, - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_command_line_t) -> libc::c_int>, - - // - // Returns a writable copy of this object. - // - pub copy: Option<extern "C" fn( - this: *mut cef_command_line_t) -> *mut interfaces::cef_command_line_t>, - - // - // Initialize the command line with the specified |argc| and |argv| values. - // The first argument must be the name of the program. This function is only - // supported on non-Windows platforms. - // - pub init_from_argv: Option<extern "C" fn(this: *mut cef_command_line_t, - argc: libc::c_int, argv: *const *const libc::c_char) -> ()>, - - // - // Initialize the command line with the string returned by calling - // GetCommandLineW(). This function is only supported on Windows. - // - pub init_from_string: Option<extern "C" fn(this: *mut cef_command_line_t, - command_line: *const types::cef_string_t) -> ()>, - - // - // Reset the command-line switches and arguments but leave the program - // component unchanged. - // - pub reset: Option<extern "C" fn(this: *mut cef_command_line_t) -> ()>, - - // - // Retrieve the original command line string as a vector of strings. The argv - // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } - // - pub get_argv: Option<extern "C" fn(this: *mut cef_command_line_t, - argv: &types::cef_string_list_t) -> ()>, - - // - // Constructs and returns the represented command line string. Use this - // function cautiously because quoting behavior is unclear. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_command_line_string: Option<extern "C" fn( - this: *mut cef_command_line_t) -> types::cef_string_userfree_t>, - - // - // Get the program part of the command line string (the first item). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_program: Option<extern "C" fn( - this: *mut cef_command_line_t) -> types::cef_string_userfree_t>, - - // - // Set the program part of the command line string (the first item). - // - pub set_program: Option<extern "C" fn(this: *mut cef_command_line_t, - program: *const types::cef_string_t) -> ()>, - - // - // Returns true (1) if the command line has switches. - // - pub has_switches: Option<extern "C" fn( - this: *mut cef_command_line_t) -> libc::c_int>, - - // - // Returns true (1) if the command line contains the given switch. - // - pub has_switch: Option<extern "C" fn(this: *mut cef_command_line_t, - name: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the value associated with the given switch. If the switch has no - // value or isn't present this function returns the NULL string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_switch_value: Option<extern "C" fn(this: *mut cef_command_line_t, - name: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Returns the map of switch names and values. If a switch has no value an - // NULL string is returned. - // - pub get_switches: Option<extern "C" fn(this: *mut cef_command_line_t, - switches: types::cef_string_map_t) -> ()>, - - // - // Add a switch to the end of the command line. If the switch has no value - // pass an NULL value string. - // - pub append_switch: Option<extern "C" fn(this: *mut cef_command_line_t, - name: *const types::cef_string_t) -> ()>, - - // - // Add a switch with the specified value to the end of the command line. - // - pub append_switch_with_value: Option<extern "C" fn( - this: *mut cef_command_line_t, name: *const types::cef_string_t, - value: *const types::cef_string_t) -> ()>, - - // - // True if there are remaining command line arguments. - // - pub has_arguments: Option<extern "C" fn( - this: *mut cef_command_line_t) -> libc::c_int>, - - // - // Get the remaining command line arguments. - // - pub get_arguments: Option<extern "C" fn(this: *mut cef_command_line_t, - arguments: &types::cef_string_list_t) -> ()>, - - // - // Add an argument to the end of the command line. - // - pub append_argument: Option<extern "C" fn(this: *mut cef_command_line_t, - argument: *const types::cef_string_t) -> ()>, - - // - // Insert a command before the current command. Common for debuggers, like - // "valgrind" or "gdb --args". - // - pub prepend_wrapper: Option<extern "C" fn(this: *mut cef_command_line_t, - wrapper: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_command_line_t = _cef_command_line_t; - - -// -// Structure used to create and/or parse command line arguments. Arguments with -// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches -// will always precede any arguments without switch prefixes. Switches can -// optionally have a value specified using the '=' delimiter (e.g. -// "-switch=value"). An argument of "--" will terminate switch parsing with all -// subsequent tokens, regardless of prefix, being interpreted as non-switch -// arguments. Switch names are considered case-insensitive. This structure can -// be used before cef_initialize() is called. -// -pub struct CefCommandLine { - c_object: *mut cef_command_line_t, -} - -impl Clone for CefCommandLine { - fn clone(&self) -> CefCommandLine{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefCommandLine { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefCommandLine { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefCommandLine { - pub unsafe fn from_c_object(c_object: *mut cef_command_line_t) -> CefCommandLine { - CefCommandLine { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_command_line_t) -> CefCommandLine { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefCommandLine { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_command_line_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_command_line_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns a writable copy of this object. - // - pub fn copy(&self) -> interfaces::CefCommandLine { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Initialize the command line with the specified |argc| and |argv| values. - // The first argument must be the name of the program. This function is only - // supported on non-Windows platforms. - // - pub fn init_from_argv(&self, argc: libc::c_int, argv: &&str) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).init_from_argv.unwrap())( - self.c_object, - CefWrap::to_c(argc), - CefWrap::to_c(argv))) - } - } - - // - // Initialize the command line with the string returned by calling - // GetCommandLineW(). This function is only supported on Windows. - // - pub fn init_from_string(&self, command_line: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).init_from_string.unwrap())( - self.c_object, - CefWrap::to_c(command_line))) - } - } - - // - // Reset the command-line switches and arguments but leave the program - // component unchanged. - // - pub fn reset(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).reset.unwrap())( - self.c_object)) - } - } - - // - // Retrieve the original command line string as a vector of strings. The argv - // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } - // - pub fn get_argv(&self, argv: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_argv.unwrap())( - self.c_object, - CefWrap::to_c(argv))) - } - } - - // - // Constructs and returns the represented command line string. Use this - // function cautiously because quoting behavior is unclear. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_command_line_string(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_command_line_string.unwrap())( - self.c_object)) - } - } - - // - // Get the program part of the command line string (the first item). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_program(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_program.unwrap())( - self.c_object)) - } - } - - // - // Set the program part of the command line string (the first item). - // - pub fn set_program(&self, program: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_program.unwrap())( - self.c_object, - CefWrap::to_c(program))) - } - } - - // - // Returns true (1) if the command line has switches. - // - pub fn has_switches(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_switches.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the command line contains the given switch. - // - pub fn has_switch(&self, name: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_switch.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Returns the value associated with the given switch. If the switch has no - // value or isn't present this function returns the NULL string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_switch_value(&self, name: &[u16]) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_switch_value.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Returns the map of switch names and values. If a switch has no value an - // NULL string is returned. - // - pub fn get_switches(&self, switches: HashMap<String,String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_switches.unwrap())( - self.c_object, - CefWrap::to_c(switches))) - } - } - - // - // Add a switch to the end of the command line. If the switch has no value - // pass an NULL value string. - // - pub fn append_switch(&self, name: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).append_switch.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Add a switch with the specified value to the end of the command line. - // - pub fn append_switch_with_value(&self, name: &[u16], value: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).append_switch_with_value.unwrap())( - self.c_object, - CefWrap::to_c(name), - CefWrap::to_c(value))) - } - } - - // - // True if there are remaining command line arguments. - // - pub fn has_arguments(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_arguments.unwrap())( - self.c_object)) - } - } - - // - // Get the remaining command line arguments. - // - pub fn get_arguments(&self, arguments: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_arguments.unwrap())( - self.c_object, - CefWrap::to_c(arguments))) - } - } - - // - // Add an argument to the end of the command line. - // - pub fn append_argument(&self, argument: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).append_argument.unwrap())( - self.c_object, - CefWrap::to_c(argument))) - } - } - - // - // Insert a command before the current command. Common for debuggers, like - // "valgrind" or "gdb --args". - // - pub fn prepend_wrapper(&self, wrapper: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).prepend_wrapper.unwrap())( - self.c_object, - CefWrap::to_c(wrapper))) - } - } - - // - // Create a new cef_command_line_t instance. - // - pub fn create_command_line() -> interfaces::CefCommandLine { - unsafe { - CefWrap::to_rust( - ::command_line::cef_command_line_create_command_line( -)) - } - } - - // - // Returns the singleton global cef_command_line_t object. The returned object - // will be read-only. - // - pub fn get_global_command_line() -> interfaces::CefCommandLine { - unsafe { - CefWrap::to_rust( - ::command_line::cef_command_line_get_global_command_line( -)) - } - } -} - -impl CefWrap<*mut cef_command_line_t> for CefCommandLine { - fn to_c(rust_object: CefCommandLine) -> *mut cef_command_line_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_command_line_t) -> CefCommandLine { - CefCommandLine::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_command_line_t> for Option<CefCommandLine> { - fn to_c(rust_object: Option<CefCommandLine>) -> *mut cef_command_line_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_command_line_t) -> Option<CefCommandLine> { - if c_object.is_null() { - None - } else { - Some(CefCommandLine::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_context_menu_handler.rs b/ports/cef/interfaces/cef_context_menu_handler.rs deleted file mode 100644 index ed61ad30bd3..00000000000 --- a/ports/cef/interfaces/cef_context_menu_handler.rs +++ /dev/null @@ -1,804 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle context menu events. The functions of this -// structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_context_menu_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called before a context menu is displayed. |params| provides information - // about the context menu state. |model| initially contains the default - // context menu. The |model| can be cleared to show no context menu or - // modified to show a custom menu. Do not keep references to |params| or - // |model| outside of this callback. - // - pub on_before_context_menu: Option<extern "C" fn( - this: *mut cef_context_menu_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - params: *mut interfaces::cef_context_menu_params_t, - model: *mut interfaces::cef_menu_model_t) -> ()>, - - // - // Called to execute a command selected from the context menu. Return true (1) - // if the command was handled or false (0) for the default implementation. See - // cef_menu_id_t for the command ids that have default implementations. All - // user-defined command ids should be between MENU_ID_USER_FIRST and - // MENU_ID_USER_LAST. |params| will have the same values as what was passed to - // on_before_context_menu(). Do not keep a reference to |params| outside of - // this callback. - // - pub on_context_menu_command: Option<extern "C" fn( - this: *mut cef_context_menu_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - params: *mut interfaces::cef_context_menu_params_t, - command_id: libc::c_int, - event_flags: types::cef_event_flags_t) -> libc::c_int>, - - // - // Called when the context menu is dismissed irregardless of whether the menu - // was NULL or a command was selected. - // - pub on_context_menu_dismissed: Option<extern "C" fn( - this: *mut cef_context_menu_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_context_menu_handler_t = _cef_context_menu_handler_t; - - -// -// Implement this structure to handle context menu events. The functions of this -// structure will be called on the UI thread. -// -pub struct CefContextMenuHandler { - c_object: *mut cef_context_menu_handler_t, -} - -impl Clone for CefContextMenuHandler { - fn clone(&self) -> CefContextMenuHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefContextMenuHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefContextMenuHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefContextMenuHandler { - pub unsafe fn from_c_object(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler { - CefContextMenuHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefContextMenuHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_context_menu_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_context_menu_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called before a context menu is displayed. |params| provides information - // about the context menu state. |model| initially contains the default - // context menu. The |model| can be cleared to show no context menu or - // modified to show a custom menu. Do not keep references to |params| or - // |model| outside of this callback. - // - pub fn on_before_context_menu(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams, - model: interfaces::CefMenuModel) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_context_menu.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(params), - CefWrap::to_c(model))) - } - } - - // - // Called to execute a command selected from the context menu. Return true (1) - // if the command was handled or false (0) for the default implementation. See - // cef_menu_id_t for the command ids that have default implementations. All - // user-defined command ids should be between MENU_ID_USER_FIRST and - // MENU_ID_USER_LAST. |params| will have the same values as what was passed to - // on_before_context_menu(). Do not keep a reference to |params| outside of - // this callback. - // - pub fn on_context_menu_command(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams, - command_id: libc::c_int, - event_flags: types::cef_event_flags_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_context_menu_command.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(params), - CefWrap::to_c(command_id), - CefWrap::to_c(event_flags))) - } - } - - // - // Called when the context menu is dismissed irregardless of whether the menu - // was NULL or a command was selected. - // - pub fn on_context_menu_dismissed(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_context_menu_dismissed.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame))) - } - } -} - -impl CefWrap<*mut cef_context_menu_handler_t> for CefContextMenuHandler { - fn to_c(rust_object: CefContextMenuHandler) -> *mut cef_context_menu_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler { - CefContextMenuHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_context_menu_handler_t> for Option<CefContextMenuHandler> { - fn to_c(rust_object: Option<CefContextMenuHandler>) -> *mut cef_context_menu_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_context_menu_handler_t) -> Option<CefContextMenuHandler> { - if c_object.is_null() { - None - } else { - Some(CefContextMenuHandler::from_c_object_addref(c_object)) - } - } -} - - -// -// Provides information about the context menu state. The ethods of this -// structure can only be accessed on browser process the UI thread. -// -#[repr(C)] -pub struct _cef_context_menu_params_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the X coordinate of the mouse where the context menu was invoked. - // Coords are relative to the associated RenderView's origin. - // - pub get_xcoord: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> libc::c_int>, - - // - // Returns the Y coordinate of the mouse where the context menu was invoked. - // Coords are relative to the associated RenderView's origin. - // - pub get_ycoord: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> libc::c_int>, - - // - // Returns flags representing the type of node that the context menu was - // invoked on. - // - pub get_type_flags: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_context_menu_type_flags_t>, - - // - // Returns the URL of the link, if any, that encloses the node that the - // context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_link_url: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the link URL, if any, to be used ONLY for "copy link address". We - // don't validate this field in the frontend process. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_unfiltered_link_url: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the source URL, if any, for the element that the context menu was - // invoked on. Example of elements with source URLs are img, audio, and video. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_source_url: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if the context menu was invoked on an image which has non- - // NULL contents. - // - pub has_image_contents: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> libc::c_int>, - - // - // Returns the URL of the top level page that the context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_page_url: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the URL of the subframe that the context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_frame_url: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the character encoding of the subframe that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_frame_charset: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the type of context node that the context menu was invoked on. - // - pub get_media_type: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_context_menu_media_type_t>, - - // - // Returns flags representing the actions supported by the media element, if - // any, that the context menu was invoked on. - // - pub get_media_state_flags: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_context_menu_media_state_flags_t>, - - // - // Returns the text of the selection, if any, that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_selection_text: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns the text of the misspelled word, if any, that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_misspelled_word: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if suggestions exist, false (0) otherwise. Fills in - // |suggestions| from the spell check service for the misspelled word if there - // is one. - // - pub get_dictionary_suggestions: Option<extern "C" fn( - this: *mut cef_context_menu_params_t, - suggestions: &types::cef_string_list_t) -> libc::c_int>, - - // - // Returns true (1) if the context menu was invoked on an editable node. - // - pub is_editable: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> libc::c_int>, - - // - // Returns true (1) if the context menu was invoked on an editable node where - // spell-check is enabled. - // - pub is_spell_check_enabled: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> libc::c_int>, - - // - // Returns flags representing the actions supported by the editable node, if - // any, that the context menu was invoked on. - // - pub get_edit_state_flags: Option<extern "C" fn( - this: *mut cef_context_menu_params_t) -> types::cef_context_menu_edit_state_flags_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_context_menu_params_t = _cef_context_menu_params_t; - - -// -// Provides information about the context menu state. The ethods of this -// structure can only be accessed on browser process the UI thread. -// -pub struct CefContextMenuParams { - c_object: *mut cef_context_menu_params_t, -} - -impl Clone for CefContextMenuParams { - fn clone(&self) -> CefContextMenuParams{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefContextMenuParams { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefContextMenuParams { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefContextMenuParams { - pub unsafe fn from_c_object(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams { - CefContextMenuParams { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefContextMenuParams { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_context_menu_params_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_context_menu_params_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the X coordinate of the mouse where the context menu was invoked. - // Coords are relative to the associated RenderView's origin. - // - pub fn get_xcoord(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_xcoord.unwrap())( - self.c_object)) - } - } - - // - // Returns the Y coordinate of the mouse where the context menu was invoked. - // Coords are relative to the associated RenderView's origin. - // - pub fn get_ycoord(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_ycoord.unwrap())( - self.c_object)) - } - } - - // - // Returns flags representing the type of node that the context menu was - // invoked on. - // - pub fn get_type_flags(&self) -> types::cef_context_menu_type_flags_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type_flags.unwrap())( - self.c_object)) - } - } - - // - // Returns the URL of the link, if any, that encloses the node that the - // context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_link_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_link_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the link URL, if any, to be used ONLY for "copy link address". We - // don't validate this field in the frontend process. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_unfiltered_link_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_unfiltered_link_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the source URL, if any, for the element that the context menu was - // invoked on. Example of elements with source URLs are img, audio, and video. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_source_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_source_url.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the context menu was invoked on an image which has non- - // NULL contents. - // - pub fn has_image_contents(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_image_contents.unwrap())( - self.c_object)) - } - } - - // - // Returns the URL of the top level page that the context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_page_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_page_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the URL of the subframe that the context menu was invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_frame_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the character encoding of the subframe that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_frame_charset(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_charset.unwrap())( - self.c_object)) - } - } - - // - // Returns the type of context node that the context menu was invoked on. - // - pub fn get_media_type(&self) -> types::cef_context_menu_media_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_media_type.unwrap())( - self.c_object)) - } - } - - // - // Returns flags representing the actions supported by the media element, if - // any, that the context menu was invoked on. - // - pub fn get_media_state_flags( - &self) -> types::cef_context_menu_media_state_flags_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_media_state_flags.unwrap())( - self.c_object)) - } - } - - // - // Returns the text of the selection, if any, that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_selection_text(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_selection_text.unwrap())( - self.c_object)) - } - } - - // - // Returns the text of the misspelled word, if any, that the context menu was - // invoked on. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_misspelled_word(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_misspelled_word.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if suggestions exist, false (0) otherwise. Fills in - // |suggestions| from the spell check service for the misspelled word if there - // is one. - // - pub fn get_dictionary_suggestions(&self, - suggestions: &Vec<String>) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dictionary_suggestions.unwrap())( - self.c_object, - CefWrap::to_c(suggestions))) - } - } - - // - // Returns true (1) if the context menu was invoked on an editable node. - // - pub fn is_editable(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_editable.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the context menu was invoked on an editable node where - // spell-check is enabled. - // - pub fn is_spell_check_enabled(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_spell_check_enabled.unwrap())( - self.c_object)) - } - } - - // - // Returns flags representing the actions supported by the editable node, if - // any, that the context menu was invoked on. - // - pub fn get_edit_state_flags( - &self) -> types::cef_context_menu_edit_state_flags_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_edit_state_flags.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_context_menu_params_t> for CefContextMenuParams { - fn to_c(rust_object: CefContextMenuParams) -> *mut cef_context_menu_params_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams { - CefContextMenuParams::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_context_menu_params_t> for Option<CefContextMenuParams> { - fn to_c(rust_object: Option<CefContextMenuParams>) -> *mut cef_context_menu_params_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_context_menu_params_t) -> Option<CefContextMenuParams> { - if c_object.is_null() { - None - } else { - Some(CefContextMenuParams::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_cookie.rs b/ports/cef/interfaces/cef_cookie.rs deleted file mode 100644 index 257ebeea4c9..00000000000 --- a/ports/cef/interfaces/cef_cookie.rs +++ /dev/null @@ -1,870 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used for managing cookies. The functions of this structure may be -// called on any thread unless otherwise indicated. -// -#[repr(C)] -pub struct _cef_cookie_manager_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Set the schemes supported by this manager. The default schemes ("http", - // "https", "ws" and "wss") will always be supported. If |callback| is non- - // NULL it will be executed asnychronously on the IO thread after the change - // has been applied. Must be called before any cookies are accessed. - // - pub set_supported_schemes: Option<extern "C" fn( - this: *mut cef_cookie_manager_t, schemes: &types::cef_string_list_t, - callback: *mut interfaces::cef_completion_callback_t) -> ()>, - - // - // Visit all cookies on the IO thread. The returned cookies are ordered by - // longest path, then by earliest creation date. Returns false (0) if cookies - // cannot be accessed. - // - pub visit_all_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - visitor: *mut interfaces::cef_cookie_visitor_t) -> libc::c_int>, - - // - // Visit a subset of cookies on the IO thread. 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. - // - pub visit_url_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - url: *const types::cef_string_t, includeHttpOnly: libc::c_int, - visitor: *mut interfaces::cef_cookie_visitor_t) -> libc::c_int>, - - // - // 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 fail without setting the cookie if - // such characters are found. If |callback| is non-NULL it will be executed - // asnychronously on the IO thread after the cookie has been set. Returns - // false (0) if an invalid URL is specified or if cookies cannot be accessed. - // - pub set_cookie: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - url: *const types::cef_string_t, cookie: *const interfaces::cef_cookie_t, - callback: *mut interfaces::cef_set_cookie_callback_t) -> libc::c_int>, - - // - // Delete all cookies that match the specified parameters. If both |url| and - // |cookie_name| values 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. If |callback| is non- - // NULL it will be executed asnychronously on the IO thread after the cookies - // have been deleted. Returns false (0) if a non-NULL invalid URL is specified - // or if cookies cannot be accessed. Cookies can alternately be deleted using - // the Visit*Cookies() functions. - // - pub delete_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - url: *const types::cef_string_t, cookie_name: *const types::cef_string_t, - callback: *mut interfaces::cef_delete_cookies_callback_t) -> libc::c_int>, - - // - // Sets the directory path that will be used for storing cookie data. If - // |path| is NULL data will be stored in memory only. Otherwise, data will be - // stored at the specified |path|. To persist session cookies (cookies without - // an expiry date or validity interval) set |persist_session_cookies| to true - // (1). Session cookies are generally intended to be transient and most Web - // browsers do not persist them. If |callback| is non-NULL it will be executed - // asnychronously on the IO thread after the manager's storage has been - // initialized. Returns false (0) if cookies cannot be accessed. - // - pub set_storage_path: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - path: *const types::cef_string_t, persist_session_cookies: libc::c_int, - callback: *mut interfaces::cef_completion_callback_t) -> libc::c_int>, - - // - // Flush the backing store (if any) to disk. If |callback| is non-NULL it will - // be executed asnychronously on the IO thread after the flush is complete. - // Returns false (0) if cookies cannot be accessed. - // - pub flush_store: Option<extern "C" fn(this: *mut cef_cookie_manager_t, - callback: *mut interfaces::cef_completion_callback_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_cookie_manager_t = _cef_cookie_manager_t; - - -// -// Structure used for managing cookies. The functions of this structure may be -// called on any thread unless otherwise indicated. -// -pub struct CefCookieManager { - c_object: *mut cef_cookie_manager_t, -} - -impl Clone for CefCookieManager { - fn clone(&self) -> CefCookieManager{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefCookieManager { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefCookieManager { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefCookieManager { - pub unsafe fn from_c_object(c_object: *mut cef_cookie_manager_t) -> CefCookieManager { - CefCookieManager { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_manager_t) -> CefCookieManager { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefCookieManager { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_cookie_manager_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_cookie_manager_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Set the schemes supported by this manager. The default schemes ("http", - // "https", "ws" and "wss") will always be supported. If |callback| is non- - // NULL it will be executed asnychronously on the IO thread after the change - // has been applied. Must be called before any cookies are accessed. - // - pub fn set_supported_schemes(&self, schemes: &Vec<String>, - callback: interfaces::CefCompletionCallback) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_supported_schemes.unwrap())( - self.c_object, - CefWrap::to_c(schemes), - CefWrap::to_c(callback))) - } - } - - // - // Visit all cookies on the IO thread. The returned cookies are ordered by - // longest path, then by earliest creation date. Returns false (0) if cookies - // cannot be accessed. - // - pub fn visit_all_cookies(&self, - visitor: interfaces::CefCookieVisitor) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit_all_cookies.unwrap())( - self.c_object, - CefWrap::to_c(visitor))) - } - } - - // - // Visit a subset of cookies on the IO thread. 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. - // - pub fn visit_url_cookies(&self, url: &[u16], includeHttpOnly: libc::c_int, - visitor: interfaces::CefCookieVisitor) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit_url_cookies.unwrap())( - self.c_object, - CefWrap::to_c(url), - CefWrap::to_c(includeHttpOnly), - CefWrap::to_c(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 fail without setting the cookie if - // such characters are found. If |callback| is non-NULL it will be executed - // asnychronously on the IO thread after the cookie has been set. Returns - // false (0) if an invalid URL is specified or if cookies cannot be accessed. - // - pub fn set_cookie(&self, url: &[u16], cookie: &interfaces::CefCookie, - callback: interfaces::CefSetCookieCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_cookie.unwrap())( - self.c_object, - CefWrap::to_c(url), - CefWrap::to_c(cookie), - CefWrap::to_c(callback))) - } - } - - // - // Delete all cookies that match the specified parameters. If both |url| and - // |cookie_name| values 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. If |callback| is non- - // NULL it will be executed asnychronously on the IO thread after the cookies - // have been deleted. Returns false (0) if a non-NULL invalid URL is specified - // or if cookies cannot be accessed. Cookies can alternately be deleted using - // the Visit*Cookies() functions. - // - pub fn delete_cookies(&self, url: &[u16], cookie_name: &[u16], - callback: interfaces::CefDeleteCookiesCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).delete_cookies.unwrap())( - self.c_object, - CefWrap::to_c(url), - CefWrap::to_c(cookie_name), - CefWrap::to_c(callback))) - } - } - - // - // Sets the directory path that will be used for storing cookie data. If - // |path| is NULL data will be stored in memory only. Otherwise, data will be - // stored at the specified |path|. To persist session cookies (cookies without - // an expiry date or validity interval) set |persist_session_cookies| to true - // (1). Session cookies are generally intended to be transient and most Web - // browsers do not persist them. If |callback| is non-NULL it will be executed - // asnychronously on the IO thread after the manager's storage has been - // initialized. Returns false (0) if cookies cannot be accessed. - // - pub fn set_storage_path(&self, path: &[u16], - persist_session_cookies: libc::c_int, - callback: interfaces::CefCompletionCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_storage_path.unwrap())( - self.c_object, - CefWrap::to_c(path), - CefWrap::to_c(persist_session_cookies), - CefWrap::to_c(callback))) - } - } - - // - // Flush the backing store (if any) to disk. If |callback| is non-NULL it will - // be executed asnychronously on the IO thread after the flush is complete. - // Returns false (0) if cookies cannot be accessed. - // - pub fn flush_store(&self, - callback: interfaces::CefCompletionCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).flush_store.unwrap())( - self.c_object, - CefWrap::to_c(callback))) - } - } - - // - // Returns the global cookie manager. By default data will be stored at - // CefSettings.cache_path if specified or in memory otherwise. If |callback| - // is non-NULL it will be executed asnychronously on the IO thread after the - // manager's storage has been initialized. Using this function is equivalent - // to calling cef_request_tContext::cef_request_context_get_global_context()-> - // get_default_cookie_manager(). - // - pub fn get_global_manager( - callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager { - unsafe { - CefWrap::to_rust( - ::cookie::cef_cookie_manager_get_global_manager( - CefWrap::to_c(callback))) - } - } - - // - // Creates a new cookie manager. If |path| is NULL data will be stored in - // memory only. Otherwise, data will be stored at the specified |path|. To - // persist session cookies (cookies without an expiry date or validity - // interval) set |persist_session_cookies| to true (1). Session cookies are - // generally intended to be transient and most Web browsers do not persist - // them. If |callback| is non-NULL it will be executed asnychronously on the - // IO thread after the manager's storage has been initialized. - // - pub fn create_manager(path: &[u16], persist_session_cookies: libc::c_int, - callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager { - unsafe { - CefWrap::to_rust( - ::cookie::cef_cookie_manager_create_manager( - CefWrap::to_c(path), - CefWrap::to_c(persist_session_cookies), - CefWrap::to_c(callback))) - } - } -} - -impl CefWrap<*mut cef_cookie_manager_t> for CefCookieManager { - fn to_c(rust_object: CefCookieManager) -> *mut cef_cookie_manager_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_cookie_manager_t) -> CefCookieManager { - CefCookieManager::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_cookie_manager_t> for Option<CefCookieManager> { - fn to_c(rust_object: Option<CefCookieManager>) -> *mut cef_cookie_manager_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_cookie_manager_t) -> Option<CefCookieManager> { - if c_object.is_null() { - None - } else { - Some(CefCookieManager::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure to implement for visiting cookie values. The functions of this -// structure will always be called on the IO thread. -// -#[repr(C)] -pub struct _cef_cookie_visitor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called once for each cookie. |count| is the 0-based - // index for the current cookie. |total| is the total number of cookies. Set - // |deleteCookie| to true (1) to delete the cookie currently being visited. - // Return false (0) to stop visiting cookies. This function may never be - // called if no cookies are found. - // - pub visit: Option<extern "C" fn(this: *mut cef_cookie_visitor_t, - cookie: *const interfaces::cef_cookie_t, count: libc::c_int, - total: libc::c_int, deleteCookie: *mut libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_cookie_visitor_t = _cef_cookie_visitor_t; - - -// -// Structure to implement for visiting cookie values. The functions of this -// structure will always be called on the IO thread. -// -pub struct CefCookieVisitor { - c_object: *mut cef_cookie_visitor_t, -} - -impl Clone for CefCookieVisitor { - fn clone(&self) -> CefCookieVisitor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefCookieVisitor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefCookieVisitor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefCookieVisitor { - pub unsafe fn from_c_object(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor { - CefCookieVisitor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefCookieVisitor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_cookie_visitor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_cookie_visitor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called once for each cookie. |count| is the 0-based - // index for the current cookie. |total| is the total number of cookies. Set - // |deleteCookie| to true (1) to delete the cookie currently being visited. - // Return false (0) to stop visiting cookies. This function may never be - // called if no cookies are found. - // - pub fn visit(&self, cookie: &interfaces::CefCookie, count: libc::c_int, - total: libc::c_int, deleteCookie: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit.unwrap())( - self.c_object, - CefWrap::to_c(cookie), - CefWrap::to_c(count), - CefWrap::to_c(total), - CefWrap::to_c(deleteCookie))) - } - } -} - -impl CefWrap<*mut cef_cookie_visitor_t> for CefCookieVisitor { - fn to_c(rust_object: CefCookieVisitor) -> *mut cef_cookie_visitor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor { - CefCookieVisitor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_cookie_visitor_t> for Option<CefCookieVisitor> { - fn to_c(rust_object: Option<CefCookieVisitor>) -> *mut cef_cookie_visitor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_cookie_visitor_t) -> Option<CefCookieVisitor> { - if c_object.is_null() { - None - } else { - Some(CefCookieVisitor::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure to implement to be notified of asynchronous completion via -// cef_cookie_manager_t::set_cookie(). -// -#[repr(C)] -pub struct _cef_set_cookie_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called upon completion. |success| will be true (1) if - // the cookie was set successfully. - // - pub on_complete: Option<extern "C" fn(this: *mut cef_set_cookie_callback_t, - success: libc::c_int) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_set_cookie_callback_t = _cef_set_cookie_callback_t; - - -// -// Structure to implement to be notified of asynchronous completion via -// cef_cookie_manager_t::set_cookie(). -// -pub struct CefSetCookieCallback { - c_object: *mut cef_set_cookie_callback_t, -} - -impl Clone for CefSetCookieCallback { - fn clone(&self) -> CefSetCookieCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefSetCookieCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefSetCookieCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefSetCookieCallback { - pub unsafe fn from_c_object(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback { - CefSetCookieCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefSetCookieCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_set_cookie_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_set_cookie_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called upon completion. |success| will be true (1) if - // the cookie was set successfully. - // - pub fn on_complete(&self, success: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_complete.unwrap())( - self.c_object, - CefWrap::to_c(success))) - } - } -} - -impl CefWrap<*mut cef_set_cookie_callback_t> for CefSetCookieCallback { - fn to_c(rust_object: CefSetCookieCallback) -> *mut cef_set_cookie_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback { - CefSetCookieCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_set_cookie_callback_t> for Option<CefSetCookieCallback> { - fn to_c(rust_object: Option<CefSetCookieCallback>) -> *mut cef_set_cookie_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_set_cookie_callback_t) -> Option<CefSetCookieCallback> { - if c_object.is_null() { - None - } else { - Some(CefSetCookieCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure to implement to be notified of asynchronous completion via -// cef_cookie_manager_t::delete_cookies(). -// -#[repr(C)] -pub struct _cef_delete_cookies_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called upon completion. |num_deleted| will be the - // number of cookies that were deleted or -1 if unknown. - // - pub on_complete: Option<extern "C" fn( - this: *mut cef_delete_cookies_callback_t, num_deleted: libc::c_int) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_delete_cookies_callback_t = _cef_delete_cookies_callback_t; - - -// -// Structure to implement to be notified of asynchronous completion via -// cef_cookie_manager_t::delete_cookies(). -// -pub struct CefDeleteCookiesCallback { - c_object: *mut cef_delete_cookies_callback_t, -} - -impl Clone for CefDeleteCookiesCallback { - fn clone(&self) -> CefDeleteCookiesCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDeleteCookiesCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDeleteCookiesCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDeleteCookiesCallback { - pub unsafe fn from_c_object(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback { - CefDeleteCookiesCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDeleteCookiesCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_delete_cookies_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_delete_cookies_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called upon completion. |num_deleted| will be the - // number of cookies that were deleted or -1 if unknown. - // - pub fn on_complete(&self, num_deleted: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_complete.unwrap())( - self.c_object, - CefWrap::to_c(num_deleted))) - } - } -} - -impl CefWrap<*mut cef_delete_cookies_callback_t> for CefDeleteCookiesCallback { - fn to_c(rust_object: CefDeleteCookiesCallback) -> *mut cef_delete_cookies_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback { - CefDeleteCookiesCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_delete_cookies_callback_t> for Option<CefDeleteCookiesCallback> { - fn to_c(rust_object: Option<CefDeleteCookiesCallback>) -> *mut cef_delete_cookies_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_delete_cookies_callback_t) -> Option<CefDeleteCookiesCallback> { - if c_object.is_null() { - None - } else { - Some(CefDeleteCookiesCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_dialog_handler.rs b/ports/cef/interfaces/cef_dialog_handler.rs deleted file mode 100644 index e0b98a14bc1..00000000000 --- a/ports/cef/interfaces/cef_dialog_handler.rs +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure for asynchronous continuation of file dialog requests. -// -#[repr(C)] -pub struct _cef_file_dialog_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue the file selection. |selected_accept_filter| should be the 0-based - // index of the value selected from the accept filters array passed to - // cef_dialog_handler_t::OnFileDialog. |file_paths| should be a single value - // or a list of values depending on the dialog mode. An NULL |file_paths| - // value is treated the same as calling cancel(). - // - pub cont: Option<extern "C" fn(this: *mut cef_file_dialog_callback_t, - selected_accept_filter: libc::c_int, - file_paths: &types::cef_string_list_t) -> ()>, - - // - // Cancel the file selection. - // - pub cancel: Option<extern "C" fn(this: *mut cef_file_dialog_callback_t) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_file_dialog_callback_t = _cef_file_dialog_callback_t; - - -// -// Callback structure for asynchronous continuation of file dialog requests. -// -pub struct CefFileDialogCallback { - c_object: *mut cef_file_dialog_callback_t, -} - -impl Clone for CefFileDialogCallback { - fn clone(&self) -> CefFileDialogCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefFileDialogCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefFileDialogCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefFileDialogCallback { - pub unsafe fn from_c_object(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback { - CefFileDialogCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefFileDialogCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_file_dialog_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_file_dialog_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue the file selection. |selected_accept_filter| should be the 0-based - // index of the value selected from the accept filters array passed to - // cef_dialog_handler_t::OnFileDialog. |file_paths| should be a single value - // or a list of values depending on the dialog mode. An NULL |file_paths| - // value is treated the same as calling cancel(). - // - pub fn cont(&self, selected_accept_filter: libc::c_int, - file_paths: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(selected_accept_filter), - CefWrap::to_c(file_paths))) - } - } - - // - // Cancel the file selection. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_file_dialog_callback_t> for CefFileDialogCallback { - fn to_c(rust_object: CefFileDialogCallback) -> *mut cef_file_dialog_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback { - CefFileDialogCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_file_dialog_callback_t> for Option<CefFileDialogCallback> { - fn to_c(rust_object: Option<CefFileDialogCallback>) -> *mut cef_file_dialog_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_file_dialog_callback_t) -> Option<CefFileDialogCallback> { - if c_object.is_null() { - None - } else { - Some(CefFileDialogCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Implement this structure to handle dialog events. The functions of this -// structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_dialog_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called to run a file chooser dialog. |mode| represents the type of dialog - // to display. |title| to the title to be used for the dialog and may be NULL - // to show the default title ("Open" or "Save" depending on the mode). - // |default_file_path| is the path with optional directory and/or file name - // component that should be initially selected in the dialog. |accept_filters| - // are used to restrict the selectable file types and may any combination of - // (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b) - // individual file extensions (e.g. ".txt" or ".png"), or (c) combined - // description and file extension delimited using "|" and ";" (e.g. "Image - // Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based index of - // the filter that should be selected by default. To display a custom dialog - // return true (1) and execute |callback| either inline or at a later time. To - // display the default dialog return false (0). - // - pub on_file_dialog: Option<extern "C" fn(this: *mut cef_dialog_handler_t, - browser: *mut interfaces::cef_browser_t, - mode: types::cef_file_dialog_mode_t, title: *const types::cef_string_t, - default_file_path: *const types::cef_string_t, - accept_filters: &types::cef_string_list_t, - selected_accept_filter: libc::c_int, - callback: *mut interfaces::cef_file_dialog_callback_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_dialog_handler_t = _cef_dialog_handler_t; - - -// -// Implement this structure to handle dialog events. The functions of this -// structure will be called on the browser process UI thread. -// -pub struct CefDialogHandler { - c_object: *mut cef_dialog_handler_t, -} - -impl Clone for CefDialogHandler { - fn clone(&self) -> CefDialogHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDialogHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDialogHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDialogHandler { - pub unsafe fn from_c_object(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler { - CefDialogHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDialogHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_dialog_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_dialog_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called to run a file chooser dialog. |mode| represents the type of dialog - // to display. |title| to the title to be used for the dialog and may be NULL - // to show the default title ("Open" or "Save" depending on the mode). - // |default_file_path| is the path with optional directory and/or file name - // component that should be initially selected in the dialog. |accept_filters| - // are used to restrict the selectable file types and may any combination of - // (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b) - // individual file extensions (e.g. ".txt" or ".png"), or (c) combined - // description and file extension delimited using "|" and ";" (e.g. "Image - // Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based index of - // the filter that should be selected by default. To display a custom dialog - // return true (1) and execute |callback| either inline or at a later time. To - // display the default dialog return false (0). - // - pub fn on_file_dialog(&self, browser: interfaces::CefBrowser, - mode: types::cef_file_dialog_mode_t, title: &[u16], - default_file_path: &[u16], accept_filters: &Vec<String>, - selected_accept_filter: libc::c_int, - callback: interfaces::CefFileDialogCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_file_dialog.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(mode), - CefWrap::to_c(title), - CefWrap::to_c(default_file_path), - CefWrap::to_c(accept_filters), - CefWrap::to_c(selected_accept_filter), - CefWrap::to_c(callback))) - } - } -} - -impl CefWrap<*mut cef_dialog_handler_t> for CefDialogHandler { - fn to_c(rust_object: CefDialogHandler) -> *mut cef_dialog_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler { - CefDialogHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_dialog_handler_t> for Option<CefDialogHandler> { - fn to_c(rust_object: Option<CefDialogHandler>) -> *mut cef_dialog_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_dialog_handler_t) -> Option<CefDialogHandler> { - if c_object.is_null() { - None - } else { - Some(CefDialogHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_display_handler.rs b/ports/cef/interfaces/cef_display_handler.rs deleted file mode 100644 index c2cdbae987e..00000000000 --- a/ports/cef/interfaces/cef_display_handler.rs +++ /dev/null @@ -1,360 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to browser display state. -// The functions of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_display_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called when a frame's address has changed. - // - pub on_address_change: Option<extern "C" fn(this: *mut cef_display_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - url: *const types::cef_string_t) -> ()>, - - // - // Called when the page title changes. - // - pub on_title_change: Option<extern "C" fn(this: *mut cef_display_handler_t, - browser: *mut interfaces::cef_browser_t, - title: *const types::cef_string_t) -> ()>, - - // - // Called when the page icon changes. - // - pub on_favicon_urlchange: Option<extern "C" fn( - this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t, - icon_urls: &types::cef_string_list_t) -> ()>, - - // - // Called when web content in the page has toggled fullscreen mode. If - // |fullscreen| is true (1) the content will automatically be sized to fill - // the browser content area. If |fullscreen| is false (0) the content will - // automatically return to its original size and position. The client is - // responsible for resizing the browser if desired. - // - pub on_fullscreen_mode_change: Option<extern "C" fn( - this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t, - fullscreen: libc::c_int) -> ()>, - - // - // Called when the browser is about to display a tooltip. |text| contains the - // text that will be displayed in the tooltip. To handle the display of the - // tooltip yourself return true (1). Otherwise, you can optionally modify - // |text| and then return false (0) to allow the browser to display the - // tooltip. When window rendering is disabled the application is responsible - // for drawing tooltips and the return value is ignored. - // - pub on_tooltip: Option<extern "C" fn(this: *mut cef_display_handler_t, - browser: *mut interfaces::cef_browser_t, - text: *mut types::cef_string_t) -> libc::c_int>, - - // - // Called when the browser receives a status message. |value| contains the - // text that will be displayed in the status message. - // - pub on_status_message: Option<extern "C" fn(this: *mut cef_display_handler_t, - browser: *mut interfaces::cef_browser_t, - value: *const types::cef_string_t) -> ()>, - - // - // Called to display a console message. Return true (1) to stop the message - // from being output to the console. - // - pub on_console_message: Option<extern "C" fn(this: *mut cef_display_handler_t, - browser: *mut interfaces::cef_browser_t, - message: *const types::cef_string_t, source: *const types::cef_string_t, - line: libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_display_handler_t = _cef_display_handler_t; - - -// -// Implement this structure to handle events related to browser display state. -// The functions of this structure will be called on the UI thread. -// -pub struct CefDisplayHandler { - c_object: *mut cef_display_handler_t, -} - -impl Clone for CefDisplayHandler { - fn clone(&self) -> CefDisplayHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDisplayHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDisplayHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDisplayHandler { - pub unsafe fn from_c_object(c_object: *mut cef_display_handler_t) -> CefDisplayHandler { - CefDisplayHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_display_handler_t) -> CefDisplayHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDisplayHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_display_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_display_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called when a frame's address has changed. - // - pub fn on_address_change(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_address_change.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(url))) - } - } - - // - // Called when the page title changes. - // - pub fn on_title_change(&self, browser: interfaces::CefBrowser, - title: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_title_change.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(title))) - } - } - - // - // Called when the page icon changes. - // - pub fn on_favicon_urlchange(&self, browser: interfaces::CefBrowser, - icon_urls: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_favicon_urlchange.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(icon_urls))) - } - } - - // - // Called when web content in the page has toggled fullscreen mode. If - // |fullscreen| is true (1) the content will automatically be sized to fill - // the browser content area. If |fullscreen| is false (0) the content will - // automatically return to its original size and position. The client is - // responsible for resizing the browser if desired. - // - pub fn on_fullscreen_mode_change(&self, browser: interfaces::CefBrowser, - fullscreen: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_fullscreen_mode_change.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(fullscreen))) - } - } - - // - // Called when the browser is about to display a tooltip. |text| contains the - // text that will be displayed in the tooltip. To handle the display of the - // tooltip yourself return true (1). Otherwise, you can optionally modify - // |text| and then return false (0) to allow the browser to display the - // tooltip. When window rendering is disabled the application is responsible - // for drawing tooltips and the return value is ignored. - // - pub fn on_tooltip(&self, browser: interfaces::CefBrowser, - text: *mut types::cef_string_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_tooltip.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(text))) - } - } - - // - // Called when the browser receives a status message. |value| contains the - // text that will be displayed in the status message. - // - pub fn on_status_message(&self, browser: interfaces::CefBrowser, - value: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_status_message.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(value))) - } - } - - // - // Called to display a console message. Return true (1) to stop the message - // from being output to the console. - // - pub fn on_console_message(&self, browser: interfaces::CefBrowser, - message: &[u16], source: &[u16], line: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_console_message.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(message), - CefWrap::to_c(source), - CefWrap::to_c(line))) - } - } -} - -impl CefWrap<*mut cef_display_handler_t> for CefDisplayHandler { - fn to_c(rust_object: CefDisplayHandler) -> *mut cef_display_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_display_handler_t) -> CefDisplayHandler { - CefDisplayHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_display_handler_t> for Option<CefDisplayHandler> { - fn to_c(rust_object: Option<CefDisplayHandler>) -> *mut cef_display_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_display_handler_t) -> Option<CefDisplayHandler> { - if c_object.is_null() { - None - } else { - Some(CefDisplayHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_dom.rs b/ports/cef/interfaces/cef_dom.rs deleted file mode 100644 index 09ca9a4ec12..00000000000 --- a/ports/cef/interfaces/cef_dom.rs +++ /dev/null @@ -1,1256 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure to implement for visiting the DOM. The functions of this structure -// will be called on the render process main thread. -// -#[repr(C)] -pub struct _cef_domvisitor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method executed for visiting the DOM. The document object passed to this - // function represents a snapshot of the DOM at the time this function is - // executed. DOM objects are only valid for the scope of this function. Do not - // keep references to or attempt to access any DOM objects outside the scope - // of this function. - // - pub visit: Option<extern "C" fn(this: *mut cef_domvisitor_t, - document: *mut interfaces::cef_domdocument_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_domvisitor_t = _cef_domvisitor_t; - - -// -// Structure to implement for visiting the DOM. The functions of this structure -// will be called on the render process main thread. -// -pub struct CefDOMVisitor { - c_object: *mut cef_domvisitor_t, -} - -impl Clone for CefDOMVisitor { - fn clone(&self) -> CefDOMVisitor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDOMVisitor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDOMVisitor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDOMVisitor { - pub unsafe fn from_c_object(c_object: *mut cef_domvisitor_t) -> CefDOMVisitor { - CefDOMVisitor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_domvisitor_t) -> CefDOMVisitor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDOMVisitor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_domvisitor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_domvisitor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method executed for visiting the DOM. The document object passed to this - // function represents a snapshot of the DOM at the time this function is - // executed. DOM objects are only valid for the scope of this function. Do not - // keep references to or attempt to access any DOM objects outside the scope - // of this function. - // - pub fn visit(&self, document: interfaces::CefDOMDocument) -> () { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit.unwrap())( - self.c_object, - CefWrap::to_c(document))) - } - } -} - -impl CefWrap<*mut cef_domvisitor_t> for CefDOMVisitor { - fn to_c(rust_object: CefDOMVisitor) -> *mut cef_domvisitor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_domvisitor_t) -> CefDOMVisitor { - CefDOMVisitor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_domvisitor_t> for Option<CefDOMVisitor> { - fn to_c(rust_object: Option<CefDOMVisitor>) -> *mut cef_domvisitor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_domvisitor_t) -> Option<CefDOMVisitor> { - if c_object.is_null() { - None - } else { - Some(CefDOMVisitor::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to represent a DOM document. The functions of this structure -// should only be called on the render process main thread thread. -// -#[repr(C)] -pub struct _cef_domdocument_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the document type. - // - pub get_type: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> types::cef_dom_document_type_t>, - - // - // Returns the root document node. - // - pub get_document: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the BODY node of an HTML document. - // - pub get_body: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the HEAD node of an HTML document. - // - pub get_head: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the title of an HTML document. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_title: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> types::cef_string_userfree_t>, - - // - // Returns the document element with the specified ID value. - // - pub get_element_by_id: Option<extern "C" fn(this: *mut cef_domdocument_t, - id: *const types::cef_string_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the node that currently has keyboard focus. - // - pub get_focused_node: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns true (1) if a portion of the document is selected. - // - pub has_selection: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> libc::c_int>, - - // - // Returns the selection offset within the start node. - // - pub get_selection_start_offset: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> libc::c_int>, - - // - // Returns the selection offset within the end node. - // - pub get_selection_end_offset: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> libc::c_int>, - - // - // Returns the contents of this selection as markup. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_selection_as_markup: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> types::cef_string_userfree_t>, - - // - // Returns the contents of this selection as text. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_selection_as_text: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> types::cef_string_userfree_t>, - - // - // Returns the base URL for the document. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_base_url: Option<extern "C" fn( - this: *mut cef_domdocument_t) -> types::cef_string_userfree_t>, - - // - // Returns a complete URL based on the document base URL and the specified - // partial URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_complete_url: Option<extern "C" fn(this: *mut cef_domdocument_t, - partialURL: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_domdocument_t = _cef_domdocument_t; - - -// -// Structure used to represent a DOM document. The functions of this structure -// should only be called on the render process main thread thread. -// -pub struct CefDOMDocument { - c_object: *mut cef_domdocument_t, -} - -impl Clone for CefDOMDocument { - fn clone(&self) -> CefDOMDocument{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDOMDocument { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDOMDocument { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDOMDocument { - pub unsafe fn from_c_object(c_object: *mut cef_domdocument_t) -> CefDOMDocument { - CefDOMDocument { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_domdocument_t) -> CefDOMDocument { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDOMDocument { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_domdocument_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_domdocument_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the document type. - // - pub fn get_type(&self) -> types::cef_dom_document_type_t { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object)) - } - } - - // - // Returns the root document node. - // - pub fn get_document(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_document.unwrap())( - self.c_object)) - } - } - - // - // Returns the BODY node of an HTML document. - // - pub fn get_body(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_body.unwrap())( - self.c_object)) - } - } - - // - // Returns the HEAD node of an HTML document. - // - pub fn get_head(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_head.unwrap())( - self.c_object)) - } - } - - // - // Returns the title of an HTML document. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_title(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_title.unwrap())( - self.c_object)) - } - } - - // - // Returns the document element with the specified ID value. - // - pub fn get_element_by_id(&self, id: &[u16]) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_by_id.unwrap())( - self.c_object, - CefWrap::to_c(id))) - } - } - - // - // Returns the node that currently has keyboard focus. - // - pub fn get_focused_node(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_focused_node.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if a portion of the document is selected. - // - pub fn has_selection(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_selection.unwrap())( - self.c_object)) - } - } - - // - // Returns the selection offset within the start node. - // - pub fn get_selection_start_offset(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_selection_start_offset.unwrap())( - self.c_object)) - } - } - - // - // Returns the selection offset within the end node. - // - pub fn get_selection_end_offset(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_selection_end_offset.unwrap())( - self.c_object)) - } - } - - // - // Returns the contents of this selection as markup. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_selection_as_markup(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_selection_as_markup.unwrap())( - self.c_object)) - } - } - - // - // Returns the contents of this selection as text. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_selection_as_text(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_selection_as_text.unwrap())( - self.c_object)) - } - } - - // - // Returns the base URL for the document. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_base_url(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_base_url.unwrap())( - self.c_object)) - } - } - - // - // Returns a complete URL based on the document base URL and the specified - // partial URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_complete_url(&self, partialURL: &[u16]) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_complete_url.unwrap())( - self.c_object, - CefWrap::to_c(partialURL))) - } - } -} - -impl CefWrap<*mut cef_domdocument_t> for CefDOMDocument { - fn to_c(rust_object: CefDOMDocument) -> *mut cef_domdocument_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_domdocument_t) -> CefDOMDocument { - CefDOMDocument::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_domdocument_t> for Option<CefDOMDocument> { - fn to_c(rust_object: Option<CefDOMDocument>) -> *mut cef_domdocument_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_domdocument_t) -> Option<CefDOMDocument> { - if c_object.is_null() { - None - } else { - Some(CefDOMDocument::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to represent a DOM node. The functions of this structure -// should only be called on the render process main thread. -// -#[repr(C)] -pub struct _cef_domnode_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the type for this node. - // - pub get_type: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_dom_node_type_t>, - - // - // Returns true (1) if this is a text node. - // - pub is_text: Option<extern "C" fn(this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Returns true (1) if this is an element node. - // - pub is_element: Option<extern "C" fn( - this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Returns true (1) if this is an editable node. - // - pub is_editable: Option<extern "C" fn( - this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Returns true (1) if this is a form control element node. - // - pub is_form_control_element: Option<extern "C" fn( - this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Returns the type of this form control element node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_form_control_element_type: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_domnode_t, - that: *mut interfaces::cef_domnode_t) -> libc::c_int>, - - // - // Returns the name of this node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_name: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // Returns the value of this node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_value: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // Set the value of this node. Returns true (1) on success. - // - pub set_value: Option<extern "C" fn(this: *mut cef_domnode_t, - value: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the contents of this node as markup. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_as_markup: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // Returns the document associated with this node. - // - pub get_document: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domdocument_t>, - - // - // Returns the parent node. - // - pub get_parent: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the previous sibling node. - // - pub get_previous_sibling: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the next sibling node. - // - pub get_next_sibling: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns true (1) if this node has child nodes. - // - pub has_children: Option<extern "C" fn( - this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Return the first child node. - // - pub get_first_child: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domnode_t>, - - // - // Returns the last child node. - // - pub get_last_child: Option<extern "C" fn( - this: *mut cef_domnode_t) -> *mut interfaces::cef_domnode_t>, - - - // The following functions are valid only for element nodes. - - // - // Returns the tag name of this element. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_element_tag_name: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if this element has attributes. - // - pub has_element_attributes: Option<extern "C" fn( - this: *mut cef_domnode_t) -> libc::c_int>, - - // - // Returns true (1) if this element has an attribute named |attrName|. - // - pub has_element_attribute: Option<extern "C" fn(this: *mut cef_domnode_t, - attrName: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the element attribute named |attrName|. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_element_attribute: Option<extern "C" fn(this: *mut cef_domnode_t, - attrName: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Returns a map of all element attributes. - // - pub get_element_attributes: Option<extern "C" fn(this: *mut cef_domnode_t, - attrMap: types::cef_string_map_t) -> ()>, - - // - // Set the value for the element attribute named |attrName|. Returns true (1) - // on success. - // - pub set_element_attribute: Option<extern "C" fn(this: *mut cef_domnode_t, - attrName: *const types::cef_string_t, - value: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the inner text of the element. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_element_inner_text: Option<extern "C" fn( - this: *mut cef_domnode_t) -> types::cef_string_userfree_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_domnode_t = _cef_domnode_t; - - -// -// Structure used to represent a DOM node. The functions of this structure -// should only be called on the render process main thread. -// -pub struct CefDOMNode { - c_object: *mut cef_domnode_t, -} - -impl Clone for CefDOMNode { - fn clone(&self) -> CefDOMNode{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDOMNode { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDOMNode { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDOMNode { - pub unsafe fn from_c_object(c_object: *mut cef_domnode_t) -> CefDOMNode { - CefDOMNode { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_domnode_t) -> CefDOMNode { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDOMNode { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_domnode_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_domnode_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the type for this node. - // - pub fn get_type(&self) -> types::cef_dom_node_type_t { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this is a text node. - // - pub fn is_text(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_text.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this is an element node. - // - pub fn is_element(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_element.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this is an editable node. - // - pub fn is_editable(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_editable.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this is a form control element node. - // - pub fn is_form_control_element(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_form_control_element.unwrap())( - self.c_object)) - } - } - - // - // Returns the type of this form control element node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_form_control_element_type(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_form_control_element_type.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub fn is_same(&self, that: interfaces::CefDOMNode) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns the name of this node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_name(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the value of this node. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_value(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value.unwrap())( - self.c_object)) - } - } - - // - // Set the value of this node. Returns true (1) on success. - // - pub fn set_value(&self, value: &[u16]) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Returns the contents of this node as markup. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_as_markup(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_as_markup.unwrap())( - self.c_object)) - } - } - - // - // Returns the document associated with this node. - // - pub fn get_document(&self) -> interfaces::CefDOMDocument { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_document.unwrap())( - self.c_object)) - } - } - - // - // Returns the parent node. - // - pub fn get_parent(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_parent.unwrap())( - self.c_object)) - } - } - - // - // Returns the previous sibling node. - // - pub fn get_previous_sibling(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_previous_sibling.unwrap())( - self.c_object)) - } - } - - // - // Returns the next sibling node. - // - pub fn get_next_sibling(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_next_sibling.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this node has child nodes. - // - pub fn has_children(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_children.unwrap())( - self.c_object)) - } - } - - // - // Return the first child node. - // - pub fn get_first_child(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_first_child.unwrap())( - self.c_object)) - } - } - - // - // Returns the last child node. - // - pub fn get_last_child(&self) -> interfaces::CefDOMNode { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_last_child.unwrap())( - self.c_object)) - } - } - - - // The following functions are valid only for element nodes. - - // - // Returns the tag name of this element. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_element_tag_name(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_tag_name.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this element has attributes. - // - pub fn has_element_attributes(&self) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_element_attributes.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this element has an attribute named |attrName|. - // - pub fn has_element_attribute(&self, attrName: &[u16]) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_element_attribute.unwrap())( - self.c_object, - CefWrap::to_c(attrName))) - } - } - - // - // Returns the element attribute named |attrName|. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_element_attribute(&self, attrName: &[u16]) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_attribute.unwrap())( - self.c_object, - CefWrap::to_c(attrName))) - } - } - - // - // Returns a map of all element attributes. - // - pub fn get_element_attributes(&self, attrMap: HashMap<String,String>) -> () { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_attributes.unwrap())( - self.c_object, - CefWrap::to_c(attrMap))) - } - } - - // - // Set the value for the element attribute named |attrName|. Returns true (1) - // on success. - // - pub fn set_element_attribute(&self, attrName: &[u16], - value: &[u16]) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_element_attribute.unwrap())( - self.c_object, - CefWrap::to_c(attrName), - CefWrap::to_c(value))) - } - } - - // - // Returns the inner text of the element. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_element_inner_text(&self) -> String { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_inner_text.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_domnode_t> for CefDOMNode { - fn to_c(rust_object: CefDOMNode) -> *mut cef_domnode_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_domnode_t) -> CefDOMNode { - CefDOMNode::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_domnode_t> for Option<CefDOMNode> { - fn to_c(rust_object: Option<CefDOMNode>) -> *mut cef_domnode_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_domnode_t) -> Option<CefDOMNode> { - if c_object.is_null() { - None - } else { - Some(CefDOMNode::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_download_handler.rs b/ports/cef/interfaces/cef_download_handler.rs deleted file mode 100644 index 143e2fe27c4..00000000000 --- a/ports/cef/interfaces/cef_download_handler.rs +++ /dev/null @@ -1,560 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure used to asynchronously continue a download. -// -#[repr(C)] -pub struct _cef_before_download_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Call to continue the download. Set |download_path| to the full file path - // for the download including the file name or leave blank to use the - // suggested name and the default temp directory. Set |show_dialog| to true - // (1) if you do wish to show the default "Save As" dialog. - // - pub cont: Option<extern "C" fn(this: *mut cef_before_download_callback_t, - download_path: *const types::cef_string_t, show_dialog: libc::c_int) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_before_download_callback_t = _cef_before_download_callback_t; - - -// -// Callback structure used to asynchronously continue a download. -// -pub struct CefBeforeDownloadCallback { - c_object: *mut cef_before_download_callback_t, -} - -impl Clone for CefBeforeDownloadCallback { - fn clone(&self) -> CefBeforeDownloadCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefBeforeDownloadCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefBeforeDownloadCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefBeforeDownloadCallback { - pub unsafe fn from_c_object(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback { - CefBeforeDownloadCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefBeforeDownloadCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_before_download_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_before_download_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Call to continue the download. Set |download_path| to the full file path - // for the download including the file name or leave blank to use the - // suggested name and the default temp directory. Set |show_dialog| to true - // (1) if you do wish to show the default "Save As" dialog. - // - pub fn cont(&self, download_path: &[u16], show_dialog: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(download_path), - CefWrap::to_c(show_dialog))) - } - } -} - -impl CefWrap<*mut cef_before_download_callback_t> for CefBeforeDownloadCallback { - fn to_c(rust_object: CefBeforeDownloadCallback) -> *mut cef_before_download_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback { - CefBeforeDownloadCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_before_download_callback_t> for Option<CefBeforeDownloadCallback> { - fn to_c(rust_object: Option<CefBeforeDownloadCallback>) -> *mut cef_before_download_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_before_download_callback_t) -> Option<CefBeforeDownloadCallback> { - if c_object.is_null() { - None - } else { - Some(CefBeforeDownloadCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Callback structure used to asynchronously cancel a download. -// -#[repr(C)] -pub struct _cef_download_item_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Call to cancel the download. - // - pub cancel: Option<extern "C" fn(this: *mut cef_download_item_callback_t) -> ( - )>, - - // - // Call to pause the download. - // - pub pause: Option<extern "C" fn(this: *mut cef_download_item_callback_t) -> ( - )>, - - // - // Call to resume the download. - // - pub resume: Option<extern "C" fn(this: *mut cef_download_item_callback_t) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_download_item_callback_t = _cef_download_item_callback_t; - - -// -// Callback structure used to asynchronously cancel a download. -// -pub struct CefDownloadItemCallback { - c_object: *mut cef_download_item_callback_t, -} - -impl Clone for CefDownloadItemCallback { - fn clone(&self) -> CefDownloadItemCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDownloadItemCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDownloadItemCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDownloadItemCallback { - pub unsafe fn from_c_object(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback { - CefDownloadItemCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDownloadItemCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_download_item_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_download_item_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Call to cancel the download. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } - - // - // Call to pause the download. - // - pub fn pause(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).pause.unwrap())( - self.c_object)) - } - } - - // - // Call to resume the download. - // - pub fn resume(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).resume.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_download_item_callback_t> for CefDownloadItemCallback { - fn to_c(rust_object: CefDownloadItemCallback) -> *mut cef_download_item_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback { - CefDownloadItemCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_download_item_callback_t> for Option<CefDownloadItemCallback> { - fn to_c(rust_object: Option<CefDownloadItemCallback>) -> *mut cef_download_item_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_download_item_callback_t) -> Option<CefDownloadItemCallback> { - if c_object.is_null() { - None - } else { - Some(CefDownloadItemCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to handle file downloads. The functions of this structure will -// called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_download_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called before a download begins. |suggested_name| is the suggested name for - // the download file. By default the download will be canceled. Execute - // |callback| either asynchronously or in this function to continue the - // download if desired. Do not keep a reference to |download_item| outside of - // this function. - // - pub on_before_download: Option<extern "C" fn( - this: *mut cef_download_handler_t, - browser: *mut interfaces::cef_browser_t, - download_item: *mut interfaces::cef_download_item_t, - suggested_name: *const types::cef_string_t, - callback: *mut interfaces::cef_before_download_callback_t) -> ()>, - - // - // Called when a download's status or progress information has been updated. - // This may be called multiple times before and after on_before_download(). - // Execute |callback| either asynchronously or in this function to cancel the - // download if desired. Do not keep a reference to |download_item| outside of - // this function. - // - pub on_download_updated: Option<extern "C" fn( - this: *mut cef_download_handler_t, - browser: *mut interfaces::cef_browser_t, - download_item: *mut interfaces::cef_download_item_t, - callback: *mut interfaces::cef_download_item_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_download_handler_t = _cef_download_handler_t; - - -// -// Structure used to handle file downloads. The functions of this structure will -// called on the browser process UI thread. -// -pub struct CefDownloadHandler { - c_object: *mut cef_download_handler_t, -} - -impl Clone for CefDownloadHandler { - fn clone(&self) -> CefDownloadHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDownloadHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDownloadHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDownloadHandler { - pub unsafe fn from_c_object(c_object: *mut cef_download_handler_t) -> CefDownloadHandler { - CefDownloadHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_download_handler_t) -> CefDownloadHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDownloadHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_download_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_download_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called before a download begins. |suggested_name| is the suggested name for - // the download file. By default the download will be canceled. Execute - // |callback| either asynchronously or in this function to continue the - // download if desired. Do not keep a reference to |download_item| outside of - // this function. - // - pub fn on_before_download(&self, browser: interfaces::CefBrowser, - download_item: interfaces::CefDownloadItem, suggested_name: &[u16], - callback: interfaces::CefBeforeDownloadCallback) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_download.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(download_item), - CefWrap::to_c(suggested_name), - CefWrap::to_c(callback))) - } - } - - // - // Called when a download's status or progress information has been updated. - // This may be called multiple times before and after on_before_download(). - // Execute |callback| either asynchronously or in this function to cancel the - // download if desired. Do not keep a reference to |download_item| outside of - // this function. - // - pub fn on_download_updated(&self, browser: interfaces::CefBrowser, - download_item: interfaces::CefDownloadItem, - callback: interfaces::CefDownloadItemCallback) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_download_updated.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(download_item), - CefWrap::to_c(callback))) - } - } -} - -impl CefWrap<*mut cef_download_handler_t> for CefDownloadHandler { - fn to_c(rust_object: CefDownloadHandler) -> *mut cef_download_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_download_handler_t) -> CefDownloadHandler { - CefDownloadHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_download_handler_t> for Option<CefDownloadHandler> { - fn to_c(rust_object: Option<CefDownloadHandler>) -> *mut cef_download_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_download_handler_t) -> Option<CefDownloadHandler> { - if c_object.is_null() { - None - } else { - Some(CefDownloadHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_download_item.rs b/ports/cef/interfaces/cef_download_item.rs deleted file mode 100644 index 93062f3555f..00000000000 --- a/ports/cef/interfaces/cef_download_item.rs +++ /dev/null @@ -1,518 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent a download item. -// -#[repr(C)] -pub struct _cef_download_item_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_download_item_t) -> libc::c_int>, - - // - // Returns true (1) if the download is in progress. - // - pub is_in_progress: Option<extern "C" fn( - this: *mut cef_download_item_t) -> libc::c_int>, - - // - // Returns true (1) if the download is complete. - // - pub is_complete: Option<extern "C" fn( - this: *mut cef_download_item_t) -> libc::c_int>, - - // - // Returns true (1) if the download has been canceled or interrupted. - // - pub is_canceled: Option<extern "C" fn( - this: *mut cef_download_item_t) -> libc::c_int>, - - // - // Returns a simple speed estimate in bytes/s. - // - pub get_current_speed: Option<extern "C" fn( - this: *mut cef_download_item_t) -> i64>, - - // - // Returns the rough percent complete or -1 if the receive total size is - // unknown. - // - pub get_percent_complete: Option<extern "C" fn( - this: *mut cef_download_item_t) -> libc::c_int>, - - // - // Returns the total number of bytes. - // - pub get_total_bytes: Option<extern "C" fn( - this: *mut cef_download_item_t) -> i64>, - - // - // Returns the number of received bytes. - // - pub get_received_bytes: Option<extern "C" fn( - this: *mut cef_download_item_t) -> i64>, - - // - // Returns the time that the download started. - // - pub get_start_time: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_time_t>, - - // - // Returns the time that the download ended. - // - pub get_end_time: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_time_t>, - - // - // Returns the full path to the downloaded or downloading file. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_full_path: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // Returns the unique identifier for this download. - // - pub get_id: Option<extern "C" fn(this: *mut cef_download_item_t) -> u32>, - - // - // Returns the URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_url: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // Returns the original URL before any redirections. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_original_url: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // Returns the suggested file name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_suggested_file_name: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // Returns the content disposition. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_content_disposition: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // Returns the mime type. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_mime_type: Option<extern "C" fn( - this: *mut cef_download_item_t) -> types::cef_string_userfree_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_download_item_t = _cef_download_item_t; - - -// -// Structure used to represent a download item. -// -pub struct CefDownloadItem { - c_object: *mut cef_download_item_t, -} - -impl Clone for CefDownloadItem { - fn clone(&self) -> CefDownloadItem{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDownloadItem { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDownloadItem { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDownloadItem { - pub unsafe fn from_c_object(c_object: *mut cef_download_item_t) -> CefDownloadItem { - CefDownloadItem { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_t) -> CefDownloadItem { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDownloadItem { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_download_item_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_download_item_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the download is in progress. - // - pub fn is_in_progress(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_in_progress.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the download is complete. - // - pub fn is_complete(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_complete.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the download has been canceled or interrupted. - // - pub fn is_canceled(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_canceled.unwrap())( - self.c_object)) - } - } - - // - // Returns a simple speed estimate in bytes/s. - // - pub fn get_current_speed(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_current_speed.unwrap())( - self.c_object)) - } - } - - // - // Returns the rough percent complete or -1 if the receive total size is - // unknown. - // - pub fn get_percent_complete(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_percent_complete.unwrap())( - self.c_object)) - } - } - - // - // Returns the total number of bytes. - // - pub fn get_total_bytes(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_total_bytes.unwrap())( - self.c_object)) - } - } - - // - // Returns the number of received bytes. - // - pub fn get_received_bytes(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_received_bytes.unwrap())( - self.c_object)) - } - } - - // - // Returns the time that the download started. - // - pub fn get_start_time(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_start_time.unwrap())( - self.c_object)) - } - } - - // - // Returns the time that the download ended. - // - pub fn get_end_time(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_end_time.unwrap())( - self.c_object)) - } - } - - // - // Returns the full path to the downloaded or downloading file. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_full_path(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_full_path.unwrap())( - self.c_object)) - } - } - - // - // Returns the unique identifier for this download. - // - pub fn get_id(&self) -> u32 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_id.unwrap())( - self.c_object)) - } - } - - // - // Returns the URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the original URL before any redirections. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_original_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_original_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the suggested file name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_suggested_file_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_suggested_file_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the content disposition. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_content_disposition(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_content_disposition.unwrap())( - self.c_object)) - } - } - - // - // Returns the mime type. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_mime_type(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_mime_type.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_download_item_t> for CefDownloadItem { - fn to_c(rust_object: CefDownloadItem) -> *mut cef_download_item_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_download_item_t) -> CefDownloadItem { - CefDownloadItem::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_download_item_t> for Option<CefDownloadItem> { - fn to_c(rust_object: Option<CefDownloadItem>) -> *mut cef_download_item_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_download_item_t) -> Option<CefDownloadItem> { - if c_object.is_null() { - None - } else { - Some(CefDownloadItem::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_drag_data.rs b/ports/cef/interfaces/cef_drag_data.rs deleted file mode 100644 index 397996083e5..00000000000 --- a/ports/cef/interfaces/cef_drag_data.rs +++ /dev/null @@ -1,654 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent drag data. The functions of this structure may be -// called on any thread. -// -#[repr(C)] -pub struct _cef_drag_data_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns a copy of the current object. - // - pub clone: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> *mut interfaces::cef_drag_data_t>, - - // - // Returns true (1) if this object is read-only. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> libc::c_int>, - - // - // Returns true (1) if the drag data is a link. - // - pub is_link: Option<extern "C" fn(this: *mut cef_drag_data_t) -> libc::c_int>, - - // - // Returns true (1) if the drag data is a text or html fragment. - // - pub is_fragment: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> libc::c_int>, - - // - // Returns true (1) if the drag data is a file. - // - pub is_file: Option<extern "C" fn(this: *mut cef_drag_data_t) -> libc::c_int>, - - // - // Return the link URL that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_link_url: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the title associated with the link being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_link_title: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the metadata, if any, associated with the link being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_link_metadata: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the plain text fragment that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_fragment_text: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the text/html fragment that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_fragment_html: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the base URL that the fragment came from. This value is used for - // resolving relative URLs and may be NULL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_fragment_base_url: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Return the name of the file being dragged out of the browser window. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_file_name: Option<extern "C" fn( - this: *mut cef_drag_data_t) -> types::cef_string_userfree_t>, - - // - // Write the contents of the file being dragged out of the web view into - // |writer|. Returns the number of bytes sent to |writer|. If |writer| is NULL - // this function will return the size of the file contents in bytes. Call - // get_file_name() to get a suggested name for the file. - // - pub get_file_contents: Option<extern "C" fn(this: *mut cef_drag_data_t, - writer: *mut interfaces::cef_stream_writer_t) -> libc::size_t>, - - // - // Retrieve the list of file names that are being dragged into the browser - // window. - // - pub get_file_names: Option<extern "C" fn(this: *mut cef_drag_data_t, - names: &types::cef_string_list_t) -> libc::c_int>, - - // - // Set the link URL that is being dragged. - // - pub set_link_url: Option<extern "C" fn(this: *mut cef_drag_data_t, - url: *const types::cef_string_t) -> ()>, - - // - // Set the title associated with the link being dragged. - // - pub set_link_title: Option<extern "C" fn(this: *mut cef_drag_data_t, - title: *const types::cef_string_t) -> ()>, - - // - // Set the metadata associated with the link being dragged. - // - pub set_link_metadata: Option<extern "C" fn(this: *mut cef_drag_data_t, - data: *const types::cef_string_t) -> ()>, - - // - // Set the plain text fragment that is being dragged. - // - pub set_fragment_text: Option<extern "C" fn(this: *mut cef_drag_data_t, - text: *const types::cef_string_t) -> ()>, - - // - // Set the text/html fragment that is being dragged. - // - pub set_fragment_html: Option<extern "C" fn(this: *mut cef_drag_data_t, - html: *const types::cef_string_t) -> ()>, - - // - // Set the base URL that the fragment came from. - // - pub set_fragment_base_url: Option<extern "C" fn(this: *mut cef_drag_data_t, - base_url: *const types::cef_string_t) -> ()>, - - // - // Reset the file contents. You should do this before calling - // cef_browser_host_t::DragTargetDragEnter as the web view does not allow us - // to drag in this kind of data. - // - pub reset_file_contents: Option<extern "C" fn(this: *mut cef_drag_data_t) -> ( - )>, - - // - // Add a file that is being dragged into the webview. - // - pub add_file: Option<extern "C" fn(this: *mut cef_drag_data_t, - path: *const types::cef_string_t, - display_name: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_drag_data_t = _cef_drag_data_t; - - -// -// Structure used to represent drag data. The functions of this structure may be -// called on any thread. -// -pub struct CefDragData { - c_object: *mut cef_drag_data_t, -} - -impl Clone for CefDragData { - fn clone(&self) -> CefDragData{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDragData { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDragData { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDragData { - pub unsafe fn from_c_object(c_object: *mut cef_drag_data_t) -> CefDragData { - CefDragData { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_data_t) -> CefDragData { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDragData { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_drag_data_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_drag_data_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns a copy of the current object. - // - pub fn clone(&self) -> interfaces::CefDragData { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clone.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is read-only. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the drag data is a link. - // - pub fn is_link(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_link.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the drag data is a text or html fragment. - // - pub fn is_fragment(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_fragment.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the drag data is a file. - // - pub fn is_file(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_file.unwrap())( - self.c_object)) - } - } - - // - // Return the link URL that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_link_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_link_url.unwrap())( - self.c_object)) - } - } - - // - // Return the title associated with the link being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_link_title(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_link_title.unwrap())( - self.c_object)) - } - } - - // - // Return the metadata, if any, associated with the link being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_link_metadata(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_link_metadata.unwrap())( - self.c_object)) - } - } - - // - // Return the plain text fragment that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_fragment_text(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_fragment_text.unwrap())( - self.c_object)) - } - } - - // - // Return the text/html fragment that is being dragged. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_fragment_html(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_fragment_html.unwrap())( - self.c_object)) - } - } - - // - // Return the base URL that the fragment came from. This value is used for - // resolving relative URLs and may be NULL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_fragment_base_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_fragment_base_url.unwrap())( - self.c_object)) - } - } - - // - // Return the name of the file being dragged out of the browser window. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_file_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_name.unwrap())( - self.c_object)) - } - } - - // - // Write the contents of the file being dragged out of the web view into - // |writer|. Returns the number of bytes sent to |writer|. If |writer| is NULL - // this function will return the size of the file contents in bytes. Call - // get_file_name() to get a suggested name for the file. - // - pub fn get_file_contents(&self, - writer: interfaces::CefStreamWriter) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_contents.unwrap())( - self.c_object, - CefWrap::to_c(writer))) - } - } - - // - // Retrieve the list of file names that are being dragged into the browser - // window. - // - pub fn get_file_names(&self, names: &Vec<String>) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_names.unwrap())( - self.c_object, - CefWrap::to_c(names))) - } - } - - // - // Set the link URL that is being dragged. - // - pub fn set_link_url(&self, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_link_url.unwrap())( - self.c_object, - CefWrap::to_c(url))) - } - } - - // - // Set the title associated with the link being dragged. - // - pub fn set_link_title(&self, title: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_link_title.unwrap())( - self.c_object, - CefWrap::to_c(title))) - } - } - - // - // Set the metadata associated with the link being dragged. - // - pub fn set_link_metadata(&self, data: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_link_metadata.unwrap())( - self.c_object, - CefWrap::to_c(data))) - } - } - - // - // Set the plain text fragment that is being dragged. - // - pub fn set_fragment_text(&self, text: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_fragment_text.unwrap())( - self.c_object, - CefWrap::to_c(text))) - } - } - - // - // Set the text/html fragment that is being dragged. - // - pub fn set_fragment_html(&self, html: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_fragment_html.unwrap())( - self.c_object, - CefWrap::to_c(html))) - } - } - - // - // Set the base URL that the fragment came from. - // - pub fn set_fragment_base_url(&self, base_url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_fragment_base_url.unwrap())( - self.c_object, - CefWrap::to_c(base_url))) - } - } - - // - // Reset the file contents. You should do this before calling - // cef_browser_host_t::DragTargetDragEnter as the web view does not allow us - // to drag in this kind of data. - // - pub fn reset_file_contents(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).reset_file_contents.unwrap())( - self.c_object)) - } - } - - // - // Add a file that is being dragged into the webview. - // - pub fn add_file(&self, path: &[u16], display_name: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_file.unwrap())( - self.c_object, - CefWrap::to_c(path), - CefWrap::to_c(display_name))) - } - } - - // - // Create a new cef_drag_data_t object. - // - pub fn create() -> interfaces::CefDragData { - unsafe { - CefWrap::to_rust( - ::drag_data::cef_drag_data_create( -)) - } - } -} - -impl CefWrap<*mut cef_drag_data_t> for CefDragData { - fn to_c(rust_object: CefDragData) -> *mut cef_drag_data_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_drag_data_t) -> CefDragData { - CefDragData::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_drag_data_t> for Option<CefDragData> { - fn to_c(rust_object: Option<CefDragData>) -> *mut cef_drag_data_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_drag_data_t) -> Option<CefDragData> { - if c_object.is_null() { - None - } else { - Some(CefDragData::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_drag_handler.rs b/ports/cef/interfaces/cef_drag_handler.rs deleted file mode 100644 index 6697ac1d434..00000000000 --- a/ports/cef/interfaces/cef_drag_handler.rs +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to dragging. The functions -// of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_drag_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called when an external drag event enters the browser window. |dragData| - // contains the drag event data and |mask| represents the type of drag - // operation. Return false (0) for default drag handling behavior or true (1) - // to cancel the drag event. - // - pub on_drag_enter: Option<extern "C" fn(this: *mut cef_drag_handler_t, - browser: *mut interfaces::cef_browser_t, - dragData: *mut interfaces::cef_drag_data_t, - mask: types::cef_drag_operations_mask_t) -> libc::c_int>, - - // - // Called whenever draggable regions for the browser window change. These can - // be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If - // draggable regions are never defined in a document this function will also - // never be called. If the last draggable region is removed from a document - // this function will be called with an NULL vector. - // - pub on_draggable_regions_changed: Option<extern "C" fn( - this: *mut cef_drag_handler_t, browser: *mut interfaces::cef_browser_t, - regions_count: libc::size_t, - regions: *const types::cef_draggable_region_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_drag_handler_t = _cef_drag_handler_t; - - -// -// Implement this structure to handle events related to dragging. The functions -// of this structure will be called on the UI thread. -// -pub struct CefDragHandler { - c_object: *mut cef_drag_handler_t, -} - -impl Clone for CefDragHandler { - fn clone(&self) -> CefDragHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDragHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDragHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDragHandler { - pub unsafe fn from_c_object(c_object: *mut cef_drag_handler_t) -> CefDragHandler { - CefDragHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_handler_t) -> CefDragHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDragHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_drag_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_drag_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called when an external drag event enters the browser window. |dragData| - // contains the drag event data and |mask| represents the type of drag - // operation. Return false (0) for default drag handling behavior or true (1) - // to cancel the drag event. - // - pub fn on_drag_enter(&self, browser: interfaces::CefBrowser, - dragData: interfaces::CefDragData, - mask: types::cef_drag_operations_mask_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_drag_enter.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(dragData), - CefWrap::to_c(mask))) - } - } - - // - // Called whenever draggable regions for the browser window change. These can - // be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If - // draggable regions are never defined in a document this function will also - // never be called. If the last draggable region is removed from a document - // this function will be called with an NULL vector. - // - pub fn on_draggable_regions_changed(&self, browser: interfaces::CefBrowser, - regions_count: libc::size_t, - regions: *const types::cef_draggable_region_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_draggable_regions_changed.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(regions_count), - CefWrap::to_c(regions))) - } - } -} - -impl CefWrap<*mut cef_drag_handler_t> for CefDragHandler { - fn to_c(rust_object: CefDragHandler) -> *mut cef_drag_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_drag_handler_t) -> CefDragHandler { - CefDragHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_drag_handler_t> for Option<CefDragHandler> { - fn to_c(rust_object: Option<CefDragHandler>) -> *mut cef_drag_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_drag_handler_t) -> Option<CefDragHandler> { - if c_object.is_null() { - None - } else { - Some(CefDragHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_find_handler.rs b/ports/cef/interfaces/cef_find_handler.rs deleted file mode 100644 index 46f17d09989..00000000000 --- a/ports/cef/interfaces/cef_find_handler.rs +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to find results. The -// functions of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_find_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called to report find results returned by cef_browser_host_t::find(). - // |identifer| is the identifier passed to find(), |count| is the number of - // matches currently identified, |selectionRect| is the location of where the - // match was found (in window coordinates), |activeMatchOrdinal| is the - // current position in the search results, and |finalUpdate| is true (1) if - // this is the last find notification. - // - pub on_find_result: Option<extern "C" fn(this: *mut cef_find_handler_t, - browser: *mut interfaces::cef_browser_t, identifier: libc::c_int, - count: libc::c_int, selectionRect: *const types::cef_rect_t, - activeMatchOrdinal: libc::c_int, finalUpdate: libc::c_int) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_find_handler_t = _cef_find_handler_t; - - -// -// Implement this structure to handle events related to find results. The -// functions of this structure will be called on the UI thread. -// -pub struct CefFindHandler { - c_object: *mut cef_find_handler_t, -} - -impl Clone for CefFindHandler { - fn clone(&self) -> CefFindHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefFindHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefFindHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefFindHandler { - pub unsafe fn from_c_object(c_object: *mut cef_find_handler_t) -> CefFindHandler { - CefFindHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_find_handler_t) -> CefFindHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefFindHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_find_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_find_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called to report find results returned by cef_browser_host_t::find(). - // |identifer| is the identifier passed to find(), |count| is the number of - // matches currently identified, |selectionRect| is the location of where the - // match was found (in window coordinates), |activeMatchOrdinal| is the - // current position in the search results, and |finalUpdate| is true (1) if - // this is the last find notification. - // - pub fn on_find_result(&self, browser: interfaces::CefBrowser, - identifier: libc::c_int, count: libc::c_int, - selectionRect: &types::cef_rect_t, activeMatchOrdinal: libc::c_int, - finalUpdate: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_find_result.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(identifier), - CefWrap::to_c(count), - CefWrap::to_c(selectionRect), - CefWrap::to_c(activeMatchOrdinal), - CefWrap::to_c(finalUpdate))) - } - } -} - -impl CefWrap<*mut cef_find_handler_t> for CefFindHandler { - fn to_c(rust_object: CefFindHandler) -> *mut cef_find_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_find_handler_t) -> CefFindHandler { - CefFindHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_find_handler_t> for Option<CefFindHandler> { - fn to_c(rust_object: Option<CefFindHandler>) -> *mut cef_find_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_find_handler_t) -> Option<CefFindHandler> { - if c_object.is_null() { - None - } else { - Some(CefFindHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_focus_handler.rs b/ports/cef/interfaces/cef_focus_handler.rs deleted file mode 100644 index 6d0ba851655..00000000000 --- a/ports/cef/interfaces/cef_focus_handler.rs +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to focus. The functions of -// this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_focus_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called when the browser component is about to loose focus. For instance, if - // focus was on the last HTML element and the user pressed the TAB key. |next| - // will be true (1) if the browser is giving focus to the next component and - // false (0) if the browser is giving focus to the previous component. - // - pub on_take_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t, - browser: *mut interfaces::cef_browser_t, next: libc::c_int) -> ()>, - - // - // Called when the browser component is requesting focus. |source| indicates - // where the focus request is originating from. Return false (0) to allow the - // focus to be set or true (1) to cancel setting the focus. - // - pub on_set_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t, - browser: *mut interfaces::cef_browser_t, - source: types::cef_focus_source_t) -> libc::c_int>, - - // - // Called when the browser component has received focus. - // - pub on_got_focus: Option<extern "C" fn(this: *mut cef_focus_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_focus_handler_t = _cef_focus_handler_t; - - -// -// Implement this structure to handle events related to focus. The functions of -// this structure will be called on the UI thread. -// -pub struct CefFocusHandler { - c_object: *mut cef_focus_handler_t, -} - -impl Clone for CefFocusHandler { - fn clone(&self) -> CefFocusHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefFocusHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefFocusHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefFocusHandler { - pub unsafe fn from_c_object(c_object: *mut cef_focus_handler_t) -> CefFocusHandler { - CefFocusHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_focus_handler_t) -> CefFocusHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefFocusHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_focus_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_focus_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called when the browser component is about to loose focus. For instance, if - // focus was on the last HTML element and the user pressed the TAB key. |next| - // will be true (1) if the browser is giving focus to the next component and - // false (0) if the browser is giving focus to the previous component. - // - pub fn on_take_focus(&self, browser: interfaces::CefBrowser, - next: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_take_focus.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(next))) - } - } - - // - // Called when the browser component is requesting focus. |source| indicates - // where the focus request is originating from. Return false (0) to allow the - // focus to be set or true (1) to cancel setting the focus. - // - pub fn on_set_focus(&self, browser: interfaces::CefBrowser, - source: types::cef_focus_source_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_set_focus.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(source))) - } - } - - // - // Called when the browser component has received focus. - // - pub fn on_got_focus(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_got_focus.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } -} - -impl CefWrap<*mut cef_focus_handler_t> for CefFocusHandler { - fn to_c(rust_object: CefFocusHandler) -> *mut cef_focus_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_focus_handler_t) -> CefFocusHandler { - CefFocusHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_focus_handler_t> for Option<CefFocusHandler> { - fn to_c(rust_object: Option<CefFocusHandler>) -> *mut cef_focus_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_focus_handler_t) -> Option<CefFocusHandler> { - if c_object.is_null() { - None - } else { - Some(CefFocusHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_frame.rs b/ports/cef/interfaces/cef_frame.rs deleted file mode 100644 index f956d4d19ab..00000000000 --- a/ports/cef/interfaces/cef_frame.rs +++ /dev/null @@ -1,688 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent a frame in the browser window. When used in the -// browser process the functions of this structure may be called on any thread -// unless otherwise indicated in the comments. When used in the render process -// the functions of this structure may only be called on the main thread. -// -#[repr(C)] -pub struct _cef_frame_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // True if this object is currently attached to a valid frame. - // - pub is_valid: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>, - - // - // Execute undo in this frame. - // - pub undo: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute redo in this frame. - // - pub redo: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute cut in this frame. - // - pub cut: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute copy in this frame. - // - pub copy: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute paste in this frame. - // - pub paste: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute delete in this frame. - // - pub del: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Execute select all in this frame. - // - pub select_all: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Save this frame's HTML source to a temporary file and open it in the - // default text viewing application. This function can only be called from the - // browser process. - // - pub view_source: Option<extern "C" fn(this: *mut cef_frame_t) -> ()>, - - // - // Retrieve this frame's HTML source as a string sent to the specified - // visitor. - // - pub get_source: Option<extern "C" fn(this: *mut cef_frame_t, - visitor: *mut interfaces::cef_string_visitor_t) -> ()>, - - // - // Retrieve this frame's display text as a string sent to the specified - // visitor. - // - pub get_text: Option<extern "C" fn(this: *mut cef_frame_t, - visitor: *mut interfaces::cef_string_visitor_t) -> ()>, - - // - // Load the request represented by the |request| object. - // - pub load_request: Option<extern "C" fn(this: *mut cef_frame_t, - request: *mut interfaces::cef_request_t) -> ()>, - - // - // Load the specified |url|. - // - pub load_url: Option<extern "C" fn(this: *mut cef_frame_t, - url: *const types::cef_string_t) -> ()>, - - // - // Load the contents of |string_val| with the specified dummy |url|. |url| - // should have a standard scheme (for example, http scheme) or behaviors like - // link clicks and web security restrictions may not behave as expected. - // - pub load_string: Option<extern "C" fn(this: *mut cef_frame_t, - string_val: *const types::cef_string_t, - url: *const types::cef_string_t) -> ()>, - - // - // Execute a string of JavaScript code in this frame. The |script_url| - // parameter is the URL where the script in question can be found, if any. The - // renderer may request this URL to show the developer the source of the - // error. The |start_line| parameter is the base line number to use for error - // reporting. - // - pub execute_java_script: Option<extern "C" fn(this: *mut cef_frame_t, - code: *const types::cef_string_t, script_url: *const types::cef_string_t, - start_line: libc::c_int) -> ()>, - - // - // Returns true (1) if this is the main (top-level) frame. - // - pub is_main: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>, - - // - // Returns true (1) if this is the focused frame. - // - pub is_focused: Option<extern "C" fn(this: *mut cef_frame_t) -> libc::c_int>, - - // - // Returns the name for this frame. If the frame has an assigned name (for - // example, set via the iframe "name" attribute) then that value will be - // returned. Otherwise a unique name will be constructed based on the frame - // parent hierarchy. The main (top-level) frame will always have an NULL name - // value. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_name: Option<extern "C" fn( - this: *mut cef_frame_t) -> types::cef_string_userfree_t>, - - // - // Returns the globally unique identifier for this frame. - // - pub get_identifier: Option<extern "C" fn(this: *mut cef_frame_t) -> i64>, - - // - // Returns the parent of this frame or NULL if this is the main (top-level) - // frame. - // - pub get_parent: Option<extern "C" fn( - this: *mut cef_frame_t) -> *mut interfaces::cef_frame_t>, - - // - // Returns the URL currently loaded in this frame. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_url: Option<extern "C" fn( - this: *mut cef_frame_t) -> types::cef_string_userfree_t>, - - // - // Returns the browser that this frame belongs to. - // - pub get_browser: Option<extern "C" fn( - this: *mut cef_frame_t) -> *mut interfaces::cef_browser_t>, - - // - // Get the V8 context associated with the frame. This function can only be - // called from the render process. - // - pub get_v8context: Option<extern "C" fn( - this: *mut cef_frame_t) -> *mut interfaces::cef_v8context_t>, - - // - // Visit the DOM document. This function can only be called from the render - // process. - // - pub visit_dom: Option<extern "C" fn(this: *mut cef_frame_t, - visitor: *mut interfaces::cef_domvisitor_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_frame_t = _cef_frame_t; - - -// -// Structure used to represent a frame in the browser window. When used in the -// browser process the functions of this structure may be called on any thread -// unless otherwise indicated in the comments. When used in the render process -// the functions of this structure may only be called on the main thread. -// -pub struct CefFrame { - c_object: *mut cef_frame_t, -} - -impl Clone for CefFrame { - fn clone(&self) -> CefFrame{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefFrame { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefFrame { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefFrame { - pub unsafe fn from_c_object(c_object: *mut cef_frame_t) -> CefFrame { - CefFrame { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_frame_t) -> CefFrame { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefFrame { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_frame_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_frame_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // True if this object is currently attached to a valid frame. - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Execute undo in this frame. - // - pub fn undo(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).undo.unwrap())( - self.c_object)) - } - } - - // - // Execute redo in this frame. - // - pub fn redo(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).redo.unwrap())( - self.c_object)) - } - } - - // - // Execute cut in this frame. - // - pub fn cut(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cut.unwrap())( - self.c_object)) - } - } - - // - // Execute copy in this frame. - // - pub fn copy(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Execute paste in this frame. - // - pub fn paste(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).paste.unwrap())( - self.c_object)) - } - } - - // - // Execute delete in this frame. - // - pub fn del(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).del.unwrap())( - self.c_object)) - } - } - - // - // Execute select all in this frame. - // - pub fn select_all(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).select_all.unwrap())( - self.c_object)) - } - } - - // - // Save this frame's HTML source to a temporary file and open it in the - // default text viewing application. This function can only be called from the - // browser process. - // - pub fn view_source(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).view_source.unwrap())( - self.c_object)) - } - } - - // - // Retrieve this frame's HTML source as a string sent to the specified - // visitor. - // - pub fn get_source(&self, visitor: interfaces::CefStringVisitor) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_source.unwrap())( - self.c_object, - CefWrap::to_c(visitor))) - } - } - - // - // Retrieve this frame's display text as a string sent to the specified - // visitor. - // - pub fn get_text(&self, visitor: interfaces::CefStringVisitor) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_text.unwrap())( - self.c_object, - CefWrap::to_c(visitor))) - } - } - - // - // Load the request represented by the |request| object. - // - pub fn load_request(&self, request: interfaces::CefRequest) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).load_request.unwrap())( - self.c_object, - CefWrap::to_c(request))) - } - } - - // - // Load the specified |url|. - // - pub fn load_url(&self, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).load_url.unwrap())( - self.c_object, - CefWrap::to_c(url))) - } - } - - // - // Load the contents of |string_val| with the specified dummy |url|. |url| - // should have a standard scheme (for example, http scheme) or behaviors like - // link clicks and web security restrictions may not behave as expected. - // - pub fn load_string(&self, string_val: &[u16], url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).load_string.unwrap())( - self.c_object, - CefWrap::to_c(string_val), - CefWrap::to_c(url))) - } - } - - // - // Execute a string of JavaScript code in this frame. The |script_url| - // parameter is the URL where the script in question can be found, if any. The - // renderer may request this URL to show the developer the source of the - // error. The |start_line| parameter is the base line number to use for error - // reporting. - // - pub fn execute_java_script(&self, code: &[u16], script_url: &[u16], - start_line: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).execute_java_script.unwrap())( - self.c_object, - CefWrap::to_c(code), - CefWrap::to_c(script_url), - CefWrap::to_c(start_line))) - } - } - - // - // Returns true (1) if this is the main (top-level) frame. - // - pub fn is_main(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_main.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this is the focused frame. - // - pub fn is_focused(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_focused.unwrap())( - self.c_object)) - } - } - - // - // Returns the name for this frame. If the frame has an assigned name (for - // example, set via the iframe "name" attribute) then that value will be - // returned. Otherwise a unique name will be constructed based on the frame - // parent hierarchy. The main (top-level) frame will always have an NULL name - // value. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the globally unique identifier for this frame. - // - pub fn get_identifier(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_identifier.unwrap())( - self.c_object)) - } - } - - // - // Returns the parent of this frame or NULL if this is the main (top-level) - // frame. - // - pub fn get_parent(&self) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_parent.unwrap())( - self.c_object)) - } - } - - // - // Returns the URL currently loaded in this frame. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the browser that this frame belongs to. - // - pub fn get_browser(&self) -> interfaces::CefBrowser { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_browser.unwrap())( - self.c_object)) - } - } - - // - // Get the V8 context associated with the frame. This function can only be - // called from the render process. - // - pub fn get_v8context(&self) -> interfaces::CefV8Context { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_v8context.unwrap())( - self.c_object)) - } - } - - // - // Visit the DOM document. This function can only be called from the render - // process. - // - pub fn visit_dom(&self, visitor: interfaces::CefDOMVisitor) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit_dom.unwrap())( - self.c_object, - CefWrap::to_c(visitor))) - } - } -} - -impl CefWrap<*mut cef_frame_t> for CefFrame { - fn to_c(rust_object: CefFrame) -> *mut cef_frame_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_frame_t) -> CefFrame { - CefFrame::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_frame_t> for Option<CefFrame> { - fn to_c(rust_object: Option<CefFrame>) -> *mut cef_frame_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_frame_t) -> Option<CefFrame> { - if c_object.is_null() { - None - } else { - Some(CefFrame::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_geolocation.rs b/ports/cef/interfaces/cef_geolocation.rs deleted file mode 100644 index f9d9fecfbc2..00000000000 --- a/ports/cef/interfaces/cef_geolocation.rs +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to receive geolocation updates. The functions of -// this structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_get_geolocation_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called with the 'best available' location information or, if the location - // update failed, with error information. - // - pub on_location_update: Option<extern "C" fn( - this: *mut cef_get_geolocation_callback_t, - position: *const interfaces::cef_geoposition_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_get_geolocation_callback_t = _cef_get_geolocation_callback_t; - - -// -// Implement this structure to receive geolocation updates. The functions of -// this structure will be called on the browser process UI thread. -// -pub struct CefGetGeolocationCallback { - c_object: *mut cef_get_geolocation_callback_t, -} - -impl Clone for CefGetGeolocationCallback { - fn clone(&self) -> CefGetGeolocationCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefGetGeolocationCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefGetGeolocationCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefGetGeolocationCallback { - pub unsafe fn from_c_object(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback { - CefGetGeolocationCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefGetGeolocationCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_get_geolocation_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_get_geolocation_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called with the 'best available' location information or, if the location - // update failed, with error information. - // - pub fn on_location_update(&self, position: &interfaces::CefGeoposition) -> ( - ) { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_location_update.unwrap())( - self.c_object, - CefWrap::to_c(position))) - } - } -} - -impl CefWrap<*mut cef_get_geolocation_callback_t> for CefGetGeolocationCallback { - fn to_c(rust_object: CefGetGeolocationCallback) -> *mut cef_get_geolocation_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback { - CefGetGeolocationCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_get_geolocation_callback_t> for Option<CefGetGeolocationCallback> { - fn to_c(rust_object: Option<CefGetGeolocationCallback>) -> *mut cef_get_geolocation_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_get_geolocation_callback_t) -> Option<CefGetGeolocationCallback> { - if c_object.is_null() { - None - } else { - Some(CefGetGeolocationCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_geolocation_handler.rs b/ports/cef/interfaces/cef_geolocation_handler.rs deleted file mode 100644 index 9d75a01ab29..00000000000 --- a/ports/cef/interfaces/cef_geolocation_handler.rs +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure used for asynchronous continuation of geolocation -// permission requests. -// -#[repr(C)] -pub struct _cef_geolocation_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Call to allow or deny geolocation access. - // - pub cont: Option<extern "C" fn(this: *mut cef_geolocation_callback_t, - allow: libc::c_int) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_geolocation_callback_t = _cef_geolocation_callback_t; - - -// -// Callback structure used for asynchronous continuation of geolocation -// permission requests. -// -pub struct CefGeolocationCallback { - c_object: *mut cef_geolocation_callback_t, -} - -impl Clone for CefGeolocationCallback { - fn clone(&self) -> CefGeolocationCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefGeolocationCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefGeolocationCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefGeolocationCallback { - pub unsafe fn from_c_object(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback { - CefGeolocationCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefGeolocationCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_geolocation_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_geolocation_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Call to allow or deny geolocation access. - // - pub fn cont(&self, allow: libc::c_int) -> () { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(allow))) - } - } -} - -impl CefWrap<*mut cef_geolocation_callback_t> for CefGeolocationCallback { - fn to_c(rust_object: CefGeolocationCallback) -> *mut cef_geolocation_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback { - CefGeolocationCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_geolocation_callback_t> for Option<CefGeolocationCallback> { - fn to_c(rust_object: Option<CefGeolocationCallback>) -> *mut cef_geolocation_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_geolocation_callback_t) -> Option<CefGeolocationCallback> { - if c_object.is_null() { - None - } else { - Some(CefGeolocationCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Implement this structure to handle events related to geolocation permission -// requests. The functions of this structure will be called on the browser -// process UI thread. -// -#[repr(C)] -pub struct _cef_geolocation_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called when a page requests permission to access geolocation information. - // |requesting_url| is the URL requesting permission and |request_id| is the - // unique ID for the permission request. Return true (1) and call - // cef_geolocation_callback_t::cont() either in this function or at a later - // time to continue or cancel the request. Return false (0) to cancel the - // request immediately. - // - pub on_request_geolocation_permission: Option<extern "C" fn( - this: *mut cef_geolocation_handler_t, - browser: *mut interfaces::cef_browser_t, - requesting_url: *const types::cef_string_t, request_id: libc::c_int, - callback: *mut interfaces::cef_geolocation_callback_t) -> libc::c_int>, - - // - // Called when a geolocation access request is canceled. |requesting_url| is - // the URL that originally requested permission and |request_id| is the unique - // ID for the permission request. - // - pub on_cancel_geolocation_permission: Option<extern "C" fn( - this: *mut cef_geolocation_handler_t, - browser: *mut interfaces::cef_browser_t, - requesting_url: *const types::cef_string_t, request_id: libc::c_int) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_geolocation_handler_t = _cef_geolocation_handler_t; - - -// -// Implement this structure to handle events related to geolocation permission -// requests. The functions of this structure will be called on the browser -// process UI thread. -// -pub struct CefGeolocationHandler { - c_object: *mut cef_geolocation_handler_t, -} - -impl Clone for CefGeolocationHandler { - fn clone(&self) -> CefGeolocationHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefGeolocationHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefGeolocationHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefGeolocationHandler { - pub unsafe fn from_c_object(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler { - CefGeolocationHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefGeolocationHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_geolocation_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_geolocation_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called when a page requests permission to access geolocation information. - // |requesting_url| is the URL requesting permission and |request_id| is the - // unique ID for the permission request. Return true (1) and call - // cef_geolocation_callback_t::cont() either in this function or at a later - // time to continue or cancel the request. Return false (0) to cancel the - // request immediately. - // - pub fn on_request_geolocation_permission(&self, - browser: interfaces::CefBrowser, requesting_url: &[u16], - request_id: libc::c_int, - callback: interfaces::CefGeolocationCallback) -> libc::c_int { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_request_geolocation_permission.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(requesting_url), - CefWrap::to_c(request_id), - CefWrap::to_c(callback))) - } - } - - // - // Called when a geolocation access request is canceled. |requesting_url| is - // the URL that originally requested permission and |request_id| is the unique - // ID for the permission request. - // - pub fn on_cancel_geolocation_permission(&self, - browser: interfaces::CefBrowser, requesting_url: &[u16], - request_id: libc::c_int) -> () { - if self.c_object.is_null(){ - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_cancel_geolocation_permission.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(requesting_url), - CefWrap::to_c(request_id))) - } - } -} - -impl CefWrap<*mut cef_geolocation_handler_t> for CefGeolocationHandler { - fn to_c(rust_object: CefGeolocationHandler) -> *mut cef_geolocation_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler { - CefGeolocationHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_geolocation_handler_t> for Option<CefGeolocationHandler> { - fn to_c(rust_object: Option<CefGeolocationHandler>) -> *mut cef_geolocation_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_geolocation_handler_t) -> Option<CefGeolocationHandler> { - if c_object.is_null() { - None - } else { - Some(CefGeolocationHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_jsdialog_handler.rs b/ports/cef/interfaces/cef_jsdialog_handler.rs deleted file mode 100644 index 13edb21fbc5..00000000000 --- a/ports/cef/interfaces/cef_jsdialog_handler.rs +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure used for asynchronous continuation of JavaScript dialog -// requests. -// -#[repr(C)] -pub struct _cef_jsdialog_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue the JS dialog request. Set |success| to true (1) if the OK button - // was pressed. The |user_input| value should be specified for prompt dialogs. - // - pub cont: Option<extern "C" fn(this: *mut cef_jsdialog_callback_t, - success: libc::c_int, user_input: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_jsdialog_callback_t = _cef_jsdialog_callback_t; - - -// -// Callback structure used for asynchronous continuation of JavaScript dialog -// requests. -// -pub struct CefJSDialogCallback { - c_object: *mut cef_jsdialog_callback_t, -} - -impl Clone for CefJSDialogCallback { - fn clone(&self) -> CefJSDialogCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefJSDialogCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefJSDialogCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefJSDialogCallback { - pub unsafe fn from_c_object(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback { - CefJSDialogCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefJSDialogCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_jsdialog_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue the JS dialog request. Set |success| to true (1) if the OK button - // was pressed. The |user_input| value should be specified for prompt dialogs. - // - pub fn cont(&self, success: libc::c_int, user_input: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(success), - CefWrap::to_c(user_input))) - } - } -} - -impl CefWrap<*mut cef_jsdialog_callback_t> for CefJSDialogCallback { - fn to_c(rust_object: CefJSDialogCallback) -> *mut cef_jsdialog_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback { - CefJSDialogCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_jsdialog_callback_t> for Option<CefJSDialogCallback> { - fn to_c(rust_object: Option<CefJSDialogCallback>) -> *mut cef_jsdialog_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_jsdialog_callback_t) -> Option<CefJSDialogCallback> { - if c_object.is_null() { - None - } else { - Some(CefJSDialogCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Implement this structure to handle events related to JavaScript dialogs. The -// functions of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_jsdialog_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called to run a JavaScript dialog. The |default_prompt_text| value will be - // specified for prompt dialogs only. Set |suppress_message| to true (1) and - // return false (0) to suppress the message (suppressing messages is - // preferable to immediately executing the callback as this is used to detect - // presumably malicious behavior like spamming alert messages in - // onbeforeunload). Set |suppress_message| to false (0) and return false (0) - // to use the default implementation (the default implementation will show one - // modal dialog at a time and suppress any additional dialog requests until - // the displayed dialog is dismissed). Return true (1) if the application will - // use a custom dialog or if the callback has been executed immediately. - // Custom dialogs may be either modal or modeless. If a custom dialog is used - // the application must execute |callback| once the custom dialog is - // dismissed. - // - pub on_jsdialog: Option<extern "C" fn(this: *mut cef_jsdialog_handler_t, - browser: *mut interfaces::cef_browser_t, - origin_url: *const types::cef_string_t, - accept_lang: *const types::cef_string_t, - dialog_type: types::cef_jsdialog_type_t, - message_text: *const types::cef_string_t, - default_prompt_text: *const types::cef_string_t, - callback: *mut interfaces::cef_jsdialog_callback_t, - suppress_message: *mut libc::c_int) -> libc::c_int>, - - // - // Called to run a dialog asking the user if they want to leave a page. Return - // false (0) to use the default dialog implementation. Return true (1) if the - // application will use a custom dialog or if the callback has been executed - // immediately. Custom dialogs may be either modal or modeless. If a custom - // dialog is used the application must execute |callback| once the custom - // dialog is dismissed. - // - pub on_before_unload_dialog: Option<extern "C" fn( - this: *mut cef_jsdialog_handler_t, - browser: *mut interfaces::cef_browser_t, - message_text: *const types::cef_string_t, is_reload: libc::c_int, - callback: *mut interfaces::cef_jsdialog_callback_t) -> libc::c_int>, - - // - // Called to cancel any pending dialogs and reset any saved dialog state. Will - // be called due to events like page navigation irregardless of whether any - // dialogs are currently pending. - // - pub on_reset_dialog_state: Option<extern "C" fn( - this: *mut cef_jsdialog_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // Called when the default implementation dialog is closed. - // - pub on_dialog_closed: Option<extern "C" fn(this: *mut cef_jsdialog_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_jsdialog_handler_t = _cef_jsdialog_handler_t; - - -// -// Implement this structure to handle events related to JavaScript dialogs. The -// functions of this structure will be called on the UI thread. -// -pub struct CefJSDialogHandler { - c_object: *mut cef_jsdialog_handler_t, -} - -impl Clone for CefJSDialogHandler { - fn clone(&self) -> CefJSDialogHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefJSDialogHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefJSDialogHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefJSDialogHandler { - pub unsafe fn from_c_object(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler { - CefJSDialogHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefJSDialogHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_jsdialog_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called to run a JavaScript dialog. The |default_prompt_text| value will be - // specified for prompt dialogs only. Set |suppress_message| to true (1) and - // return false (0) to suppress the message (suppressing messages is - // preferable to immediately executing the callback as this is used to detect - // presumably malicious behavior like spamming alert messages in - // onbeforeunload). Set |suppress_message| to false (0) and return false (0) - // to use the default implementation (the default implementation will show one - // modal dialog at a time and suppress any additional dialog requests until - // the displayed dialog is dismissed). Return true (1) if the application will - // use a custom dialog or if the callback has been executed immediately. - // Custom dialogs may be either modal or modeless. If a custom dialog is used - // the application must execute |callback| once the custom dialog is - // dismissed. - // - pub fn on_jsdialog(&self, browser: interfaces::CefBrowser, origin_url: &[u16], - accept_lang: &[u16], dialog_type: types::cef_jsdialog_type_t, - message_text: &[u16], default_prompt_text: &[u16], - callback: interfaces::CefJSDialogCallback, - suppress_message: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_jsdialog.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(origin_url), - CefWrap::to_c(accept_lang), - CefWrap::to_c(dialog_type), - CefWrap::to_c(message_text), - CefWrap::to_c(default_prompt_text), - CefWrap::to_c(callback), - CefWrap::to_c(suppress_message))) - } - } - - // - // Called to run a dialog asking the user if they want to leave a page. Return - // false (0) to use the default dialog implementation. Return true (1) if the - // application will use a custom dialog or if the callback has been executed - // immediately. Custom dialogs may be either modal or modeless. If a custom - // dialog is used the application must execute |callback| once the custom - // dialog is dismissed. - // - pub fn on_before_unload_dialog(&self, browser: interfaces::CefBrowser, - message_text: &[u16], is_reload: libc::c_int, - callback: interfaces::CefJSDialogCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_unload_dialog.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(message_text), - CefWrap::to_c(is_reload), - CefWrap::to_c(callback))) - } - } - - // - // Called to cancel any pending dialogs and reset any saved dialog state. Will - // be called due to events like page navigation irregardless of whether any - // dialogs are currently pending. - // - pub fn on_reset_dialog_state(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_reset_dialog_state.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called when the default implementation dialog is closed. - // - pub fn on_dialog_closed(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_dialog_closed.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } -} - -impl CefWrap<*mut cef_jsdialog_handler_t> for CefJSDialogHandler { - fn to_c(rust_object: CefJSDialogHandler) -> *mut cef_jsdialog_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler { - CefJSDialogHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_jsdialog_handler_t> for Option<CefJSDialogHandler> { - fn to_c(rust_object: Option<CefJSDialogHandler>) -> *mut cef_jsdialog_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_jsdialog_handler_t) -> Option<CefJSDialogHandler> { - if c_object.is_null() { - None - } else { - Some(CefJSDialogHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_keyboard_handler.rs b/ports/cef/interfaces/cef_keyboard_handler.rs deleted file mode 100644 index 67ec12c5cbe..00000000000 --- a/ports/cef/interfaces/cef_keyboard_handler.rs +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to keyboard input. The -// functions of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_keyboard_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // Called before a keyboard event is sent to the renderer. |event| contains - // information about the keyboard event. |os_event| is the operating system - // event message, if any. Return true (1) if the event was handled or false - // (0) otherwise. If the event will be handled in on_key_event() as a keyboard - // shortcut set |is_keyboard_shortcut| to true (1) and return false (0). - pub on_pre_key_event: Option<extern "C" fn(this: *mut cef_keyboard_handler_t, - browser: *mut interfaces::cef_browser_t, - event: *const interfaces::cef_key_event_t, - os_event: types::cef_event_handle_t, - is_keyboard_shortcut: *mut libc::c_int) -> libc::c_int>, - - // - // Called after the renderer and JavaScript in the page has had a chance to - // handle the event. |event| contains information about the keyboard event. - // |os_event| is the operating system event message, if any. Return true (1) - // if the keyboard event was handled or false (0) otherwise. - // - pub on_key_event: Option<extern "C" fn(this: *mut cef_keyboard_handler_t, - browser: *mut interfaces::cef_browser_t, - event: *const interfaces::cef_key_event_t, - os_event: types::cef_event_handle_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_keyboard_handler_t = _cef_keyboard_handler_t; - - -// -// Implement this structure to handle events related to keyboard input. The -// functions of this structure will be called on the UI thread. -// -pub struct CefKeyboardHandler { - c_object: *mut cef_keyboard_handler_t, -} - -impl Clone for CefKeyboardHandler { - fn clone(&self) -> CefKeyboardHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefKeyboardHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefKeyboardHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefKeyboardHandler { - pub unsafe fn from_c_object(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler { - CefKeyboardHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefKeyboardHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_keyboard_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_keyboard_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // Called before a keyboard event is sent to the renderer. |event| contains - // information about the keyboard event. |os_event| is the operating system - // event message, if any. Return true (1) if the event was handled or false - // (0) otherwise. If the event will be handled in on_key_event() as a keyboard - // shortcut set |is_keyboard_shortcut| to true (1) and return false (0). - pub fn on_pre_key_event(&self, browser: interfaces::CefBrowser, - event: &interfaces::CefKeyEvent, os_event: types::cef_event_handle_t, - is_keyboard_shortcut: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_pre_key_event.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(event), - CefWrap::to_c(os_event), - CefWrap::to_c(is_keyboard_shortcut))) - } - } - - // - // Called after the renderer and JavaScript in the page has had a chance to - // handle the event. |event| contains information about the keyboard event. - // |os_event| is the operating system event message, if any. Return true (1) - // if the keyboard event was handled or false (0) otherwise. - // - pub fn on_key_event(&self, browser: interfaces::CefBrowser, - event: &interfaces::CefKeyEvent, - os_event: types::cef_event_handle_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_key_event.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(event), - CefWrap::to_c(os_event))) - } - } -} - -impl CefWrap<*mut cef_keyboard_handler_t> for CefKeyboardHandler { - fn to_c(rust_object: CefKeyboardHandler) -> *mut cef_keyboard_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler { - CefKeyboardHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_keyboard_handler_t> for Option<CefKeyboardHandler> { - fn to_c(rust_object: Option<CefKeyboardHandler>) -> *mut cef_keyboard_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_keyboard_handler_t) -> Option<CefKeyboardHandler> { - if c_object.is_null() { - None - } else { - Some(CefKeyboardHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_life_span_handler.rs b/ports/cef/interfaces/cef_life_span_handler.rs deleted file mode 100644 index 926bfd1ec39..00000000000 --- a/ports/cef/interfaces/cef_life_span_handler.rs +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to browser life span. The -// functions of this structure will be called on the UI thread unless otherwise -// indicated. -// -#[repr(C)] -pub struct _cef_life_span_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called on the IO thread before a new popup browser is created. The - // |browser| and |frame| values represent the source of the popup request. The - // |target_url| and |target_frame_name| values indicate where the popup - // browser should navigate and may be NULL if not specified with the request. - // The |target_disposition| value indicates where the user intended to open - // the popup (e.g. current tab, new tab, etc). The |user_gesture| value will - // be true (1) if the popup was opened via explicit user gesture (e.g. - // clicking a link) or false (0) if the popup opened automatically (e.g. via - // the DomContentLoaded event). The |popupFeatures| structure contains - // additional information about the requested popup window. To allow creation - // of the popup browser optionally modify |windowInfo|, |client|, |settings| - // and |no_javascript_access| and return false (0). To cancel creation of the - // popup browser return true (1). The |client| and |settings| values will - // default to the source browser's values. If the |no_javascript_access| value - // is set to false (0) the new browser will not be scriptable and may not be - // hosted in the same renderer process as the source browser. - pub on_before_popup: Option<extern "C" fn(this: *mut cef_life_span_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - target_url: *const types::cef_string_t, - target_frame_name: *const types::cef_string_t, - target_disposition: types::cef_window_open_disposition_t, - user_gesture: libc::c_int, - popupFeatures: *const interfaces::cef_popup_features_t, - windowInfo: *mut interfaces::cef_window_info_t, - client: *mut interfaces::cef_client_t, - settings: *mut interfaces::cef_browser_settings_t, - no_javascript_access: *mut libc::c_int) -> libc::c_int>, - - // - // Called after a new browser is created. - // - pub on_after_created: Option<extern "C" fn(this: *mut cef_life_span_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // Called when a modal window is about to display and the modal loop should - // begin running. Return false (0) to use the default modal loop - // implementation or true (1) to use a custom implementation. - // - pub run_modal: Option<extern "C" fn(this: *mut cef_life_span_handler_t, - browser: *mut interfaces::cef_browser_t) -> libc::c_int>, - - // - // Called when a browser has recieved a request to close. This may result - // directly from a call to cef_browser_host_t::close_browser() or indirectly - // if the browser is a top-level OS window created by CEF and the user - // attempts to close the window. This function will be called after the - // JavaScript 'onunload' event has been fired. It will not be called for - // browsers after the associated OS window has been destroyed (for those - // browsers it is no longer possible to cancel the close). - // - // If CEF created an OS window for the browser returning false (0) will send - // an OS close notification to the browser window's top-level owner (e.g. - // WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If - // no OS window exists (window rendering disabled) returning false (0) will - // cause the browser object to be destroyed immediately. Return true (1) if - // the browser is parented to another window and that other window needs to - // receive close notification via some non-standard technique. - // - // If an application provides its own top-level window it should handle OS - // close notifications by calling cef_browser_host_t::CloseBrowser(false (0)) - // instead of immediately closing (see the example below). This gives CEF an - // opportunity to process the 'onbeforeunload' event and optionally cancel the - // close before do_close() is called. - // - // The cef_life_span_handler_t::on_before_close() function will be called - // immediately before the browser object is destroyed. The application should - // only exit after on_before_close() has been called for all existing - // browsers. - // - // If the browser represents a modal window and a custom modal loop - // implementation was provided in cef_life_span_handler_t::run_modal() this - // callback should be used to restore the opener window to a usable state. - // - // By way of example consider what should happen during window close when the - // browser is parented to an application-provided top-level OS window. 1. - // User clicks the window close button which sends an OS close - // notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and - // "delete_event" on Linux). - // 2. Application's top-level window receives the close notification and: - // A. Calls CefBrowserHost::CloseBrowser(false). - // B. Cancels the window close. - // 3. JavaScript 'onbeforeunload' handler executes and shows the close - // confirmation dialog (which can be overridden via - // CefJSDialogHandler::OnBeforeUnloadDialog()). - // 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6. - // Application's do_close() handler is called. Application will: - // A. Set a flag to indicate that the next close attempt will be allowed. - // B. Return false. - // 7. CEF sends an OS close notification. 8. Application's top-level window - // receives the OS close notification and - // allows the window to close based on the flag from #6B. - // 9. Browser OS window is destroyed. 10. Application's - // cef_life_span_handler_t::on_before_close() handler is called and - // the browser object is destroyed. - // 11. Application exits by calling cef_quit_message_loop() if no other - // browsers - // exist. - // - pub do_close: Option<extern "C" fn(this: *mut cef_life_span_handler_t, - browser: *mut interfaces::cef_browser_t) -> libc::c_int>, - - // - // Called just before a browser is destroyed. Release all references to the - // browser object and do not attempt to execute any functions on the browser - // object after this callback returns. If this is a modal window and a custom - // modal loop implementation was provided in run_modal() this callback should - // be used to exit the custom modal loop. See do_close() documentation for - // additional usage information. - // - pub on_before_close: Option<extern "C" fn(this: *mut cef_life_span_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_life_span_handler_t = _cef_life_span_handler_t; - - -// -// Implement this structure to handle events related to browser life span. The -// functions of this structure will be called on the UI thread unless otherwise -// indicated. -// -pub struct CefLifeSpanHandler { - c_object: *mut cef_life_span_handler_t, -} - -impl Clone for CefLifeSpanHandler { - fn clone(&self) -> CefLifeSpanHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefLifeSpanHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefLifeSpanHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefLifeSpanHandler { - pub unsafe fn from_c_object(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler { - CefLifeSpanHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefLifeSpanHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_life_span_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_life_span_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called on the IO thread before a new popup browser is created. The - // |browser| and |frame| values represent the source of the popup request. The - // |target_url| and |target_frame_name| values indicate where the popup - // browser should navigate and may be NULL if not specified with the request. - // The |target_disposition| value indicates where the user intended to open - // the popup (e.g. current tab, new tab, etc). The |user_gesture| value will - // be true (1) if the popup was opened via explicit user gesture (e.g. - // clicking a link) or false (0) if the popup opened automatically (e.g. via - // the DomContentLoaded event). The |popupFeatures| structure contains - // additional information about the requested popup window. To allow creation - // of the popup browser optionally modify |windowInfo|, |client|, |settings| - // and |no_javascript_access| and return false (0). To cancel creation of the - // popup browser return true (1). The |client| and |settings| values will - // default to the source browser's values. If the |no_javascript_access| value - // is set to false (0) the new browser will not be scriptable and may not be - // hosted in the same renderer process as the source browser. - pub fn on_before_popup(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, target_url: &[u16], - target_frame_name: &[u16], - target_disposition: types::cef_window_open_disposition_t, - user_gesture: libc::c_int, popupFeatures: &interfaces::CefPopupFeatures, - windowInfo: &mut interfaces::CefWindowInfo, - client: interfaces::CefClient, - settings: &mut interfaces::CefBrowserSettings, - no_javascript_access: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_popup.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(target_url), - CefWrap::to_c(target_frame_name), - CefWrap::to_c(target_disposition), - CefWrap::to_c(user_gesture), - CefWrap::to_c(popupFeatures), - CefWrap::to_c(windowInfo), - CefWrap::to_c(client), - CefWrap::to_c(settings), - CefWrap::to_c(no_javascript_access))) - } - } - - // - // Called after a new browser is created. - // - pub fn on_after_created(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_after_created.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called when a modal window is about to display and the modal loop should - // begin running. Return false (0) to use the default modal loop - // implementation or true (1) to use a custom implementation. - // - pub fn run_modal(&self, browser: interfaces::CefBrowser) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).run_modal.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called when a browser has recieved a request to close. This may result - // directly from a call to cef_browser_host_t::close_browser() or indirectly - // if the browser is a top-level OS window created by CEF and the user - // attempts to close the window. This function will be called after the - // JavaScript 'onunload' event has been fired. It will not be called for - // browsers after the associated OS window has been destroyed (for those - // browsers it is no longer possible to cancel the close). - // - // If CEF created an OS window for the browser returning false (0) will send - // an OS close notification to the browser window's top-level owner (e.g. - // WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If - // no OS window exists (window rendering disabled) returning false (0) will - // cause the browser object to be destroyed immediately. Return true (1) if - // the browser is parented to another window and that other window needs to - // receive close notification via some non-standard technique. - // - // If an application provides its own top-level window it should handle OS - // close notifications by calling cef_browser_host_t::CloseBrowser(false (0)) - // instead of immediately closing (see the example below). This gives CEF an - // opportunity to process the 'onbeforeunload' event and optionally cancel the - // close before do_close() is called. - // - // The cef_life_span_handler_t::on_before_close() function will be called - // immediately before the browser object is destroyed. The application should - // only exit after on_before_close() has been called for all existing - // browsers. - // - // If the browser represents a modal window and a custom modal loop - // implementation was provided in cef_life_span_handler_t::run_modal() this - // callback should be used to restore the opener window to a usable state. - // - // By way of example consider what should happen during window close when the - // browser is parented to an application-provided top-level OS window. 1. - // User clicks the window close button which sends an OS close - // notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and - // "delete_event" on Linux). - // 2. Application's top-level window receives the close notification and: - // A. Calls CefBrowserHost::CloseBrowser(false). - // B. Cancels the window close. - // 3. JavaScript 'onbeforeunload' handler executes and shows the close - // confirmation dialog (which can be overridden via - // CefJSDialogHandler::OnBeforeUnloadDialog()). - // 4. User approves the close. 5. JavaScript 'onunload' handler executes. 6. - // Application's do_close() handler is called. Application will: - // A. Set a flag to indicate that the next close attempt will be allowed. - // B. Return false. - // 7. CEF sends an OS close notification. 8. Application's top-level window - // receives the OS close notification and - // allows the window to close based on the flag from #6B. - // 9. Browser OS window is destroyed. 10. Application's - // cef_life_span_handler_t::on_before_close() handler is called and - // the browser object is destroyed. - // 11. Application exits by calling cef_quit_message_loop() if no other - // browsers - // exist. - // - pub fn do_close(&self, browser: interfaces::CefBrowser) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).do_close.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called just before a browser is destroyed. Release all references to the - // browser object and do not attempt to execute any functions on the browser - // object after this callback returns. If this is a modal window and a custom - // modal loop implementation was provided in run_modal() this callback should - // be used to exit the custom modal loop. See do_close() documentation for - // additional usage information. - // - pub fn on_before_close(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_close.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } -} - -impl CefWrap<*mut cef_life_span_handler_t> for CefLifeSpanHandler { - fn to_c(rust_object: CefLifeSpanHandler) -> *mut cef_life_span_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler { - CefLifeSpanHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_life_span_handler_t> for Option<CefLifeSpanHandler> { - fn to_c(rust_object: Option<CefLifeSpanHandler>) -> *mut cef_life_span_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_life_span_handler_t) -> Option<CefLifeSpanHandler> { - if c_object.is_null() { - None - } else { - Some(CefLifeSpanHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_load_handler.rs b/ports/cef/interfaces/cef_load_handler.rs deleted file mode 100644 index 2eca524acc6..00000000000 --- a/ports/cef/interfaces/cef_load_handler.rs +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events related to browser load status. The -// functions of this structure will be called on the browser process UI thread -// or render process main thread (TID_RENDERER). -// -#[repr(C)] -pub struct _cef_load_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called when the loading state has changed. This callback will be executed - // twice -- once when loading is initiated either programmatically or by user - // action, and once when loading is terminated due to completion, cancellation - // of failure. - // - pub on_loading_state_change: Option<extern "C" fn( - this: *mut cef_load_handler_t, browser: *mut interfaces::cef_browser_t, - isLoading: libc::c_int, canGoBack: libc::c_int, - canGoForward: libc::c_int) -> ()>, - - // - // Called when the browser begins loading a frame. The |frame| value will - // never be NULL -- call the is_main() function to check if this frame is the - // main frame. Multiple frames may be loading at the same time. Sub-frames may - // start or continue loading after the main frame load has ended. This - // function may not be called for a particular frame if the load request for - // that frame fails. For notification of overall browser load status use - // OnLoadingStateChange instead. - // - pub on_load_start: Option<extern "C" fn(this: *mut cef_load_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t) -> ()>, - - // - // Called when the browser is done loading a frame. The |frame| value will - // never be NULL -- call the is_main() function to check if this frame is the - // main frame. Multiple frames may be loading at the same time. Sub-frames may - // start or continue loading after the main frame load has ended. This - // function will always be called for all frames irrespective of whether the - // request completes successfully. - // - pub on_load_end: Option<extern "C" fn(this: *mut cef_load_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, httpStatusCode: libc::c_int) -> ()>, - - // - // Called when the resource load for a navigation fails or is canceled. - // |errorCode| is the error code number, |errorText| is the error text and - // |failedUrl| is the URL that failed to load. See net\base\net_error_list.h - // for complete descriptions of the error codes. - // - pub on_load_error: Option<extern "C" fn(this: *mut cef_load_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, errorCode: types::cef_errorcode_t, - errorText: *const types::cef_string_t, - failedUrl: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_load_handler_t = _cef_load_handler_t; - - -// -// Implement this structure to handle events related to browser load status. The -// functions of this structure will be called on the browser process UI thread -// or render process main thread (TID_RENDERER). -// -pub struct CefLoadHandler { - c_object: *mut cef_load_handler_t, -} - -impl Clone for CefLoadHandler { - fn clone(&self) -> CefLoadHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefLoadHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefLoadHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefLoadHandler { - pub unsafe fn from_c_object(c_object: *mut cef_load_handler_t) -> CefLoadHandler { - CefLoadHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_load_handler_t) -> CefLoadHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefLoadHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_load_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_load_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called when the loading state has changed. This callback will be executed - // twice -- once when loading is initiated either programmatically or by user - // action, and once when loading is terminated due to completion, cancellation - // of failure. - // - pub fn on_loading_state_change(&self, browser: interfaces::CefBrowser, - isLoading: libc::c_int, canGoBack: libc::c_int, - canGoForward: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_loading_state_change.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(isLoading), - CefWrap::to_c(canGoBack), - CefWrap::to_c(canGoForward))) - } - } - - // - // Called when the browser begins loading a frame. The |frame| value will - // never be NULL -- call the is_main() function to check if this frame is the - // main frame. Multiple frames may be loading at the same time. Sub-frames may - // start or continue loading after the main frame load has ended. This - // function may not be called for a particular frame if the load request for - // that frame fails. For notification of overall browser load status use - // OnLoadingStateChange instead. - // - pub fn on_load_start(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_load_start.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame))) - } - } - - // - // Called when the browser is done loading a frame. The |frame| value will - // never be NULL -- call the is_main() function to check if this frame is the - // main frame. Multiple frames may be loading at the same time. Sub-frames may - // start or continue loading after the main frame load has ended. This - // function will always be called for all frames irrespective of whether the - // request completes successfully. - // - pub fn on_load_end(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, httpStatusCode: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_load_end.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(httpStatusCode))) - } - } - - // - // Called when the resource load for a navigation fails or is canceled. - // |errorCode| is the error code number, |errorText| is the error text and - // |failedUrl| is the URL that failed to load. See net\base\net_error_list.h - // for complete descriptions of the error codes. - // - pub fn on_load_error(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, errorCode: types::cef_errorcode_t, - errorText: &[u16], failedUrl: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_load_error.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(errorCode), - CefWrap::to_c(errorText), - CefWrap::to_c(failedUrl))) - } - } -} - -impl CefWrap<*mut cef_load_handler_t> for CefLoadHandler { - fn to_c(rust_object: CefLoadHandler) -> *mut cef_load_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> CefLoadHandler { - CefLoadHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_load_handler_t> for Option<CefLoadHandler> { - fn to_c(rust_object: Option<CefLoadHandler>) -> *mut cef_load_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> Option<CefLoadHandler> { - if c_object.is_null() { - None - } else { - Some(CefLoadHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_menu_model.rs b/ports/cef/interfaces/cef_menu_model.rs deleted file mode 100644 index c8cdf7c4c89..00000000000 --- a/ports/cef/interfaces/cef_menu_model.rs +++ /dev/null @@ -1,1344 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Supports creation and modification of menus. See cef_menu_id_t for the -// command ids that have default implementations. All user-defined command ids -// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The functions of -// this structure can only be accessed on the browser process the UI thread. -// -#[repr(C)] -pub struct _cef_menu_model_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Clears the menu. Returns true (1) on success. - // - pub clear: Option<extern "C" fn(this: *mut cef_menu_model_t) -> libc::c_int>, - - // - // Returns the number of items in this menu. - // - pub get_count: Option<extern "C" fn( - this: *mut cef_menu_model_t) -> libc::c_int>, - - // - // Add a separator to the menu. Returns true (1) on success. - // - pub add_separator: Option<extern "C" fn( - this: *mut cef_menu_model_t) -> libc::c_int>, - - // - // Add an item to the menu. Returns true (1) on success. - // - pub add_item: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, - label: *const types::cef_string_t) -> libc::c_int>, - - // - // Add a check item to the menu. Returns true (1) on success. - // - pub add_check_item: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, - label: *const types::cef_string_t) -> libc::c_int>, - - // - // Add a radio item to the menu. Only a single item with the specified - // |group_id| can be checked at a time. Returns true (1) on success. - // - pub add_radio_item: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, label: *const types::cef_string_t, - group_id: libc::c_int) -> libc::c_int>, - - // - // Add a sub-menu to the menu. The new sub-menu is returned. - // - pub add_sub_menu: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, - label: *const types::cef_string_t) -> *mut interfaces::cef_menu_model_t>, - - // - // Insert a separator in the menu at the specified |index|. Returns true (1) - // on success. - // - pub insert_separator_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Insert an item in the menu at the specified |index|. Returns true (1) on - // success. - // - pub insert_item_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, command_id: libc::c_int, - label: *const types::cef_string_t) -> libc::c_int>, - - // - // Insert a check item in the menu at the specified |index|. Returns true (1) - // on success. - // - pub insert_check_item_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, command_id: libc::c_int, - label: *const types::cef_string_t) -> libc::c_int>, - - // - // Insert a radio item in the menu at the specified |index|. Only a single - // item with the specified |group_id| can be checked at a time. Returns true - // (1) on success. - // - pub insert_radio_item_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, command_id: libc::c_int, - label: *const types::cef_string_t, - group_id: libc::c_int) -> libc::c_int>, - - // - // Insert a sub-menu in the menu at the specified |index|. The new sub-menu is - // returned. - // - pub insert_sub_menu_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, command_id: libc::c_int, - label: *const types::cef_string_t) -> *mut interfaces::cef_menu_model_t>, - - // - // Removes the item with the specified |command_id|. Returns true (1) on - // success. - // - pub remove: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Removes the item at the specified |index|. Returns true (1) on success. - // - pub remove_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Returns the index associated with the specified |command_id| or -1 if not - // found due to the command id not existing in the menu. - // - pub get_index_of: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns the command id at the specified |index| or -1 if not found due to - // invalid range or the index being a separator. - // - pub get_command_id_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Sets the command id at the specified |index|. Returns true (1) on success. - // - pub set_command_id_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, command_id: libc::c_int) -> libc::c_int>, - - // - // Returns the label for the specified |command_id| or NULL if not found. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_label: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> types::cef_string_userfree_t>, - - // - // Returns the label at the specified |index| or NULL if not found due to - // invalid range or the index being a separator. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_label_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> types::cef_string_userfree_t>, - - // - // Sets the label for the specified |command_id|. Returns true (1) on success. - // - pub set_label: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, - label: *const types::cef_string_t) -> libc::c_int>, - - // - // Set the label at the specified |index|. Returns true (1) on success. - // - pub set_label_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, label: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the item type for the specified |command_id|. - // - pub get_type: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> types::cef_menu_item_type_t>, - - // - // Returns the item type at the specified |index|. - // - pub get_type_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> types::cef_menu_item_type_t>, - - // - // Returns the group id for the specified |command_id| or -1 if invalid. - // - pub get_group_id: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns the group id at the specified |index| or -1 if invalid. - // - pub get_group_id_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Sets the group id for the specified |command_id|. Returns true (1) on - // success. - // - pub set_group_id: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, group_id: libc::c_int) -> libc::c_int>, - - // - // Sets the group id at the specified |index|. Returns true (1) on success. - // - pub set_group_id_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, group_id: libc::c_int) -> libc::c_int>, - - // - // Returns the submenu for the specified |command_id| or NULL if invalid. - // - pub get_sub_menu: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> *mut interfaces::cef_menu_model_t>, - - // - // Returns the submenu at the specified |index| or NULL if invalid. - // - pub get_sub_menu_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> *mut interfaces::cef_menu_model_t>, - - // - // Returns true (1) if the specified |command_id| is visible. - // - pub is_visible: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |index| is visible. - // - pub is_visible_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Change the visibility of the specified |command_id|. Returns true (1) on - // success. - // - pub set_visible: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, visible: libc::c_int) -> libc::c_int>, - - // - // Change the visibility at the specified |index|. Returns true (1) on - // success. - // - pub set_visible_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, visible: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |command_id| is enabled. - // - pub is_enabled: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |index| is enabled. - // - pub is_enabled_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Change the enabled status of the specified |command_id|. Returns true (1) - // on success. - // - pub set_enabled: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, enabled: libc::c_int) -> libc::c_int>, - - // - // Change the enabled status at the specified |index|. Returns true (1) on - // success. - // - pub set_enabled_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, enabled: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |command_id| is checked. Only applies to - // check and radio items. - // - pub is_checked: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |index| is checked. Only applies to check - // and radio items. - // - pub is_checked_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Check the specified |command_id|. Only applies to check and radio items. - // Returns true (1) on success. - // - pub set_checked: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, checked: libc::c_int) -> libc::c_int>, - - // - // Check the specified |index|. Only applies to check and radio items. Returns - // true (1) on success. - // - pub set_checked_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, checked: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |command_id| has a keyboard accelerator - // assigned. - // - pub has_accelerator: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the specified |index| has a keyboard accelerator - // assigned. - // - pub has_accelerator_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Set the keyboard accelerator for the specified |command_id|. |key_code| can - // be any virtual key or character value. Returns true (1) on success. - // - pub set_accelerator: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, key_code: libc::c_int, - shift_pressed: libc::c_int, ctrl_pressed: libc::c_int, - alt_pressed: libc::c_int) -> libc::c_int>, - - // - // Set the keyboard accelerator at the specified |index|. |key_code| can be - // any virtual key or character value. Returns true (1) on success. - // - pub set_accelerator_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, key_code: libc::c_int, shift_pressed: libc::c_int, - ctrl_pressed: libc::c_int, alt_pressed: libc::c_int) -> libc::c_int>, - - // - // Remove the keyboard accelerator for the specified |command_id|. Returns - // true (1) on success. - // - pub remove_accelerator: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int) -> libc::c_int>, - - // - // Remove the keyboard accelerator at the specified |index|. Returns true (1) - // on success. - // - pub remove_accelerator_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int) -> libc::c_int>, - - // - // Retrieves the keyboard accelerator for the specified |command_id|. Returns - // true (1) on success. - // - pub get_accelerator: Option<extern "C" fn(this: *mut cef_menu_model_t, - command_id: libc::c_int, key_code: *mut libc::c_int, - shift_pressed: *mut libc::c_int, ctrl_pressed: *mut libc::c_int, - alt_pressed: *mut libc::c_int) -> libc::c_int>, - - // - // Retrieves the keyboard accelerator for the specified |index|. Returns true - // (1) on success. - // - pub get_accelerator_at: Option<extern "C" fn(this: *mut cef_menu_model_t, - index: libc::c_int, key_code: *mut libc::c_int, - shift_pressed: *mut libc::c_int, ctrl_pressed: *mut libc::c_int, - alt_pressed: *mut libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_menu_model_t = _cef_menu_model_t; - - -// -// Supports creation and modification of menus. See cef_menu_id_t for the -// command ids that have default implementations. All user-defined command ids -// should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The functions of -// this structure can only be accessed on the browser process the UI thread. -// -pub struct CefMenuModel { - c_object: *mut cef_menu_model_t, -} - -impl Clone for CefMenuModel { - fn clone(&self) -> CefMenuModel{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefMenuModel { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefMenuModel { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefMenuModel { - pub unsafe fn from_c_object(c_object: *mut cef_menu_model_t) -> CefMenuModel { - CefMenuModel { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_menu_model_t) -> CefMenuModel { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefMenuModel { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_menu_model_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_menu_model_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Clears the menu. Returns true (1) on success. - // - pub fn clear(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clear.unwrap())( - self.c_object)) - } - } - - // - // Returns the number of items in this menu. - // - pub fn get_count(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_count.unwrap())( - self.c_object)) - } - } - - // - // Add a separator to the menu. Returns true (1) on success. - // - pub fn add_separator(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_separator.unwrap())( - self.c_object)) - } - } - - // - // Add an item to the menu. Returns true (1) on success. - // - pub fn add_item(&self, command_id: libc::c_int, - label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_item.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Add a check item to the menu. Returns true (1) on success. - // - pub fn add_check_item(&self, command_id: libc::c_int, - label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_check_item.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Add a radio item to the menu. Only a single item with the specified - // |group_id| can be checked at a time. Returns true (1) on success. - // - pub fn add_radio_item(&self, command_id: libc::c_int, label: &[u16], - group_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_radio_item.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(label), - CefWrap::to_c(group_id))) - } - } - - // - // Add a sub-menu to the menu. The new sub-menu is returned. - // - pub fn add_sub_menu(&self, command_id: libc::c_int, - label: &[u16]) -> interfaces::CefMenuModel { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_sub_menu.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Insert a separator in the menu at the specified |index|. Returns true (1) - // on success. - // - pub fn insert_separator_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).insert_separator_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Insert an item in the menu at the specified |index|. Returns true (1) on - // success. - // - pub fn insert_item_at(&self, index: libc::c_int, command_id: libc::c_int, - label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).insert_item_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Insert a check item in the menu at the specified |index|. Returns true (1) - // on success. - // - pub fn insert_check_item_at(&self, index: libc::c_int, - command_id: libc::c_int, label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).insert_check_item_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Insert a radio item in the menu at the specified |index|. Only a single - // item with the specified |group_id| can be checked at a time. Returns true - // (1) on success. - // - pub fn insert_radio_item_at(&self, index: libc::c_int, - command_id: libc::c_int, label: &[u16], - group_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).insert_radio_item_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(command_id), - CefWrap::to_c(label), - CefWrap::to_c(group_id))) - } - } - - // - // Insert a sub-menu in the menu at the specified |index|. The new sub-menu is - // returned. - // - pub fn insert_sub_menu_at(&self, index: libc::c_int, command_id: libc::c_int, - label: &[u16]) -> interfaces::CefMenuModel { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).insert_sub_menu_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Removes the item with the specified |command_id|. Returns true (1) on - // success. - // - pub fn remove(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Removes the item at the specified |index|. Returns true (1) on success. - // - pub fn remove_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the index associated with the specified |command_id| or -1 if not - // found due to the command id not existing in the menu. - // - pub fn get_index_of(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_index_of.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns the command id at the specified |index| or -1 if not found due to - // invalid range or the index being a separator. - // - pub fn get_command_id_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_command_id_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Sets the command id at the specified |index|. Returns true (1) on success. - // - pub fn set_command_id_at(&self, index: libc::c_int, - command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_command_id_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(command_id))) - } - } - - // - // Returns the label for the specified |command_id| or NULL if not found. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_label(&self, command_id: libc::c_int) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_label.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns the label at the specified |index| or NULL if not found due to - // invalid range or the index being a separator. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_label_at(&self, index: libc::c_int) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_label_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Sets the label for the specified |command_id|. Returns true (1) on success. - // - pub fn set_label(&self, command_id: libc::c_int, - label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_label.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(label))) - } - } - - // - // Set the label at the specified |index|. Returns true (1) on success. - // - pub fn set_label_at(&self, index: libc::c_int, label: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_label_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(label))) - } - } - - // - // Returns the item type for the specified |command_id|. - // - pub fn get_type(&self, - command_id: libc::c_int) -> types::cef_menu_item_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns the item type at the specified |index|. - // - pub fn get_type_at(&self, index: libc::c_int) -> types::cef_menu_item_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the group id for the specified |command_id| or -1 if invalid. - // - pub fn get_group_id(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_group_id.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns the group id at the specified |index| or -1 if invalid. - // - pub fn get_group_id_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_group_id_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Sets the group id for the specified |command_id|. Returns true (1) on - // success. - // - pub fn set_group_id(&self, command_id: libc::c_int, - group_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_group_id.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(group_id))) - } - } - - // - // Sets the group id at the specified |index|. Returns true (1) on success. - // - pub fn set_group_id_at(&self, index: libc::c_int, - group_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_group_id_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(group_id))) - } - } - - // - // Returns the submenu for the specified |command_id| or NULL if invalid. - // - pub fn get_sub_menu(&self, - command_id: libc::c_int) -> interfaces::CefMenuModel { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_sub_menu.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns the submenu at the specified |index| or NULL if invalid. - // - pub fn get_sub_menu_at(&self, - index: libc::c_int) -> interfaces::CefMenuModel { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_sub_menu_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns true (1) if the specified |command_id| is visible. - // - pub fn is_visible(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_visible.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns true (1) if the specified |index| is visible. - // - pub fn is_visible_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_visible_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Change the visibility of the specified |command_id|. Returns true (1) on - // success. - // - pub fn set_visible(&self, command_id: libc::c_int, - visible: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_visible.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(visible))) - } - } - - // - // Change the visibility at the specified |index|. Returns true (1) on - // success. - // - pub fn set_visible_at(&self, index: libc::c_int, - visible: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_visible_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(visible))) - } - } - - // - // Returns true (1) if the specified |command_id| is enabled. - // - pub fn is_enabled(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_enabled.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns true (1) if the specified |index| is enabled. - // - pub fn is_enabled_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_enabled_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Change the enabled status of the specified |command_id|. Returns true (1) - // on success. - // - pub fn set_enabled(&self, command_id: libc::c_int, - enabled: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_enabled.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(enabled))) - } - } - - // - // Change the enabled status at the specified |index|. Returns true (1) on - // success. - // - pub fn set_enabled_at(&self, index: libc::c_int, - enabled: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_enabled_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(enabled))) - } - } - - // - // Returns true (1) if the specified |command_id| is checked. Only applies to - // check and radio items. - // - pub fn is_checked(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_checked.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns true (1) if the specified |index| is checked. Only applies to check - // and radio items. - // - pub fn is_checked_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_checked_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Check the specified |command_id|. Only applies to check and radio items. - // Returns true (1) on success. - // - pub fn set_checked(&self, command_id: libc::c_int, - checked: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_checked.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(checked))) - } - } - - // - // Check the specified |index|. Only applies to check and radio items. Returns - // true (1) on success. - // - pub fn set_checked_at(&self, index: libc::c_int, - checked: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_checked_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(checked))) - } - } - - // - // Returns true (1) if the specified |command_id| has a keyboard accelerator - // assigned. - // - pub fn has_accelerator(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_accelerator.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Returns true (1) if the specified |index| has a keyboard accelerator - // assigned. - // - pub fn has_accelerator_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_accelerator_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Set the keyboard accelerator for the specified |command_id|. |key_code| can - // be any virtual key or character value. Returns true (1) on success. - // - pub fn set_accelerator(&self, command_id: libc::c_int, key_code: libc::c_int, - shift_pressed: libc::c_int, ctrl_pressed: libc::c_int, - alt_pressed: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_accelerator.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(key_code), - CefWrap::to_c(shift_pressed), - CefWrap::to_c(ctrl_pressed), - CefWrap::to_c(alt_pressed))) - } - } - - // - // Set the keyboard accelerator at the specified |index|. |key_code| can be - // any virtual key or character value. Returns true (1) on success. - // - pub fn set_accelerator_at(&self, index: libc::c_int, key_code: libc::c_int, - shift_pressed: libc::c_int, ctrl_pressed: libc::c_int, - alt_pressed: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_accelerator_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(key_code), - CefWrap::to_c(shift_pressed), - CefWrap::to_c(ctrl_pressed), - CefWrap::to_c(alt_pressed))) - } - } - - // - // Remove the keyboard accelerator for the specified |command_id|. Returns - // true (1) on success. - // - pub fn remove_accelerator(&self, command_id: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove_accelerator.unwrap())( - self.c_object, - CefWrap::to_c(command_id))) - } - } - - // - // Remove the keyboard accelerator at the specified |index|. Returns true (1) - // on success. - // - pub fn remove_accelerator_at(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove_accelerator_at.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Retrieves the keyboard accelerator for the specified |command_id|. Returns - // true (1) on success. - // - pub fn get_accelerator(&self, command_id: libc::c_int, - key_code: &mut libc::c_int, shift_pressed: &mut libc::c_int, - ctrl_pressed: &mut libc::c_int, - alt_pressed: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_accelerator.unwrap())( - self.c_object, - CefWrap::to_c(command_id), - CefWrap::to_c(key_code), - CefWrap::to_c(shift_pressed), - CefWrap::to_c(ctrl_pressed), - CefWrap::to_c(alt_pressed))) - } - } - - // - // Retrieves the keyboard accelerator for the specified |index|. Returns true - // (1) on success. - // - pub fn get_accelerator_at(&self, index: libc::c_int, - key_code: &mut libc::c_int, shift_pressed: &mut libc::c_int, - ctrl_pressed: &mut libc::c_int, - alt_pressed: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_accelerator_at.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(key_code), - CefWrap::to_c(shift_pressed), - CefWrap::to_c(ctrl_pressed), - CefWrap::to_c(alt_pressed))) - } - } -} - -impl CefWrap<*mut cef_menu_model_t> for CefMenuModel { - fn to_c(rust_object: CefMenuModel) -> *mut cef_menu_model_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_menu_model_t) -> CefMenuModel { - CefMenuModel::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_menu_model_t> for Option<CefMenuModel> { - fn to_c(rust_object: Option<CefMenuModel>) -> *mut cef_menu_model_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_menu_model_t) -> Option<CefMenuModel> { - if c_object.is_null() { - None - } else { - Some(CefMenuModel::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_navigation_entry.rs b/ports/cef/interfaces/cef_navigation_entry.rs deleted file mode 100644 index 3deaa7fc6f1..00000000000 --- a/ports/cef/interfaces/cef_navigation_entry.rs +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent an entry in navigation history. -// -#[repr(C)] -pub struct _cef_navigation_entry_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> libc::c_int>, - - // - // Returns the actual URL of the page. For some pages this may be data: URL or - // similar. Use get_display_url() to return a display-friendly version. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_url: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_string_userfree_t>, - - // - // Returns a display-friendly version of the URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_display_url: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_string_userfree_t>, - - // - // Returns the original URL that was entered by the user before any redirects. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_original_url: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_string_userfree_t>, - - // - // Returns the title set by the page. This value may be NULL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_title: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_string_userfree_t>, - - // - // Returns the transition type which indicates what the user did to move to - // this page from the previous page. - // - pub get_transition_type: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_transition_type_t>, - - // - // Returns true (1) if this navigation includes post data. - // - pub has_post_data: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> libc::c_int>, - - // - // Returns the time for the last known successful navigation completion. A - // navigation may be completed more than once if the page is reloaded. May be - // 0 if the navigation has not yet completed. - // - pub get_completion_time: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> types::cef_time_t>, - - // - // Returns the HTTP status code for the last known successful navigation - // response. May be 0 if the response has not yet been received or if the - // navigation has not yet completed. - // - pub get_http_status_code: Option<extern "C" fn( - this: *mut cef_navigation_entry_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_navigation_entry_t = _cef_navigation_entry_t; - - -// -// Structure used to represent an entry in navigation history. -// -pub struct CefNavigationEntry { - c_object: *mut cef_navigation_entry_t, -} - -impl Clone for CefNavigationEntry { - fn clone(&self) -> CefNavigationEntry{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefNavigationEntry { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefNavigationEntry { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefNavigationEntry { - pub unsafe fn from_c_object(c_object: *mut cef_navigation_entry_t) -> CefNavigationEntry { - CefNavigationEntry { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_navigation_entry_t) -> CefNavigationEntry { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefNavigationEntry { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_navigation_entry_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_navigation_entry_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns the actual URL of the page. For some pages this may be data: URL or - // similar. Use get_display_url() to return a display-friendly version. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_url.unwrap())( - self.c_object)) - } - } - - // - // Returns a display-friendly version of the URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_display_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_display_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the original URL that was entered by the user before any redirects. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_original_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_original_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the title set by the page. This value may be NULL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_title(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_title.unwrap())( - self.c_object)) - } - } - - // - // Returns the transition type which indicates what the user did to move to - // this page from the previous page. - // - pub fn get_transition_type(&self) -> types::cef_transition_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_transition_type.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this navigation includes post data. - // - pub fn has_post_data(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_post_data.unwrap())( - self.c_object)) - } - } - - // - // Returns the time for the last known successful navigation completion. A - // navigation may be completed more than once if the page is reloaded. May be - // 0 if the navigation has not yet completed. - // - pub fn get_completion_time(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_completion_time.unwrap())( - self.c_object)) - } - } - - // - // Returns the HTTP status code for the last known successful navigation - // response. May be 0 if the response has not yet been received or if the - // navigation has not yet completed. - // - pub fn get_http_status_code(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_http_status_code.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_navigation_entry_t> for CefNavigationEntry { - fn to_c(rust_object: CefNavigationEntry) -> *mut cef_navigation_entry_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_navigation_entry_t) -> CefNavigationEntry { - CefNavigationEntry::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_navigation_entry_t> for Option<CefNavigationEntry> { - fn to_c(rust_object: Option<CefNavigationEntry>) -> *mut cef_navigation_entry_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_navigation_entry_t) -> Option<CefNavigationEntry> { - if c_object.is_null() { - None - } else { - Some(CefNavigationEntry::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_origin_whitelist.rs b/ports/cef/interfaces/cef_origin_whitelist.rs deleted file mode 100644 index c396bf66e02..00000000000 --- a/ports/cef/interfaces/cef_origin_whitelist.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; diff --git a/ports/cef/interfaces/cef_parser.rs b/ports/cef/interfaces/cef_parser.rs deleted file mode 100644 index c396bf66e02..00000000000 --- a/ports/cef/interfaces/cef_parser.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; diff --git a/ports/cef/interfaces/cef_path_util.rs b/ports/cef/interfaces/cef_path_util.rs deleted file mode 100644 index c396bf66e02..00000000000 --- a/ports/cef/interfaces/cef_path_util.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; diff --git a/ports/cef/interfaces/cef_print_handler.rs b/ports/cef/interfaces/cef_print_handler.rs deleted file mode 100644 index 020fddbd025..00000000000 --- a/ports/cef/interfaces/cef_print_handler.rs +++ /dev/null @@ -1,587 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure for asynchronous continuation of print dialog requests. -// -#[repr(C)] -pub struct _cef_print_dialog_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue printing with the specified |settings|. - // - pub cont: Option<extern "C" fn(this: *mut cef_print_dialog_callback_t, - settings: *mut interfaces::cef_print_settings_t) -> ()>, - - // - // Cancel the printing. - // - pub cancel: Option<extern "C" fn(this: *mut cef_print_dialog_callback_t) -> ( - )>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_print_dialog_callback_t = _cef_print_dialog_callback_t; - - -// -// Callback structure for asynchronous continuation of print dialog requests. -// -pub struct CefPrintDialogCallback { - c_object: *mut cef_print_dialog_callback_t, -} - -impl Clone for CefPrintDialogCallback { - fn clone(&self) -> CefPrintDialogCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPrintDialogCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPrintDialogCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPrintDialogCallback { - pub unsafe fn from_c_object(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback { - CefPrintDialogCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPrintDialogCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_print_dialog_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_print_dialog_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue printing with the specified |settings|. - // - pub fn cont(&self, settings: interfaces::CefPrintSettings) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(settings))) - } - } - - // - // Cancel the printing. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_print_dialog_callback_t> for CefPrintDialogCallback { - fn to_c(rust_object: CefPrintDialogCallback) -> *mut cef_print_dialog_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback { - CefPrintDialogCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_print_dialog_callback_t> for Option<CefPrintDialogCallback> { - fn to_c(rust_object: Option<CefPrintDialogCallback>) -> *mut cef_print_dialog_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_print_dialog_callback_t) -> Option<CefPrintDialogCallback> { - if c_object.is_null() { - None - } else { - Some(CefPrintDialogCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Callback structure for asynchronous continuation of print job requests. -// -#[repr(C)] -pub struct _cef_print_job_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Indicate completion of the print job. - // - pub cont: Option<extern "C" fn(this: *mut cef_print_job_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_print_job_callback_t = _cef_print_job_callback_t; - - -// -// Callback structure for asynchronous continuation of print job requests. -// -pub struct CefPrintJobCallback { - c_object: *mut cef_print_job_callback_t, -} - -impl Clone for CefPrintJobCallback { - fn clone(&self) -> CefPrintJobCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPrintJobCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPrintJobCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPrintJobCallback { - pub unsafe fn from_c_object(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback { - CefPrintJobCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPrintJobCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_print_job_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_print_job_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Indicate completion of the print job. - // - pub fn cont(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_print_job_callback_t> for CefPrintJobCallback { - fn to_c(rust_object: CefPrintJobCallback) -> *mut cef_print_job_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback { - CefPrintJobCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_print_job_callback_t> for Option<CefPrintJobCallback> { - fn to_c(rust_object: Option<CefPrintJobCallback>) -> *mut cef_print_job_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_print_job_callback_t) -> Option<CefPrintJobCallback> { - if c_object.is_null() { - None - } else { - Some(CefPrintJobCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Implement this structure to handle printing on Linux. The functions of this -// structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_print_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Synchronize |settings| with client state. If |get_defaults| is true (1) - // then populate |settings| with the default print settings. Do not keep a - // reference to |settings| outside of this callback. - // - pub on_print_settings: Option<extern "C" fn(this: *mut cef_print_handler_t, - settings: *mut interfaces::cef_print_settings_t, - get_defaults: libc::c_int) -> ()>, - - // - // Show the print dialog. Execute |callback| once the dialog is dismissed. - // Return true (1) if the dialog will be displayed or false (0) to cancel the - // printing immediately. - // - pub on_print_dialog: Option<extern "C" fn(this: *mut cef_print_handler_t, - has_selection: libc::c_int, - callback: *mut interfaces::cef_print_dialog_callback_t) -> libc::c_int>, - - // - // Send the print job to the printer. Execute |callback| once the job is - // completed. Return true (1) if the job will proceed or false (0) to cancel - // the job immediately. - // - pub on_print_job: Option<extern "C" fn(this: *mut cef_print_handler_t, - document_name: *const types::cef_string_t, - pdf_file_path: *const types::cef_string_t, - callback: *mut interfaces::cef_print_job_callback_t) -> libc::c_int>, - - // - // Reset client state related to printing. - // - pub on_print_reset: Option<extern "C" fn(this: *mut cef_print_handler_t) -> ( - )>, - - // - // Return the PDF paper size in device units. Used in combination with - // cef_browser_host_t::print_to_pdf(). - // - pub get_pdf_paper_size: Option<extern "C" fn(this: *mut cef_print_handler_t, - device_units_per_inch: libc::c_int) -> types::cef_size_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_print_handler_t = _cef_print_handler_t; - - -// -// Implement this structure to handle printing on Linux. The functions of this -// structure will be called on the browser process UI thread. -// -pub struct CefPrintHandler { - c_object: *mut cef_print_handler_t, -} - -impl Clone for CefPrintHandler { - fn clone(&self) -> CefPrintHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPrintHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPrintHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPrintHandler { - pub unsafe fn from_c_object(c_object: *mut cef_print_handler_t) -> CefPrintHandler { - CefPrintHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_print_handler_t) -> CefPrintHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPrintHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_print_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_print_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Synchronize |settings| with client state. If |get_defaults| is true (1) - // then populate |settings| with the default print settings. Do not keep a - // reference to |settings| outside of this callback. - // - pub fn on_print_settings(&self, settings: interfaces::CefPrintSettings, - get_defaults: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_print_settings.unwrap())( - self.c_object, - CefWrap::to_c(settings), - CefWrap::to_c(get_defaults))) - } - } - - // - // Show the print dialog. Execute |callback| once the dialog is dismissed. - // Return true (1) if the dialog will be displayed or false (0) to cancel the - // printing immediately. - // - pub fn on_print_dialog(&self, has_selection: libc::c_int, - callback: interfaces::CefPrintDialogCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_print_dialog.unwrap())( - self.c_object, - CefWrap::to_c(has_selection), - CefWrap::to_c(callback))) - } - } - - // - // Send the print job to the printer. Execute |callback| once the job is - // completed. Return true (1) if the job will proceed or false (0) to cancel - // the job immediately. - // - pub fn on_print_job(&self, document_name: &[u16], pdf_file_path: &[u16], - callback: interfaces::CefPrintJobCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_print_job.unwrap())( - self.c_object, - CefWrap::to_c(document_name), - CefWrap::to_c(pdf_file_path), - CefWrap::to_c(callback))) - } - } - - // - // Reset client state related to printing. - // - pub fn on_print_reset(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_print_reset.unwrap())( - self.c_object)) - } - } - - // - // Return the PDF paper size in device units. Used in combination with - // cef_browser_host_t::print_to_pdf(). - // - pub fn get_pdf_paper_size(&self, - device_units_per_inch: libc::c_int) -> types::cef_size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_pdf_paper_size.unwrap())( - self.c_object, - CefWrap::to_c(device_units_per_inch))) - } - } -} - -impl CefWrap<*mut cef_print_handler_t> for CefPrintHandler { - fn to_c(rust_object: CefPrintHandler) -> *mut cef_print_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_print_handler_t) -> CefPrintHandler { - CefPrintHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_print_handler_t> for Option<CefPrintHandler> { - fn to_c(rust_object: Option<CefPrintHandler>) -> *mut cef_print_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_print_handler_t) -> Option<CefPrintHandler> { - if c_object.is_null() { - None - } else { - Some(CefPrintHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_print_settings.rs b/ports/cef/interfaces/cef_print_settings.rs deleted file mode 100644 index 06bebf7dc34..00000000000 --- a/ports/cef/interfaces/cef_print_settings.rs +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure representing print settings. -// -#[repr(C)] -pub struct _cef_print_settings_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Returns a writable copy of this object. - // - pub copy: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> *mut interfaces::cef_print_settings_t>, - - // - // Set the page orientation. - // - pub set_orientation: Option<extern "C" fn(this: *mut cef_print_settings_t, - landscape: libc::c_int) -> ()>, - - // - // Returns true (1) if the orientation is landscape. - // - pub is_landscape: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Set the printer printable area in device units. Some platforms already - // provide flipped area. Set |landscape_needs_flip| to false (0) on those - // platforms to avoid double flipping. - // - pub set_printer_printable_area: Option<extern "C" fn( - this: *mut cef_print_settings_t, - physical_size_device_units: *const types::cef_size_t, - printable_area_device_units: *const types::cef_rect_t, - landscape_needs_flip: libc::c_int) -> ()>, - - // - // Set the device name. - // - pub set_device_name: Option<extern "C" fn(this: *mut cef_print_settings_t, - name: *const types::cef_string_t) -> ()>, - - // - // Get the device name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_device_name: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> types::cef_string_userfree_t>, - - // - // Set the DPI (dots per inch). - // - pub set_dpi: Option<extern "C" fn(this: *mut cef_print_settings_t, - dpi: libc::c_int) -> ()>, - - // - // Get the DPI (dots per inch). - // - pub get_dpi: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Set the page ranges. - // - pub set_page_ranges: Option<extern "C" fn(this: *mut cef_print_settings_t, - ranges_count: libc::size_t, ranges: *const types::cef_page_range_t) -> ( - )>, - - // - // Returns the number of page ranges that currently exist. - // - pub get_page_ranges_count: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::size_t>, - - // - // Retrieve the page ranges. - // - pub get_page_ranges: Option<extern "C" fn(this: *mut cef_print_settings_t, - ranges_count: *mut libc::size_t, - ranges: *mut types::cef_page_range_t) -> ()>, - - // - // Set whether only the selection will be printed. - // - pub set_selection_only: Option<extern "C" fn(this: *mut cef_print_settings_t, - selection_only: libc::c_int) -> ()>, - - // - // Returns true (1) if only the selection will be printed. - // - pub is_selection_only: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Set whether pages will be collated. - // - pub set_collate: Option<extern "C" fn(this: *mut cef_print_settings_t, - collate: libc::c_int) -> ()>, - - // - // Returns true (1) if pages will be collated. - // - pub will_collate: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Set the color model. - // - pub set_color_model: Option<extern "C" fn(this: *mut cef_print_settings_t, - model: types::cef_color_model_t) -> ()>, - - // - // Get the color model. - // - pub get_color_model: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> types::cef_color_model_t>, - - // - // Set the number of copies. - // - pub set_copies: Option<extern "C" fn(this: *mut cef_print_settings_t, - copies: libc::c_int) -> ()>, - - // - // Get the number of copies. - // - pub get_copies: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> libc::c_int>, - - // - // Set the duplex mode. - // - pub set_duplex_mode: Option<extern "C" fn(this: *mut cef_print_settings_t, - mode: types::cef_duplex_mode_t) -> ()>, - - // - // Get the duplex mode. - // - pub get_duplex_mode: Option<extern "C" fn( - this: *mut cef_print_settings_t) -> types::cef_duplex_mode_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_print_settings_t = _cef_print_settings_t; - - -// -// Structure representing print settings. -// -pub struct CefPrintSettings { - c_object: *mut cef_print_settings_t, -} - -impl Clone for CefPrintSettings { - fn clone(&self) -> CefPrintSettings{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPrintSettings { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPrintSettings { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPrintSettings { - pub unsafe fn from_c_object(c_object: *mut cef_print_settings_t) -> CefPrintSettings { - CefPrintSettings { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_print_settings_t) -> CefPrintSettings { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPrintSettings { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_print_settings_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_print_settings_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns a writable copy of this object. - // - pub fn copy(&self) -> interfaces::CefPrintSettings { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Set the page orientation. - // - pub fn set_orientation(&self, landscape: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_orientation.unwrap())( - self.c_object, - CefWrap::to_c(landscape))) - } - } - - // - // Returns true (1) if the orientation is landscape. - // - pub fn is_landscape(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_landscape.unwrap())( - self.c_object)) - } - } - - // - // Set the printer printable area in device units. Some platforms already - // provide flipped area. Set |landscape_needs_flip| to false (0) on those - // platforms to avoid double flipping. - // - pub fn set_printer_printable_area(&self, - physical_size_device_units: &types::cef_size_t, - printable_area_device_units: &types::cef_rect_t, - landscape_needs_flip: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_printer_printable_area.unwrap())( - self.c_object, - CefWrap::to_c(physical_size_device_units), - CefWrap::to_c(printable_area_device_units), - CefWrap::to_c(landscape_needs_flip))) - } - } - - // - // Set the device name. - // - pub fn set_device_name(&self, name: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_device_name.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Get the device name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_device_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_device_name.unwrap())( - self.c_object)) - } - } - - // - // Set the DPI (dots per inch). - // - pub fn set_dpi(&self, dpi: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_dpi.unwrap())( - self.c_object, - CefWrap::to_c(dpi))) - } - } - - // - // Get the DPI (dots per inch). - // - pub fn get_dpi(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dpi.unwrap())( - self.c_object)) - } - } - - // - // Set the page ranges. - // - pub fn set_page_ranges(&self, ranges_count: libc::size_t, - ranges: *const types::cef_page_range_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_page_ranges.unwrap())( - self.c_object, - CefWrap::to_c(ranges_count), - CefWrap::to_c(ranges))) - } - } - - // - // Returns the number of page ranges that currently exist. - // - pub fn get_page_ranges_count(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_page_ranges_count.unwrap())( - self.c_object)) - } - } - - // - // Retrieve the page ranges. - // - pub fn get_page_ranges(&self, ranges_count: *mut libc::size_t, - ranges: *mut types::cef_page_range_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_page_ranges.unwrap())( - self.c_object, - CefWrap::to_c(ranges_count), - CefWrap::to_c(ranges))) - } - } - - // - // Set whether only the selection will be printed. - // - pub fn set_selection_only(&self, selection_only: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_selection_only.unwrap())( - self.c_object, - CefWrap::to_c(selection_only))) - } - } - - // - // Returns true (1) if only the selection will be printed. - // - pub fn is_selection_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_selection_only.unwrap())( - self.c_object)) - } - } - - // - // Set whether pages will be collated. - // - pub fn set_collate(&self, collate: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_collate.unwrap())( - self.c_object, - CefWrap::to_c(collate))) - } - } - - // - // Returns true (1) if pages will be collated. - // - pub fn will_collate(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).will_collate.unwrap())( - self.c_object)) - } - } - - // - // Set the color model. - // - pub fn set_color_model(&self, model: types::cef_color_model_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_color_model.unwrap())( - self.c_object, - CefWrap::to_c(model))) - } - } - - // - // Get the color model. - // - pub fn get_color_model(&self) -> types::cef_color_model_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_color_model.unwrap())( - self.c_object)) - } - } - - // - // Set the number of copies. - // - pub fn set_copies(&self, copies: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_copies.unwrap())( - self.c_object, - CefWrap::to_c(copies))) - } - } - - // - // Get the number of copies. - // - pub fn get_copies(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_copies.unwrap())( - self.c_object)) - } - } - - // - // Set the duplex mode. - // - pub fn set_duplex_mode(&self, mode: types::cef_duplex_mode_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_duplex_mode.unwrap())( - self.c_object, - CefWrap::to_c(mode))) - } - } - - // - // Get the duplex mode. - // - pub fn get_duplex_mode(&self) -> types::cef_duplex_mode_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_duplex_mode.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_print_settings_t object. - // - pub fn create() -> interfaces::CefPrintSettings { - unsafe { - CefWrap::to_rust( - ::print_settings::cef_print_settings_create( -)) - } - } -} - -impl CefWrap<*mut cef_print_settings_t> for CefPrintSettings { - fn to_c(rust_object: CefPrintSettings) -> *mut cef_print_settings_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_print_settings_t) -> CefPrintSettings { - CefPrintSettings::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_print_settings_t> for Option<CefPrintSettings> { - fn to_c(rust_object: Option<CefPrintSettings>) -> *mut cef_print_settings_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_print_settings_t) -> Option<CefPrintSettings> { - if c_object.is_null() { - None - } else { - Some(CefPrintSettings::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_process_message.rs b/ports/cef/interfaces/cef_process_message.rs deleted file mode 100644 index 16562683d29..00000000000 --- a/ports/cef/interfaces/cef_process_message.rs +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure representing a message. Can be used on any process and thread. -// -#[repr(C)] -pub struct _cef_process_message_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_process_message_t) -> libc::c_int>, - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_process_message_t) -> libc::c_int>, - - // - // Returns a writable copy of this object. - // - pub copy: Option<extern "C" fn( - this: *mut cef_process_message_t) -> *mut interfaces::cef_process_message_t>, - - // - // Returns the message name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_name: Option<extern "C" fn( - this: *mut cef_process_message_t) -> types::cef_string_userfree_t>, - - // - // Returns the list of arguments. - // - pub get_argument_list: Option<extern "C" fn( - this: *mut cef_process_message_t) -> *mut interfaces::cef_list_value_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_process_message_t = _cef_process_message_t; - - -// -// Structure representing a message. Can be used on any process and thread. -// -pub struct CefProcessMessage { - c_object: *mut cef_process_message_t, -} - -impl Clone for CefProcessMessage { - fn clone(&self) -> CefProcessMessage{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefProcessMessage { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefProcessMessage { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefProcessMessage { - pub unsafe fn from_c_object(c_object: *mut cef_process_message_t) -> CefProcessMessage { - CefProcessMessage { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_process_message_t) -> CefProcessMessage { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefProcessMessage { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_process_message_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_process_message_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. Do not call any other functions - // if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns a writable copy of this object. - // - pub fn copy(&self) -> interfaces::CefProcessMessage { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Returns the message name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the list of arguments. - // - pub fn get_argument_list(&self) -> interfaces::CefListValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_argument_list.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_process_message_t object with the specified name. - // - pub fn create(name: &[u16]) -> interfaces::CefProcessMessage { - unsafe { - CefWrap::to_rust( - ::process_message::cef_process_message_create( - CefWrap::to_c(name))) - } - } -} - -impl CefWrap<*mut cef_process_message_t> for CefProcessMessage { - fn to_c(rust_object: CefProcessMessage) -> *mut cef_process_message_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_process_message_t) -> CefProcessMessage { - CefProcessMessage::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_process_message_t> for Option<CefProcessMessage> { - fn to_c(rust_object: Option<CefProcessMessage>) -> *mut cef_process_message_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_process_message_t) -> Option<CefProcessMessage> { - if c_object.is_null() { - None - } else { - Some(CefProcessMessage::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_process_util.rs b/ports/cef/interfaces/cef_process_util.rs deleted file mode 100644 index c396bf66e02..00000000000 --- a/ports/cef/interfaces/cef_process_util.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; diff --git a/ports/cef/interfaces/cef_render_handler.rs b/ports/cef/interfaces/cef_render_handler.rs deleted file mode 100644 index 125bafede8f..00000000000 --- a/ports/cef/interfaces/cef_render_handler.rs +++ /dev/null @@ -1,571 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to handle events when window rendering is disabled. -// The functions of this structure will be called on the UI thread. -// -#[repr(C)] -pub struct _cef_render_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called to retrieve the root window rectangle in screen coordinates. Return - // true (1) if the rectangle was provided. - // - pub get_root_screen_rect: Option<extern "C" fn( - this: *mut cef_render_handler_t, browser: *mut interfaces::cef_browser_t, - rect: *mut types::cef_rect_t) -> libc::c_int>, - - // - // Called to retrieve the view rectangle which is relative to screen - // coordinates. Return true (1) if the rectangle was provided. - // - pub get_view_rect: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - rect: *mut types::cef_rect_t) -> libc::c_int>, - - // - // Called to retrieve the translation from view coordinates to actual screen - // coordinates. Return true (1) if the screen coordinates were provided. - // - pub get_screen_point: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, viewX: libc::c_int, - viewY: libc::c_int, screenX: *mut libc::c_int, - screenY: *mut libc::c_int) -> libc::c_int>, - - // - // Called to allow the client to fill in the CefScreenInfo object with - // appropriate values. Return true (1) if the |screen_info| structure has been - // modified. - // - // If the screen info rectangle is left NULL the rectangle from GetViewRect - // will be used. If the rectangle is still NULL or invalid popups may not be - // drawn correctly. - // - pub get_screen_info: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - screen_info: *mut interfaces::cef_screen_info_t) -> libc::c_int>, - - // - // Called when the browser wants to show or hide the popup widget. The popup - // should be shown if |show| is true (1) and hidden if |show| is false (0). - // - pub on_popup_show: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, show: libc::c_int) -> ()>, - - // - // Called when the browser wants to move or resize the popup widget. |rect| - // contains the new location and size in view coordinates. - // - pub on_popup_size: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - rect: *const types::cef_rect_t) -> ()>, - - // - // Called when an element should be painted. Pixel values passed to this - // function are scaled relative to view coordinates based on the value of - // CefScreenInfo.device_scale_factor returned from GetScreenInfo. |type| - // indicates whether the element is the view or the popup widget. |buffer| - // contains the pixel data for the whole image. |dirtyRects| contains the set - // of rectangles in pixel coordinates that need to be repainted. |buffer| will - // be |width|*|height|*4 bytes in size and represents a BGRA image with an - // upper-left origin. - // - pub on_paint: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - ty: types::cef_paint_element_type_t, dirtyRects_count: libc::size_t, - dirtyRects: *const types::cef_rect_t, buffer: *const (), - width: libc::c_int, height: libc::c_int) -> ()>, - - // - // Called when the browser's cursor has changed. If |type| is CT_CUSTOM then - // |custom_cursor_info| will be populated with the custom cursor information. - // - pub on_cursor_change: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - cursor: types::cef_cursor_handle_t, ty: types::cef_cursor_type_t, - custom_cursor_info: *const interfaces::cef_cursor_info_t) -> ()>, - - // - // Called when the user starts dragging content in the web view. Contextual - // information about the dragged content is supplied by |drag_data|. (|x|, - // |y|) is the drag start location in screen coordinates. OS APIs that run a - // system message loop may be used within the StartDragging call. - // - // Return false (0) to abort the drag operation. Don't call any of - // cef_browser_host_t::DragSource*Ended* functions after returning false (0). - // - // Return true (1) to handle the drag operation. Call - // cef_browser_host_t::DragSourceEndedAt and DragSourceSystemDragEnded either - // synchronously or asynchronously to inform the web view that the drag - // operation has ended. - // - pub start_dragging: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - drag_data: *mut interfaces::cef_drag_data_t, - allowed_ops: types::cef_drag_operations_mask_t, x: libc::c_int, - y: libc::c_int) -> libc::c_int>, - - // - // Called when the web view wants to update the mouse cursor during a drag & - // drop operation. |operation| describes the allowed operation (none, move, - // copy, link). - // - pub update_drag_cursor: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - operation: types::cef_drag_operations_mask_t) -> ()>, - - // - // Called when the scroll offset has changed. - // - pub on_scroll_offset_changed: Option<extern "C" fn( - this: *mut cef_render_handler_t, browser: *mut interfaces::cef_browser_t, - x: libc::c_double, y: libc::c_double) -> ()>, - - // - // Called to retrieve the backing size of the view rectangle which is relative - // to screen coordinates. On HiDPI displays, the backing size can differ from - // the view size as returned by |GetViewRect|. Return true (1) if the - // rectangle was provided. Only used on Mac OS. - // - pub get_backing_rect: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t, - rect: *mut types::cef_rect_t) -> libc::c_int>, - - // - // Called when an element should be presented (e.g. double buffers should page - // flip). This is called only during accelerated compositing. - // - pub on_present: Option<extern "C" fn(this: *mut cef_render_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_render_handler_t = _cef_render_handler_t; - - -// -// Implement this structure to handle events when window rendering is disabled. -// The functions of this structure will be called on the UI thread. -// -pub struct CefRenderHandler { - c_object: *mut cef_render_handler_t, -} - -impl Clone for CefRenderHandler { - fn clone(&self) -> CefRenderHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRenderHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRenderHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRenderHandler { - pub unsafe fn from_c_object(c_object: *mut cef_render_handler_t) -> CefRenderHandler { - CefRenderHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_render_handler_t) -> CefRenderHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRenderHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_render_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_render_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called to retrieve the root window rectangle in screen coordinates. Return - // true (1) if the rectangle was provided. - // - pub fn get_root_screen_rect(&self, browser: interfaces::CefBrowser, - rect: &mut types::cef_rect_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_root_screen_rect.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(rect))) - } - } - - // - // Called to retrieve the view rectangle which is relative to screen - // coordinates. Return true (1) if the rectangle was provided. - // - pub fn get_view_rect(&self, browser: interfaces::CefBrowser, - rect: &mut types::cef_rect_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_view_rect.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(rect))) - } - } - - // - // Called to retrieve the translation from view coordinates to actual screen - // coordinates. Return true (1) if the screen coordinates were provided. - // - pub fn get_screen_point(&self, browser: interfaces::CefBrowser, - viewX: libc::c_int, viewY: libc::c_int, screenX: &mut libc::c_int, - screenY: &mut libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_screen_point.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(viewX), - CefWrap::to_c(viewY), - CefWrap::to_c(screenX), - CefWrap::to_c(screenY))) - } - } - - // - // Called to allow the client to fill in the CefScreenInfo object with - // appropriate values. Return true (1) if the |screen_info| structure has been - // modified. - // - // If the screen info rectangle is left NULL the rectangle from GetViewRect - // will be used. If the rectangle is still NULL or invalid popups may not be - // drawn correctly. - // - pub fn get_screen_info(&self, browser: interfaces::CefBrowser, - screen_info: &mut interfaces::CefScreenInfo) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_screen_info.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(screen_info))) - } - } - - // - // Called when the browser wants to show or hide the popup widget. The popup - // should be shown if |show| is true (1) and hidden if |show| is false (0). - // - pub fn on_popup_show(&self, browser: interfaces::CefBrowser, - show: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_popup_show.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(show))) - } - } - - // - // Called when the browser wants to move or resize the popup widget. |rect| - // contains the new location and size in view coordinates. - // - pub fn on_popup_size(&self, browser: interfaces::CefBrowser, - rect: &types::cef_rect_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_popup_size.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(rect))) - } - } - - // - // Called when an element should be painted. Pixel values passed to this - // function are scaled relative to view coordinates based on the value of - // CefScreenInfo.device_scale_factor returned from GetScreenInfo. |type| - // indicates whether the element is the view or the popup widget. |buffer| - // contains the pixel data for the whole image. |dirtyRects| contains the set - // of rectangles in pixel coordinates that need to be repainted. |buffer| will - // be |width|*|height|*4 bytes in size and represents a BGRA image with an - // upper-left origin. - // - pub fn on_paint(&self, browser: interfaces::CefBrowser, - ty: types::cef_paint_element_type_t, dirtyRects_count: libc::size_t, - dirtyRects: *const types::cef_rect_t, buffer: &(), width: libc::c_int, - height: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_paint.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(ty), - CefWrap::to_c(dirtyRects_count), - CefWrap::to_c(dirtyRects), - CefWrap::to_c(buffer), - CefWrap::to_c(width), - CefWrap::to_c(height))) - } - } - - // - // Called when the browser's cursor has changed. If |type| is CT_CUSTOM then - // |custom_cursor_info| will be populated with the custom cursor information. - // - pub fn on_cursor_change(&self, browser: interfaces::CefBrowser, - cursor: types::cef_cursor_handle_t, ty: types::cef_cursor_type_t, - custom_cursor_info: &interfaces::CefCursorInfo) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_cursor_change.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(cursor), - CefWrap::to_c(ty), - CefWrap::to_c(custom_cursor_info))) - } - } - - // - // Called when the user starts dragging content in the web view. Contextual - // information about the dragged content is supplied by |drag_data|. (|x|, - // |y|) is the drag start location in screen coordinates. OS APIs that run a - // system message loop may be used within the StartDragging call. - // - // Return false (0) to abort the drag operation. Don't call any of - // cef_browser_host_t::DragSource*Ended* functions after returning false (0). - // - // Return true (1) to handle the drag operation. Call - // cef_browser_host_t::DragSourceEndedAt and DragSourceSystemDragEnded either - // synchronously or asynchronously to inform the web view that the drag - // operation has ended. - // - pub fn start_dragging(&self, browser: interfaces::CefBrowser, - drag_data: interfaces::CefDragData, - allowed_ops: types::cef_drag_operations_mask_t, x: libc::c_int, - y: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).start_dragging.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(drag_data), - CefWrap::to_c(allowed_ops), - CefWrap::to_c(x), - CefWrap::to_c(y))) - } - } - - // - // Called when the web view wants to update the mouse cursor during a drag & - // drop operation. |operation| describes the allowed operation (none, move, - // copy, link). - // - pub fn update_drag_cursor(&self, browser: interfaces::CefBrowser, - operation: types::cef_drag_operations_mask_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).update_drag_cursor.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(operation))) - } - } - - // - // Called when the scroll offset has changed. - // - pub fn on_scroll_offset_changed(&self, browser: interfaces::CefBrowser, - x: libc::c_double, y: libc::c_double) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_scroll_offset_changed.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(x), - CefWrap::to_c(y))) - } - } - - // - // Called to retrieve the backing size of the view rectangle which is relative - // to screen coordinates. On HiDPI displays, the backing size can differ from - // the view size as returned by |GetViewRect|. Return true (1) if the - // rectangle was provided. Only used on Mac OS. - // - pub fn get_backing_rect(&self, browser: interfaces::CefBrowser, - rect: &mut types::cef_rect_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_backing_rect.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(rect))) - } - } - - // - // Called when an element should be presented (e.g. double buffers should page - // flip). This is called only during accelerated compositing. - // - pub fn on_present(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_present.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } -} - -impl CefWrap<*mut cef_render_handler_t> for CefRenderHandler { - fn to_c(rust_object: CefRenderHandler) -> *mut cef_render_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_render_handler_t) -> CefRenderHandler { - CefRenderHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_render_handler_t> for Option<CefRenderHandler> { - fn to_c(rust_object: Option<CefRenderHandler>) -> *mut cef_render_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_render_handler_t) -> Option<CefRenderHandler> { - if c_object.is_null() { - None - } else { - Some(CefRenderHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_render_process_handler.rs b/ports/cef/interfaces/cef_render_process_handler.rs deleted file mode 100644 index 404d073a66b..00000000000 --- a/ports/cef/interfaces/cef_render_process_handler.rs +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to implement render process callbacks. The functions of this -// structure will be called on the render process main thread (TID_RENDERER) -// unless otherwise indicated. -// -#[repr(C)] -pub struct _cef_render_process_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called after the render process main thread has been created. |extra_info| - // is a read-only value originating from - // cef_browser_process_handler_t::on_render_process_thread_created(). Do not - // keep a reference to |extra_info| outside of this function. - // - pub on_render_thread_created: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - extra_info: *mut interfaces::cef_list_value_t) -> ()>, - - // - // Called after WebKit has been initialized. - // - pub on_web_kit_initialized: Option<extern "C" fn( - this: *mut cef_render_process_handler_t) -> ()>, - - // - // Called after a browser has been created. When browsing cross-origin a new - // browser will be created before the old browser with the same identifier is - // destroyed. - // - pub on_browser_created: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // Called before a browser is destroyed. - // - pub on_browser_destroyed: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // Return the handler for browser load status events. - // - pub get_load_handler: Option<extern "C" fn( - this: *mut cef_render_process_handler_t) -> *mut interfaces::cef_load_handler_t>, - - // - // Called before browser navigation. Return true (1) to cancel the navigation - // or false (0) to allow the navigation to proceed. The |request| object - // cannot be modified in this callback. - // - pub on_before_navigation: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t, - navigation_type: types::cef_navigation_type_t, - is_redirect: libc::c_int) -> libc::c_int>, - - // - // Called immediately after the V8 context for a frame has been created. To - // retrieve the JavaScript 'window' object use the - // cef_v8context_t::get_global() function. V8 handles can only be accessed - // from the thread on which they are created. A task runner for posting tasks - // on the associated thread can be retrieved via the - // cef_v8context_t::get_task_runner() function. - // - pub on_context_created: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - context: *mut interfaces::cef_v8context_t) -> ()>, - - // - // Called immediately before the V8 context for a frame is released. No - // references to the context should be kept after this function is called. - // - pub on_context_released: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - context: *mut interfaces::cef_v8context_t) -> ()>, - - // - // Called for global uncaught exceptions in a frame. Execution of this - // callback is disabled by default. To enable set - // CefSettings.uncaught_exception_stack_size > 0. - // - pub on_uncaught_exception: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - context: *mut interfaces::cef_v8context_t, - exception: *mut interfaces::cef_v8exception_t, - stackTrace: *mut interfaces::cef_v8stack_trace_t) -> ()>, - - // - // Called when a new node in the the browser gets focus. The |node| value may - // be NULL if no specific node has gained focus. The node object passed to - // this function represents a snapshot of the DOM at the time this function is - // executed. DOM objects are only valid for the scope of this function. Do not - // keep references to or attempt to access any DOM objects outside the scope - // of this function. - // - pub on_focused_node_changed: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - node: *mut interfaces::cef_domnode_t) -> ()>, - - // - // Called when a new message is received from a different process. Return true - // (1) if the message was handled or false (0) otherwise. Do not keep a - // reference to or attempt to access the message outside of this callback. - // - pub on_process_message_received: Option<extern "C" fn( - this: *mut cef_render_process_handler_t, - browser: *mut interfaces::cef_browser_t, - source_process: interfaces::cef_process_id_t, - message: *mut interfaces::cef_process_message_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_render_process_handler_t = _cef_render_process_handler_t; - - -// -// Structure used to implement render process callbacks. The functions of this -// structure will be called on the render process main thread (TID_RENDERER) -// unless otherwise indicated. -// -pub struct CefRenderProcessHandler { - c_object: *mut cef_render_process_handler_t, -} - -impl Clone for CefRenderProcessHandler { - fn clone(&self) -> CefRenderProcessHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRenderProcessHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRenderProcessHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRenderProcessHandler { - pub unsafe fn from_c_object(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler { - CefRenderProcessHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRenderProcessHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_render_process_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_render_process_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called after the render process main thread has been created. |extra_info| - // is a read-only value originating from - // cef_browser_process_handler_t::on_render_process_thread_created(). Do not - // keep a reference to |extra_info| outside of this function. - // - pub fn on_render_thread_created(&self, - extra_info: interfaces::CefListValue) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_render_thread_created.unwrap())( - self.c_object, - CefWrap::to_c(extra_info))) - } - } - - // - // Called after WebKit has been initialized. - // - pub fn on_web_kit_initialized(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_web_kit_initialized.unwrap())( - self.c_object)) - } - } - - // - // Called after a browser has been created. When browsing cross-origin a new - // browser will be created before the old browser with the same identifier is - // destroyed. - // - pub fn on_browser_created(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_browser_created.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called before a browser is destroyed. - // - pub fn on_browser_destroyed(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_browser_destroyed.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Return the handler for browser load status events. - // - pub fn get_load_handler(&self) -> interfaces::CefLoadHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_load_handler.unwrap())( - self.c_object)) - } - } - - // - // Called before browser navigation. Return true (1) to cancel the navigation - // or false (0) to allow the navigation to proceed. The |request| object - // cannot be modified in this callback. - // - pub fn on_before_navigation(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, request: interfaces::CefRequest, - navigation_type: types::cef_navigation_type_t, - is_redirect: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_navigation.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request), - CefWrap::to_c(navigation_type), - CefWrap::to_c(is_redirect))) - } - } - - // - // Called immediately after the V8 context for a frame has been created. To - // retrieve the JavaScript 'window' object use the - // cef_v8context_t::get_global() function. V8 handles can only be accessed - // from the thread on which they are created. A task runner for posting tasks - // on the associated thread can be retrieved via the - // cef_v8context_t::get_task_runner() function. - // - pub fn on_context_created(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_context_created.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(context))) - } - } - - // - // Called immediately before the V8 context for a frame is released. No - // references to the context should be kept after this function is called. - // - pub fn on_context_released(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_context_released.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(context))) - } - } - - // - // Called for global uncaught exceptions in a frame. Execution of this - // callback is disabled by default. To enable set - // CefSettings.uncaught_exception_stack_size > 0. - // - pub fn on_uncaught_exception(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, context: interfaces::CefV8Context, - exception: interfaces::CefV8Exception, - stackTrace: interfaces::CefV8StackTrace) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_uncaught_exception.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(context), - CefWrap::to_c(exception), - CefWrap::to_c(stackTrace))) - } - } - - // - // Called when a new node in the the browser gets focus. The |node| value may - // be NULL if no specific node has gained focus. The node object passed to - // this function represents a snapshot of the DOM at the time this function is - // executed. DOM objects are only valid for the scope of this function. Do not - // keep references to or attempt to access any DOM objects outside the scope - // of this function. - // - pub fn on_focused_node_changed(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, node: interfaces::CefDOMNode) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_focused_node_changed.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(node))) - } - } - - // - // Called when a new message is received from a different process. Return true - // (1) if the message was handled or false (0) otherwise. Do not keep a - // reference to or attempt to access the message outside of this callback. - // - pub fn on_process_message_received(&self, browser: interfaces::CefBrowser, - source_process: interfaces::CefProcessId, - message: interfaces::CefProcessMessage) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_process_message_received.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(source_process), - CefWrap::to_c(message))) - } - } -} - -impl CefWrap<*mut cef_render_process_handler_t> for CefRenderProcessHandler { - fn to_c(rust_object: CefRenderProcessHandler) -> *mut cef_render_process_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler { - CefRenderProcessHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_render_process_handler_t> for Option<CefRenderProcessHandler> { - fn to_c(rust_object: Option<CefRenderProcessHandler>) -> *mut cef_render_process_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_render_process_handler_t) -> Option<CefRenderProcessHandler> { - if c_object.is_null() { - None - } else { - Some(CefRenderProcessHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_request.rs b/ports/cef/interfaces/cef_request.rs deleted file mode 100644 index d47a465fe86..00000000000 --- a/ports/cef/interfaces/cef_request.rs +++ /dev/null @@ -1,1113 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent a web request. The functions of this structure -// may be called on any thread. -// -#[repr(C)] -pub struct _cef_request_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is read-only. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_request_t) -> libc::c_int>, - - // - // Get the fully qualified URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_url: Option<extern "C" fn( - this: *mut cef_request_t) -> types::cef_string_userfree_t>, - - // - // Set the fully qualified URL. - // - pub set_url: Option<extern "C" fn(this: *mut cef_request_t, - url: *const types::cef_string_t) -> ()>, - - // - // Get the request function type. The value will default to POST if post data - // is provided and GET otherwise. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_method: Option<extern "C" fn( - this: *mut cef_request_t) -> types::cef_string_userfree_t>, - - // - // Set the request function type. - // - pub set_method: Option<extern "C" fn(this: *mut cef_request_t, - method: *const types::cef_string_t) -> ()>, - - // - // Get the post data. - // - pub get_post_data: Option<extern "C" fn( - this: *mut cef_request_t) -> *mut interfaces::cef_post_data_t>, - - // - // Set the post data. - // - pub set_post_data: Option<extern "C" fn(this: *mut cef_request_t, - postData: *mut interfaces::cef_post_data_t) -> ()>, - - // - // Get the header values. - // - pub get_header_map: Option<extern "C" fn(this: *mut cef_request_t, - headerMap: types::cef_string_multimap_t) -> ()>, - - // - // Set the header values. - // - pub set_header_map: Option<extern "C" fn(this: *mut cef_request_t, - headerMap: types::cef_string_multimap_t) -> ()>, - - // - // Set all values at one time. - // - pub set: Option<extern "C" fn(this: *mut cef_request_t, - url: *const types::cef_string_t, method: *const types::cef_string_t, - postData: *mut interfaces::cef_post_data_t, - headerMap: types::cef_string_multimap_t) -> ()>, - - // - // Get the flags used in combination with cef_urlrequest_t. See - // cef_urlrequest_flags_t for supported values. - // - pub get_flags: Option<extern "C" fn(this: *mut cef_request_t) -> libc::c_int>, - - // - // Set the flags used in combination with cef_urlrequest_t. See - // cef_urlrequest_flags_t for supported values. - // - pub set_flags: Option<extern "C" fn(this: *mut cef_request_t, - flags: libc::c_int) -> ()>, - - // - // Set the URL to the first party for cookies used in combination with - // cef_urlrequest_t. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_first_party_for_cookies: Option<extern "C" fn( - this: *mut cef_request_t) -> types::cef_string_userfree_t>, - - // - // Get the URL to the first party for cookies used in combination with - // cef_urlrequest_t. - // - pub set_first_party_for_cookies: Option<extern "C" fn( - this: *mut cef_request_t, url: *const types::cef_string_t) -> ()>, - - // - // Get the resource type for this request. Only available in the browser - // process. - // - pub get_resource_type: Option<extern "C" fn( - this: *mut cef_request_t) -> types::cef_resource_type_t>, - - // - // Get the transition type for this request. Only available in the browser - // process and only applies to requests that represent a main frame or sub- - // frame navigation. - // - pub get_transition_type: Option<extern "C" fn( - this: *mut cef_request_t) -> types::cef_transition_type_t>, - - // - // Returns the globally unique identifier for this request or 0 if not - // specified. Can be used by cef_request_tHandler implementations in the - // browser process to track a single request across multiple callbacks. - // - pub get_identifier: Option<extern "C" fn(this: *mut cef_request_t) -> u64>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_request_t = _cef_request_t; - - -// -// Structure used to represent a web request. The functions of this structure -// may be called on any thread. -// -pub struct CefRequest { - c_object: *mut cef_request_t, -} - -impl Clone for CefRequest { - fn clone(&self) -> CefRequest{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRequest { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRequest { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRequest { - pub unsafe fn from_c_object(c_object: *mut cef_request_t) -> CefRequest { - CefRequest { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_request_t) -> CefRequest { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRequest { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_request_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_request_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is read-only. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Get the fully qualified URL. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_url.unwrap())( - self.c_object)) - } - } - - // - // Set the fully qualified URL. - // - pub fn set_url(&self, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_url.unwrap())( - self.c_object, - CefWrap::to_c(url))) - } - } - - // - // Get the request function type. The value will default to POST if post data - // is provided and GET otherwise. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_method(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_method.unwrap())( - self.c_object)) - } - } - - // - // Set the request function type. - // - pub fn set_method(&self, method: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_method.unwrap())( - self.c_object, - CefWrap::to_c(method))) - } - } - - // - // Get the post data. - // - pub fn get_post_data(&self) -> interfaces::CefPostData { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_post_data.unwrap())( - self.c_object)) - } - } - - // - // Set the post data. - // - pub fn set_post_data(&self, postData: interfaces::CefPostData) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_post_data.unwrap())( - self.c_object, - CefWrap::to_c(postData))) - } - } - - // - // Get the header values. - // - pub fn get_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_header_map.unwrap())( - self.c_object, - CefWrap::to_c(headerMap))) - } - } - - // - // Set the header values. - // - pub fn set_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_header_map.unwrap())( - self.c_object, - CefWrap::to_c(headerMap))) - } - } - - // - // Set all values at one time. - // - pub fn set(&self, url: &[u16], method: &[u16], - postData: interfaces::CefPostData, headerMap: HashMap<String, - Vec<String>>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set.unwrap())( - self.c_object, - CefWrap::to_c(url), - CefWrap::to_c(method), - CefWrap::to_c(postData), - CefWrap::to_c(headerMap))) - } - } - - // - // Get the flags used in combination with cef_urlrequest_t. See - // cef_urlrequest_flags_t for supported values. - // - pub fn get_flags(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_flags.unwrap())( - self.c_object)) - } - } - - // - // Set the flags used in combination with cef_urlrequest_t. See - // cef_urlrequest_flags_t for supported values. - // - pub fn set_flags(&self, flags: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_flags.unwrap())( - self.c_object, - CefWrap::to_c(flags))) - } - } - - // - // Set the URL to the first party for cookies used in combination with - // cef_urlrequest_t. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_first_party_for_cookies(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_first_party_for_cookies.unwrap())( - self.c_object)) - } - } - - // - // Get the URL to the first party for cookies used in combination with - // cef_urlrequest_t. - // - pub fn set_first_party_for_cookies(&self, url: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_first_party_for_cookies.unwrap())( - self.c_object, - CefWrap::to_c(url))) - } - } - - // - // Get the resource type for this request. Only available in the browser - // process. - // - pub fn get_resource_type(&self) -> types::cef_resource_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_resource_type.unwrap())( - self.c_object)) - } - } - - // - // Get the transition type for this request. Only available in the browser - // process and only applies to requests that represent a main frame or sub- - // frame navigation. - // - pub fn get_transition_type(&self) -> types::cef_transition_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_transition_type.unwrap())( - self.c_object)) - } - } - - // - // Returns the globally unique identifier for this request or 0 if not - // specified. Can be used by cef_request_tHandler implementations in the - // browser process to track a single request across multiple callbacks. - // - pub fn get_identifier(&self) -> u64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_identifier.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_request_t object. - // - pub fn create() -> interfaces::CefRequest { - unsafe { - CefWrap::to_rust( - ::request::cef_request_create( -)) - } - } -} - -impl CefWrap<*mut cef_request_t> for CefRequest { - fn to_c(rust_object: CefRequest) -> *mut cef_request_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_request_t) -> CefRequest { - CefRequest::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_request_t> for Option<CefRequest> { - fn to_c(rust_object: Option<CefRequest>) -> *mut cef_request_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_request_t) -> Option<CefRequest> { - if c_object.is_null() { - None - } else { - Some(CefRequest::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to represent post data for a web request. The functions of -// this structure may be called on any thread. -// -#[repr(C)] -pub struct _cef_post_data_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is read-only. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_post_data_t) -> libc::c_int>, - - // - // Returns the number of existing post data elements. - // - pub get_element_count: Option<extern "C" fn( - this: *mut cef_post_data_t) -> libc::size_t>, - - // - // Retrieve the post data elements. - // - pub get_elements: Option<extern "C" fn(this: *mut cef_post_data_t, - elements_count: *mut libc::size_t, - elements: *mut *mut interfaces::cef_post_data_element_t) -> ()>, - - // - // Remove the specified post data element. Returns true (1) if the removal - // succeeds. - // - pub remove_element: Option<extern "C" fn(this: *mut cef_post_data_t, - element: *mut interfaces::cef_post_data_element_t) -> libc::c_int>, - - // - // Add the specified post data element. Returns true (1) if the add succeeds. - // - pub add_element: Option<extern "C" fn(this: *mut cef_post_data_t, - element: *mut interfaces::cef_post_data_element_t) -> libc::c_int>, - - // - // Remove all existing post data elements. - // - pub remove_elements: Option<extern "C" fn(this: *mut cef_post_data_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_post_data_t = _cef_post_data_t; - - -// -// Structure used to represent post data for a web request. The functions of -// this structure may be called on any thread. -// -pub struct CefPostData { - c_object: *mut cef_post_data_t, -} - -impl Clone for CefPostData { - fn clone(&self) -> CefPostData{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPostData { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPostData { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPostData { - pub unsafe fn from_c_object(c_object: *mut cef_post_data_t) -> CefPostData { - CefPostData { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_post_data_t) -> CefPostData { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPostData { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_post_data_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_post_data_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is read-only. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns the number of existing post data elements. - // - pub fn get_element_count(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_element_count.unwrap())( - self.c_object)) - } - } - - // - // Retrieve the post data elements. - // - pub fn get_elements(&self, elements_count: *mut libc::size_t, - elements: *mut interfaces::CefPostDataElement) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_elements.unwrap())( - self.c_object, - CefWrap::to_c(elements_count), - CefWrap::to_c(elements))) - } - } - - // - // Remove the specified post data element. Returns true (1) if the removal - // succeeds. - // - pub fn remove_element(&self, - element: interfaces::CefPostDataElement) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove_element.unwrap())( - self.c_object, - CefWrap::to_c(element))) - } - } - - // - // Add the specified post data element. Returns true (1) if the add succeeds. - // - pub fn add_element(&self, - element: interfaces::CefPostDataElement) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_element.unwrap())( - self.c_object, - CefWrap::to_c(element))) - } - } - - // - // Remove all existing post data elements. - // - pub fn remove_elements(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove_elements.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_post_data_t object. - // - pub fn create() -> interfaces::CefPostData { - unsafe { - CefWrap::to_rust( - ::request::cef_post_data_create( -)) - } - } -} - -impl CefWrap<*mut cef_post_data_t> for CefPostData { - fn to_c(rust_object: CefPostData) -> *mut cef_post_data_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_post_data_t) -> CefPostData { - CefPostData::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_post_data_t> for Option<CefPostData> { - fn to_c(rust_object: Option<CefPostData>) -> *mut cef_post_data_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_post_data_t) -> Option<CefPostData> { - if c_object.is_null() { - None - } else { - Some(CefPostData::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to represent a single element in the request post data. The -// functions of this structure may be called on any thread. -// -#[repr(C)] -pub struct _cef_post_data_element_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is read-only. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_post_data_element_t) -> libc::c_int>, - - // - // Remove all contents from the post data element. - // - pub set_to_empty: Option<extern "C" fn( - this: *mut cef_post_data_element_t) -> ()>, - - // - // The post data element will represent a file. - // - pub set_to_file: Option<extern "C" fn(this: *mut cef_post_data_element_t, - fileName: *const types::cef_string_t) -> ()>, - - // - // The post data element will represent bytes. The bytes passed in will be - // copied. - // - pub set_to_bytes: Option<extern "C" fn(this: *mut cef_post_data_element_t, - size: libc::size_t, bytes: *const ()) -> ()>, - - // - // Return the type of this post data element. - // - pub get_type: Option<extern "C" fn( - this: *mut cef_post_data_element_t) -> types::cef_postdataelement_type_t>, - - // - // Return the file name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_file: Option<extern "C" fn( - this: *mut cef_post_data_element_t) -> types::cef_string_userfree_t>, - - // - // Return the number of bytes. - // - pub get_bytes_count: Option<extern "C" fn( - this: *mut cef_post_data_element_t) -> libc::size_t>, - - // - // Read up to |size| bytes into |bytes| and return the number of bytes - // actually read. - // - pub get_bytes: Option<extern "C" fn(this: *mut cef_post_data_element_t, - size: libc::size_t, bytes: *mut ()) -> libc::size_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_post_data_element_t = _cef_post_data_element_t; - - -// -// Structure used to represent a single element in the request post data. The -// functions of this structure may be called on any thread. -// -pub struct CefPostDataElement { - c_object: *mut cef_post_data_element_t, -} - -impl Clone for CefPostDataElement { - fn clone(&self) -> CefPostDataElement{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefPostDataElement { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefPostDataElement { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefPostDataElement { - pub unsafe fn from_c_object(c_object: *mut cef_post_data_element_t) -> CefPostDataElement { - CefPostDataElement { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_post_data_element_t) -> CefPostDataElement { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefPostDataElement { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_post_data_element_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_post_data_element_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is read-only. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Remove all contents from the post data element. - // - pub fn set_to_empty(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_to_empty.unwrap())( - self.c_object)) - } - } - - // - // The post data element will represent a file. - // - pub fn set_to_file(&self, fileName: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_to_file.unwrap())( - self.c_object, - CefWrap::to_c(fileName))) - } - } - - // - // The post data element will represent bytes. The bytes passed in will be - // copied. - // - pub fn set_to_bytes(&self, size: libc::size_t, bytes: &()) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_to_bytes.unwrap())( - self.c_object, - CefWrap::to_c(size), - CefWrap::to_c(bytes))) - } - } - - // - // Return the type of this post data element. - // - pub fn get_type(&self) -> types::cef_postdataelement_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object)) - } - } - - // - // Return the file name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_file(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file.unwrap())( - self.c_object)) - } - } - - // - // Return the number of bytes. - // - pub fn get_bytes_count(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bytes_count.unwrap())( - self.c_object)) - } - } - - // - // Read up to |size| bytes into |bytes| and return the number of bytes - // actually read. - // - pub fn get_bytes(&self, size: libc::size_t, bytes: &mut ()) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bytes.unwrap())( - self.c_object, - CefWrap::to_c(size), - CefWrap::to_c(bytes))) - } - } - - // - // Create a new cef_post_data_element_t object. - // - pub fn create() -> interfaces::CefPostDataElement { - unsafe { - CefWrap::to_rust( - ::request::cef_post_data_element_create( -)) - } - } -} - -impl CefWrap<*mut cef_post_data_element_t> for CefPostDataElement { - fn to_c(rust_object: CefPostDataElement) -> *mut cef_post_data_element_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_post_data_element_t) -> CefPostDataElement { - CefPostDataElement::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_post_data_element_t> for Option<CefPostDataElement> { - fn to_c(rust_object: Option<CefPostDataElement>) -> *mut cef_post_data_element_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_post_data_element_t) -> Option<CefPostDataElement> { - if c_object.is_null() { - None - } else { - Some(CefPostDataElement::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_request_context.rs b/ports/cef/interfaces/cef_request_context.rs deleted file mode 100644 index e5c639407a2..00000000000 --- a/ports/cef/interfaces/cef_request_context.rs +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// A request context provides request handling for a set of related browser or -// URL request objects. A request context can be specified when creating a new -// browser via the cef_browser_host_t static factory functions or when creating -// a new URL request via the cef_urlrequest_t static factory functions. Browser -// objects with different request contexts will never be hosted in the same -// render process. Browser objects with the same request context may or may not -// be hosted in the same render process depending on the process model. Browser -// objects created indirectly via the JavaScript window.open function or -// targeted links will share the same render process and the same request -// context as the source browser. When running in single-process mode there is -// only a single render process (the main process) and so all browsers created -// in single-process mode will share the same request context. This will be the -// first request context passed into a cef_browser_host_t static factory -// function and all other request context objects will be ignored. -// -#[repr(C)] -pub struct _cef_request_context_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is pointing to the same context as |that| - // object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_request_context_t, - other: *mut interfaces::cef_request_context_t) -> libc::c_int>, - - // - // Returns true (1) if this object is sharing the same storage as |that| - // object. - // - pub is_sharing_with: Option<extern "C" fn(this: *mut cef_request_context_t, - other: *mut interfaces::cef_request_context_t) -> libc::c_int>, - - // - // Returns true (1) if this object is the global context. The global context - // is used by default when creating a browser or URL request with a NULL - // context argument. - // - pub is_global: Option<extern "C" fn( - this: *mut cef_request_context_t) -> libc::c_int>, - - // - // Returns the handler for this context if any. - // - pub get_handler: Option<extern "C" fn( - this: *mut cef_request_context_t) -> *mut interfaces::cef_request_context_handler_t>, - - // - // Returns the cache path for this object. If NULL an "incognito mode" in- - // memory cache is being used. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_cache_path: Option<extern "C" fn( - this: *mut cef_request_context_t) -> types::cef_string_userfree_t>, - - // - // Returns the default cookie manager for this object. This will be the global - // cookie manager if this object is the global request context. Otherwise, - // this will be the default cookie manager used when this request context does - // not receive a value via cef_request_tContextHandler::get_cookie_manager(). - // If |callback| is non-NULL it will be executed asnychronously on the IO - // thread after the manager's storage has been initialized. - // - pub get_default_cookie_manager: Option<extern "C" fn( - this: *mut cef_request_context_t, - callback: *mut interfaces::cef_completion_callback_t) -> *mut interfaces::cef_cookie_manager_t>, - - // - // Register a scheme handler factory for the specified |scheme_name| and - // optional |domain_name|. An NULL |domain_name| value for a standard scheme - // will cause the factory to match all domain names. The |domain_name| value - // will be ignored for non-standard schemes. If |scheme_name| is a built-in - // scheme and no handler is returned by |factory| then the built-in scheme - // handler factory will be called. If |scheme_name| is a custom scheme then - // you must also implement the cef_app_t::on_register_custom_schemes() - // function in all processes. This function may be called multiple times to - // change or remove the factory that matches the specified |scheme_name| and - // optional |domain_name|. Returns false (0) if an error occurs. This function - // may be called on any thread in the browser process. - // - pub register_scheme_handler_factory: Option<extern "C" fn( - this: *mut cef_request_context_t, scheme_name: *const types::cef_string_t, - domain_name: *const types::cef_string_t, - factory: *mut interfaces::cef_scheme_handler_factory_t) -> libc::c_int>, - - // - // Clear all registered scheme handler factories. Returns false (0) on error. - // This function may be called on any thread in the browser process. - // - pub clear_scheme_handler_factories: Option<extern "C" fn( - this: *mut cef_request_context_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_request_context_t = _cef_request_context_t; - - -// -// A request context provides request handling for a set of related browser or -// URL request objects. A request context can be specified when creating a new -// browser via the cef_browser_host_t static factory functions or when creating -// a new URL request via the cef_urlrequest_t static factory functions. Browser -// objects with different request contexts will never be hosted in the same -// render process. Browser objects with the same request context may or may not -// be hosted in the same render process depending on the process model. Browser -// objects created indirectly via the JavaScript window.open function or -// targeted links will share the same render process and the same request -// context as the source browser. When running in single-process mode there is -// only a single render process (the main process) and so all browsers created -// in single-process mode will share the same request context. This will be the -// first request context passed into a cef_browser_host_t static factory -// function and all other request context objects will be ignored. -// -pub struct CefRequestContext { - c_object: *mut cef_request_context_t, -} - -impl Clone for CefRequestContext { - fn clone(&self) -> CefRequestContext{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRequestContext { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRequestContext { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRequestContext { - pub unsafe fn from_c_object(c_object: *mut cef_request_context_t) -> CefRequestContext { - CefRequestContext { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_t) -> CefRequestContext { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRequestContext { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_request_context_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_request_context_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is pointing to the same context as |that| - // object. - // - pub fn is_same(&self, other: interfaces::CefRequestContext) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(other))) - } - } - - // - // Returns true (1) if this object is sharing the same storage as |that| - // object. - // - pub fn is_sharing_with(&self, - other: interfaces::CefRequestContext) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_sharing_with.unwrap())( - self.c_object, - CefWrap::to_c(other))) - } - } - - // - // Returns true (1) if this object is the global context. The global context - // is used by default when creating a browser or URL request with a NULL - // context argument. - // - pub fn is_global(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_global.unwrap())( - self.c_object)) - } - } - - // - // Returns the handler for this context if any. - // - pub fn get_handler(&self) -> interfaces::CefRequestContextHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_handler.unwrap())( - self.c_object)) - } - } - - // - // Returns the cache path for this object. If NULL an "incognito mode" in- - // memory cache is being used. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_cache_path(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_cache_path.unwrap())( - self.c_object)) - } - } - - // - // Returns the default cookie manager for this object. This will be the global - // cookie manager if this object is the global request context. Otherwise, - // this will be the default cookie manager used when this request context does - // not receive a value via cef_request_tContextHandler::get_cookie_manager(). - // If |callback| is non-NULL it will be executed asnychronously on the IO - // thread after the manager's storage has been initialized. - // - pub fn get_default_cookie_manager(&self, - callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_default_cookie_manager.unwrap())( - self.c_object, - CefWrap::to_c(callback))) - } - } - - // - // Register a scheme handler factory for the specified |scheme_name| and - // optional |domain_name|. An NULL |domain_name| value for a standard scheme - // will cause the factory to match all domain names. The |domain_name| value - // will be ignored for non-standard schemes. If |scheme_name| is a built-in - // scheme and no handler is returned by |factory| then the built-in scheme - // handler factory will be called. If |scheme_name| is a custom scheme then - // you must also implement the cef_app_t::on_register_custom_schemes() - // function in all processes. This function may be called multiple times to - // change or remove the factory that matches the specified |scheme_name| and - // optional |domain_name|. Returns false (0) if an error occurs. This function - // may be called on any thread in the browser process. - // - pub fn register_scheme_handler_factory(&self, scheme_name: &[u16], - domain_name: &[u16], - factory: interfaces::CefSchemeHandlerFactory) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).register_scheme_handler_factory.unwrap())( - self.c_object, - CefWrap::to_c(scheme_name), - CefWrap::to_c(domain_name), - CefWrap::to_c(factory))) - } - } - - // - // Clear all registered scheme handler factories. Returns false (0) on error. - // This function may be called on any thread in the browser process. - // - pub fn clear_scheme_handler_factories(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clear_scheme_handler_factories.unwrap())( - self.c_object)) - } - } - - // - // Returns the global context object. - // - pub fn get_global_context() -> interfaces::CefRequestContext { - unsafe { - CefWrap::to_rust( - ::request_context::cef_request_context_get_global_context( -)) - } - } - - // - // Creates a new context object with the specified |settings| and optional - // |handler|. - // - pub fn create_context(settings: &interfaces::CefRequestContextSettings, - handler: interfaces::CefRequestContextHandler) -> interfaces::CefRequestContext { - unsafe { - CefWrap::to_rust( - ::request_context::cef_request_context_create_context( - CefWrap::to_c(settings), - CefWrap::to_c(handler))) - } - } - - // - // Creates a new context object that shares storage with |other| and uses an - // optional |handler|. - // - pub fn create_context_shared(other: interfaces::CefRequestContext, - handler: interfaces::CefRequestContextHandler) -> interfaces::CefRequestContext { - unsafe { - CefWrap::to_rust( - ::request_context::cef_request_context_create_context_shared( - CefWrap::to_c(other), - CefWrap::to_c(handler))) - } - } -} - -impl CefWrap<*mut cef_request_context_t> for CefRequestContext { - fn to_c(rust_object: CefRequestContext) -> *mut cef_request_context_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_request_context_t) -> CefRequestContext { - CefRequestContext::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_request_context_t> for Option<CefRequestContext> { - fn to_c(rust_object: Option<CefRequestContext>) -> *mut cef_request_context_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_request_context_t) -> Option<CefRequestContext> { - if c_object.is_null() { - None - } else { - Some(CefRequestContext::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_request_context_handler.rs b/ports/cef/interfaces/cef_request_context_handler.rs deleted file mode 100644 index a3ae82d1b80..00000000000 --- a/ports/cef/interfaces/cef_request_context_handler.rs +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to provide handler implementations. The handler -// instance will not be released until all objects related to the context have -// been destroyed. -// -#[repr(C)] -pub struct _cef_request_context_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called on the IO thread to retrieve the cookie manager. If this function - // returns NULL the default cookie manager retrievable via - // cef_request_tContext::get_default_cookie_manager() will be used. - // - pub get_cookie_manager: Option<extern "C" fn( - this: *mut cef_request_context_handler_t) -> *mut interfaces::cef_cookie_manager_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_request_context_handler_t = _cef_request_context_handler_t; - - -// -// Implement this structure to provide handler implementations. The handler -// instance will not be released until all objects related to the context have -// been destroyed. -// -pub struct CefRequestContextHandler { - c_object: *mut cef_request_context_handler_t, -} - -impl Clone for CefRequestContextHandler { - fn clone(&self) -> CefRequestContextHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRequestContextHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRequestContextHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRequestContextHandler { - pub unsafe fn from_c_object(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler { - CefRequestContextHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRequestContextHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_request_context_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_request_context_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called on the IO thread to retrieve the cookie manager. If this function - // returns NULL the default cookie manager retrievable via - // cef_request_tContext::get_default_cookie_manager() will be used. - // - pub fn get_cookie_manager(&self) -> interfaces::CefCookieManager { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_cookie_manager.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_request_context_handler_t> for CefRequestContextHandler { - fn to_c(rust_object: CefRequestContextHandler) -> *mut cef_request_context_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler { - CefRequestContextHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_request_context_handler_t> for Option<CefRequestContextHandler> { - fn to_c(rust_object: Option<CefRequestContextHandler>) -> *mut cef_request_context_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_request_context_handler_t) -> Option<CefRequestContextHandler> { - if c_object.is_null() { - None - } else { - Some(CefRequestContextHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_request_handler.rs b/ports/cef/interfaces/cef_request_handler.rs deleted file mode 100644 index 0ebeff40826..00000000000 --- a/ports/cef/interfaces/cef_request_handler.rs +++ /dev/null @@ -1,837 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Callback structure used for asynchronous continuation of url requests. -// -#[repr(C)] -pub struct _cef_request_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Continue the url request. If |allow| is true (1) the request will be - // continued. Otherwise, the request will be canceled. - // - pub cont: Option<extern "C" fn(this: *mut cef_request_callback_t, - allow: libc::c_int) -> ()>, - - // - // Cancel the url request. - // - pub cancel: Option<extern "C" fn(this: *mut cef_request_callback_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_request_callback_t = _cef_request_callback_t; - - -// -// Callback structure used for asynchronous continuation of url requests. -// -pub struct CefRequestCallback { - c_object: *mut cef_request_callback_t, -} - -impl Clone for CefRequestCallback { - fn clone(&self) -> CefRequestCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRequestCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRequestCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRequestCallback { - pub unsafe fn from_c_object(c_object: *mut cef_request_callback_t) -> CefRequestCallback { - CefRequestCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_request_callback_t) -> CefRequestCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRequestCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_request_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_request_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Continue the url request. If |allow| is true (1) the request will be - // continued. Otherwise, the request will be canceled. - // - pub fn cont(&self, allow: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cont.unwrap())( - self.c_object, - CefWrap::to_c(allow))) - } - } - - // - // Cancel the url request. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_request_callback_t> for CefRequestCallback { - fn to_c(rust_object: CefRequestCallback) -> *mut cef_request_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_request_callback_t) -> CefRequestCallback { - CefRequestCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_request_callback_t> for Option<CefRequestCallback> { - fn to_c(rust_object: Option<CefRequestCallback>) -> *mut cef_request_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_request_callback_t) -> Option<CefRequestCallback> { - if c_object.is_null() { - None - } else { - Some(CefRequestCallback::from_c_object_addref(c_object)) - } - } -} - - -// -// Implement this structure to handle events related to browser requests. The -// functions of this structure will be called on the thread indicated. -// -#[repr(C)] -pub struct _cef_request_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called on the UI thread before browser navigation. Return true (1) to - // cancel the navigation or false (0) to allow the navigation to proceed. The - // |request| object cannot be modified in this callback. - // cef_load_handler_t::OnLoadingStateChange will be called twice in all cases. - // If the navigation is allowed cef_load_handler_t::OnLoadStart and - // cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled - // cef_load_handler_t::OnLoadError will be called with an |errorCode| value of - // ERR_ABORTED. - // - pub on_before_browse: Option<extern "C" fn(this: *mut cef_request_handler_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t, - is_redirect: libc::c_int) -> libc::c_int>, - - // - // Called on the UI thread before OnBeforeBrowse in certain limited cases - // where navigating a new or different browser might be desirable. This - // includes user-initiated navigation that might open in a special way (e.g. - // links clicked via middle-click or ctrl + left-click) and certain types of - // cross-origin navigation initiated from the renderer process (e.g. - // navigating the top-level frame to/from a file URL). The |browser| and - // |frame| values represent the source of the navigation. The - // |target_disposition| value indicates where the user intended to navigate - // the browser based on standard Chromium behaviors (e.g. current tab, new - // tab, etc). The |user_gesture| value will be true (1) if the browser - // navigated via explicit user gesture (e.g. clicking a link) or false (0) if - // it navigated automatically (e.g. via the DomContentLoaded event). Return - // true (1) to cancel the navigation or false (0) to allow the navigation to - // proceed in the source browser's top-level frame. - // - pub on_open_urlfrom_tab: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - target_url: *const types::cef_string_t, - target_disposition: types::cef_window_open_disposition_t, - user_gesture: libc::c_int) -> libc::c_int>, - - // - // Called on the IO thread before a resource request is loaded. The |request| - // object may be modified. Return RV_CONTINUE to continue the request - // immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback:: - // cont() at a later time to continue or cancel the request asynchronously. - // Return RV_CANCEL to cancel the request immediately. - // - // - pub on_before_resource_load: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t, - callback: *mut interfaces::cef_request_callback_t) -> types::cef_return_value_t>, - - // - // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return NULL. To specify a handler for the resource return - // a cef_resource_handler_t object. The |request| object should not be - // modified in this callback. - // - pub get_resource_handler: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t) -> *mut interfaces::cef_resource_handler_t>, - - // - // Called on the IO thread when a resource load is redirected. The |request| - // parameter will contain the old URL and other request-related information. - // The |new_url| parameter will contain the new URL and can be changed if - // desired. The |request| object cannot be modified in this callback. - // - pub on_resource_redirect: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t, - new_url: *mut types::cef_string_t) -> ()>, - - // - // Called on the IO thread when a resource response is received. To allow the - // resource to load normally return false (0). To redirect or retry the - // resource modify |request| (url, headers or post body) and return true (1). - // The |response| object cannot be modified in this callback. - // - pub on_resource_response: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - request: *mut interfaces::cef_request_t, - response: *mut interfaces::cef_response_t) -> libc::c_int>, - - // - // Called on the IO thread when the browser needs credentials from the user. - // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and |port| contains the port number. Return true (1) to continue - // the request and call cef_auth_callback_t::cont() either in this function or - // at a later time when the authentication information is available. Return - // false (0) to cancel the request immediately. - // - pub get_auth_credentials: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, isProxy: libc::c_int, - host: *const types::cef_string_t, port: libc::c_int, - realm: *const types::cef_string_t, scheme: *const types::cef_string_t, - callback: *mut interfaces::cef_auth_callback_t) -> libc::c_int>, - - // - // Called on the IO thread when JavaScript requests a specific storage quota - // size via the webkitStorageInfo.requestQuota function. |origin_url| is the - // origin of the page making the request. |new_size| is the requested quota - // size in bytes. Return true (1) to continue the request and call - // cef_request_tCallback::cont() either in this function or at a later time to - // grant or deny the request. Return false (0) to cancel the request - // immediately. - // - pub on_quota_request: Option<extern "C" fn(this: *mut cef_request_handler_t, - browser: *mut interfaces::cef_browser_t, - origin_url: *const types::cef_string_t, new_size: i64, - callback: *mut interfaces::cef_request_callback_t) -> libc::c_int>, - - // - // Called on the UI thread to handle requests for URLs with an unknown - // protocol component. Set |allow_os_execution| to true (1) to attempt - // execution via the registered OS protocol handler, if any. SECURITY WARNING: - // YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR - // OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. - // - pub on_protocol_execution: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - url: *const types::cef_string_t, - allow_os_execution: *mut libc::c_int) -> ()>, - - // - // Called on the UI thread to handle requests for URLs with an invalid SSL - // certificate. Return true (1) and call cef_request_tCallback::cont() either - // in this function or at a later time to continue or cancel the request. - // Return false (0) to cancel the request immediately. If |callback| is NULL - // the error cannot be recovered from and the request will be canceled - // automatically. If CefSettings.ignore_certificate_errors is set all invalid - // certificates will be accepted without calling this function. - // - pub on_certificate_error: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - cert_error: types::cef_errorcode_t, - request_url: *const types::cef_string_t, - ssl_info: *mut interfaces::cef_sslinfo_t, - callback: *mut interfaces::cef_request_callback_t) -> libc::c_int>, - - // - // Called on the browser process IO thread before a plugin is loaded. Return - // true (1) to block loading of the plugin. - // - pub on_before_plugin_load: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - url: *const types::cef_string_t, policy_url: *const types::cef_string_t, - info: *mut interfaces::cef_web_plugin_info_t) -> libc::c_int>, - - // - // Called on the browser process UI thread when a plugin has crashed. - // |plugin_path| is the path of the plugin that crashed. - // - pub on_plugin_crashed: Option<extern "C" fn(this: *mut cef_request_handler_t, - browser: *mut interfaces::cef_browser_t, - plugin_path: *const types::cef_string_t) -> ()>, - - // - // Called on the browser process UI thread when the render view associated - // with |browser| is ready to receive/handle IPC messages in the render - // process. - // - pub on_render_view_ready: Option<extern "C" fn( - this: *mut cef_request_handler_t, - browser: *mut interfaces::cef_browser_t) -> ()>, - - // - // Called on the browser process UI thread when the render process terminates - // unexpectedly. |status| indicates how the process terminated. - // - pub on_render_process_terminated: Option<extern "C" fn( - this: *mut cef_request_handler_t, browser: *mut interfaces::cef_browser_t, - status: types::cef_termination_status_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_request_handler_t = _cef_request_handler_t; - - -// -// Implement this structure to handle events related to browser requests. The -// functions of this structure will be called on the thread indicated. -// -pub struct CefRequestHandler { - c_object: *mut cef_request_handler_t, -} - -impl Clone for CefRequestHandler { - fn clone(&self) -> CefRequestHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefRequestHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefRequestHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefRequestHandler { - pub unsafe fn from_c_object(c_object: *mut cef_request_handler_t) -> CefRequestHandler { - CefRequestHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_request_handler_t) -> CefRequestHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefRequestHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_request_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_request_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called on the UI thread before browser navigation. Return true (1) to - // cancel the navigation or false (0) to allow the navigation to proceed. The - // |request| object cannot be modified in this callback. - // cef_load_handler_t::OnLoadingStateChange will be called twice in all cases. - // If the navigation is allowed cef_load_handler_t::OnLoadStart and - // cef_load_handler_t::OnLoadEnd will be called. If the navigation is canceled - // cef_load_handler_t::OnLoadError will be called with an |errorCode| value of - // ERR_ABORTED. - // - pub fn on_before_browse(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, request: interfaces::CefRequest, - is_redirect: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_browse.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request), - CefWrap::to_c(is_redirect))) - } - } - - // - // Called on the UI thread before OnBeforeBrowse in certain limited cases - // where navigating a new or different browser might be desirable. This - // includes user-initiated navigation that might open in a special way (e.g. - // links clicked via middle-click or ctrl + left-click) and certain types of - // cross-origin navigation initiated from the renderer process (e.g. - // navigating the top-level frame to/from a file URL). The |browser| and - // |frame| values represent the source of the navigation. The - // |target_disposition| value indicates where the user intended to navigate - // the browser based on standard Chromium behaviors (e.g. current tab, new - // tab, etc). The |user_gesture| value will be true (1) if the browser - // navigated via explicit user gesture (e.g. clicking a link) or false (0) if - // it navigated automatically (e.g. via the DomContentLoaded event). Return - // true (1) to cancel the navigation or false (0) to allow the navigation to - // proceed in the source browser's top-level frame. - // - pub fn on_open_urlfrom_tab(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, target_url: &[u16], - target_disposition: types::cef_window_open_disposition_t, - user_gesture: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_open_urlfrom_tab.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(target_url), - CefWrap::to_c(target_disposition), - CefWrap::to_c(user_gesture))) - } - } - - // - // Called on the IO thread before a resource request is loaded. The |request| - // object may be modified. Return RV_CONTINUE to continue the request - // immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback:: - // cont() at a later time to continue or cancel the request asynchronously. - // Return RV_CANCEL to cancel the request immediately. - // - // - pub fn on_before_resource_load(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, request: interfaces::CefRequest, - callback: interfaces::CefRequestCallback) -> types::cef_return_value_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_resource_load.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request), - CefWrap::to_c(callback))) - } - } - - // - // Called on the IO thread before a resource is loaded. To allow the resource - // to load normally return NULL. To specify a handler for the resource return - // a cef_resource_handler_t object. The |request| object should not be - // modified in this callback. - // - pub fn get_resource_handler(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, - request: interfaces::CefRequest) -> interfaces::CefResourceHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_resource_handler.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request))) - } - } - - // - // Called on the IO thread when a resource load is redirected. The |request| - // parameter will contain the old URL and other request-related information. - // The |new_url| parameter will contain the new URL and can be changed if - // desired. The |request| object cannot be modified in this callback. - // - pub fn on_resource_redirect(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, request: interfaces::CefRequest, - new_url: *mut types::cef_string_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_resource_redirect.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request), - CefWrap::to_c(new_url))) - } - } - - // - // Called on the IO thread when a resource response is received. To allow the - // resource to load normally return false (0). To redirect or retry the - // resource modify |request| (url, headers or post body) and return true (1). - // The |response| object cannot be modified in this callback. - // - pub fn on_resource_response(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, request: interfaces::CefRequest, - response: interfaces::CefResponse) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_resource_response.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(request), - CefWrap::to_c(response))) - } - } - - // - // Called on the IO thread when the browser needs credentials from the user. - // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and |port| contains the port number. Return true (1) to continue - // the request and call cef_auth_callback_t::cont() either in this function or - // at a later time when the authentication information is available. Return - // false (0) to cancel the request immediately. - // - pub fn get_auth_credentials(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, isProxy: libc::c_int, host: &[u16], - port: libc::c_int, realm: &[u16], scheme: &[u16], - callback: interfaces::CefAuthCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_auth_credentials.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(isProxy), - CefWrap::to_c(host), - CefWrap::to_c(port), - CefWrap::to_c(realm), - CefWrap::to_c(scheme), - CefWrap::to_c(callback))) - } - } - - // - // Called on the IO thread when JavaScript requests a specific storage quota - // size via the webkitStorageInfo.requestQuota function. |origin_url| is the - // origin of the page making the request. |new_size| is the requested quota - // size in bytes. Return true (1) to continue the request and call - // cef_request_tCallback::cont() either in this function or at a later time to - // grant or deny the request. Return false (0) to cancel the request - // immediately. - // - pub fn on_quota_request(&self, browser: interfaces::CefBrowser, - origin_url: &[u16], new_size: i64, - callback: interfaces::CefRequestCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_quota_request.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(origin_url), - CefWrap::to_c(new_size), - CefWrap::to_c(callback))) - } - } - - // - // Called on the UI thread to handle requests for URLs with an unknown - // protocol component. Set |allow_os_execution| to true (1) to attempt - // execution via the registered OS protocol handler, if any. SECURITY WARNING: - // YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR - // OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION. - // - pub fn on_protocol_execution(&self, browser: interfaces::CefBrowser, - url: &[u16], allow_os_execution: &mut libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_protocol_execution.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(url), - CefWrap::to_c(allow_os_execution))) - } - } - - // - // Called on the UI thread to handle requests for URLs with an invalid SSL - // certificate. Return true (1) and call cef_request_tCallback::cont() either - // in this function or at a later time to continue or cancel the request. - // Return false (0) to cancel the request immediately. If |callback| is NULL - // the error cannot be recovered from and the request will be canceled - // automatically. If CefSettings.ignore_certificate_errors is set all invalid - // certificates will be accepted without calling this function. - // - pub fn on_certificate_error(&self, browser: interfaces::CefBrowser, - cert_error: types::cef_errorcode_t, request_url: &[u16], - ssl_info: interfaces::CefSSLInfo, - callback: interfaces::CefRequestCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_certificate_error.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(cert_error), - CefWrap::to_c(request_url), - CefWrap::to_c(ssl_info), - CefWrap::to_c(callback))) - } - } - - // - // Called on the browser process IO thread before a plugin is loaded. Return - // true (1) to block loading of the plugin. - // - pub fn on_before_plugin_load(&self, browser: interfaces::CefBrowser, - url: &[u16], policy_url: &[u16], - info: interfaces::CefWebPluginInfo) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_before_plugin_load.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(url), - CefWrap::to_c(policy_url), - CefWrap::to_c(info))) - } - } - - // - // Called on the browser process UI thread when a plugin has crashed. - // |plugin_path| is the path of the plugin that crashed. - // - pub fn on_plugin_crashed(&self, browser: interfaces::CefBrowser, - plugin_path: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_plugin_crashed.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(plugin_path))) - } - } - - // - // Called on the browser process UI thread when the render view associated - // with |browser| is ready to receive/handle IPC messages in the render - // process. - // - pub fn on_render_view_ready(&self, browser: interfaces::CefBrowser) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_render_view_ready.unwrap())( - self.c_object, - CefWrap::to_c(browser))) - } - } - - // - // Called on the browser process UI thread when the render process terminates - // unexpectedly. |status| indicates how the process terminated. - // - pub fn on_render_process_terminated(&self, browser: interfaces::CefBrowser, - status: types::cef_termination_status_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_render_process_terminated.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(status))) - } - } -} - -impl CefWrap<*mut cef_request_handler_t> for CefRequestHandler { - fn to_c(rust_object: CefRequestHandler) -> *mut cef_request_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_request_handler_t) -> CefRequestHandler { - CefRequestHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_request_handler_t> for Option<CefRequestHandler> { - fn to_c(rust_object: Option<CefRequestHandler>) -> *mut cef_request_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_request_handler_t) -> Option<CefRequestHandler> { - if c_object.is_null() { - None - } else { - Some(CefRequestHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_resource_bundle_handler.rs b/ports/cef/interfaces/cef_resource_bundle_handler.rs deleted file mode 100644 index 50f4e904405..00000000000 --- a/ports/cef/interfaces/cef_resource_bundle_handler.rs +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to implement a custom resource bundle structure. The functions -// of this structure may be called on multiple threads. -// -#[repr(C)] -pub struct _cef_resource_bundle_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called to retrieve a localized translation for the string specified by - // |message_id|. To provide the translation set |string| to the translation - // string and return true (1). To use the default translation return false - // (0). Supported message IDs are listed in cef_pack_strings.h. - // - pub get_localized_string: Option<extern "C" fn( - this: *mut cef_resource_bundle_handler_t, message_id: libc::c_int, - string: *mut types::cef_string_t) -> libc::c_int>, - - // - // Called to retrieve data for the resource specified by |resource_id|. To - // provide the resource data set |data| and |data_size| to the data pointer - // and size respectively and return true (1). To use the default resource data - // return false (0). The resource data will not be copied and must remain - // resident in memory. Supported resource IDs are listed in - // cef_pack_resources.h. - // - pub get_data_resource: Option<extern "C" fn( - this: *mut cef_resource_bundle_handler_t, resource_id: libc::c_int, - data: *mut *mut libc::c_void, - data_size: *mut libc::size_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_resource_bundle_handler_t = _cef_resource_bundle_handler_t; - - -// -// Structure used to implement a custom resource bundle structure. The functions -// of this structure may be called on multiple threads. -// -pub struct CefResourceBundleHandler { - c_object: *mut cef_resource_bundle_handler_t, -} - -impl Clone for CefResourceBundleHandler { - fn clone(&self) -> CefResourceBundleHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefResourceBundleHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefResourceBundleHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefResourceBundleHandler { - pub unsafe fn from_c_object(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler { - CefResourceBundleHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefResourceBundleHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_resource_bundle_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_resource_bundle_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called to retrieve a localized translation for the string specified by - // |message_id|. To provide the translation set |string| to the translation - // string and return true (1). To use the default translation return false - // (0). Supported message IDs are listed in cef_pack_strings.h. - // - pub fn get_localized_string(&self, message_id: libc::c_int, - string: *mut types::cef_string_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_localized_string.unwrap())( - self.c_object, - CefWrap::to_c(message_id), - CefWrap::to_c(string))) - } - } - - // - // Called to retrieve data for the resource specified by |resource_id|. To - // provide the resource data set |data| and |data_size| to the data pointer - // and size respectively and return true (1). To use the default resource data - // return false (0). The resource data will not be copied and must remain - // resident in memory. Supported resource IDs are listed in - // cef_pack_resources.h. - // - pub fn get_data_resource(&self, resource_id: libc::c_int, - data: &mut *mut libc::c_void, - data_size: &mut libc::size_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_data_resource.unwrap())( - self.c_object, - CefWrap::to_c(resource_id), - CefWrap::to_c(data), - CefWrap::to_c(data_size))) - } - } -} - -impl CefWrap<*mut cef_resource_bundle_handler_t> for CefResourceBundleHandler { - fn to_c(rust_object: CefResourceBundleHandler) -> *mut cef_resource_bundle_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler { - CefResourceBundleHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_resource_bundle_handler_t> for Option<CefResourceBundleHandler> { - fn to_c(rust_object: Option<CefResourceBundleHandler>) -> *mut cef_resource_bundle_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_resource_bundle_handler_t) -> Option<CefResourceBundleHandler> { - if c_object.is_null() { - None - } else { - Some(CefResourceBundleHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_resource_handler.rs b/ports/cef/interfaces/cef_resource_handler.rs deleted file mode 100644 index 27bbd9520f4..00000000000 --- a/ports/cef/interfaces/cef_resource_handler.rs +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to implement a custom request handler structure. The functions -// of this structure will always be called on the IO thread. -// -#[repr(C)] -pub struct _cef_resource_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Begin processing the request. To handle the request return true (1) and - // call cef_callback_t::cont() once the response header information is - // available (cef_callback_t::cont() can also be called from inside this - // function if header information is available immediately). To cancel the - // request return false (0). - // - pub process_request: Option<extern "C" fn(this: *mut cef_resource_handler_t, - request: *mut interfaces::cef_request_t, - callback: *mut interfaces::cef_callback_t) -> libc::c_int>, - - // - // Retrieve response header information. If the response length is not known - // set |response_length| to -1 and read_response() will be called until it - // returns false (0). If the response length is known set |response_length| to - // a positive value and read_response() will be called until it returns false - // (0) or the specified number of bytes have been read. Use the |response| - // object to set the mime type, http status code and other optional header - // values. To redirect the request to a new URL set |redirectUrl| to the new - // URL. - // - pub get_response_headers: Option<extern "C" fn( - this: *mut cef_resource_handler_t, - response: *mut interfaces::cef_response_t, response_length: *mut i64, - redirectUrl: *mut types::cef_string_t) -> ()>, - - // - // Read response data. If data is available immediately copy up to - // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of - // bytes copied, and return true (1). To read the data at a later time set - // |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the - // data is available. To indicate response completion return false (0). - // - pub read_response: Option<extern "C" fn(this: *mut cef_resource_handler_t, - data_out: *mut (), bytes_to_read: libc::c_int, - bytes_read: *mut libc::c_int, - callback: *mut interfaces::cef_callback_t) -> libc::c_int>, - - // - // Return true (1) if the specified cookie can be sent with the request or - // false (0) otherwise. If false (0) is returned for any cookie then no - // cookies will be sent with the request. - // - pub can_get_cookie: Option<extern "C" fn(this: *mut cef_resource_handler_t, - cookie: *const interfaces::cef_cookie_t) -> libc::c_int>, - - // - // Return true (1) if the specified cookie returned with the response can be - // set or false (0) otherwise. - // - pub can_set_cookie: Option<extern "C" fn(this: *mut cef_resource_handler_t, - cookie: *const interfaces::cef_cookie_t) -> libc::c_int>, - - // - // Request processing has been canceled. - // - pub cancel: Option<extern "C" fn(this: *mut cef_resource_handler_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_resource_handler_t = _cef_resource_handler_t; - - -// -// Structure used to implement a custom request handler structure. The functions -// of this structure will always be called on the IO thread. -// -pub struct CefResourceHandler { - c_object: *mut cef_resource_handler_t, -} - -impl Clone for CefResourceHandler { - fn clone(&self) -> CefResourceHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefResourceHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefResourceHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefResourceHandler { - pub unsafe fn from_c_object(c_object: *mut cef_resource_handler_t) -> CefResourceHandler { - CefResourceHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_handler_t) -> CefResourceHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefResourceHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_resource_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_resource_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Begin processing the request. To handle the request return true (1) and - // call cef_callback_t::cont() once the response header information is - // available (cef_callback_t::cont() can also be called from inside this - // function if header information is available immediately). To cancel the - // request return false (0). - // - pub fn process_request(&self, request: interfaces::CefRequest, - callback: interfaces::CefCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).process_request.unwrap())( - self.c_object, - CefWrap::to_c(request), - CefWrap::to_c(callback))) - } - } - - // - // Retrieve response header information. If the response length is not known - // set |response_length| to -1 and read_response() will be called until it - // returns false (0). If the response length is known set |response_length| to - // a positive value and read_response() will be called until it returns false - // (0) or the specified number of bytes have been read. Use the |response| - // object to set the mime type, http status code and other optional header - // values. To redirect the request to a new URL set |redirectUrl| to the new - // URL. - // - pub fn get_response_headers(&self, response: interfaces::CefResponse, - response_length: &mut i64, redirectUrl: *mut types::cef_string_t) -> ( - ) { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_response_headers.unwrap())( - self.c_object, - CefWrap::to_c(response), - CefWrap::to_c(response_length), - CefWrap::to_c(redirectUrl))) - } - } - - // - // Read response data. If data is available immediately copy up to - // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of - // bytes copied, and return true (1). To read the data at a later time set - // |bytes_read| to 0, return true (1) and call cef_callback_t::cont() when the - // data is available. To indicate response completion return false (0). - // - pub fn read_response(&self, data_out: &mut (), bytes_to_read: libc::c_int, - bytes_read: &mut libc::c_int, - callback: interfaces::CefCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).read_response.unwrap())( - self.c_object, - CefWrap::to_c(data_out), - CefWrap::to_c(bytes_to_read), - CefWrap::to_c(bytes_read), - CefWrap::to_c(callback))) - } - } - - // - // Return true (1) if the specified cookie can be sent with the request or - // false (0) otherwise. If false (0) is returned for any cookie then no - // cookies will be sent with the request. - // - pub fn can_get_cookie(&self, cookie: &interfaces::CefCookie) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).can_get_cookie.unwrap())( - self.c_object, - CefWrap::to_c(cookie))) - } - } - - // - // Return true (1) if the specified cookie returned with the response can be - // set or false (0) otherwise. - // - pub fn can_set_cookie(&self, cookie: &interfaces::CefCookie) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).can_set_cookie.unwrap())( - self.c_object, - CefWrap::to_c(cookie))) - } - } - - // - // Request processing has been canceled. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_resource_handler_t> for CefResourceHandler { - fn to_c(rust_object: CefResourceHandler) -> *mut cef_resource_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_resource_handler_t) -> CefResourceHandler { - CefResourceHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_resource_handler_t> for Option<CefResourceHandler> { - fn to_c(rust_object: Option<CefResourceHandler>) -> *mut cef_resource_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_resource_handler_t) -> Option<CefResourceHandler> { - if c_object.is_null() { - None - } else { - Some(CefResourceHandler::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_response.rs b/ports/cef/interfaces/cef_response.rs deleted file mode 100644 index bc61f60d0da..00000000000 --- a/ports/cef/interfaces/cef_response.rs +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to represent a web response. The functions of this structure -// may be called on any thread. -// -#[repr(C)] -pub struct _cef_response_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is read-only. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_response_t) -> libc::c_int>, - - // - // Get the response status code. - // - pub get_status: Option<extern "C" fn( - this: *mut cef_response_t) -> libc::c_int>, - - // - // Set the response status code. - // - pub set_status: Option<extern "C" fn(this: *mut cef_response_t, - status: libc::c_int) -> ()>, - - // - // Get the response status text. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_status_text: Option<extern "C" fn( - this: *mut cef_response_t) -> types::cef_string_userfree_t>, - - // - // Set the response status text. - // - pub set_status_text: Option<extern "C" fn(this: *mut cef_response_t, - statusText: *const types::cef_string_t) -> ()>, - - // - // Get the response mime type. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_mime_type: Option<extern "C" fn( - this: *mut cef_response_t) -> types::cef_string_userfree_t>, - - // - // Set the response mime type. - // - pub set_mime_type: Option<extern "C" fn(this: *mut cef_response_t, - mimeType: *const types::cef_string_t) -> ()>, - - // - // Get the value for the specified response header field. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_header: Option<extern "C" fn(this: *mut cef_response_t, - name: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Get all response header fields. - // - pub get_header_map: Option<extern "C" fn(this: *mut cef_response_t, - headerMap: types::cef_string_multimap_t) -> ()>, - - // - // Set all response header fields. - // - pub set_header_map: Option<extern "C" fn(this: *mut cef_response_t, - headerMap: types::cef_string_multimap_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_response_t = _cef_response_t; - - -// -// Structure used to represent a web response. The functions of this structure -// may be called on any thread. -// -pub struct CefResponse { - c_object: *mut cef_response_t, -} - -impl Clone for CefResponse { - fn clone(&self) -> CefResponse{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefResponse { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefResponse { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefResponse { - pub unsafe fn from_c_object(c_object: *mut cef_response_t) -> CefResponse { - CefResponse { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_response_t) -> CefResponse { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefResponse { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_response_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_response_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is read-only. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Get the response status code. - // - pub fn get_status(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_status.unwrap())( - self.c_object)) - } - } - - // - // Set the response status code. - // - pub fn set_status(&self, status: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_status.unwrap())( - self.c_object, - CefWrap::to_c(status))) - } - } - - // - // Get the response status text. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_status_text(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_status_text.unwrap())( - self.c_object)) - } - } - - // - // Set the response status text. - // - pub fn set_status_text(&self, statusText: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_status_text.unwrap())( - self.c_object, - CefWrap::to_c(statusText))) - } - } - - // - // Get the response mime type. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_mime_type(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_mime_type.unwrap())( - self.c_object)) - } - } - - // - // Set the response mime type. - // - pub fn set_mime_type(&self, mimeType: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_mime_type.unwrap())( - self.c_object, - CefWrap::to_c(mimeType))) - } - } - - // - // Get the value for the specified response header field. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_header(&self, name: &[u16]) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_header.unwrap())( - self.c_object, - CefWrap::to_c(name))) - } - } - - // - // Get all response header fields. - // - pub fn get_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_header_map.unwrap())( - self.c_object, - CefWrap::to_c(headerMap))) - } - } - - // - // Set all response header fields. - // - pub fn set_header_map(&self, headerMap: HashMap<String,Vec<String>>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_header_map.unwrap())( - self.c_object, - CefWrap::to_c(headerMap))) - } - } - - // - // Create a new cef_response_t object. - // - pub fn create() -> interfaces::CefResponse { - unsafe { - CefWrap::to_rust( - ::response::cef_response_create( -)) - } - } -} - -impl CefWrap<*mut cef_response_t> for CefResponse { - fn to_c(rust_object: CefResponse) -> *mut cef_response_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_response_t) -> CefResponse { - CefResponse::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_response_t> for Option<CefResponse> { - fn to_c(rust_object: Option<CefResponse>) -> *mut cef_response_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_response_t) -> Option<CefResponse> { - if c_object.is_null() { - None - } else { - Some(CefResponse::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_scheme.rs b/ports/cef/interfaces/cef_scheme.rs deleted file mode 100644 index db65269d343..00000000000 --- a/ports/cef/interfaces/cef_scheme.rs +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure that manages custom scheme registrations. -// -#[repr(C)] -pub struct _cef_scheme_registrar_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Register a custom scheme. This function should not be called for the built- - // in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. - // - // If |is_standard| is true (1) the scheme will be treated as a standard - // scheme. Standard schemes are subject to URL canonicalization and parsing - // rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 - // available at http://www.ietf.org/rfc/rfc1738.txt - // - // In particular, the syntax for standard scheme URLs must be of the form: - // <pre> - // [scheme]://[username]:[password]@[host]:[port]/[url-path] - // </pre> Standard scheme URLs must have a host component that is a fully - // qualified domain name as defined in Section 3.5 of RFC 1034 [13] and - // Section 2.1 of RFC 1123. These URLs will be canonicalized to - // "scheme://host/path" in the simplest case and - // "scheme://username:password@host:port/path" in the most explicit case. For - // example, "scheme:host/path" and "scheme:///host/path" will both be - // canonicalized to "scheme://host/path". The origin of a standard scheme URL - // is the combination of scheme, host and port (i.e., "scheme://host:port" in - // the most explicit case). - // - // For non-standard scheme URLs only the "scheme:" component is parsed and - // canonicalized. The remainder of the URL will be passed to the handler as- - // is. For example, "scheme:///some%20text" will remain the same. Non-standard - // scheme URLs cannot be used as a target for form submission. - // - // If |is_local| is true (1) the scheme will be treated as local (i.e., with - // the same security rules as those applied to "file" URLs). Normal pages - // cannot link to or access local URLs. Also, by default, local URLs can only - // perform XMLHttpRequest calls to the same URL (origin + path) that - // originated the request. To allow XMLHttpRequest calls from a local URL to - // other URLs with the same origin set the - // CefSettings.file_access_from_file_urls_allowed value to true (1). To allow - // XMLHttpRequest calls from a local URL to all origins set the - // CefSettings.universal_access_from_file_urls_allowed value to true (1). - // - // If |is_display_isolated| is true (1) the scheme will be treated as display- - // isolated. This means that pages cannot display these URLs unless they are - // from the same scheme. For example, pages in another origin cannot create - // iframes or hyperlinks to URLs with this scheme. - // - // This function may be called on any thread. It should only be called once - // per unique |scheme_name| value. If |scheme_name| is already registered or - // if an error occurs this function will return false (0). - // - pub add_custom_scheme: Option<extern "C" fn(this: *mut cef_scheme_registrar_t, - scheme_name: *const types::cef_string_t, is_standard: libc::c_int, - is_local: libc::c_int, is_display_isolated: libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_scheme_registrar_t = _cef_scheme_registrar_t; - - -// -// Structure that manages custom scheme registrations. -// -pub struct CefSchemeRegistrar { - c_object: *mut cef_scheme_registrar_t, -} - -impl Clone for CefSchemeRegistrar { - fn clone(&self) -> CefSchemeRegistrar{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefSchemeRegistrar { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefSchemeRegistrar { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefSchemeRegistrar { - pub unsafe fn from_c_object(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar { - CefSchemeRegistrar { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefSchemeRegistrar { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_scheme_registrar_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_scheme_registrar_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Register a custom scheme. This function should not be called for the built- - // in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. - // - // If |is_standard| is true (1) the scheme will be treated as a standard - // scheme. Standard schemes are subject to URL canonicalization and parsing - // rules as defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 - // available at http://www.ietf.org/rfc/rfc1738.txt - // - // In particular, the syntax for standard scheme URLs must be of the form: - // <pre> - // [scheme]://[username]:[password]@[host]:[port]/[url-path] - // </pre> Standard scheme URLs must have a host component that is a fully - // qualified domain name as defined in Section 3.5 of RFC 1034 [13] and - // Section 2.1 of RFC 1123. These URLs will be canonicalized to - // "scheme://host/path" in the simplest case and - // "scheme://username:password@host:port/path" in the most explicit case. For - // example, "scheme:host/path" and "scheme:///host/path" will both be - // canonicalized to "scheme://host/path". The origin of a standard scheme URL - // is the combination of scheme, host and port (i.e., "scheme://host:port" in - // the most explicit case). - // - // For non-standard scheme URLs only the "scheme:" component is parsed and - // canonicalized. The remainder of the URL will be passed to the handler as- - // is. For example, "scheme:///some%20text" will remain the same. Non-standard - // scheme URLs cannot be used as a target for form submission. - // - // If |is_local| is true (1) the scheme will be treated as local (i.e., with - // the same security rules as those applied to "file" URLs). Normal pages - // cannot link to or access local URLs. Also, by default, local URLs can only - // perform XMLHttpRequest calls to the same URL (origin + path) that - // originated the request. To allow XMLHttpRequest calls from a local URL to - // other URLs with the same origin set the - // CefSettings.file_access_from_file_urls_allowed value to true (1). To allow - // XMLHttpRequest calls from a local URL to all origins set the - // CefSettings.universal_access_from_file_urls_allowed value to true (1). - // - // If |is_display_isolated| is true (1) the scheme will be treated as display- - // isolated. This means that pages cannot display these URLs unless they are - // from the same scheme. For example, pages in another origin cannot create - // iframes or hyperlinks to URLs with this scheme. - // - // This function may be called on any thread. It should only be called once - // per unique |scheme_name| value. If |scheme_name| is already registered or - // if an error occurs this function will return false (0). - // - pub fn add_custom_scheme(&self, scheme_name: &[u16], is_standard: libc::c_int, - is_local: libc::c_int, - is_display_isolated: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).add_custom_scheme.unwrap())( - self.c_object, - CefWrap::to_c(scheme_name), - CefWrap::to_c(is_standard), - CefWrap::to_c(is_local), - CefWrap::to_c(is_display_isolated))) - } - } -} - -impl CefWrap<*mut cef_scheme_registrar_t> for CefSchemeRegistrar { - fn to_c(rust_object: CefSchemeRegistrar) -> *mut cef_scheme_registrar_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar { - CefSchemeRegistrar::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_scheme_registrar_t> for Option<CefSchemeRegistrar> { - fn to_c(rust_object: Option<CefSchemeRegistrar>) -> *mut cef_scheme_registrar_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_scheme_registrar_t) -> Option<CefSchemeRegistrar> { - if c_object.is_null() { - None - } else { - Some(CefSchemeRegistrar::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure that creates cef_resource_handler_t instances for handling scheme -// requests. The functions of this structure will always be called on the IO -// thread. -// -#[repr(C)] -pub struct _cef_scheme_handler_factory_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Return a new resource handler instance to handle the request or an NULL - // reference to allow default handling of the request. |browser| and |frame| - // will be the browser window and frame respectively that originated the - // request or NULL if the request did not originate from a browser window (for - // example, if the request came from cef_urlrequest_t). The |request| object - // passed to this function will not contain cookie data. - // - pub create: Option<extern "C" fn(this: *mut cef_scheme_handler_factory_t, - browser: *mut interfaces::cef_browser_t, - frame: *mut interfaces::cef_frame_t, - scheme_name: *const types::cef_string_t, - request: *mut interfaces::cef_request_t) -> *mut interfaces::cef_resource_handler_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_scheme_handler_factory_t = _cef_scheme_handler_factory_t; - - -// -// Structure that creates cef_resource_handler_t instances for handling scheme -// requests. The functions of this structure will always be called on the IO -// thread. -// -pub struct CefSchemeHandlerFactory { - c_object: *mut cef_scheme_handler_factory_t, -} - -impl Clone for CefSchemeHandlerFactory { - fn clone(&self) -> CefSchemeHandlerFactory{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefSchemeHandlerFactory { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefSchemeHandlerFactory { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefSchemeHandlerFactory { - pub unsafe fn from_c_object(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory { - CefSchemeHandlerFactory { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefSchemeHandlerFactory { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_scheme_handler_factory_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_scheme_handler_factory_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Return a new resource handler instance to handle the request or an NULL - // reference to allow default handling of the request. |browser| and |frame| - // will be the browser window and frame respectively that originated the - // request or NULL if the request did not originate from a browser window (for - // example, if the request came from cef_urlrequest_t). The |request| object - // passed to this function will not contain cookie data. - // - pub fn create(&self, browser: interfaces::CefBrowser, - frame: interfaces::CefFrame, scheme_name: &[u16], - request: interfaces::CefRequest) -> interfaces::CefResourceHandler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).create.unwrap())( - self.c_object, - CefWrap::to_c(browser), - CefWrap::to_c(frame), - CefWrap::to_c(scheme_name), - CefWrap::to_c(request))) - } - } -} - -impl CefWrap<*mut cef_scheme_handler_factory_t> for CefSchemeHandlerFactory { - fn to_c(rust_object: CefSchemeHandlerFactory) -> *mut cef_scheme_handler_factory_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory { - CefSchemeHandlerFactory::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_scheme_handler_factory_t> for Option<CefSchemeHandlerFactory> { - fn to_c(rust_object: Option<CefSchemeHandlerFactory>) -> *mut cef_scheme_handler_factory_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_scheme_handler_factory_t) -> Option<CefSchemeHandlerFactory> { - if c_object.is_null() { - None - } else { - Some(CefSchemeHandlerFactory::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_ssl_info.rs b/ports/cef/interfaces/cef_ssl_info.rs deleted file mode 100644 index 9382e7e06e8..00000000000 --- a/ports/cef/interfaces/cef_ssl_info.rs +++ /dev/null @@ -1,629 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure representing the issuer or subject field of an X.509 certificate. -// -#[repr(C)] -pub struct _cef_sslcert_principal_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns a name that can be used to represent the issuer. It tries in this - // order: CN, O and OU and returns the first non-NULL one found. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_display_name: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t) -> types::cef_string_userfree_t>, - - // - // Returns the common name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_common_name: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t) -> types::cef_string_userfree_t>, - - // - // Returns the locality name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_locality_name: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t) -> types::cef_string_userfree_t>, - - // - // Returns the state or province name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_state_or_province_name: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t) -> types::cef_string_userfree_t>, - - // - // Returns the country name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_country_name: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t) -> types::cef_string_userfree_t>, - - // - // Retrieve the list of street addresses. - // - pub get_street_addresses: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t, - addresses: &types::cef_string_list_t) -> ()>, - - // - // Retrieve the list of organization names. - // - pub get_organization_names: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t, names: &types::cef_string_list_t) -> ( - )>, - - // - // Retrieve the list of organization unit names. - // - pub get_organization_unit_names: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t, names: &types::cef_string_list_t) -> ( - )>, - - // - // Retrieve the list of domain components. - // - pub get_domain_components: Option<extern "C" fn( - this: *mut cef_sslcert_principal_t, - components: &types::cef_string_list_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_sslcert_principal_t = _cef_sslcert_principal_t; - - -// -// Structure representing the issuer or subject field of an X.509 certificate. -// -pub struct CefSSLCertPrincipal { - c_object: *mut cef_sslcert_principal_t, -} - -impl Clone for CefSSLCertPrincipal { - fn clone(&self) -> CefSSLCertPrincipal{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefSSLCertPrincipal { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefSSLCertPrincipal { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefSSLCertPrincipal { - pub unsafe fn from_c_object(c_object: *mut cef_sslcert_principal_t) -> CefSSLCertPrincipal { - CefSSLCertPrincipal { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_sslcert_principal_t) -> CefSSLCertPrincipal { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefSSLCertPrincipal { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_sslcert_principal_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_sslcert_principal_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns a name that can be used to represent the issuer. It tries in this - // order: CN, O and OU and returns the first non-NULL one found. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_display_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_display_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the common name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_common_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_common_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the locality name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_locality_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_locality_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the state or province name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_state_or_province_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_state_or_province_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the country name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_country_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_country_name.unwrap())( - self.c_object)) - } - } - - // - // Retrieve the list of street addresses. - // - pub fn get_street_addresses(&self, addresses: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_street_addresses.unwrap())( - self.c_object, - CefWrap::to_c(addresses))) - } - } - - // - // Retrieve the list of organization names. - // - pub fn get_organization_names(&self, names: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_organization_names.unwrap())( - self.c_object, - CefWrap::to_c(names))) - } - } - - // - // Retrieve the list of organization unit names. - // - pub fn get_organization_unit_names(&self, names: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_organization_unit_names.unwrap())( - self.c_object, - CefWrap::to_c(names))) - } - } - - // - // Retrieve the list of domain components. - // - pub fn get_domain_components(&self, components: &Vec<String>) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_domain_components.unwrap())( - self.c_object, - CefWrap::to_c(components))) - } - } -} - -impl CefWrap<*mut cef_sslcert_principal_t> for CefSSLCertPrincipal { - fn to_c(rust_object: CefSSLCertPrincipal) -> *mut cef_sslcert_principal_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_sslcert_principal_t) -> CefSSLCertPrincipal { - CefSSLCertPrincipal::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_sslcert_principal_t> for Option<CefSSLCertPrincipal> { - fn to_c(rust_object: Option<CefSSLCertPrincipal>) -> *mut cef_sslcert_principal_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_sslcert_principal_t) -> Option<CefSSLCertPrincipal> { - if c_object.is_null() { - None - } else { - Some(CefSSLCertPrincipal::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing SSL information. -// -#[repr(C)] -pub struct _cef_sslinfo_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the subject of the X.509 certificate. For HTTPS server certificates - // this represents the web server. The common name of the subject should - // match the host name of the web server. - // - pub get_subject: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> *mut interfaces::cef_sslcert_principal_t>, - - // - // Returns the issuer of the X.509 certificate. - // - pub get_issuer: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> *mut interfaces::cef_sslcert_principal_t>, - - // - // Returns the DER encoded serial number for the X.509 certificate. The value - // possibly includes a leading 00 byte. - // - pub get_serial_number: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the date before which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - // - pub get_valid_start: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> types::cef_time_t>, - - // - // Returns the date after which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - // - pub get_valid_expiry: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> types::cef_time_t>, - - // - // Returns the DER encoded data for the X.509 certificate. - // - pub get_derencoded: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the PEM encoded data for the X.509 certificate. - // - pub get_pemencoded: Option<extern "C" fn( - this: *mut cef_sslinfo_t) -> *mut interfaces::cef_binary_value_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_sslinfo_t = _cef_sslinfo_t; - - -// -// Structure representing SSL information. -// -pub struct CefSSLInfo { - c_object: *mut cef_sslinfo_t, -} - -impl Clone for CefSSLInfo { - fn clone(&self) -> CefSSLInfo{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefSSLInfo { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefSSLInfo { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefSSLInfo { - pub unsafe fn from_c_object(c_object: *mut cef_sslinfo_t) -> CefSSLInfo { - CefSSLInfo { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_sslinfo_t) -> CefSSLInfo { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefSSLInfo { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_sslinfo_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_sslinfo_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the subject of the X.509 certificate. For HTTPS server certificates - // this represents the web server. The common name of the subject should - // match the host name of the web server. - // - pub fn get_subject(&self) -> interfaces::CefSSLCertPrincipal { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_subject.unwrap())( - self.c_object)) - } - } - - // - // Returns the issuer of the X.509 certificate. - // - pub fn get_issuer(&self) -> interfaces::CefSSLCertPrincipal { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_issuer.unwrap())( - self.c_object)) - } - } - - // - // Returns the DER encoded serial number for the X.509 certificate. The value - // possibly includes a leading 00 byte. - // - pub fn get_serial_number(&self) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_serial_number.unwrap())( - self.c_object)) - } - } - - // - // Returns the date before which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - // - pub fn get_valid_start(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_valid_start.unwrap())( - self.c_object)) - } - } - - // - // Returns the date after which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - // - pub fn get_valid_expiry(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_valid_expiry.unwrap())( - self.c_object)) - } - } - - // - // Returns the DER encoded data for the X.509 certificate. - // - pub fn get_derencoded(&self) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_derencoded.unwrap())( - self.c_object)) - } - } - - // - // Returns the PEM encoded data for the X.509 certificate. - // - pub fn get_pemencoded(&self) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_pemencoded.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_sslinfo_t> for CefSSLInfo { - fn to_c(rust_object: CefSSLInfo) -> *mut cef_sslinfo_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_sslinfo_t) -> CefSSLInfo { - CefSSLInfo::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_sslinfo_t> for Option<CefSSLInfo> { - fn to_c(rust_object: Option<CefSSLInfo>) -> *mut cef_sslinfo_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_sslinfo_t) -> Option<CefSSLInfo> { - if c_object.is_null() { - None - } else { - Some(CefSSLInfo::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_stream.rs b/ports/cef/interfaces/cef_stream.rs deleted file mode 100644 index e4e1ede1557..00000000000 --- a/ports/cef/interfaces/cef_stream.rs +++ /dev/null @@ -1,1020 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure the client can implement to provide a custom stream reader. The -// functions of this structure may be called on any thread. -// -#[repr(C)] -pub struct _cef_read_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Read raw binary data. - // - pub read: Option<extern "C" fn(this: *mut cef_read_handler_t, ptr: *mut (), - size: libc::size_t, n: libc::size_t) -> libc::size_t>, - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. - // - pub seek: Option<extern "C" fn(this: *mut cef_read_handler_t, offset: i64, - whence: libc::c_int) -> libc::c_int>, - - // - // Return the current offset position. - // - pub tell: Option<extern "C" fn(this: *mut cef_read_handler_t) -> i64>, - - // - // Return non-zero if at end of file. - // - pub eof: Option<extern "C" fn(this: *mut cef_read_handler_t) -> libc::c_int>, - - // - // Return true (1) if this handler performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the handler from. - // - pub may_block: Option<extern "C" fn( - this: *mut cef_read_handler_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_read_handler_t = _cef_read_handler_t; - - -// -// Structure the client can implement to provide a custom stream reader. The -// functions of this structure may be called on any thread. -// -pub struct CefReadHandler { - c_object: *mut cef_read_handler_t, -} - -impl Clone for CefReadHandler { - fn clone(&self) -> CefReadHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefReadHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefReadHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefReadHandler { - pub unsafe fn from_c_object(c_object: *mut cef_read_handler_t) -> CefReadHandler { - CefReadHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_read_handler_t) -> CefReadHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefReadHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_read_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_read_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Read raw binary data. - // - pub fn read(&self, ptr: &mut (), size: libc::size_t, - n: libc::size_t) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).read.unwrap())( - self.c_object, - CefWrap::to_c(ptr), - CefWrap::to_c(size), - CefWrap::to_c(n))) - } - } - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. - // - pub fn seek(&self, offset: i64, whence: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).seek.unwrap())( - self.c_object, - CefWrap::to_c(offset), - CefWrap::to_c(whence))) - } - } - - // - // Return the current offset position. - // - pub fn tell(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).tell.unwrap())( - self.c_object)) - } - } - - // - // Return non-zero if at end of file. - // - pub fn eof(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).eof.unwrap())( - self.c_object)) - } - } - - // - // Return true (1) if this handler performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the handler from. - // - pub fn may_block(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).may_block.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_read_handler_t> for CefReadHandler { - fn to_c(rust_object: CefReadHandler) -> *mut cef_read_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_read_handler_t) -> CefReadHandler { - CefReadHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_read_handler_t> for Option<CefReadHandler> { - fn to_c(rust_object: Option<CefReadHandler>) -> *mut cef_read_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_read_handler_t) -> Option<CefReadHandler> { - if c_object.is_null() { - None - } else { - Some(CefReadHandler::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to read data from a stream. The functions of this structure -// may be called on any thread. -// -#[repr(C)] -pub struct _cef_stream_reader_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Read raw binary data. - // - pub read: Option<extern "C" fn(this: *mut cef_stream_reader_t, ptr: *mut (), - size: libc::size_t, n: libc::size_t) -> libc::size_t>, - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. - // - pub seek: Option<extern "C" fn(this: *mut cef_stream_reader_t, offset: i64, - whence: libc::c_int) -> libc::c_int>, - - // - // Return the current offset position. - // - pub tell: Option<extern "C" fn(this: *mut cef_stream_reader_t) -> i64>, - - // - // Return non-zero if at end of file. - // - pub eof: Option<extern "C" fn(this: *mut cef_stream_reader_t) -> libc::c_int>, - - // - // Returns true (1) if this reader performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the reader from. - // - pub may_block: Option<extern "C" fn( - this: *mut cef_stream_reader_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_stream_reader_t = _cef_stream_reader_t; - - -// -// Structure used to read data from a stream. The functions of this structure -// may be called on any thread. -// -pub struct CefStreamReader { - c_object: *mut cef_stream_reader_t, -} - -impl Clone for CefStreamReader { - fn clone(&self) -> CefStreamReader{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefStreamReader { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefStreamReader { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefStreamReader { - pub unsafe fn from_c_object(c_object: *mut cef_stream_reader_t) -> CefStreamReader { - CefStreamReader { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_stream_reader_t) -> CefStreamReader { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefStreamReader { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_stream_reader_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_stream_reader_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Read raw binary data. - // - pub fn read(&self, ptr: &mut (), size: libc::size_t, - n: libc::size_t) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).read.unwrap())( - self.c_object, - CefWrap::to_c(ptr), - CefWrap::to_c(size), - CefWrap::to_c(n))) - } - } - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. - // - pub fn seek(&self, offset: i64, whence: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).seek.unwrap())( - self.c_object, - CefWrap::to_c(offset), - CefWrap::to_c(whence))) - } - } - - // - // Return the current offset position. - // - pub fn tell(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).tell.unwrap())( - self.c_object)) - } - } - - // - // Return non-zero if at end of file. - // - pub fn eof(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).eof.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this reader performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the reader from. - // - pub fn may_block(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).may_block.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_stream_reader_t object from a file. - // - pub fn create_for_file(fileName: &[u16]) -> interfaces::CefStreamReader { - unsafe { - CefWrap::to_rust( - ::stream::cef_stream_reader_create_for_file( - CefWrap::to_c(fileName))) - } - } - - // - // Create a new cef_stream_reader_t object from data. - // - pub fn create_for_data(data: &mut (), - size: libc::size_t) -> interfaces::CefStreamReader { - unsafe { - CefWrap::to_rust( - ::stream::cef_stream_reader_create_for_data( - CefWrap::to_c(data), - CefWrap::to_c(size))) - } - } - - // - // Create a new cef_stream_reader_t object from a custom handler. - // - pub fn create_for_handler( - handler: interfaces::CefReadHandler) -> interfaces::CefStreamReader { - unsafe { - CefWrap::to_rust( - ::stream::cef_stream_reader_create_for_handler( - CefWrap::to_c(handler))) - } - } -} - -impl CefWrap<*mut cef_stream_reader_t> for CefStreamReader { - fn to_c(rust_object: CefStreamReader) -> *mut cef_stream_reader_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_stream_reader_t) -> CefStreamReader { - CefStreamReader::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_stream_reader_t> for Option<CefStreamReader> { - fn to_c(rust_object: Option<CefStreamReader>) -> *mut cef_stream_reader_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_stream_reader_t) -> Option<CefStreamReader> { - if c_object.is_null() { - None - } else { - Some(CefStreamReader::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure the client can implement to provide a custom stream writer. The -// functions of this structure may be called on any thread. -// -#[repr(C)] -pub struct _cef_write_handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Write raw binary data. - // - pub write: Option<extern "C" fn(this: *mut cef_write_handler_t, ptr: *const ( - ), size: libc::size_t, n: libc::size_t) -> libc::size_t>, - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. - // - pub seek: Option<extern "C" fn(this: *mut cef_write_handler_t, offset: i64, - whence: libc::c_int) -> libc::c_int>, - - // - // Return the current offset position. - // - pub tell: Option<extern "C" fn(this: *mut cef_write_handler_t) -> i64>, - - // - // Flush the stream. - // - pub flush: Option<extern "C" fn( - this: *mut cef_write_handler_t) -> libc::c_int>, - - // - // Return true (1) if this handler performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the handler from. - // - pub may_block: Option<extern "C" fn( - this: *mut cef_write_handler_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_write_handler_t = _cef_write_handler_t; - - -// -// Structure the client can implement to provide a custom stream writer. The -// functions of this structure may be called on any thread. -// -pub struct CefWriteHandler { - c_object: *mut cef_write_handler_t, -} - -impl Clone for CefWriteHandler { - fn clone(&self) -> CefWriteHandler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefWriteHandler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefWriteHandler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefWriteHandler { - pub unsafe fn from_c_object(c_object: *mut cef_write_handler_t) -> CefWriteHandler { - CefWriteHandler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_write_handler_t) -> CefWriteHandler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefWriteHandler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_write_handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_write_handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Write raw binary data. - // - pub fn write(&self, ptr: &(), size: libc::size_t, - n: libc::size_t) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).write.unwrap())( - self.c_object, - CefWrap::to_c(ptr), - CefWrap::to_c(size), - CefWrap::to_c(n))) - } - } - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. - // - pub fn seek(&self, offset: i64, whence: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).seek.unwrap())( - self.c_object, - CefWrap::to_c(offset), - CefWrap::to_c(whence))) - } - } - - // - // Return the current offset position. - // - pub fn tell(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).tell.unwrap())( - self.c_object)) - } - } - - // - // Flush the stream. - // - pub fn flush(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).flush.unwrap())( - self.c_object)) - } - } - - // - // Return true (1) if this handler performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the handler from. - // - pub fn may_block(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).may_block.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_write_handler_t> for CefWriteHandler { - fn to_c(rust_object: CefWriteHandler) -> *mut cef_write_handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_write_handler_t) -> CefWriteHandler { - CefWriteHandler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_write_handler_t> for Option<CefWriteHandler> { - fn to_c(rust_object: Option<CefWriteHandler>) -> *mut cef_write_handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_write_handler_t) -> Option<CefWriteHandler> { - if c_object.is_null() { - None - } else { - Some(CefWriteHandler::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure used to write data to a stream. The functions of this structure may -// be called on any thread. -// -#[repr(C)] -pub struct _cef_stream_writer_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Write raw binary data. - // - pub write: Option<extern "C" fn(this: *mut cef_stream_writer_t, ptr: *const ( - ), size: libc::size_t, n: libc::size_t) -> libc::size_t>, - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. - // - pub seek: Option<extern "C" fn(this: *mut cef_stream_writer_t, offset: i64, - whence: libc::c_int) -> libc::c_int>, - - // - // Return the current offset position. - // - pub tell: Option<extern "C" fn(this: *mut cef_stream_writer_t) -> i64>, - - // - // Flush the stream. - // - pub flush: Option<extern "C" fn( - this: *mut cef_stream_writer_t) -> libc::c_int>, - - // - // Returns true (1) if this writer performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the writer from. - // - pub may_block: Option<extern "C" fn( - this: *mut cef_stream_writer_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_stream_writer_t = _cef_stream_writer_t; - - -// -// Structure used to write data to a stream. The functions of this structure may -// be called on any thread. -// -pub struct CefStreamWriter { - c_object: *mut cef_stream_writer_t, -} - -impl Clone for CefStreamWriter { - fn clone(&self) -> CefStreamWriter{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefStreamWriter { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefStreamWriter { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefStreamWriter { - pub unsafe fn from_c_object(c_object: *mut cef_stream_writer_t) -> CefStreamWriter { - CefStreamWriter { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_stream_writer_t) -> CefStreamWriter { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefStreamWriter { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_stream_writer_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_stream_writer_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Write raw binary data. - // - pub fn write(&self, ptr: &(), size: libc::size_t, - n: libc::size_t) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).write.unwrap())( - self.c_object, - CefWrap::to_c(ptr), - CefWrap::to_c(size), - CefWrap::to_c(n))) - } - } - - // - // Seek to the specified offset position. |whence| may be any one of SEEK_CUR, - // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. - // - pub fn seek(&self, offset: i64, whence: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).seek.unwrap())( - self.c_object, - CefWrap::to_c(offset), - CefWrap::to_c(whence))) - } - } - - // - // Return the current offset position. - // - pub fn tell(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).tell.unwrap())( - self.c_object)) - } - } - - // - // Flush the stream. - // - pub fn flush(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).flush.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this writer performs work like accessing the file - // system which may block. Used as a hint for determining the thread to access - // the writer from. - // - pub fn may_block(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).may_block.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_stream_writer_t object for a file. - // - pub fn create_for_file(fileName: &[u16]) -> interfaces::CefStreamWriter { - unsafe { - CefWrap::to_rust( - ::stream::cef_stream_writer_create_for_file( - CefWrap::to_c(fileName))) - } - } - - // - // Create a new cef_stream_writer_t object for a custom handler. - // - pub fn create_for_handler( - handler: interfaces::CefWriteHandler) -> interfaces::CefStreamWriter { - unsafe { - CefWrap::to_rust( - ::stream::cef_stream_writer_create_for_handler( - CefWrap::to_c(handler))) - } - } -} - -impl CefWrap<*mut cef_stream_writer_t> for CefStreamWriter { - fn to_c(rust_object: CefStreamWriter) -> *mut cef_stream_writer_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_stream_writer_t) -> CefStreamWriter { - CefStreamWriter::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_stream_writer_t> for Option<CefStreamWriter> { - fn to_c(rust_object: Option<CefStreamWriter>) -> *mut cef_stream_writer_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_stream_writer_t) -> Option<CefStreamWriter> { - if c_object.is_null() { - None - } else { - Some(CefStreamWriter::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_string_visitor.rs b/ports/cef/interfaces/cef_string_visitor.rs deleted file mode 100644 index 7c94dd4bbe6..00000000000 --- a/ports/cef/interfaces/cef_string_visitor.rs +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to receive string values asynchronously. -// -#[repr(C)] -pub struct _cef_string_visitor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be executed. - // - pub visit: Option<extern "C" fn(this: *mut cef_string_visitor_t, - string: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_string_visitor_t = _cef_string_visitor_t; - - -// -// Implement this structure to receive string values asynchronously. -// -pub struct CefStringVisitor { - c_object: *mut cef_string_visitor_t, -} - -impl Clone for CefStringVisitor { - fn clone(&self) -> CefStringVisitor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefStringVisitor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefStringVisitor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefStringVisitor { - pub unsafe fn from_c_object(c_object: *mut cef_string_visitor_t) -> CefStringVisitor { - CefStringVisitor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_string_visitor_t) -> CefStringVisitor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefStringVisitor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_string_visitor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_string_visitor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be executed. - // - pub fn visit(&self, string: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit.unwrap())( - self.c_object, - CefWrap::to_c(string))) - } - } -} - -impl CefWrap<*mut cef_string_visitor_t> for CefStringVisitor { - fn to_c(rust_object: CefStringVisitor) -> *mut cef_string_visitor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_string_visitor_t) -> CefStringVisitor { - CefStringVisitor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_string_visitor_t> for Option<CefStringVisitor> { - fn to_c(rust_object: Option<CefStringVisitor>) -> *mut cef_string_visitor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_string_visitor_t) -> Option<CefStringVisitor> { - if c_object.is_null() { - None - } else { - Some(CefStringVisitor::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_task.rs b/ports/cef/interfaces/cef_task.rs deleted file mode 100644 index 9b60b025c73..00000000000 --- a/ports/cef/interfaces/cef_task.rs +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure for asynchronous task execution. If the task is -// posted successfully and if the associated message loop is still running then -// the execute() function will be called on the target thread. If the task fails -// to post then the task object may be destroyed on the source thread instead of -// the target thread. For this reason be cautious when performing work in the -// task object destructor. -// -#[repr(C)] -pub struct _cef_task_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be executed on the target thread. - // - pub execute: Option<extern "C" fn(this: *mut cef_task_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_task_t = _cef_task_t; - - -// -// Implement this structure for asynchronous task execution. If the task is -// posted successfully and if the associated message loop is still running then -// the execute() function will be called on the target thread. If the task fails -// to post then the task object may be destroyed on the source thread instead of -// the target thread. For this reason be cautious when performing work in the -// task object destructor. -// -pub struct CefTask { - c_object: *mut cef_task_t, -} - -impl Clone for CefTask { - fn clone(&self) -> CefTask{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefTask { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefTask { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefTask { - pub unsafe fn from_c_object(c_object: *mut cef_task_t) -> CefTask { - CefTask { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_task_t) -> CefTask { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefTask { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_task_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_task_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be executed on the target thread. - // - pub fn execute(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).execute.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_task_t> for CefTask { - fn to_c(rust_object: CefTask) -> *mut cef_task_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_task_t) -> CefTask { - CefTask::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_task_t> for Option<CefTask> { - fn to_c(rust_object: Option<CefTask>) -> *mut cef_task_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_task_t) -> Option<CefTask> { - if c_object.is_null() { - None - } else { - Some(CefTask::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure that asynchronously executes tasks on the associated thread. It is -// safe to call the functions of this structure on any thread. -// -// CEF maintains multiple internal threads that are used for handling different -// types of tasks in different processes. The cef_thread_id_t definitions in -// cef_types.h list the common CEF threads. Task runners are also available for -// other CEF threads as appropriate (for example, V8 WebWorker threads). -// -#[repr(C)] -pub struct _cef_task_runner_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is pointing to the same task runner as - // |that| object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_task_runner_t, - that: *mut interfaces::cef_task_runner_t) -> libc::c_int>, - - // - // Returns true (1) if this task runner belongs to the current thread. - // - pub belongs_to_current_thread: Option<extern "C" fn( - this: *mut cef_task_runner_t) -> libc::c_int>, - - // - // Returns true (1) if this task runner is for the specified CEF thread. - // - pub belongs_to_thread: Option<extern "C" fn(this: *mut cef_task_runner_t, - threadId: types::cef_thread_id_t) -> libc::c_int>, - - // - // Post a task for execution on the thread associated with this task runner. - // Execution will occur asynchronously. - // - pub post_task: Option<extern "C" fn(this: *mut cef_task_runner_t, - task: *mut interfaces::cef_task_t) -> libc::c_int>, - - // - // Post a task for delayed execution on the thread associated with this task - // runner. Execution will occur asynchronously. Delayed tasks are not - // supported on V8 WebWorker threads and will be executed without the - // specified delay. - // - pub post_delayed_task: Option<extern "C" fn(this: *mut cef_task_runner_t, - task: *mut interfaces::cef_task_t, delay_ms: i64) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_task_runner_t = _cef_task_runner_t; - - -// -// Structure that asynchronously executes tasks on the associated thread. It is -// safe to call the functions of this structure on any thread. -// -// CEF maintains multiple internal threads that are used for handling different -// types of tasks in different processes. The cef_thread_id_t definitions in -// cef_types.h list the common CEF threads. Task runners are also available for -// other CEF threads as appropriate (for example, V8 WebWorker threads). -// -pub struct CefTaskRunner { - c_object: *mut cef_task_runner_t, -} - -impl Clone for CefTaskRunner { - fn clone(&self) -> CefTaskRunner{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefTaskRunner { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefTaskRunner { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefTaskRunner { - pub unsafe fn from_c_object(c_object: *mut cef_task_runner_t) -> CefTaskRunner { - CefTaskRunner { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_task_runner_t) -> CefTaskRunner { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefTaskRunner { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_task_runner_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_task_runner_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is pointing to the same task runner as - // |that| object. - // - pub fn is_same(&self, that: interfaces::CefTaskRunner) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if this task runner belongs to the current thread. - // - pub fn belongs_to_current_thread(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).belongs_to_current_thread.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this task runner is for the specified CEF thread. - // - pub fn belongs_to_thread(&self, - threadId: types::cef_thread_id_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).belongs_to_thread.unwrap())( - self.c_object, - CefWrap::to_c(threadId))) - } - } - - // - // Post a task for execution on the thread associated with this task runner. - // Execution will occur asynchronously. - // - pub fn post_task(&self, task: interfaces::CefTask) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).post_task.unwrap())( - self.c_object, - CefWrap::to_c(task))) - } - } - - // - // Post a task for delayed execution on the thread associated with this task - // runner. Execution will occur asynchronously. Delayed tasks are not - // supported on V8 WebWorker threads and will be executed without the - // specified delay. - // - pub fn post_delayed_task(&self, task: interfaces::CefTask, - delay_ms: i64) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).post_delayed_task.unwrap())( - self.c_object, - CefWrap::to_c(task), - CefWrap::to_c(delay_ms))) - } - } - - // - // Returns the task runner for the current thread. Only CEF threads will have - // task runners. An NULL reference will be returned if this function is called - // on an invalid thread. - // - pub fn get_for_current_thread() -> interfaces::CefTaskRunner { - unsafe { - CefWrap::to_rust( - ::task::cef_task_runner_get_for_current_thread( -)) - } - } - - // - // Returns the task runner for the specified CEF thread. - // - pub fn get_for_thread( - threadId: types::cef_thread_id_t) -> interfaces::CefTaskRunner { - unsafe { - CefWrap::to_rust( - ::task::cef_task_runner_get_for_thread( - CefWrap::to_c(threadId))) - } - } -} - -impl CefWrap<*mut cef_task_runner_t> for CefTaskRunner { - fn to_c(rust_object: CefTaskRunner) -> *mut cef_task_runner_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> CefTaskRunner { - CefTaskRunner::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_task_runner_t> for Option<CefTaskRunner> { - fn to_c(rust_object: Option<CefTaskRunner>) -> *mut cef_task_runner_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> Option<CefTaskRunner> { - if c_object.is_null() { - None - } else { - Some(CefTaskRunner::from_c_object_addref(c_object)) - } - } -} diff --git a/ports/cef/interfaces/cef_trace.rs b/ports/cef/interfaces/cef_trace.rs deleted file mode 100644 index b2ebad90900..00000000000 --- a/ports/cef/interfaces/cef_trace.rs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Implement this structure to receive notification when tracing has completed. -// The functions of this structure will be called on the browser process UI -// thread. -// -#[repr(C)] -pub struct _cef_end_tracing_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Called after all processes have sent their trace data. |tracing_file| is - // the path at which tracing data was written. The client is responsible for - // deleting |tracing_file|. - // - pub on_end_tracing_complete: Option<extern "C" fn( - this: *mut cef_end_tracing_callback_t, - tracing_file: *const types::cef_string_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_end_tracing_callback_t = _cef_end_tracing_callback_t; - - -// -// Implement this structure to receive notification when tracing has completed. -// The functions of this structure will be called on the browser process UI -// thread. -// -pub struct CefEndTracingCallback { - c_object: *mut cef_end_tracing_callback_t, -} - -impl Clone for CefEndTracingCallback { - fn clone(&self) -> CefEndTracingCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefEndTracingCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefEndTracingCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefEndTracingCallback { - pub unsafe fn from_c_object(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback { - CefEndTracingCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefEndTracingCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_end_tracing_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_end_tracing_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Called after all processes have sent their trace data. |tracing_file| is - // the path at which tracing data was written. The client is responsible for - // deleting |tracing_file|. - // - pub fn on_end_tracing_complete(&self, tracing_file: &[u16]) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_end_tracing_complete.unwrap())( - self.c_object, - CefWrap::to_c(tracing_file))) - } - } -} - -impl CefWrap<*mut cef_end_tracing_callback_t> for CefEndTracingCallback { - fn to_c(rust_object: CefEndTracingCallback) -> *mut cef_end_tracing_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback { - CefEndTracingCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_end_tracing_callback_t> for Option<CefEndTracingCallback> { - fn to_c(rust_object: Option<CefEndTracingCallback>) -> *mut cef_end_tracing_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_end_tracing_callback_t) -> Option<CefEndTracingCallback> { - if c_object.is_null() { - None - } else { - Some(CefEndTracingCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_urlrequest.rs b/ports/cef/interfaces/cef_urlrequest.rs deleted file mode 100644 index eb15bd66df0..00000000000 --- a/ports/cef/interfaces/cef_urlrequest.rs +++ /dev/null @@ -1,605 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure used to make a URL request. URL requests are not associated with a -// browser instance so no cef_client_t callbacks will be executed. URL requests -// can be created on any valid CEF thread in either the browser or render -// process. Once created the functions of the URL request object must be -// accessed on the same thread that created it. -// -#[repr(C)] -pub struct _cef_urlrequest_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the request object used to create this URL request. The returned - // object is read-only and should not be modified. - // - pub get_request: Option<extern "C" fn( - this: *mut cef_urlrequest_t) -> *mut interfaces::cef_request_t>, - - // - // Returns the client. - // - pub get_client: Option<extern "C" fn( - this: *mut cef_urlrequest_t) -> *mut interfaces::cef_urlrequest_client_t>, - - // - // Returns the request status. - // - pub get_request_status: Option<extern "C" fn( - this: *mut cef_urlrequest_t) -> types::cef_urlrequest_status_t>, - - // - // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 - // otherwise. - // - pub get_request_error: Option<extern "C" fn( - this: *mut cef_urlrequest_t) -> types::cef_errorcode_t>, - - // - // Returns the response, or NULL if no response information is available. - // Response information will only be available after the upload has completed. - // The returned object is read-only and should not be modified. - // - pub get_response: Option<extern "C" fn( - this: *mut cef_urlrequest_t) -> *mut interfaces::cef_response_t>, - - // - // Cancel the request. - // - pub cancel: Option<extern "C" fn(this: *mut cef_urlrequest_t) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_urlrequest_t = _cef_urlrequest_t; - - -// -// Structure used to make a URL request. URL requests are not associated with a -// browser instance so no cef_client_t callbacks will be executed. URL requests -// can be created on any valid CEF thread in either the browser or render -// process. Once created the functions of the URL request object must be -// accessed on the same thread that created it. -// -pub struct CefURLRequest { - c_object: *mut cef_urlrequest_t, -} - -impl Clone for CefURLRequest { - fn clone(&self) -> CefURLRequest{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefURLRequest { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefURLRequest { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefURLRequest { - pub unsafe fn from_c_object(c_object: *mut cef_urlrequest_t) -> CefURLRequest { - CefURLRequest { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_t) -> CefURLRequest { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefURLRequest { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_urlrequest_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the request object used to create this URL request. The returned - // object is read-only and should not be modified. - // - pub fn get_request(&self) -> interfaces::CefRequest { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_request.unwrap())( - self.c_object)) - } - } - - // - // Returns the client. - // - pub fn get_client(&self) -> interfaces::CefURLRequestClient { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_client.unwrap())( - self.c_object)) - } - } - - // - // Returns the request status. - // - pub fn get_request_status(&self) -> types::cef_urlrequest_status_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_request_status.unwrap())( - self.c_object)) - } - } - - // - // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 - // otherwise. - // - pub fn get_request_error(&self) -> types::cef_errorcode_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_request_error.unwrap())( - self.c_object)) - } - } - - // - // Returns the response, or NULL if no response information is available. - // Response information will only be available after the upload has completed. - // The returned object is read-only and should not be modified. - // - pub fn get_response(&self) -> interfaces::CefResponse { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_response.unwrap())( - self.c_object)) - } - } - - // - // Cancel the request. - // - pub fn cancel(&self) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).cancel.unwrap())( - self.c_object)) - } - } - - // - // Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request - // functions are supported. Multiple post data elements are not supported and - // elements of type PDE_TYPE_FILE are only supported for requests originating - // from the browser process. Requests originating from the render process will - // receive the same handling as requests originating from Web content -- if - // the response contains Content-Disposition or Mime-Type header values that - // would not normally be rendered then the response may receive special - // handling inside the browser (for example, via the file download code path - // instead of the URL request code path). The |request| object will be marked - // as read-only after calling this function. In the browser process if - // |request_context| is NULL the global request context will be used. In the - // render process |request_context| must be NULL and the context associated - // with the current renderer process' browser will be used. - // - pub fn create(request: interfaces::CefRequest, - client: interfaces::CefURLRequestClient, - request_context: interfaces::CefRequestContext) -> interfaces::CefURLRequest { - unsafe { - CefWrap::to_rust( - ::urlrequest::cef_urlrequest_create( - CefWrap::to_c(request), - CefWrap::to_c(client), - CefWrap::to_c(request_context))) - } - } -} - -impl CefWrap<*mut cef_urlrequest_t> for CefURLRequest { - fn to_c(rust_object: CefURLRequest) -> *mut cef_urlrequest_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_urlrequest_t) -> CefURLRequest { - CefURLRequest::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_urlrequest_t> for Option<CefURLRequest> { - fn to_c(rust_object: Option<CefURLRequest>) -> *mut cef_urlrequest_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_urlrequest_t) -> Option<CefURLRequest> { - if c_object.is_null() { - None - } else { - Some(CefURLRequest::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure that should be implemented by the cef_urlrequest_t client. The -// functions of this structure will be called on the same thread that created -// the request unless otherwise documented. -// -#[repr(C)] -pub struct _cef_urlrequest_client_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Notifies the client that the request has completed. Use the - // cef_urlrequest_t::GetRequestStatus function to determine if the request was - // successful or not. - // - pub on_request_complete: Option<extern "C" fn( - this: *mut cef_urlrequest_client_t, - request: *mut interfaces::cef_urlrequest_t) -> ()>, - - // - // Notifies the client of upload progress. |current| denotes the number of - // bytes sent so far and |total| is the total size of uploading data (or -1 if - // chunked upload is enabled). This function will only be called if the - // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. - // - pub on_upload_progress: Option<extern "C" fn( - this: *mut cef_urlrequest_client_t, - request: *mut interfaces::cef_urlrequest_t, current: i64, - total: i64) -> ()>, - - // - // Notifies the client of download progress. |current| denotes the number of - // bytes received up to the call and |total| is the expected total size of the - // response (or -1 if not determined). - // - pub on_download_progress: Option<extern "C" fn( - this: *mut cef_urlrequest_client_t, - request: *mut interfaces::cef_urlrequest_t, current: i64, - total: i64) -> ()>, - - // - // Called when some part of the response is read. |data| contains the current - // bytes received since the last call. This function will not be called if the - // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. - // - pub on_download_data: Option<extern "C" fn(this: *mut cef_urlrequest_client_t, - request: *mut interfaces::cef_urlrequest_t, data: *const (), - data_length: libc::size_t) -> ()>, - - // - // Called on the IO thread when the browser needs credentials from the user. - // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and |port| contains the port number. Return true (1) to continue - // the request and call cef_auth_callback_t::cont() when the authentication - // information is available. Return false (0) to cancel the request. This - // function will only be called for requests initiated from the browser - // process. - // - pub get_auth_credentials: Option<extern "C" fn( - this: *mut cef_urlrequest_client_t, isProxy: libc::c_int, - host: *const types::cef_string_t, port: libc::c_int, - realm: *const types::cef_string_t, scheme: *const types::cef_string_t, - callback: *mut interfaces::cef_auth_callback_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_urlrequest_client_t = _cef_urlrequest_client_t; - - -// -// Structure that should be implemented by the cef_urlrequest_t client. The -// functions of this structure will be called on the same thread that created -// the request unless otherwise documented. -// -pub struct CefURLRequestClient { - c_object: *mut cef_urlrequest_client_t, -} - -impl Clone for CefURLRequestClient { - fn clone(&self) -> CefURLRequestClient{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefURLRequestClient { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefURLRequestClient { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefURLRequestClient { - pub unsafe fn from_c_object(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient { - CefURLRequestClient { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefURLRequestClient { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_urlrequest_client_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_client_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Notifies the client that the request has completed. Use the - // cef_urlrequest_t::GetRequestStatus function to determine if the request was - // successful or not. - // - pub fn on_request_complete(&self, request: interfaces::CefURLRequest) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_request_complete.unwrap())( - self.c_object, - CefWrap::to_c(request))) - } - } - - // - // Notifies the client of upload progress. |current| denotes the number of - // bytes sent so far and |total| is the total size of uploading data (or -1 if - // chunked upload is enabled). This function will only be called if the - // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. - // - pub fn on_upload_progress(&self, request: interfaces::CefURLRequest, - current: i64, total: i64) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_upload_progress.unwrap())( - self.c_object, - CefWrap::to_c(request), - CefWrap::to_c(current), - CefWrap::to_c(total))) - } - } - - // - // Notifies the client of download progress. |current| denotes the number of - // bytes received up to the call and |total| is the expected total size of the - // response (or -1 if not determined). - // - pub fn on_download_progress(&self, request: interfaces::CefURLRequest, - current: i64, total: i64) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_download_progress.unwrap())( - self.c_object, - CefWrap::to_c(request), - CefWrap::to_c(current), - CefWrap::to_c(total))) - } - } - - // - // Called when some part of the response is read. |data| contains the current - // bytes received since the last call. This function will not be called if the - // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. - // - pub fn on_download_data(&self, request: interfaces::CefURLRequest, data: &(), - data_length: libc::size_t) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).on_download_data.unwrap())( - self.c_object, - CefWrap::to_c(request), - CefWrap::to_c(data), - CefWrap::to_c(data_length))) - } - } - - // - // Called on the IO thread when the browser needs credentials from the user. - // |isProxy| indicates whether the host is a proxy server. |host| contains the - // hostname and |port| contains the port number. Return true (1) to continue - // the request and call cef_auth_callback_t::cont() when the authentication - // information is available. Return false (0) to cancel the request. This - // function will only be called for requests initiated from the browser - // process. - // - pub fn get_auth_credentials(&self, isProxy: libc::c_int, host: &[u16], - port: libc::c_int, realm: &[u16], scheme: &[u16], - callback: interfaces::CefAuthCallback) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_auth_credentials.unwrap())( - self.c_object, - CefWrap::to_c(isProxy), - CefWrap::to_c(host), - CefWrap::to_c(port), - CefWrap::to_c(realm), - CefWrap::to_c(scheme), - CefWrap::to_c(callback))) - } - } -} - -impl CefWrap<*mut cef_urlrequest_client_t> for CefURLRequestClient { - fn to_c(rust_object: CefURLRequestClient) -> *mut cef_urlrequest_client_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient { - CefURLRequestClient::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_urlrequest_client_t> for Option<CefURLRequestClient> { - fn to_c(rust_object: Option<CefURLRequestClient>) -> *mut cef_urlrequest_client_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_urlrequest_client_t) -> Option<CefURLRequestClient> { - if c_object.is_null() { - None - } else { - Some(CefURLRequestClient::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_v8.rs b/ports/cef/interfaces/cef_v8.rs deleted file mode 100644 index 90fdead3d7f..00000000000 --- a/ports/cef/interfaces/cef_v8.rs +++ /dev/null @@ -1,2889 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure representing a V8 context handle. V8 handles can only be accessed -// from the thread on which they are created. Valid threads for creating a V8 -// handle include the render process main thread (TID_RENDERER) and WebWorker -// threads. A task runner for posting tasks on the associated thread can be -// retrieved via the cef_v8context_t::get_task_runner() function. -// -#[repr(C)] -pub struct _cef_v8context_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the task runner associated with this context. V8 handles can only - // be accessed from the thread on which they are created. This function can be - // called on any render process thread. - // - pub get_task_runner: Option<extern "C" fn( - this: *mut cef_v8context_t) -> *mut interfaces::cef_task_runner_t>, - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_v8context_t) -> libc::c_int>, - - // - // Returns the browser for this context. This function will return an NULL - // reference for WebWorker contexts. - // - pub get_browser: Option<extern "C" fn( - this: *mut cef_v8context_t) -> *mut interfaces::cef_browser_t>, - - // - // Returns the frame for this context. This function will return an NULL - // reference for WebWorker contexts. - // - pub get_frame: Option<extern "C" fn( - this: *mut cef_v8context_t) -> *mut interfaces::cef_frame_t>, - - // - // Returns the global object for this context. The context must be entered - // before calling this function. - // - pub get_global: Option<extern "C" fn( - this: *mut cef_v8context_t) -> *mut interfaces::cef_v8value_t>, - - // - // Enter this context. A context must be explicitly entered before creating a - // V8 Object, Array, Function or Date asynchronously. exit() must be called - // the same number of times as enter() before releasing this context. V8 - // objects belong to the context in which they are created. Returns true (1) - // if the scope was entered successfully. - // - pub enter: Option<extern "C" fn(this: *mut cef_v8context_t) -> libc::c_int>, - - // - // Exit this context. Call this function only after calling enter(). Returns - // true (1) if the scope was exited successfully. - // - pub exit: Option<extern "C" fn(this: *mut cef_v8context_t) -> libc::c_int>, - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_v8context_t, - that: *mut interfaces::cef_v8context_t) -> libc::c_int>, - - // - // Evaluates the specified JavaScript code using this context's global object. - // On success |retval| will be set to the return value, if any, and the - // function will return true (1). On failure |exception| will be set to the - // exception, if any, and the function will return false (0). - // - pub eval: Option<extern "C" fn(this: *mut cef_v8context_t, - code: *const types::cef_string_t, retval: *mut interfaces::cef_v8value_t, - exception: *mut interfaces::cef_v8exception_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8context_t = _cef_v8context_t; - - -// -// Structure representing a V8 context handle. V8 handles can only be accessed -// from the thread on which they are created. Valid threads for creating a V8 -// handle include the render process main thread (TID_RENDERER) and WebWorker -// threads. A task runner for posting tasks on the associated thread can be -// retrieved via the cef_v8context_t::get_task_runner() function. -// -pub struct CefV8Context { - c_object: *mut cef_v8context_t, -} - -impl Clone for CefV8Context { - fn clone(&self) -> CefV8Context{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8Context { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8Context { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8Context { - pub unsafe fn from_c_object(c_object: *mut cef_v8context_t) -> CefV8Context { - CefV8Context { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8context_t) -> CefV8Context { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8Context { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8context_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8context_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the task runner associated with this context. V8 handles can only - // be accessed from the thread on which they are created. This function can be - // called on any render process thread. - // - pub fn get_task_runner(&self) -> interfaces::CefTaskRunner { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_task_runner.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns the browser for this context. This function will return an NULL - // reference for WebWorker contexts. - // - pub fn get_browser(&self) -> interfaces::CefBrowser { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_browser.unwrap())( - self.c_object)) - } - } - - // - // Returns the frame for this context. This function will return an NULL - // reference for WebWorker contexts. - // - pub fn get_frame(&self) -> interfaces::CefFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame.unwrap())( - self.c_object)) - } - } - - // - // Returns the global object for this context. The context must be entered - // before calling this function. - // - pub fn get_global(&self) -> interfaces::CefV8Value { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_global.unwrap())( - self.c_object)) - } - } - - // - // Enter this context. A context must be explicitly entered before creating a - // V8 Object, Array, Function or Date asynchronously. exit() must be called - // the same number of times as enter() before releasing this context. V8 - // objects belong to the context in which they are created. Returns true (1) - // if the scope was entered successfully. - // - pub fn enter(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).enter.unwrap())( - self.c_object)) - } - } - - // - // Exit this context. Call this function only after calling enter(). Returns - // true (1) if the scope was exited successfully. - // - pub fn exit(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).exit.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub fn is_same(&self, that: interfaces::CefV8Context) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Evaluates the specified JavaScript code using this context's global object. - // On success |retval| will be set to the return value, if any, and the - // function will return true (1). On failure |exception| will be set to the - // exception, if any, and the function will return false (0). - // - pub fn eval(&self, code: &[u16], retval: interfaces::CefV8Value, - exception: interfaces::CefV8Exception) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).eval.unwrap())( - self.c_object, - CefWrap::to_c(code), - CefWrap::to_c(retval), - CefWrap::to_c(exception))) - } - } - - // - // Returns the current (top) context object in the V8 context stack. - // - pub fn get_current_context() -> interfaces::CefV8Context { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8context_get_current_context( -)) - } - } - - // - // Returns the entered (bottom) context object in the V8 context stack. - // - pub fn get_entered_context() -> interfaces::CefV8Context { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8context_get_entered_context( -)) - } - } - - // - // Returns true (1) if V8 is currently inside a context. - // - pub fn in_context() -> libc::c_int { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8context_in_context( -)) - } - } -} - -impl CefWrap<*mut cef_v8context_t> for CefV8Context { - fn to_c(rust_object: CefV8Context) -> *mut cef_v8context_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8context_t) -> CefV8Context { - CefV8Context::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8context_t> for Option<CefV8Context> { - fn to_c(rust_object: Option<CefV8Context>) -> *mut cef_v8context_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8context_t) -> Option<CefV8Context> { - if c_object.is_null() { - None - } else { - Some(CefV8Context::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure that should be implemented to handle V8 function calls. The -// functions of this structure will be called on the thread associated with the -// V8 function. -// -#[repr(C)] -pub struct _cef_v8handler_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Handle execution of the function identified by |name|. |object| is the - // receiver ('this' object) of the function. |arguments| is the list of - // arguments passed to the function. If execution succeeds set |retval| to the - // function return value. If execution fails set |exception| to the exception - // that will be thrown. Return true (1) if execution was handled. - // - pub execute: Option<extern "C" fn(this: *mut cef_v8handler_t, - name: *const types::cef_string_t, object: *mut interfaces::cef_v8value_t, - arguments_count: libc::size_t, - arguments: *const *mut interfaces::cef_v8value_t, - retval: *mut interfaces::cef_v8value_t, - exception: *mut types::cef_string_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8handler_t = _cef_v8handler_t; - - -// -// Structure that should be implemented to handle V8 function calls. The -// functions of this structure will be called on the thread associated with the -// V8 function. -// -pub struct CefV8Handler { - c_object: *mut cef_v8handler_t, -} - -impl Clone for CefV8Handler { - fn clone(&self) -> CefV8Handler{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8Handler { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8Handler { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8Handler { - pub unsafe fn from_c_object(c_object: *mut cef_v8handler_t) -> CefV8Handler { - CefV8Handler { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8handler_t) -> CefV8Handler { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8Handler { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8handler_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8handler_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Handle execution of the function identified by |name|. |object| is the - // receiver ('this' object) of the function. |arguments| is the list of - // arguments passed to the function. If execution succeeds set |retval| to the - // function return value. If execution fails set |exception| to the exception - // that will be thrown. Return true (1) if execution was handled. - // - pub fn execute(&self, name: &[u16], object: interfaces::CefV8Value, - arguments_count: libc::size_t, arguments: *const interfaces::CefV8Value, - retval: interfaces::CefV8Value, - exception: *mut types::cef_string_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).execute.unwrap())( - self.c_object, - CefWrap::to_c(name), - CefWrap::to_c(object), - CefWrap::to_c(arguments_count), - CefWrap::to_c(arguments), - CefWrap::to_c(retval), - CefWrap::to_c(exception))) - } - } -} - -impl CefWrap<*mut cef_v8handler_t> for CefV8Handler { - fn to_c(rust_object: CefV8Handler) -> *mut cef_v8handler_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8handler_t) -> CefV8Handler { - CefV8Handler::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8handler_t> for Option<CefV8Handler> { - fn to_c(rust_object: Option<CefV8Handler>) -> *mut cef_v8handler_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8handler_t) -> Option<CefV8Handler> { - if c_object.is_null() { - None - } else { - Some(CefV8Handler::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure that should be implemented to handle V8 accessor calls. Accessor -// identifiers are registered by calling cef_v8value_t::set_value(). The -// functions of this structure will be called on the thread associated with the -// V8 accessor. -// -#[repr(C)] -pub struct _cef_v8accessor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Handle retrieval the accessor value identified by |name|. |object| is the - // receiver ('this' object) of the accessor. If retrieval succeeds set - // |retval| to the return value. If retrieval fails set |exception| to the - // exception that will be thrown. Return true (1) if accessor retrieval was - // handled. - // - pub get: Option<extern "C" fn(this: *mut cef_v8accessor_t, - name: *const types::cef_string_t, object: *mut interfaces::cef_v8value_t, - retval: *mut interfaces::cef_v8value_t, - exception: *mut types::cef_string_t) -> libc::c_int>, - - // - // Handle assignment of the accessor value identified by |name|. |object| is - // the receiver ('this' object) of the accessor. |value| is the new value - // being assigned to the accessor. If assignment fails set |exception| to the - // exception that will be thrown. Return true (1) if accessor assignment was - // handled. - // - pub set: Option<extern "C" fn(this: *mut cef_v8accessor_t, - name: *const types::cef_string_t, object: *mut interfaces::cef_v8value_t, - value: *mut interfaces::cef_v8value_t, - exception: *mut types::cef_string_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8accessor_t = _cef_v8accessor_t; - - -// -// Structure that should be implemented to handle V8 accessor calls. Accessor -// identifiers are registered by calling cef_v8value_t::set_value(). The -// functions of this structure will be called on the thread associated with the -// V8 accessor. -// -pub struct CefV8Accessor { - c_object: *mut cef_v8accessor_t, -} - -impl Clone for CefV8Accessor { - fn clone(&self) -> CefV8Accessor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8Accessor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8Accessor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8Accessor { - pub unsafe fn from_c_object(c_object: *mut cef_v8accessor_t) -> CefV8Accessor { - CefV8Accessor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8accessor_t) -> CefV8Accessor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8Accessor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8accessor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8accessor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Handle retrieval the accessor value identified by |name|. |object| is the - // receiver ('this' object) of the accessor. If retrieval succeeds set - // |retval| to the return value. If retrieval fails set |exception| to the - // exception that will be thrown. Return true (1) if accessor retrieval was - // handled. - // - pub fn get(&self, name: &[u16], object: interfaces::CefV8Value, - retval: interfaces::CefV8Value, - exception: *mut types::cef_string_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get.unwrap())( - self.c_object, - CefWrap::to_c(name), - CefWrap::to_c(object), - CefWrap::to_c(retval), - CefWrap::to_c(exception))) - } - } - - // - // Handle assignment of the accessor value identified by |name|. |object| is - // the receiver ('this' object) of the accessor. |value| is the new value - // being assigned to the accessor. If assignment fails set |exception| to the - // exception that will be thrown. Return true (1) if accessor assignment was - // handled. - // - pub fn set(&self, name: &[u16], object: interfaces::CefV8Value, - value: interfaces::CefV8Value, - exception: *mut types::cef_string_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set.unwrap())( - self.c_object, - CefWrap::to_c(name), - CefWrap::to_c(object), - CefWrap::to_c(value), - CefWrap::to_c(exception))) - } - } -} - -impl CefWrap<*mut cef_v8accessor_t> for CefV8Accessor { - fn to_c(rust_object: CefV8Accessor) -> *mut cef_v8accessor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8accessor_t) -> CefV8Accessor { - CefV8Accessor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8accessor_t> for Option<CefV8Accessor> { - fn to_c(rust_object: Option<CefV8Accessor>) -> *mut cef_v8accessor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8accessor_t) -> Option<CefV8Accessor> { - if c_object.is_null() { - None - } else { - Some(CefV8Accessor::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a V8 exception. The functions of this structure may be -// called on any render process thread. -// -#[repr(C)] -pub struct _cef_v8exception_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the exception message. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_message: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> types::cef_string_userfree_t>, - - // - // Returns the line of source code that the exception occurred within. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_source_line: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> types::cef_string_userfree_t>, - - // - // Returns the resource name for the script from where the function causing - // the error originates. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_script_resource_name: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> types::cef_string_userfree_t>, - - // - // Returns the 1-based number of the line where the error occurred or 0 if the - // line number is unknown. - // - pub get_line_number: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> libc::c_int>, - - // - // Returns the index within the script of the first character where the error - // occurred. - // - pub get_start_position: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> libc::c_int>, - - // - // Returns the index within the script of the last character where the error - // occurred. - // - pub get_end_position: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> libc::c_int>, - - // - // Returns the index within the line of the first character where the error - // occurred. - // - pub get_start_column: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> libc::c_int>, - - // - // Returns the index within the line of the last character where the error - // occurred. - // - pub get_end_column: Option<extern "C" fn( - this: *mut cef_v8exception_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8exception_t = _cef_v8exception_t; - - -// -// Structure representing a V8 exception. The functions of this structure may be -// called on any render process thread. -// -pub struct CefV8Exception { - c_object: *mut cef_v8exception_t, -} - -impl Clone for CefV8Exception { - fn clone(&self) -> CefV8Exception{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8Exception { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8Exception { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8Exception { - pub unsafe fn from_c_object(c_object: *mut cef_v8exception_t) -> CefV8Exception { - CefV8Exception { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8exception_t) -> CefV8Exception { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8Exception { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8exception_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8exception_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the exception message. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_message(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_message.unwrap())( - self.c_object)) - } - } - - // - // Returns the line of source code that the exception occurred within. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_source_line(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_source_line.unwrap())( - self.c_object)) - } - } - - // - // Returns the resource name for the script from where the function causing - // the error originates. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_script_resource_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_script_resource_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the 1-based number of the line where the error occurred or 0 if the - // line number is unknown. - // - pub fn get_line_number(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_line_number.unwrap())( - self.c_object)) - } - } - - // - // Returns the index within the script of the first character where the error - // occurred. - // - pub fn get_start_position(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_start_position.unwrap())( - self.c_object)) - } - } - - // - // Returns the index within the script of the last character where the error - // occurred. - // - pub fn get_end_position(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_end_position.unwrap())( - self.c_object)) - } - } - - // - // Returns the index within the line of the first character where the error - // occurred. - // - pub fn get_start_column(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_start_column.unwrap())( - self.c_object)) - } - } - - // - // Returns the index within the line of the last character where the error - // occurred. - // - pub fn get_end_column(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_end_column.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_v8exception_t> for CefV8Exception { - fn to_c(rust_object: CefV8Exception) -> *mut cef_v8exception_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8exception_t) -> CefV8Exception { - CefV8Exception::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8exception_t> for Option<CefV8Exception> { - fn to_c(rust_object: Option<CefV8Exception>) -> *mut cef_v8exception_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8exception_t) -> Option<CefV8Exception> { - if c_object.is_null() { - None - } else { - Some(CefV8Exception::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a V8 value handle. V8 handles can only be accessed -// from the thread on which they are created. Valid threads for creating a V8 -// handle include the render process main thread (TID_RENDERER) and WebWorker -// threads. A task runner for posting tasks on the associated thread can be -// retrieved via the cef_v8context_t::get_task_runner() function. -// -#[repr(C)] -pub struct _cef_v8value_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub is_valid: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is undefined. - // - pub is_undefined: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is null. - // - pub is_null: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is bool. - // - pub is_bool: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is int. - // - pub is_int: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is unsigned int. - // - pub is_uint: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is double. - // - pub is_double: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is Date. - // - pub is_date: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is string. - // - pub is_string: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is object. - // - pub is_object: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is array. - // - pub is_array: Option<extern "C" fn(this: *mut cef_v8value_t) -> libc::c_int>, - - // - // True if the value type is function. - // - pub is_function: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub is_same: Option<extern "C" fn(this: *mut cef_v8value_t, - that: *mut interfaces::cef_v8value_t) -> libc::c_int>, - - // - // Return a bool value. The underlying data will be converted to if - // necessary. - // - pub get_bool_value: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Return an int value. The underlying data will be converted to if - // necessary. - // - pub get_int_value: Option<extern "C" fn(this: *mut cef_v8value_t) -> i32>, - - // - // Return an unisgned int value. The underlying data will be converted to if - // necessary. - // - pub get_uint_value: Option<extern "C" fn(this: *mut cef_v8value_t) -> u32>, - - // - // Return a double value. The underlying data will be converted to if - // necessary. - // - pub get_double_value: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_double>, - - // - // Return a Date value. The underlying data will be converted to if - // necessary. - // - pub get_date_value: Option<extern "C" fn( - this: *mut cef_v8value_t) -> types::cef_time_t>, - - // - // Return a string value. The underlying data will be converted to if - // necessary. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_string_value: Option<extern "C" fn( - this: *mut cef_v8value_t) -> types::cef_string_userfree_t>, - - - // OBJECT METHODS - These functions are only available on objects. Arrays and - // functions are also objects. String- and integer-based keys can be used - // interchangably with the framework converting between them as necessary. - - // - // Returns true (1) if this is a user created object. - // - pub is_user_created: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Returns true (1) if the last function call resulted in an exception. This - // attribute exists only in the scope of the current CEF value object. - // - pub has_exception: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Returns the exception resulting from the last function call. This attribute - // exists only in the scope of the current CEF value object. - // - pub get_exception: Option<extern "C" fn( - this: *mut cef_v8value_t) -> *mut interfaces::cef_v8exception_t>, - - // - // Clears the last exception and returns true (1) on success. - // - pub clear_exception: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Returns true (1) if this object will re-throw future exceptions. This - // attribute exists only in the scope of the current CEF value object. - // - pub will_rethrow_exceptions: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Set whether this object will re-throw future exceptions. By default - // exceptions are not re-thrown. If a exception is re-thrown the current - // context should not be accessed again until after the exception has been - // caught and not re-thrown. Returns true (1) on success. This attribute - // exists only in the scope of the current CEF value object. - // - pub set_rethrow_exceptions: Option<extern "C" fn(this: *mut cef_v8value_t, - rethrow: libc::c_int) -> libc::c_int>, - - // - // Returns true (1) if the object has a value with the specified identifier. - // - pub has_value_bykey: Option<extern "C" fn(this: *mut cef_v8value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns true (1) if the object has a value with the specified identifier. - // - pub has_value_byindex: Option<extern "C" fn(this: *mut cef_v8value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Deletes the value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only and don't-delete values this function - // will return true (1) even though deletion failed. - // - pub delete_value_bykey: Option<extern "C" fn(this: *mut cef_v8value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Deletes the value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly, deletion - // fails or an exception is thrown. For read-only and don't-delete values this - // function will return true (1) even though deletion failed. - // - pub delete_value_byindex: Option<extern "C" fn(this: *mut cef_v8value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Returns the value with the specified identifier on success. Returns NULL if - // this function is called incorrectly or an exception is thrown. - // - pub get_value_bykey: Option<extern "C" fn(this: *mut cef_v8value_t, - key: *const types::cef_string_t) -> *mut interfaces::cef_v8value_t>, - - // - // Returns the value with the specified identifier on success. Returns NULL if - // this function is called incorrectly or an exception is thrown. - // - pub get_value_byindex: Option<extern "C" fn(this: *mut cef_v8value_t, - index: libc::c_int) -> *mut interfaces::cef_v8value_t>, - - // - // Associates a value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only values this function will return true - // (1) even though assignment failed. - // - pub set_value_bykey: Option<extern "C" fn(this: *mut cef_v8value_t, - key: *const types::cef_string_t, value: *mut interfaces::cef_v8value_t, - attribute: types::cef_v8_propertyattribute_t) -> libc::c_int>, - - // - // Associates a value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only values this function will return true - // (1) even though assignment failed. - // - pub set_value_byindex: Option<extern "C" fn(this: *mut cef_v8value_t, - index: libc::c_int, - value: *mut interfaces::cef_v8value_t) -> libc::c_int>, - - // - // Registers an identifier and returns true (1) on success. Access to the - // identifier will be forwarded to the cef_v8accessor_t instance passed to - // cef_v8value_t::cef_v8value_create_object(). Returns false (0) if this - // function is called incorrectly or an exception is thrown. For read-only - // values this function will return true (1) even though assignment failed. - // - pub set_value_byaccessor: Option<extern "C" fn(this: *mut cef_v8value_t, - key: *const types::cef_string_t, settings: types::cef_v8_accesscontrol_t, - attribute: types::cef_v8_propertyattribute_t) -> libc::c_int>, - - // - // Read the keys for the object's values into the specified vector. Integer- - // based keys will also be returned as strings. - // - pub get_keys: Option<extern "C" fn(this: *mut cef_v8value_t, - keys: &types::cef_string_list_t) -> libc::c_int>, - - // - // Sets the user data for this object and returns true (1) on success. Returns - // false (0) if this function is called incorrectly. This function can only be - // called on user created objects. - // - pub set_user_data: Option<extern "C" fn(this: *mut cef_v8value_t, - user_data: *mut interfaces::cef_base_t) -> libc::c_int>, - - // - // Returns the user data, if any, assigned to this object. - // - pub get_user_data: Option<extern "C" fn( - this: *mut cef_v8value_t) -> *mut interfaces::cef_base_t>, - - // - // Returns the amount of externally allocated memory registered for the - // object. - // - pub get_externally_allocated_memory: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - // - // Adjusts the amount of registered external memory for the object. Used to - // give V8 an indication of the amount of externally allocated memory that is - // kept alive by JavaScript objects. V8 uses this information to decide when - // to perform global garbage collection. Each cef_v8value_t tracks the amount - // of external memory associated with it and automatically decreases the - // global total by the appropriate amount on its destruction. - // |change_in_bytes| specifies the number of bytes to adjust by. This function - // returns the number of bytes associated with the object after the - // adjustment. This function can only be called on user created objects. - // - pub adjust_externally_allocated_memory: Option<extern "C" fn( - this: *mut cef_v8value_t, change_in_bytes: libc::c_int) -> libc::c_int>, - - - // ARRAY METHODS - These functions are only available on arrays. - - // - // Returns the number of elements in the array. - // - pub get_array_length: Option<extern "C" fn( - this: *mut cef_v8value_t) -> libc::c_int>, - - - // FUNCTION METHODS - These functions are only available on functions. - - // - // Returns the function name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_function_name: Option<extern "C" fn( - this: *mut cef_v8value_t) -> types::cef_string_userfree_t>, - - // - // Returns the function handler or NULL if not a CEF-created function. - // - pub get_function_handler: Option<extern "C" fn( - this: *mut cef_v8value_t) -> *mut interfaces::cef_v8handler_t>, - - // - // Execute the function using the current V8 context. This function should - // only be called from within the scope of a cef_v8handler_t or - // cef_v8accessor_t callback, or in combination with calling enter() and - // exit() on a stored cef_v8context_t reference. |object| is the receiver - // ('this' object) of the function. If |object| is NULL the current context's - // global object will be used. |arguments| is the list of arguments that will - // be passed to the function. Returns the function return value on success. - // Returns NULL if this function is called incorrectly or an exception is - // thrown. - // - pub execute_function: Option<extern "C" fn(this: *mut cef_v8value_t, - object: *mut interfaces::cef_v8value_t, arguments_count: libc::size_t, - arguments: *const *mut interfaces::cef_v8value_t) -> *mut interfaces::cef_v8value_t>, - - // - // Execute the function using the specified V8 context. |object| is the - // receiver ('this' object) of the function. If |object| is NULL the specified - // context's global object will be used. |arguments| is the list of arguments - // that will be passed to the function. Returns the function return value on - // success. Returns NULL if this function is called incorrectly or an - // exception is thrown. - // - pub execute_function_with_context: Option<extern "C" fn( - this: *mut cef_v8value_t, context: *mut interfaces::cef_v8context_t, - object: *mut interfaces::cef_v8value_t, arguments_count: libc::size_t, - arguments: *const *mut interfaces::cef_v8value_t) -> *mut interfaces::cef_v8value_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8value_t = _cef_v8value_t; - - -// -// Structure representing a V8 value handle. V8 handles can only be accessed -// from the thread on which they are created. Valid threads for creating a V8 -// handle include the render process main thread (TID_RENDERER) and WebWorker -// threads. A task runner for posting tasks on the associated thread can be -// retrieved via the cef_v8context_t::get_task_runner() function. -// -pub struct CefV8Value { - c_object: *mut cef_v8value_t, -} - -impl Clone for CefV8Value { - fn clone(&self) -> CefV8Value{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8Value { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8Value { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8Value { - pub unsafe fn from_c_object(c_object: *mut cef_v8value_t) -> CefV8Value { - CefV8Value { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8value_t) -> CefV8Value { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8Value { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8value_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8value_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is undefined. - // - pub fn is_undefined(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_undefined.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is null. - // - pub fn is_null(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_null.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is bool. - // - pub fn is_bool(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_bool.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is int. - // - pub fn is_int(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_int.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is unsigned int. - // - pub fn is_uint(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_uint.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is double. - // - pub fn is_double(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_double.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is Date. - // - pub fn is_date(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_date.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is string. - // - pub fn is_string(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_string.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is object. - // - pub fn is_object(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_object.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is array. - // - pub fn is_array(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_array.unwrap())( - self.c_object)) - } - } - - // - // True if the value type is function. - // - pub fn is_function(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_function.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is pointing to the same handle as |that| - // object. - // - pub fn is_same(&self, that: interfaces::CefV8Value) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Return a bool value. The underlying data will be converted to if - // necessary. - // - pub fn get_bool_value(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bool_value.unwrap())( - self.c_object)) - } - } - - // - // Return an int value. The underlying data will be converted to if - // necessary. - // - pub fn get_int_value(&self) -> i32 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_int_value.unwrap())( - self.c_object)) - } - } - - // - // Return an unisgned int value. The underlying data will be converted to if - // necessary. - // - pub fn get_uint_value(&self) -> u32 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_uint_value.unwrap())( - self.c_object)) - } - } - - // - // Return a double value. The underlying data will be converted to if - // necessary. - // - pub fn get_double_value(&self) -> libc::c_double { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_double_value.unwrap())( - self.c_object)) - } - } - - // - // Return a Date value. The underlying data will be converted to if - // necessary. - // - pub fn get_date_value(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_date_value.unwrap())( - self.c_object)) - } - } - - // - // Return a string value. The underlying data will be converted to if - // necessary. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_string_value(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_string_value.unwrap())( - self.c_object)) - } - } - - - // OBJECT METHODS - These functions are only available on objects. Arrays and - // functions are also objects. String- and integer-based keys can be used - // interchangably with the framework converting between them as necessary. - - // - // Returns true (1) if this is a user created object. - // - pub fn is_user_created(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_user_created.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the last function call resulted in an exception. This - // attribute exists only in the scope of the current CEF value object. - // - pub fn has_exception(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_exception.unwrap())( - self.c_object)) - } - } - - // - // Returns the exception resulting from the last function call. This attribute - // exists only in the scope of the current CEF value object. - // - pub fn get_exception(&self) -> interfaces::CefV8Exception { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_exception.unwrap())( - self.c_object)) - } - } - - // - // Clears the last exception and returns true (1) on success. - // - pub fn clear_exception(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clear_exception.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object will re-throw future exceptions. This - // attribute exists only in the scope of the current CEF value object. - // - pub fn will_rethrow_exceptions(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).will_rethrow_exceptions.unwrap())( - self.c_object)) - } - } - - // - // Set whether this object will re-throw future exceptions. By default - // exceptions are not re-thrown. If a exception is re-thrown the current - // context should not be accessed again until after the exception has been - // caught and not re-thrown. Returns true (1) on success. This attribute - // exists only in the scope of the current CEF value object. - // - pub fn set_rethrow_exceptions(&self, rethrow: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_rethrow_exceptions.unwrap())( - self.c_object, - CefWrap::to_c(rethrow))) - } - } - - // - // Returns true (1) if the object has a value with the specified identifier. - // - pub fn has_value_bykey(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_value_bykey.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns true (1) if the object has a value with the specified identifier. - // - pub fn has_value_byindex(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_value_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Deletes the value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only and don't-delete values this function - // will return true (1) even though deletion failed. - // - pub fn delete_value_bykey(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).delete_value_bykey.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Deletes the value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly, deletion - // fails or an exception is thrown. For read-only and don't-delete values this - // function will return true (1) even though deletion failed. - // - pub fn delete_value_byindex(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).delete_value_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value with the specified identifier on success. Returns NULL if - // this function is called incorrectly or an exception is thrown. - // - pub fn get_value_bykey(&self, key: &[u16]) -> interfaces::CefV8Value { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value_bykey.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value with the specified identifier on success. Returns NULL if - // this function is called incorrectly or an exception is thrown. - // - pub fn get_value_byindex(&self, - index: libc::c_int) -> interfaces::CefV8Value { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Associates a value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only values this function will return true - // (1) even though assignment failed. - // - pub fn set_value_bykey(&self, key: &[u16], value: interfaces::CefV8Value, - attribute: types::cef_v8_propertyattribute_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value_bykey.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value), - CefWrap::to_c(attribute))) - } - } - - // - // Associates a value with the specified identifier and returns true (1) on - // success. Returns false (0) if this function is called incorrectly or an - // exception is thrown. For read-only values this function will return true - // (1) even though assignment failed. - // - pub fn set_value_byindex(&self, index: libc::c_int, - value: interfaces::CefV8Value) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Registers an identifier and returns true (1) on success. Access to the - // identifier will be forwarded to the cef_v8accessor_t instance passed to - // cef_v8value_t::cef_v8value_create_object(). Returns false (0) if this - // function is called incorrectly or an exception is thrown. For read-only - // values this function will return true (1) even though assignment failed. - // - pub fn set_value_byaccessor(&self, key: &[u16], - settings: types::cef_v8_accesscontrol_t, - attribute: types::cef_v8_propertyattribute_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value_byaccessor.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(settings), - CefWrap::to_c(attribute))) - } - } - - // - // Read the keys for the object's values into the specified vector. Integer- - // based keys will also be returned as strings. - // - pub fn get_keys(&self, keys: &Vec<String>) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_keys.unwrap())( - self.c_object, - CefWrap::to_c(keys))) - } - } - - // - // Sets the user data for this object and returns true (1) on success. Returns - // false (0) if this function is called incorrectly. This function can only be - // called on user created objects. - // - pub fn set_user_data(&self, user_data: interfaces::CefBase) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_user_data.unwrap())( - self.c_object, - CefWrap::to_c(user_data))) - } - } - - // - // Returns the user data, if any, assigned to this object. - // - pub fn get_user_data(&self) -> interfaces::CefBase { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_user_data.unwrap())( - self.c_object)) - } - } - - // - // Returns the amount of externally allocated memory registered for the - // object. - // - pub fn get_externally_allocated_memory(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_externally_allocated_memory.unwrap())( - self.c_object)) - } - } - - // - // Adjusts the amount of registered external memory for the object. Used to - // give V8 an indication of the amount of externally allocated memory that is - // kept alive by JavaScript objects. V8 uses this information to decide when - // to perform global garbage collection. Each cef_v8value_t tracks the amount - // of external memory associated with it and automatically decreases the - // global total by the appropriate amount on its destruction. - // |change_in_bytes| specifies the number of bytes to adjust by. This function - // returns the number of bytes associated with the object after the - // adjustment. This function can only be called on user created objects. - // - pub fn adjust_externally_allocated_memory(&self, - change_in_bytes: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).adjust_externally_allocated_memory.unwrap())( - self.c_object, - CefWrap::to_c(change_in_bytes))) - } - } - - - // ARRAY METHODS - These functions are only available on arrays. - - // - // Returns the number of elements in the array. - // - pub fn get_array_length(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_array_length.unwrap())( - self.c_object)) - } - } - - - // FUNCTION METHODS - These functions are only available on functions. - - // - // Returns the function name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_function_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_function_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the function handler or NULL if not a CEF-created function. - // - pub fn get_function_handler(&self) -> interfaces::CefV8Handler { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_function_handler.unwrap())( - self.c_object)) - } - } - - // - // Execute the function using the current V8 context. This function should - // only be called from within the scope of a cef_v8handler_t or - // cef_v8accessor_t callback, or in combination with calling enter() and - // exit() on a stored cef_v8context_t reference. |object| is the receiver - // ('this' object) of the function. If |object| is NULL the current context's - // global object will be used. |arguments| is the list of arguments that will - // be passed to the function. Returns the function return value on success. - // Returns NULL if this function is called incorrectly or an exception is - // thrown. - // - pub fn execute_function(&self, object: interfaces::CefV8Value, - arguments_count: libc::size_t, - arguments: *const interfaces::CefV8Value) -> interfaces::CefV8Value { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).execute_function.unwrap())( - self.c_object, - CefWrap::to_c(object), - CefWrap::to_c(arguments_count), - CefWrap::to_c(arguments))) - } - } - - // - // Execute the function using the specified V8 context. |object| is the - // receiver ('this' object) of the function. If |object| is NULL the specified - // context's global object will be used. |arguments| is the list of arguments - // that will be passed to the function. Returns the function return value on - // success. Returns NULL if this function is called incorrectly or an - // exception is thrown. - // - pub fn execute_function_with_context(&self, context: interfaces::CefV8Context, - object: interfaces::CefV8Value, arguments_count: libc::size_t, - arguments: *const interfaces::CefV8Value) -> interfaces::CefV8Value { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).execute_function_with_context.unwrap())( - self.c_object, - CefWrap::to_c(context), - CefWrap::to_c(object), - CefWrap::to_c(arguments_count), - CefWrap::to_c(arguments))) - } - } - - // - // Create a new cef_v8value_t object of type undefined. - // - pub fn create_undefined() -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_undefined( -)) - } - } - - // - // Create a new cef_v8value_t object of type null. - // - pub fn create_null() -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_null( -)) - } - } - - // - // Create a new cef_v8value_t object of type bool. - // - pub fn create_bool(value: libc::c_int) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_bool( - CefWrap::to_c(value))) - } - } - - // - // Create a new cef_v8value_t object of type int. - // - pub fn create_int(value: i32) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_int( - CefWrap::to_c(value))) - } - } - - // - // Create a new cef_v8value_t object of type unsigned int. - // - pub fn create_uint(value: u32) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_uint( - CefWrap::to_c(value))) - } - } - - // - // Create a new cef_v8value_t object of type double. - // - pub fn create_double(value: libc::c_double) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_double( - CefWrap::to_c(value))) - } - } - - // - // Create a new cef_v8value_t object of type Date. This function should only - // be called from within the scope of a cef_render_process_handler_t, - // cef_v8handler_t or cef_v8accessor_t callback, or in combination with - // calling enter() and exit() on a stored cef_v8context_t reference. - // - pub fn create_date(date: &types::cef_time_t) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_date( - CefWrap::to_c(date))) - } - } - - // - // Create a new cef_v8value_t object of type string. - // - pub fn create_string(value: &[u16]) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_string( - CefWrap::to_c(value))) - } - } - - // - // Create a new cef_v8value_t object of type object with optional accessor. - // This function should only be called from within the scope of a - // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback, - // or in combination with calling enter() and exit() on a stored - // cef_v8context_t reference. - // - pub fn create_object( - accessor: interfaces::CefV8Accessor) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_object( - CefWrap::to_c(accessor))) - } - } - - // - // Create a new cef_v8value_t object of type array with the specified - // |length|. If |length| is negative the returned array will have length 0. - // This function should only be called from within the scope of a - // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback, - // or in combination with calling enter() and exit() on a stored - // cef_v8context_t reference. - // - pub fn create_array(length: libc::c_int) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_array( - CefWrap::to_c(length))) - } - } - - // - // Create a new cef_v8value_t object of type function. This function should - // only be called from within the scope of a cef_render_process_handler_t, - // cef_v8handler_t or cef_v8accessor_t callback, or in combination with - // calling enter() and exit() on a stored cef_v8context_t reference. - // - pub fn create_function(name: &[u16], - handler: interfaces::CefV8Handler) -> interfaces::CefV8Value { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8value_create_function( - CefWrap::to_c(name), - CefWrap::to_c(handler))) - } - } -} - -impl CefWrap<*mut cef_v8value_t> for CefV8Value { - fn to_c(rust_object: CefV8Value) -> *mut cef_v8value_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8value_t) -> CefV8Value { - CefV8Value::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8value_t> for Option<CefV8Value> { - fn to_c(rust_object: Option<CefV8Value>) -> *mut cef_v8value_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8value_t) -> Option<CefV8Value> { - if c_object.is_null() { - None - } else { - Some(CefV8Value::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a V8 stack trace handle. V8 handles can only be -// accessed from the thread on which they are created. Valid threads for -// creating a V8 handle include the render process main thread (TID_RENDERER) -// and WebWorker threads. A task runner for posting tasks on the associated -// thread can be retrieved via the cef_v8context_t::get_task_runner() function. -// -#[repr(C)] -pub struct _cef_v8stack_trace_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_v8stack_trace_t) -> libc::c_int>, - - // - // Returns the number of stack frames. - // - pub get_frame_count: Option<extern "C" fn( - this: *mut cef_v8stack_trace_t) -> libc::c_int>, - - // - // Returns the stack frame at the specified 0-based index. - // - pub get_frame: Option<extern "C" fn(this: *mut cef_v8stack_trace_t, - index: libc::c_int) -> *mut interfaces::cef_v8stack_frame_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8stack_trace_t = _cef_v8stack_trace_t; - - -// -// Structure representing a V8 stack trace handle. V8 handles can only be -// accessed from the thread on which they are created. Valid threads for -// creating a V8 handle include the render process main thread (TID_RENDERER) -// and WebWorker threads. A task runner for posting tasks on the associated -// thread can be retrieved via the cef_v8context_t::get_task_runner() function. -// -pub struct CefV8StackTrace { - c_object: *mut cef_v8stack_trace_t, -} - -impl Clone for CefV8StackTrace { - fn clone(&self) -> CefV8StackTrace{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8StackTrace { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8StackTrace { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8StackTrace { - pub unsafe fn from_c_object(c_object: *mut cef_v8stack_trace_t) -> CefV8StackTrace { - CefV8StackTrace { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8stack_trace_t) -> CefV8StackTrace { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8StackTrace { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8stack_trace_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8stack_trace_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns the number of stack frames. - // - pub fn get_frame_count(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame_count.unwrap())( - self.c_object)) - } - } - - // - // Returns the stack frame at the specified 0-based index. - // - pub fn get_frame(&self, index: libc::c_int) -> interfaces::CefV8StackFrame { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_frame.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the stack trace for the currently active context. |frame_limit| is - // the maximum number of frames that will be captured. - // - pub fn get_current(frame_limit: libc::c_int) -> interfaces::CefV8StackTrace { - unsafe { - CefWrap::to_rust( - ::v8::cef_v8stack_trace_get_current( - CefWrap::to_c(frame_limit))) - } - } -} - -impl CefWrap<*mut cef_v8stack_trace_t> for CefV8StackTrace { - fn to_c(rust_object: CefV8StackTrace) -> *mut cef_v8stack_trace_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8stack_trace_t) -> CefV8StackTrace { - CefV8StackTrace::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8stack_trace_t> for Option<CefV8StackTrace> { - fn to_c(rust_object: Option<CefV8StackTrace>) -> *mut cef_v8stack_trace_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8stack_trace_t) -> Option<CefV8StackTrace> { - if c_object.is_null() { - None - } else { - Some(CefV8StackTrace::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a V8 stack frame handle. V8 handles can only be -// accessed from the thread on which they are created. Valid threads for -// creating a V8 handle include the render process main thread (TID_RENDERER) -// and WebWorker threads. A task runner for posting tasks on the associated -// thread can be retrieved via the cef_v8context_t::get_task_runner() function. -// -#[repr(C)] -pub struct _cef_v8stack_frame_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> libc::c_int>, - - // - // Returns the name of the resource script that contains the function. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_script_name: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> types::cef_string_userfree_t>, - - // - // Returns the name of the resource script that contains the function or the - // sourceURL value if the script name is undefined and its source ends with a - // "//@ sourceURL=..." string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_script_name_or_source_url: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> types::cef_string_userfree_t>, - - // - // Returns the name of the function. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_function_name: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> types::cef_string_userfree_t>, - - // - // Returns the 1-based line number for the function call or 0 if unknown. - // - pub get_line_number: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> libc::c_int>, - - // - // Returns the 1-based column offset on the line for the function call or 0 if - // unknown. - // - pub get_column: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> libc::c_int>, - - // - // Returns true (1) if the function was compiled using eval(). - // - pub is_eval: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> libc::c_int>, - - // - // Returns true (1) if the function was called as a constructor via "new". - // - pub is_constructor: Option<extern "C" fn( - this: *mut cef_v8stack_frame_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_v8stack_frame_t = _cef_v8stack_frame_t; - - -// -// Structure representing a V8 stack frame handle. V8 handles can only be -// accessed from the thread on which they are created. Valid threads for -// creating a V8 handle include the render process main thread (TID_RENDERER) -// and WebWorker threads. A task runner for posting tasks on the associated -// thread can be retrieved via the cef_v8context_t::get_task_runner() function. -// -pub struct CefV8StackFrame { - c_object: *mut cef_v8stack_frame_t, -} - -impl Clone for CefV8StackFrame { - fn clone(&self) -> CefV8StackFrame{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefV8StackFrame { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefV8StackFrame { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefV8StackFrame { - pub unsafe fn from_c_object(c_object: *mut cef_v8stack_frame_t) -> CefV8StackFrame { - CefV8StackFrame { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_v8stack_frame_t) -> CefV8StackFrame { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefV8StackFrame { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_v8stack_frame_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_v8stack_frame_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if the underlying handle is valid and it can be accessed - // on the current thread. Do not call any other functions if this function - // returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns the name of the resource script that contains the function. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_script_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_script_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the name of the resource script that contains the function or the - // sourceURL value if the script name is undefined and its source ends with a - // "//@ sourceURL=..." string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_script_name_or_source_url(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_script_name_or_source_url.unwrap())( - self.c_object)) - } - } - - // - // Returns the name of the function. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_function_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_function_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the 1-based line number for the function call or 0 if unknown. - // - pub fn get_line_number(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_line_number.unwrap())( - self.c_object)) - } - } - - // - // Returns the 1-based column offset on the line for the function call or 0 if - // unknown. - // - pub fn get_column(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_column.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the function was compiled using eval(). - // - pub fn is_eval(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_eval.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the function was called as a constructor via "new". - // - pub fn is_constructor(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_constructor.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_v8stack_frame_t> for CefV8StackFrame { - fn to_c(rust_object: CefV8StackFrame) -> *mut cef_v8stack_frame_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_v8stack_frame_t) -> CefV8StackFrame { - CefV8StackFrame::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_v8stack_frame_t> for Option<CefV8StackFrame> { - fn to_c(rust_object: Option<CefV8StackFrame>) -> *mut cef_v8stack_frame_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_v8stack_frame_t) -> Option<CefV8StackFrame> { - if c_object.is_null() { - None - } else { - Some(CefV8StackFrame::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_values.rs b/ports/cef/interfaces/cef_values.rs deleted file mode 100644 index 0283ae10b4e..00000000000 --- a/ports/cef/interfaces/cef_values.rs +++ /dev/null @@ -1,2623 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure that wraps other data value types. Complex types (binary, -// dictionary and list) will be referenced but not owned by this object. Can be -// used on any process and thread. -// -#[repr(C)] -pub struct _cef_value_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if the underlying data is valid. This will always be true - // (1) for simple types. For complex types (binary, dictionary and list) the - // underlying data may become invalid if owned by another object (e.g. list or - // dictionary) and that other object is then modified or destroyed. This value - // object can be re-used by calling Set*() even if the underlying data is - // invalid. - // - pub is_valid: Option<extern "C" fn(this: *mut cef_value_t) -> libc::c_int>, - - // - // Returns true (1) if the underlying data is owned by another object. - // - pub is_owned: Option<extern "C" fn(this: *mut cef_value_t) -> libc::c_int>, - - // - // Returns true (1) if the underlying data is read-only. Some APIs may expose - // read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub is_same: Option<extern "C" fn(this: *mut cef_value_t, - that: *mut interfaces::cef_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub is_equal: Option<extern "C" fn(this: *mut cef_value_t, - that: *mut interfaces::cef_value_t) -> libc::c_int>, - - // - // Returns a copy of this object. The underlying data will also be copied. - // - pub copy: Option<extern "C" fn( - this: *mut cef_value_t) -> *mut interfaces::cef_value_t>, - - // - // Returns the underlying value type. - // - pub get_type: Option<extern "C" fn( - this: *mut cef_value_t) -> interfaces::cef_value_type_t>, - - // - // Returns the underlying value as type bool. - // - pub get_bool: Option<extern "C" fn(this: *mut cef_value_t) -> libc::c_int>, - - // - // Returns the underlying value as type int. - // - pub get_int: Option<extern "C" fn(this: *mut cef_value_t) -> libc::c_int>, - - // - // Returns the underlying value as type double. - // - pub get_double: Option<extern "C" fn( - this: *mut cef_value_t) -> libc::c_double>, - - // - // Returns the underlying value as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_string: Option<extern "C" fn( - this: *mut cef_value_t) -> types::cef_string_userfree_t>, - - // - // Returns the underlying value as type binary. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_binary(). - // - pub get_binary: Option<extern "C" fn( - this: *mut cef_value_t) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the underlying value as type dictionary. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_dictionary(). - // - pub get_dictionary: Option<extern "C" fn( - this: *mut cef_value_t) -> *mut interfaces::cef_dictionary_value_t>, - - // - // Returns the underlying value as type list. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_list(). - // - pub get_list: Option<extern "C" fn( - this: *mut cef_value_t) -> *mut interfaces::cef_list_value_t>, - - // - // Sets the underlying value as type null. Returns true (1) if the value was - // set successfully. - // - pub set_null: Option<extern "C" fn(this: *mut cef_value_t) -> libc::c_int>, - - // - // Sets the underlying value as type bool. Returns true (1) if the value was - // set successfully. - // - pub set_bool: Option<extern "C" fn(this: *mut cef_value_t, - value: libc::c_int) -> libc::c_int>, - - // - // Sets the underlying value as type int. Returns true (1) if the value was - // set successfully. - // - pub set_int: Option<extern "C" fn(this: *mut cef_value_t, - value: libc::c_int) -> libc::c_int>, - - // - // Sets the underlying value as type double. Returns true (1) if the value was - // set successfully. - // - pub set_double: Option<extern "C" fn(this: *mut cef_value_t, - value: libc::c_double) -> libc::c_int>, - - // - // Sets the underlying value as type string. Returns true (1) if the value was - // set successfully. - // - pub set_string: Option<extern "C" fn(this: *mut cef_value_t, - value: *const types::cef_string_t) -> libc::c_int>, - - // - // Sets the underlying value as type binary. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub set_binary: Option<extern "C" fn(this: *mut cef_value_t, - value: *mut interfaces::cef_binary_value_t) -> libc::c_int>, - - // - // Sets the underlying value as type dict. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub set_dictionary: Option<extern "C" fn(this: *mut cef_value_t, - value: *mut interfaces::cef_dictionary_value_t) -> libc::c_int>, - - // - // Sets the underlying value as type list. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub set_list: Option<extern "C" fn(this: *mut cef_value_t, - value: *mut interfaces::cef_list_value_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_value_t = _cef_value_t; - - -// -// Structure that wraps other data value types. Complex types (binary, -// dictionary and list) will be referenced but not owned by this object. Can be -// used on any process and thread. -// -pub struct CefValue { - c_object: *mut cef_value_t, -} - -impl Clone for CefValue { - fn clone(&self) -> CefValue{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefValue { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefValue { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefValue { - pub unsafe fn from_c_object(c_object: *mut cef_value_t) -> CefValue { - CefValue { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_value_t) -> CefValue { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefValue { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_value_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_value_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if the underlying data is valid. This will always be true - // (1) for simple types. For complex types (binary, dictionary and list) the - // underlying data may become invalid if owned by another object (e.g. list or - // dictionary) and that other object is then modified or destroyed. This value - // object can be re-used by calling Set*() even if the underlying data is - // invalid. - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the underlying data is owned by another object. - // - pub fn is_owned(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_owned.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the underlying data is read-only. Some APIs may expose - // read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub fn is_same(&self, that: interfaces::CefValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub fn is_equal(&self, that: interfaces::CefValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_equal.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns a copy of this object. The underlying data will also be copied. - // - pub fn copy(&self) -> interfaces::CefValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value type. - // - pub fn get_type(&self) -> interfaces::CefValueType { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type bool. - // - pub fn get_bool(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bool.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type int. - // - pub fn get_int(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_int.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type double. - // - pub fn get_double(&self) -> libc::c_double { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_double.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_string(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_string.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type binary. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_binary(). - // - pub fn get_binary(&self) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_binary.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type dictionary. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_dictionary(). - // - pub fn get_dictionary(&self) -> interfaces::CefDictionaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dictionary.unwrap())( - self.c_object)) - } - } - - // - // Returns the underlying value as type list. The returned reference may - // become invalid if the value is owned by another object or if ownership is - // transferred to another object in the future. To maintain a reference to the - // value after assigning ownership to a dictionary or list pass this object to - // the set_value() function instead of passing the returned reference to - // set_list(). - // - pub fn get_list(&self) -> interfaces::CefListValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_list.unwrap())( - self.c_object)) - } - } - - // - // Sets the underlying value as type null. Returns true (1) if the value was - // set successfully. - // - pub fn set_null(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_null.unwrap())( - self.c_object)) - } - } - - // - // Sets the underlying value as type bool. Returns true (1) if the value was - // set successfully. - // - pub fn set_bool(&self, value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_bool.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type int. Returns true (1) if the value was - // set successfully. - // - pub fn set_int(&self, value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_int.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type double. Returns true (1) if the value was - // set successfully. - // - pub fn set_double(&self, value: libc::c_double) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_double.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type string. Returns true (1) if the value was - // set successfully. - // - pub fn set_string(&self, value: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_string.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type binary. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub fn set_binary(&self, value: interfaces::CefBinaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_binary.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type dict. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub fn set_dictionary(&self, - value: interfaces::CefDictionaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Sets the underlying value as type list. Returns true (1) if the value was - // set successfully. This object keeps a reference to |value| and ownership of - // the underlying data remains unchanged. - // - pub fn set_list(&self, value: interfaces::CefListValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_list.unwrap())( - self.c_object, - CefWrap::to_c(value))) - } - } - - // - // Creates a new object. - // - pub fn create() -> interfaces::CefValue { - unsafe { - CefWrap::to_rust( - ::values::cef_value_create( -)) - } - } -} - -impl CefWrap<*mut cef_value_t> for CefValue { - fn to_c(rust_object: CefValue) -> *mut cef_value_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_value_t) -> CefValue { - CefValue::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_value_t> for Option<CefValue> { - fn to_c(rust_object: Option<CefValue>) -> *mut cef_value_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_value_t) -> Option<CefValue> { - if c_object.is_null() { - None - } else { - Some(CefValue::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a binary value. Can be used on any process and thread. -// -#[repr(C)] -pub struct _cef_binary_value_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_binary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object is currently owned by another object. - // - pub is_owned: Option<extern "C" fn( - this: *mut cef_binary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. - // - pub is_same: Option<extern "C" fn(this: *mut cef_binary_value_t, - that: *mut interfaces::cef_binary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub is_equal: Option<extern "C" fn(this: *mut cef_binary_value_t, - that: *mut interfaces::cef_binary_value_t) -> libc::c_int>, - - // - // Returns a copy of this object. The data in this object will also be copied. - // - pub copy: Option<extern "C" fn( - this: *mut cef_binary_value_t) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the data size. - // - pub get_size: Option<extern "C" fn( - this: *mut cef_binary_value_t) -> libc::size_t>, - - // - // Read up to |buffer_size| number of bytes into |buffer|. Reading begins at - // the specified byte |data_offset|. Returns the number of bytes read. - // - pub get_data: Option<extern "C" fn(this: *mut cef_binary_value_t, - buffer: *mut (), buffer_size: libc::size_t, - data_offset: libc::size_t) -> libc::size_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_binary_value_t = _cef_binary_value_t; - - -// -// Structure representing a binary value. Can be used on any process and thread. -// -pub struct CefBinaryValue { - c_object: *mut cef_binary_value_t, -} - -impl Clone for CefBinaryValue { - fn clone(&self) -> CefBinaryValue{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefBinaryValue { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefBinaryValue { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefBinaryValue { - pub unsafe fn from_c_object(c_object: *mut cef_binary_value_t) -> CefBinaryValue { - CefBinaryValue { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_binary_value_t) -> CefBinaryValue { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefBinaryValue { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_binary_value_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_binary_value_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is currently owned by another object. - // - pub fn is_owned(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_owned.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. - // - pub fn is_same(&self, that: interfaces::CefBinaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub fn is_equal(&self, that: interfaces::CefBinaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_equal.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns a copy of this object. The data in this object will also be copied. - // - pub fn copy(&self) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Returns the data size. - // - pub fn get_size(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_size.unwrap())( - self.c_object)) - } - } - - // - // Read up to |buffer_size| number of bytes into |buffer|. Reading begins at - // the specified byte |data_offset|. Returns the number of bytes read. - // - pub fn get_data(&self, buffer: &mut (), buffer_size: libc::size_t, - data_offset: libc::size_t) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_data.unwrap())( - self.c_object, - CefWrap::to_c(buffer), - CefWrap::to_c(buffer_size), - CefWrap::to_c(data_offset))) - } - } - - // - // Creates a new object that is not owned by any other object. The specified - // |data| will be copied. - // - pub fn create(data: &(), - data_size: libc::size_t) -> interfaces::CefBinaryValue { - unsafe { - CefWrap::to_rust( - ::values::cef_binary_value_create( - CefWrap::to_c(data), - CefWrap::to_c(data_size))) - } - } -} - -impl CefWrap<*mut cef_binary_value_t> for CefBinaryValue { - fn to_c(rust_object: CefBinaryValue) -> *mut cef_binary_value_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_binary_value_t) -> CefBinaryValue { - CefBinaryValue::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_binary_value_t> for Option<CefBinaryValue> { - fn to_c(rust_object: Option<CefBinaryValue>) -> *mut cef_binary_value_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_binary_value_t) -> Option<CefBinaryValue> { - if c_object.is_null() { - None - } else { - Some(CefBinaryValue::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a dictionary value. Can be used on any process and -// thread. -// -#[repr(C)] -pub struct _cef_dictionary_value_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object is currently owned by another object. - // - pub is_owned: Option<extern "C" fn( - this: *mut cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub is_same: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - that: *mut interfaces::cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub is_equal: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - that: *mut interfaces::cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns a writable copy of this object. If |exclude_NULL_children| is true - // (1) any NULL dictionaries or lists will be excluded from the copy. - // - pub copy: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - exclude_empty_children: libc::c_int) -> *mut interfaces::cef_dictionary_value_t>, - - // - // Returns the number of values. - // - pub get_size: Option<extern "C" fn( - this: *mut cef_dictionary_value_t) -> libc::size_t>, - - // - // Removes all values. Returns true (1) on success. - // - pub clear: Option<extern "C" fn( - this: *mut cef_dictionary_value_t) -> libc::c_int>, - - // - // Returns true (1) if the current dictionary has a value for the given key. - // - pub has_key: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Reads all keys for this dictionary into the specified vector. - // - pub get_keys: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - keys: &types::cef_string_list_t) -> libc::c_int>, - - // - // Removes the value at the specified key. Returns true (1) is the value was - // removed successfully. - // - pub remove: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the value type for the specified key. - // - pub get_type: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> interfaces::cef_value_type_t>, - - // - // Returns the value at the specified key. For simple types the returned value - // will copy existing data and modifications to the value will not modify this - // object. For complex types (binary, dictionary and list) the returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub get_value: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> *mut interfaces::cef_value_t>, - - // - // Returns the value at the specified key as type bool. - // - pub get_bool: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the value at the specified key as type int. - // - pub get_int: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Returns the value at the specified key as type double. - // - pub get_double: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_double>, - - // - // Returns the value at the specified key as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_string: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Returns the value at the specified key as type binary. The returned value - // will reference existing data. - // - pub get_binary: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the value at the specified key as type dictionary. The returned - // value will reference existing data and modifications to the value will - // modify this object. - // - pub get_dictionary: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> *mut interfaces::cef_dictionary_value_t>, - - // - // Returns the value at the specified key as type list. The returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub get_list: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> *mut interfaces::cef_list_value_t>, - - // - // Sets the value at the specified key. Returns true (1) if the value was set - // successfully. If |value| represents simple data then the underlying data - // will be copied and modifications to |value| will not modify this object. If - // |value| represents complex data (binary, dictionary or list) then the - // underlying data will be referenced and modifications to |value| will modify - // this object. - // - pub set_value: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, - value: *mut interfaces::cef_value_t) -> libc::c_int>, - - // - // Sets the value at the specified key as type null. Returns true (1) if the - // value was set successfully. - // - pub set_null: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t) -> libc::c_int>, - - // - // Sets the value at the specified key as type bool. Returns true (1) if the - // value was set successfully. - // - pub set_bool: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, value: libc::c_int) -> libc::c_int>, - - // - // Sets the value at the specified key as type int. Returns true (1) if the - // value was set successfully. - // - pub set_int: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, value: libc::c_int) -> libc::c_int>, - - // - // Sets the value at the specified key as type double. Returns true (1) if the - // value was set successfully. - // - pub set_double: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, value: libc::c_double) -> libc::c_int>, - - // - // Sets the value at the specified key as type string. Returns true (1) if the - // value was set successfully. - // - pub set_string: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, - value: *const types::cef_string_t) -> libc::c_int>, - - // - // Sets the value at the specified key as type binary. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub set_binary: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, - value: *mut interfaces::cef_binary_value_t) -> libc::c_int>, - - // - // Sets the value at the specified key as type dict. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub set_dictionary: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, - value: *mut interfaces::cef_dictionary_value_t) -> libc::c_int>, - - // - // Sets the value at the specified key as type list. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub set_list: Option<extern "C" fn(this: *mut cef_dictionary_value_t, - key: *const types::cef_string_t, - value: *mut interfaces::cef_list_value_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_dictionary_value_t = _cef_dictionary_value_t; - - -// -// Structure representing a dictionary value. Can be used on any process and -// thread. -// -pub struct CefDictionaryValue { - c_object: *mut cef_dictionary_value_t, -} - -impl Clone for CefDictionaryValue { - fn clone(&self) -> CefDictionaryValue{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefDictionaryValue { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefDictionaryValue { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefDictionaryValue { - pub unsafe fn from_c_object(c_object: *mut cef_dictionary_value_t) -> CefDictionaryValue { - CefDictionaryValue { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_dictionary_value_t) -> CefDictionaryValue { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefDictionaryValue { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_dictionary_value_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_dictionary_value_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is currently owned by another object. - // - pub fn is_owned(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_owned.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub fn is_same(&self, that: interfaces::CefDictionaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub fn is_equal(&self, that: interfaces::CefDictionaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_equal.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns a writable copy of this object. If |exclude_NULL_children| is true - // (1) any NULL dictionaries or lists will be excluded from the copy. - // - pub fn copy(&self, - exclude_empty_children: libc::c_int) -> interfaces::CefDictionaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object, - CefWrap::to_c(exclude_empty_children))) - } - } - - // - // Returns the number of values. - // - pub fn get_size(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_size.unwrap())( - self.c_object)) - } - } - - // - // Removes all values. Returns true (1) on success. - // - pub fn clear(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clear.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the current dictionary has a value for the given key. - // - pub fn has_key(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_key.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Reads all keys for this dictionary into the specified vector. - // - pub fn get_keys(&self, keys: &Vec<String>) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_keys.unwrap())( - self.c_object, - CefWrap::to_c(keys))) - } - } - - // - // Removes the value at the specified key. Returns true (1) is the value was - // removed successfully. - // - pub fn remove(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value type for the specified key. - // - pub fn get_type(&self, key: &[u16]) -> interfaces::CefValueType { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key. For simple types the returned value - // will copy existing data and modifications to the value will not modify this - // object. For complex types (binary, dictionary and list) the returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub fn get_value(&self, key: &[u16]) -> interfaces::CefValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type bool. - // - pub fn get_bool(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bool.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type int. - // - pub fn get_int(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_int.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type double. - // - pub fn get_double(&self, key: &[u16]) -> libc::c_double { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_double.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_string(&self, key: &[u16]) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_string.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type binary. The returned value - // will reference existing data. - // - pub fn get_binary(&self, key: &[u16]) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_binary.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type dictionary. The returned - // value will reference existing data and modifications to the value will - // modify this object. - // - pub fn get_dictionary(&self, key: &[u16]) -> interfaces::CefDictionaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Returns the value at the specified key as type list. The returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub fn get_list(&self, key: &[u16]) -> interfaces::CefListValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_list.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Sets the value at the specified key. Returns true (1) if the value was set - // successfully. If |value| represents simple data then the underlying data - // will be copied and modifications to |value| will not modify this object. If - // |value| represents complex data (binary, dictionary or list) then the - // underlying data will be referenced and modifications to |value| will modify - // this object. - // - pub fn set_value(&self, key: &[u16], - value: interfaces::CefValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type null. Returns true (1) if the - // value was set successfully. - // - pub fn set_null(&self, key: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_null.unwrap())( - self.c_object, - CefWrap::to_c(key))) - } - } - - // - // Sets the value at the specified key as type bool. Returns true (1) if the - // value was set successfully. - // - pub fn set_bool(&self, key: &[u16], value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_bool.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type int. Returns true (1) if the - // value was set successfully. - // - pub fn set_int(&self, key: &[u16], value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_int.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type double. Returns true (1) if the - // value was set successfully. - // - pub fn set_double(&self, key: &[u16], value: libc::c_double) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_double.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type string. Returns true (1) if the - // value was set successfully. - // - pub fn set_string(&self, key: &[u16], value: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_string.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type binary. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub fn set_binary(&self, key: &[u16], - value: interfaces::CefBinaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_binary.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type dict. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub fn set_dictionary(&self, key: &[u16], - value: interfaces::CefDictionaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified key as type list. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub fn set_list(&self, key: &[u16], - value: interfaces::CefListValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_list.unwrap())( - self.c_object, - CefWrap::to_c(key), - CefWrap::to_c(value))) - } - } - - // - // Creates a new object that is not owned by any other object. - // - pub fn create() -> interfaces::CefDictionaryValue { - unsafe { - CefWrap::to_rust( - ::values::cef_dictionary_value_create( -)) - } - } -} - -impl CefWrap<*mut cef_dictionary_value_t> for CefDictionaryValue { - fn to_c(rust_object: CefDictionaryValue) -> *mut cef_dictionary_value_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_dictionary_value_t) -> CefDictionaryValue { - CefDictionaryValue::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_dictionary_value_t> for Option<CefDictionaryValue> { - fn to_c(rust_object: Option<CefDictionaryValue>) -> *mut cef_dictionary_value_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_dictionary_value_t) -> Option<CefDictionaryValue> { - if c_object.is_null() { - None - } else { - Some(CefDictionaryValue::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure representing a list value. Can be used on any process and thread. -// -#[repr(C)] -pub struct _cef_list_value_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub is_valid: Option<extern "C" fn( - this: *mut cef_list_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object is currently owned by another object. - // - pub is_owned: Option<extern "C" fn( - this: *mut cef_list_value_t) -> libc::c_int>, - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub is_read_only: Option<extern "C" fn( - this: *mut cef_list_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub is_same: Option<extern "C" fn(this: *mut cef_list_value_t, - that: *mut interfaces::cef_list_value_t) -> libc::c_int>, - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub is_equal: Option<extern "C" fn(this: *mut cef_list_value_t, - that: *mut interfaces::cef_list_value_t) -> libc::c_int>, - - // - // Returns a writable copy of this object. - // - pub copy: Option<extern "C" fn( - this: *mut cef_list_value_t) -> *mut interfaces::cef_list_value_t>, - - // - // Sets the number of values. If the number of values is expanded all new - // value slots will default to type null. Returns true (1) on success. - // - pub set_size: Option<extern "C" fn(this: *mut cef_list_value_t, - size: libc::size_t) -> libc::c_int>, - - // - // Returns the number of values. - // - pub get_size: Option<extern "C" fn( - this: *mut cef_list_value_t) -> libc::size_t>, - - // - // Removes all values. Returns true (1) on success. - // - pub clear: Option<extern "C" fn(this: *mut cef_list_value_t) -> libc::c_int>, - - // - // Removes the value at the specified index. - // - pub remove: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Returns the value type at the specified index. - // - pub get_type: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> interfaces::cef_value_type_t>, - - // - // Returns the value at the specified index. For simple types the returned - // value will copy existing data and modifications to the value will not - // modify this object. For complex types (binary, dictionary and list) the - // returned value will reference existing data and modifications to the value - // will modify this object. - // - pub get_value: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> *mut interfaces::cef_value_t>, - - // - // Returns the value at the specified index as type bool. - // - pub get_bool: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Returns the value at the specified index as type int. - // - pub get_int: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Returns the value at the specified index as type double. - // - pub get_double: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> libc::c_double>, - - // - // Returns the value at the specified index as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_string: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> types::cef_string_userfree_t>, - - // - // Returns the value at the specified index as type binary. The returned value - // will reference existing data. - // - pub get_binary: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> *mut interfaces::cef_binary_value_t>, - - // - // Returns the value at the specified index as type dictionary. The returned - // value will reference existing data and modifications to the value will - // modify this object. - // - pub get_dictionary: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> *mut interfaces::cef_dictionary_value_t>, - - // - // Returns the value at the specified index as type list. The returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub get_list: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> *mut interfaces::cef_list_value_t>, - - // - // Sets the value at the specified index. Returns true (1) if the value was - // set successfully. If |value| represents simple data then the underlying - // data will be copied and modifications to |value| will not modify this - // object. If |value| represents complex data (binary, dictionary or list) - // then the underlying data will be referenced and modifications to |value| - // will modify this object. - // - pub set_value: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, value: *mut interfaces::cef_value_t) -> libc::c_int>, - - // - // Sets the value at the specified index as type null. Returns true (1) if the - // value was set successfully. - // - pub set_null: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int) -> libc::c_int>, - - // - // Sets the value at the specified index as type bool. Returns true (1) if the - // value was set successfully. - // - pub set_bool: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, value: libc::c_int) -> libc::c_int>, - - // - // Sets the value at the specified index as type int. Returns true (1) if the - // value was set successfully. - // - pub set_int: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, value: libc::c_int) -> libc::c_int>, - - // - // Sets the value at the specified index as type double. Returns true (1) if - // the value was set successfully. - // - pub set_double: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, value: libc::c_double) -> libc::c_int>, - - // - // Sets the value at the specified index as type string. Returns true (1) if - // the value was set successfully. - // - pub set_string: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, value: *const types::cef_string_t) -> libc::c_int>, - - // - // Sets the value at the specified index as type binary. Returns true (1) if - // the value was set successfully. If |value| is currently owned by another - // object then the value will be copied and the |value| reference will not - // change. Otherwise, ownership will be transferred to this object and the - // |value| reference will be invalidated. - // - pub set_binary: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, - value: *mut interfaces::cef_binary_value_t) -> libc::c_int>, - - // - // Sets the value at the specified index as type dict. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub set_dictionary: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, - value: *mut interfaces::cef_dictionary_value_t) -> libc::c_int>, - - // - // Sets the value at the specified index as type list. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub set_list: Option<extern "C" fn(this: *mut cef_list_value_t, - index: libc::c_int, - value: *mut interfaces::cef_list_value_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_list_value_t = _cef_list_value_t; - - -// -// Structure representing a list value. Can be used on any process and thread. -// -pub struct CefListValue { - c_object: *mut cef_list_value_t, -} - -impl Clone for CefListValue { - fn clone(&self) -> CefListValue{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefListValue { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefListValue { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefListValue { - pub unsafe fn from_c_object(c_object: *mut cef_list_value_t) -> CefListValue { - CefListValue { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_list_value_t) -> CefListValue { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefListValue { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_list_value_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_list_value_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns true (1) if this object is valid. This object may become invalid if - // the underlying data is owned by another object (e.g. list or dictionary) - // and that other object is then modified or destroyed. Do not call any other - // functions if this function returns false (0). - // - pub fn is_valid(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_valid.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object is currently owned by another object. - // - pub fn is_owned(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_owned.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the values of this object are read-only. Some APIs may - // expose read-only objects. - // - pub fn is_read_only(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_read_only.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if this object and |that| object have the same underlying - // data. If true (1) modifications to this object will also affect |that| - // object and vice-versa. - // - pub fn is_same(&self, that: interfaces::CefListValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_same.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns true (1) if this object and |that| object have an equivalent - // underlying value but are not necessarily the same object. - // - pub fn is_equal(&self, that: interfaces::CefListValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_equal.unwrap())( - self.c_object, - CefWrap::to_c(that))) - } - } - - // - // Returns a writable copy of this object. - // - pub fn copy(&self) -> interfaces::CefListValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).copy.unwrap())( - self.c_object)) - } - } - - // - // Sets the number of values. If the number of values is expanded all new - // value slots will default to type null. Returns true (1) on success. - // - pub fn set_size(&self, size: libc::size_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_size.unwrap())( - self.c_object, - CefWrap::to_c(size))) - } - } - - // - // Returns the number of values. - // - pub fn get_size(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_size.unwrap())( - self.c_object)) - } - } - - // - // Removes all values. Returns true (1) on success. - // - pub fn clear(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).clear.unwrap())( - self.c_object)) - } - } - - // - // Removes the value at the specified index. - // - pub fn remove(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).remove.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value type at the specified index. - // - pub fn get_type(&self, index: libc::c_int) -> interfaces::CefValueType { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index. For simple types the returned - // value will copy existing data and modifications to the value will not - // modify this object. For complex types (binary, dictionary and list) the - // returned value will reference existing data and modifications to the value - // will modify this object. - // - pub fn get_value(&self, index: libc::c_int) -> interfaces::CefValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type bool. - // - pub fn get_bool(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_bool.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type int. - // - pub fn get_int(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_int.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type double. - // - pub fn get_double(&self, index: libc::c_int) -> libc::c_double { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_double.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_string(&self, index: libc::c_int) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_string.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type binary. The returned value - // will reference existing data. - // - pub fn get_binary(&self, index: libc::c_int) -> interfaces::CefBinaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_binary.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type dictionary. The returned - // value will reference existing data and modifications to the value will - // modify this object. - // - pub fn get_dictionary(&self, - index: libc::c_int) -> interfaces::CefDictionaryValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value at the specified index as type list. The returned value - // will reference existing data and modifications to the value will modify - // this object. - // - pub fn get_list(&self, index: libc::c_int) -> interfaces::CefListValue { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_list.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Sets the value at the specified index. Returns true (1) if the value was - // set successfully. If |value| represents simple data then the underlying - // data will be copied and modifications to |value| will not modify this - // object. If |value| represents complex data (binary, dictionary or list) - // then the underlying data will be referenced and modifications to |value| - // will modify this object. - // - pub fn set_value(&self, index: libc::c_int, - value: interfaces::CefValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_value.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type null. Returns true (1) if the - // value was set successfully. - // - pub fn set_null(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_null.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Sets the value at the specified index as type bool. Returns true (1) if the - // value was set successfully. - // - pub fn set_bool(&self, index: libc::c_int, - value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_bool.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type int. Returns true (1) if the - // value was set successfully. - // - pub fn set_int(&self, index: libc::c_int, value: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_int.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type double. Returns true (1) if - // the value was set successfully. - // - pub fn set_double(&self, index: libc::c_int, - value: libc::c_double) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_double.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type string. Returns true (1) if - // the value was set successfully. - // - pub fn set_string(&self, index: libc::c_int, value: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_string.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type binary. Returns true (1) if - // the value was set successfully. If |value| is currently owned by another - // object then the value will be copied and the |value| reference will not - // change. Otherwise, ownership will be transferred to this object and the - // |value| reference will be invalidated. - // - pub fn set_binary(&self, index: libc::c_int, - value: interfaces::CefBinaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_binary.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type dict. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub fn set_dictionary(&self, index: libc::c_int, - value: interfaces::CefDictionaryValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_dictionary.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Sets the value at the specified index as type list. Returns true (1) if the - // value was set successfully. If |value| is currently owned by another object - // then the value will be copied and the |value| reference will not change. - // Otherwise, ownership will be transferred to this object and the |value| - // reference will be invalidated. - // - pub fn set_list(&self, index: libc::c_int, - value: interfaces::CefListValue) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).set_list.unwrap())( - self.c_object, - CefWrap::to_c(index), - CefWrap::to_c(value))) - } - } - - // - // Creates a new object that is not owned by any other object. - // - pub fn create() -> interfaces::CefListValue { - unsafe { - CefWrap::to_rust( - ::values::cef_list_value_create( -)) - } - } -} - -impl CefWrap<*mut cef_list_value_t> for CefListValue { - fn to_c(rust_object: CefListValue) -> *mut cef_list_value_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_list_value_t) -> CefListValue { - CefListValue::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_list_value_t> for Option<CefListValue> { - fn to_c(rust_object: Option<CefListValue>) -> *mut cef_list_value_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_list_value_t) -> Option<CefListValue> { - if c_object.is_null() { - None - } else { - Some(CefListValue::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_web_plugin.rs b/ports/cef/interfaces/cef_web_plugin.rs deleted file mode 100644 index 705cc24ad04..00000000000 --- a/ports/cef/interfaces/cef_web_plugin.rs +++ /dev/null @@ -1,545 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Information about a specific web plugin. -// -#[repr(C)] -pub struct _cef_web_plugin_info_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Returns the plugin name (i.e. Flash). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_name: Option<extern "C" fn( - this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>, - - // - // Returns the plugin file path (DLL/bundle/library). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_path: Option<extern "C" fn( - this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>, - - // - // Returns the version of the plugin (may be OS-specific). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_version: Option<extern "C" fn( - this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>, - - // - // Returns a description of the plugin from the version information. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_description: Option<extern "C" fn( - this: *mut cef_web_plugin_info_t) -> types::cef_string_userfree_t>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_web_plugin_info_t = _cef_web_plugin_info_t; - - -// -// Information about a specific web plugin. -// -pub struct CefWebPluginInfo { - c_object: *mut cef_web_plugin_info_t, -} - -impl Clone for CefWebPluginInfo { - fn clone(&self) -> CefWebPluginInfo{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefWebPluginInfo { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefWebPluginInfo { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefWebPluginInfo { - pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo { - CefWebPluginInfo { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefWebPluginInfo { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_web_plugin_info_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Returns the plugin name (i.e. Flash). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the plugin file path (DLL/bundle/library). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_path(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_path.unwrap())( - self.c_object)) - } - } - - // - // Returns the version of the plugin (may be OS-specific). - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_version(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_version.unwrap())( - self.c_object)) - } - } - - // - // Returns a description of the plugin from the version information. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_description(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_description.unwrap())( - self.c_object)) - } - } -} - -impl CefWrap<*mut cef_web_plugin_info_t> for CefWebPluginInfo { - fn to_c(rust_object: CefWebPluginInfo) -> *mut cef_web_plugin_info_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo { - CefWebPluginInfo::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_web_plugin_info_t> for Option<CefWebPluginInfo> { - fn to_c(rust_object: Option<CefWebPluginInfo>) -> *mut cef_web_plugin_info_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_info_t) -> Option<CefWebPluginInfo> { - if c_object.is_null() { - None - } else { - Some(CefWebPluginInfo::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure to implement for visiting web plugin information. The functions of -// this structure will be called on the browser process UI thread. -// -#[repr(C)] -pub struct _cef_web_plugin_info_visitor_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called once for each plugin. |count| is the 0-based - // index for the current plugin. |total| is the total number of plugins. - // Return false (0) to stop visiting plugins. This function may never be - // called if no plugins are found. - // - pub visit: Option<extern "C" fn(this: *mut cef_web_plugin_info_visitor_t, - info: *mut interfaces::cef_web_plugin_info_t, count: libc::c_int, - total: libc::c_int) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_web_plugin_info_visitor_t = _cef_web_plugin_info_visitor_t; - - -// -// Structure to implement for visiting web plugin information. The functions of -// this structure will be called on the browser process UI thread. -// -pub struct CefWebPluginInfoVisitor { - c_object: *mut cef_web_plugin_info_visitor_t, -} - -impl Clone for CefWebPluginInfoVisitor { - fn clone(&self) -> CefWebPluginInfoVisitor{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefWebPluginInfoVisitor { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefWebPluginInfoVisitor { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefWebPluginInfoVisitor { - pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor { - CefWebPluginInfoVisitor { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefWebPluginInfoVisitor { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_web_plugin_info_visitor_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_visitor_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called once for each plugin. |count| is the 0-based - // index for the current plugin. |total| is the total number of plugins. - // Return false (0) to stop visiting plugins. This function may never be - // called if no plugins are found. - // - pub fn visit(&self, info: interfaces::CefWebPluginInfo, count: libc::c_int, - total: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).visit.unwrap())( - self.c_object, - CefWrap::to_c(info), - CefWrap::to_c(count), - CefWrap::to_c(total))) - } - } -} - -impl CefWrap<*mut cef_web_plugin_info_visitor_t> for CefWebPluginInfoVisitor { - fn to_c(rust_object: CefWebPluginInfoVisitor) -> *mut cef_web_plugin_info_visitor_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor { - CefWebPluginInfoVisitor::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_web_plugin_info_visitor_t> for Option<CefWebPluginInfoVisitor> { - fn to_c(rust_object: Option<CefWebPluginInfoVisitor>) -> *mut cef_web_plugin_info_visitor_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_info_visitor_t) -> Option<CefWebPluginInfoVisitor> { - if c_object.is_null() { - None - } else { - Some(CefWebPluginInfoVisitor::from_c_object_addref(c_object)) - } - } -} - - -// -// Structure to implement for receiving unstable plugin information. The -// functions of this structure will be called on the browser process IO thread. -// -#[repr(C)] -pub struct _cef_web_plugin_unstable_callback_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Method that will be called for the requested plugin. |unstable| will be - // true (1) if the plugin has reached the crash count threshold of 3 times in - // 120 seconds. - // - pub is_unstable: Option<extern "C" fn( - this: *mut cef_web_plugin_unstable_callback_t, - path: *const types::cef_string_t, unstable: libc::c_int) -> ()>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_web_plugin_unstable_callback_t = _cef_web_plugin_unstable_callback_t; - - -// -// Structure to implement for receiving unstable plugin information. The -// functions of this structure will be called on the browser process IO thread. -// -pub struct CefWebPluginUnstableCallback { - c_object: *mut cef_web_plugin_unstable_callback_t, -} - -impl Clone for CefWebPluginUnstableCallback { - fn clone(&self) -> CefWebPluginUnstableCallback{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefWebPluginUnstableCallback { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefWebPluginUnstableCallback { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefWebPluginUnstableCallback { - pub unsafe fn from_c_object(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback { - CefWebPluginUnstableCallback { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefWebPluginUnstableCallback { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_web_plugin_unstable_callback_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_unstable_callback_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Method that will be called for the requested plugin. |unstable| will be - // true (1) if the plugin has reached the crash count threshold of 3 times in - // 120 seconds. - // - pub fn is_unstable(&self, path: &[u16], unstable: libc::c_int) -> () { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_unstable.unwrap())( - self.c_object, - CefWrap::to_c(path), - CefWrap::to_c(unstable))) - } - } -} - -impl CefWrap<*mut cef_web_plugin_unstable_callback_t> for CefWebPluginUnstableCallback { - fn to_c(rust_object: CefWebPluginUnstableCallback) -> *mut cef_web_plugin_unstable_callback_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback { - CefWebPluginUnstableCallback::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_web_plugin_unstable_callback_t> for Option<CefWebPluginUnstableCallback> { - fn to_c(rust_object: Option<CefWebPluginUnstableCallback>) -> *mut cef_web_plugin_unstable_callback_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_web_plugin_unstable_callback_t) -> Option<CefWebPluginUnstableCallback> { - if c_object.is_null() { - None - } else { - Some(CefWebPluginUnstableCallback::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_xml_reader.rs b/ports/cef/interfaces/cef_xml_reader.rs deleted file mode 100644 index 0de8b956a7d..00000000000 --- a/ports/cef/interfaces/cef_xml_reader.rs +++ /dev/null @@ -1,858 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure that supports the reading of XML data via the libxml streaming API. -// The functions of this structure should only be called on the thread that -// creates the object. -// -#[repr(C)] -pub struct _cef_xml_reader_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Moves the cursor to the next node in the document. This function must be - // called at least once to set the current cursor position. Returns true (1) - // if the cursor position was set successfully. - // - pub move_to_next_node: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Close the document. This should be called directly to ensure that cleanup - // occurs on the correct thread. - // - pub close: Option<extern "C" fn(this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns true (1) if an error has been reported by the XML parser. - // - pub has_error: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns the error string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_error: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - - // The below functions retrieve data for the node at the current cursor - // position. - - // - // Returns the node type. - // - pub get_type: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_xml_node_type_t>, - - // - // Returns the node depth. Depth starts at 0 for the root node. - // - pub get_depth: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT- - // LocalPart for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_local_name: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for - // additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_prefix: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the qualified name, equal to (Prefix:)LocalName. See - // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_qualified_name: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the URI defining the namespace associated with the node. See - // http://www.w3.org/TR/REC-xml-names/ for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_namespace_uri: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for - // additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_base_uri: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the xml:lang scope within which the node resides. See - // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_xml_lang: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if the node represents an NULL element. <a/> is considered - // NULL but <a></a> is not. - // - pub is_empty_element: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns true (1) if the node has a text value. - // - pub has_value: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns the text value. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_value: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns true (1) if the node has attributes. - // - pub has_attributes: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Returns the number of attributes. - // - pub get_attribute_count: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::size_t>, - - // - // Returns the value of the attribute at the specified 0-based index. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_attribute_byindex: Option<extern "C" fn(this: *mut cef_xml_reader_t, - index: libc::c_int) -> types::cef_string_userfree_t>, - - // - // Returns the value of the attribute with the specified qualified name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_attribute_byqname: Option<extern "C" fn(this: *mut cef_xml_reader_t, - qualifiedName: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Returns the value of the attribute with the specified local name and - // namespace URI. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_attribute_bylname: Option<extern "C" fn(this: *mut cef_xml_reader_t, - localName: *const types::cef_string_t, - namespaceURI: *const types::cef_string_t) -> types::cef_string_userfree_t>, - - // - // Returns an XML representation of the current node's children. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_inner_xml: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns an XML representation of the current node including its children. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_outer_xml: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the line number for the current node. - // - pub get_line_number: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - - // Attribute nodes are not traversed by default. The below functions can be - // used to move the cursor to an attribute node. move_to_carrying_element() - // can be called afterwards to return the cursor to the carrying element. The - // depth of an attribute node will be 1 + the depth of the carrying element. - - // - // Moves the cursor to the attribute at the specified 0-based index. Returns - // true (1) if the cursor position was set successfully. - // - pub move_to_attribute_byindex: Option<extern "C" fn( - this: *mut cef_xml_reader_t, index: libc::c_int) -> libc::c_int>, - - // - // Moves the cursor to the attribute with the specified qualified name. - // Returns true (1) if the cursor position was set successfully. - // - pub move_to_attribute_byqname: Option<extern "C" fn( - this: *mut cef_xml_reader_t, - qualifiedName: *const types::cef_string_t) -> libc::c_int>, - - // - // Moves the cursor to the attribute with the specified local name and - // namespace URI. Returns true (1) if the cursor position was set - // successfully. - // - pub move_to_attribute_bylname: Option<extern "C" fn( - this: *mut cef_xml_reader_t, localName: *const types::cef_string_t, - namespaceURI: *const types::cef_string_t) -> libc::c_int>, - - // - // Moves the cursor to the first attribute in the current element. Returns - // true (1) if the cursor position was set successfully. - // - pub move_to_first_attribute: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Moves the cursor to the next attribute in the current element. Returns true - // (1) if the cursor position was set successfully. - // - pub move_to_next_attribute: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // Moves the cursor back to the carrying element. Returns true (1) if the - // cursor position was set successfully. - // - pub move_to_carrying_element: Option<extern "C" fn( - this: *mut cef_xml_reader_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_xml_reader_t = _cef_xml_reader_t; - - -// -// Structure that supports the reading of XML data via the libxml streaming API. -// The functions of this structure should only be called on the thread that -// creates the object. -// -pub struct CefXmlReader { - c_object: *mut cef_xml_reader_t, -} - -impl Clone for CefXmlReader { - fn clone(&self) -> CefXmlReader{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefXmlReader { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefXmlReader { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefXmlReader { - pub unsafe fn from_c_object(c_object: *mut cef_xml_reader_t) -> CefXmlReader { - CefXmlReader { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_xml_reader_t) -> CefXmlReader { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefXmlReader { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_xml_reader_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_xml_reader_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Moves the cursor to the next node in the document. This function must be - // called at least once to set the current cursor position. Returns true (1) - // if the cursor position was set successfully. - // - pub fn move_to_next_node(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_next_node.unwrap())( - self.c_object)) - } - } - - // - // Close the document. This should be called directly to ensure that cleanup - // occurs on the correct thread. - // - pub fn close(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).close.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if an error has been reported by the XML parser. - // - pub fn has_error(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_error.unwrap())( - self.c_object)) - } - } - - // - // Returns the error string. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_error(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_error.unwrap())( - self.c_object)) - } - } - - - // The below functions retrieve data for the node at the current cursor - // position. - - // - // Returns the node type. - // - pub fn get_type(&self) -> types::cef_xml_node_type_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_type.unwrap())( - self.c_object)) - } - } - - // - // Returns the node depth. Depth starts at 0 for the root node. - // - pub fn get_depth(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_depth.unwrap())( - self.c_object)) - } - } - - // - // Returns the local name. See http://www.w3.org/TR/REC-xml-names/#NT- - // LocalPart for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_local_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_local_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the namespace prefix. See http://www.w3.org/TR/REC-xml-names/ for - // additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_prefix(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_prefix.unwrap())( - self.c_object)) - } - } - - // - // Returns the qualified name, equal to (Prefix:)LocalName. See - // http://www.w3.org/TR/REC-xml-names/#ns-qualnames for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_qualified_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_qualified_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the URI defining the namespace associated with the node. See - // http://www.w3.org/TR/REC-xml-names/ for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_namespace_uri(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_namespace_uri.unwrap())( - self.c_object)) - } - } - - // - // Returns the base URI of the node. See http://www.w3.org/TR/xmlbase/ for - // additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_base_uri(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_base_uri.unwrap())( - self.c_object)) - } - } - - // - // Returns the xml:lang scope within which the node resides. See - // http://www.w3.org/TR/REC-xml/#sec-lang-tag for additional details. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_xml_lang(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_xml_lang.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the node represents an NULL element. <a/> is considered - // NULL but <a></a> is not. - // - pub fn is_empty_element(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).is_empty_element.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the node has a text value. - // - pub fn has_value(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_value.unwrap())( - self.c_object)) - } - } - - // - // Returns the text value. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_value(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_value.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if the node has attributes. - // - pub fn has_attributes(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).has_attributes.unwrap())( - self.c_object)) - } - } - - // - // Returns the number of attributes. - // - pub fn get_attribute_count(&self) -> libc::size_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_attribute_count.unwrap())( - self.c_object)) - } - } - - // - // Returns the value of the attribute at the specified 0-based index. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_attribute_byindex(&self, index: libc::c_int) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_attribute_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Returns the value of the attribute with the specified qualified name. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_attribute_byqname(&self, qualifiedName: &[u16]) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_attribute_byqname.unwrap())( - self.c_object, - CefWrap::to_c(qualifiedName))) - } - } - - // - // Returns the value of the attribute with the specified local name and - // namespace URI. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_attribute_bylname(&self, localName: &[u16], - namespaceURI: &[u16]) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_attribute_bylname.unwrap())( - self.c_object, - CefWrap::to_c(localName), - CefWrap::to_c(namespaceURI))) - } - } - - // - // Returns an XML representation of the current node's children. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_inner_xml(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_inner_xml.unwrap())( - self.c_object)) - } - } - - // - // Returns an XML representation of the current node including its children. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_outer_xml(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_outer_xml.unwrap())( - self.c_object)) - } - } - - // - // Returns the line number for the current node. - // - pub fn get_line_number(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_line_number.unwrap())( - self.c_object)) - } - } - - - // Attribute nodes are not traversed by default. The below functions can be - // used to move the cursor to an attribute node. move_to_carrying_element() - // can be called afterwards to return the cursor to the carrying element. The - // depth of an attribute node will be 1 + the depth of the carrying element. - - // - // Moves the cursor to the attribute at the specified 0-based index. Returns - // true (1) if the cursor position was set successfully. - // - pub fn move_to_attribute_byindex(&self, index: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_attribute_byindex.unwrap())( - self.c_object, - CefWrap::to_c(index))) - } - } - - // - // Moves the cursor to the attribute with the specified qualified name. - // Returns true (1) if the cursor position was set successfully. - // - pub fn move_to_attribute_byqname(&self, - qualifiedName: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_attribute_byqname.unwrap())( - self.c_object, - CefWrap::to_c(qualifiedName))) - } - } - - // - // Moves the cursor to the attribute with the specified local name and - // namespace URI. Returns true (1) if the cursor position was set - // successfully. - // - pub fn move_to_attribute_bylname(&self, localName: &[u16], - namespaceURI: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_attribute_bylname.unwrap())( - self.c_object, - CefWrap::to_c(localName), - CefWrap::to_c(namespaceURI))) - } - } - - // - // Moves the cursor to the first attribute in the current element. Returns - // true (1) if the cursor position was set successfully. - // - pub fn move_to_first_attribute(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_first_attribute.unwrap())( - self.c_object)) - } - } - - // - // Moves the cursor to the next attribute in the current element. Returns true - // (1) if the cursor position was set successfully. - // - pub fn move_to_next_attribute(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_next_attribute.unwrap())( - self.c_object)) - } - } - - // - // Moves the cursor back to the carrying element. Returns true (1) if the - // cursor position was set successfully. - // - pub fn move_to_carrying_element(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_carrying_element.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_xml_reader_t object. The returned object's functions can - // only be called from the thread that created the object. - // - pub fn create(stream: interfaces::CefStreamReader, - encodingType: types::cef_xml_encoding_type_t, - URI: &[u16]) -> interfaces::CefXmlReader { - unsafe { - CefWrap::to_rust( - ::xml_reader::cef_xml_reader_create( - CefWrap::to_c(stream), - CefWrap::to_c(encodingType), - CefWrap::to_c(URI))) - } - } -} - -impl CefWrap<*mut cef_xml_reader_t> for CefXmlReader { - fn to_c(rust_object: CefXmlReader) -> *mut cef_xml_reader_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_xml_reader_t) -> CefXmlReader { - CefXmlReader::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_xml_reader_t> for Option<CefXmlReader> { - fn to_c(rust_object: Option<CefXmlReader>) -> *mut cef_xml_reader_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_xml_reader_t) -> Option<CefXmlReader> { - if c_object.is_null() { - None - } else { - Some(CefXmlReader::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/cef_zip_reader.rs b/ports/cef/interfaces/cef_zip_reader.rs deleted file mode 100644 index 36af7b19611..00000000000 --- a/ports/cef/interfaces/cef_zip_reader.rs +++ /dev/null @@ -1,446 +0,0 @@ -// Copyright (c) 2015 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 be edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#![allow(non_snake_case, unused_imports)] - -use eutil; -use interfaces; -use types; -use wrappers::CefWrap; - -use libc; -use std::collections::HashMap; -use std::mem; -use std::ptr; - -// -// Structure that supports the reading of zip archives via the zlib unzip API. -// The functions of this structure should only be called on the thread that -// creates the object. -// -#[repr(C)] -pub struct _cef_zip_reader_t { - // - // Base structure. - // - pub base: types::cef_base_t, - - // - // Moves the cursor to the first file in the archive. Returns true (1) if the - // cursor position was set successfully. - // - pub move_to_first_file: Option<extern "C" fn( - this: *mut cef_zip_reader_t) -> libc::c_int>, - - // - // Moves the cursor to the next file in the archive. Returns true (1) if the - // cursor position was set successfully. - // - pub move_to_next_file: Option<extern "C" fn( - this: *mut cef_zip_reader_t) -> libc::c_int>, - - // - // Moves the cursor to the specified file in the archive. If |caseSensitive| - // is true (1) then the search will be case sensitive. Returns true (1) if the - // cursor position was set successfully. - // - pub move_to_file: Option<extern "C" fn(this: *mut cef_zip_reader_t, - fileName: *const types::cef_string_t, - caseSensitive: libc::c_int) -> libc::c_int>, - - // - // Closes the archive. This should be called directly to ensure that cleanup - // occurs on the correct thread. - // - pub close: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> libc::c_int>, - - - // The below functions act on the file at the current cursor position. - - // - // Returns the name of the file. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub get_file_name: Option<extern "C" fn( - this: *mut cef_zip_reader_t) -> types::cef_string_userfree_t>, - - // - // Returns the uncompressed size of the file. - // - pub get_file_size: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> i64>, - - // - // Returns the last modified timestamp for the file. - // - pub get_file_last_modified: Option<extern "C" fn( - this: *mut cef_zip_reader_t) -> types::cef_time_t>, - - // - // Opens the file for reading of uncompressed data. A read password may - // optionally be specified. - // - pub open_file: Option<extern "C" fn(this: *mut cef_zip_reader_t, - password: *const types::cef_string_t) -> libc::c_int>, - - // - // Closes the file. - // - pub close_file: Option<extern "C" fn( - this: *mut cef_zip_reader_t) -> libc::c_int>, - - // - // Read uncompressed file contents into the specified buffer. Returns < 0 if - // an error occurred, 0 if at the end of file, or the number of bytes read. - // - pub read_file: Option<extern "C" fn(this: *mut cef_zip_reader_t, - buffer: *mut (), bufferSize: libc::size_t) -> libc::c_int>, - - // - // Returns the current offset in the uncompressed file contents. - // - pub tell: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> i64>, - - // - // Returns true (1) if at end of the file contents. - // - pub eof: Option<extern "C" fn(this: *mut cef_zip_reader_t) -> libc::c_int>, - - // - // The reference count. This will only be present for Rust instances! - // - pub ref_count: u32, - - // - // Extra data. This will only be present for Rust instances! - // - pub extra: u8, -} - -pub type cef_zip_reader_t = _cef_zip_reader_t; - - -// -// Structure that supports the reading of zip archives via the zlib unzip API. -// The functions of this structure should only be called on the thread that -// creates the object. -// -pub struct CefZipReader { - c_object: *mut cef_zip_reader_t, -} - -impl Clone for CefZipReader { - fn clone(&self) -> CefZipReader{ - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base); - } - CefZipReader { - c_object: self.c_object, - } - } - } -} - -impl Drop for CefZipReader { - fn drop(&mut self) { - unsafe { - if !self.c_object.is_null() { - ((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base); - } - } - } -} - -impl CefZipReader { - pub unsafe fn from_c_object(c_object: *mut cef_zip_reader_t) -> CefZipReader { - CefZipReader { - c_object: c_object, - } - } - - pub unsafe fn from_c_object_addref(c_object: *mut cef_zip_reader_t) -> CefZipReader { - if !c_object.is_null() { - ((*c_object).base.add_ref.unwrap())(&mut (*c_object).base); - } - CefZipReader { - c_object: c_object, - } - } - - pub fn c_object(&self) -> *mut cef_zip_reader_t { - self.c_object - } - - pub fn c_object_addrefed(&self) -> *mut cef_zip_reader_t { - unsafe { - if !self.c_object.is_null() { - eutil::add_ref(self.c_object as *mut types::cef_base_t); - } - self.c_object - } - } - - pub fn is_null_cef_object(&self) -> bool { - self.c_object.is_null() - } - pub fn is_not_null_cef_object(&self) -> bool { - !self.c_object.is_null() - } - - // - // Moves the cursor to the first file in the archive. Returns true (1) if the - // cursor position was set successfully. - // - pub fn move_to_first_file(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_first_file.unwrap())( - self.c_object)) - } - } - - // - // Moves the cursor to the next file in the archive. Returns true (1) if the - // cursor position was set successfully. - // - pub fn move_to_next_file(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_next_file.unwrap())( - self.c_object)) - } - } - - // - // Moves the cursor to the specified file in the archive. If |caseSensitive| - // is true (1) then the search will be case sensitive. Returns true (1) if the - // cursor position was set successfully. - // - pub fn move_to_file(&self, fileName: &[u16], - caseSensitive: libc::c_int) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).move_to_file.unwrap())( - self.c_object, - CefWrap::to_c(fileName), - CefWrap::to_c(caseSensitive))) - } - } - - // - // Closes the archive. This should be called directly to ensure that cleanup - // occurs on the correct thread. - // - pub fn close(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).close.unwrap())( - self.c_object)) - } - } - - - // The below functions act on the file at the current cursor position. - - // - // Returns the name of the file. - // - // The resulting string must be freed by calling cef_string_userfree_free(). - pub fn get_file_name(&self) -> String { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_name.unwrap())( - self.c_object)) - } - } - - // - // Returns the uncompressed size of the file. - // - pub fn get_file_size(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_size.unwrap())( - self.c_object)) - } - } - - // - // Returns the last modified timestamp for the file. - // - pub fn get_file_last_modified(&self) -> types::cef_time_t { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).get_file_last_modified.unwrap())( - self.c_object)) - } - } - - // - // Opens the file for reading of uncompressed data. A read password may - // optionally be specified. - // - pub fn open_file(&self, password: &[u16]) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).open_file.unwrap())( - self.c_object, - CefWrap::to_c(password))) - } - } - - // - // Closes the file. - // - pub fn close_file(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).close_file.unwrap())( - self.c_object)) - } - } - - // - // Read uncompressed file contents into the specified buffer. Returns < 0 if - // an error occurred, 0 if at the end of file, or the number of bytes read. - // - pub fn read_file(&self, buffer: &mut (), - bufferSize: libc::size_t) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).read_file.unwrap())( - self.c_object, - CefWrap::to_c(buffer), - CefWrap::to_c(bufferSize))) - } - } - - // - // Returns the current offset in the uncompressed file contents. - // - pub fn tell(&self) -> i64 { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).tell.unwrap())( - self.c_object)) - } - } - - // - // Returns true (1) if at end of the file contents. - // - pub fn eof(&self) -> libc::c_int { - if self.c_object.is_null() { - panic!("called a CEF method on a null object") - } - unsafe { - CefWrap::to_rust( - ((*self.c_object).eof.unwrap())( - self.c_object)) - } - } - - // - // Create a new cef_zip_reader_t object. The returned object's functions can - // only be called from the thread that created the object. - // - pub fn create( - stream: interfaces::CefStreamReader) -> interfaces::CefZipReader { - unsafe { - CefWrap::to_rust( - ::zip_reader::cef_zip_reader_create( - CefWrap::to_c(stream))) - } - } -} - -impl CefWrap<*mut cef_zip_reader_t> for CefZipReader { - fn to_c(rust_object: CefZipReader) -> *mut cef_zip_reader_t { - rust_object.c_object_addrefed() - } - unsafe fn to_rust(c_object: *mut cef_zip_reader_t) -> CefZipReader { - CefZipReader::from_c_object_addref(c_object) - } -} -impl CefWrap<*mut cef_zip_reader_t> for Option<CefZipReader> { - fn to_c(rust_object: Option<CefZipReader>) -> *mut cef_zip_reader_t { - match rust_object { - None => ptr::null_mut(), - Some(rust_object) => rust_object.c_object_addrefed(), - } - } - unsafe fn to_rust(c_object: *mut cef_zip_reader_t) -> Option<CefZipReader> { - if c_object.is_null() { - None - } else { - Some(CefZipReader::from_c_object_addref(c_object)) - } - } -} - diff --git a/ports/cef/interfaces/mod.rs b/ports/cef/interfaces/mod.rs deleted file mode 100644 index f07ed203e9b..00000000000 --- a/ports/cef/interfaces/mod.rs +++ /dev/null @@ -1,118 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -pub use interfaces::cef_app::{CefApp,cef_app_t,}; -pub use interfaces::cef_auth_callback::{CefAuthCallback,cef_auth_callback_t,}; -pub use interfaces::cef_browser_process_handler::{CefBrowserProcessHandler,cef_browser_process_handler_t,}; -pub use interfaces::cef_browser::{CefBrowser,CefRunFileDialogCallback,CefNavigationEntryVisitor,CefPdfPrintCallback,CefBrowserHost,cef_browser_t,cef_run_file_dialog_callback_t,cef_navigation_entry_visitor_t,cef_pdf_print_callback_t,cef_browser_host_t,}; -pub use interfaces::cef_callback::{CefCallback,CefCompletionCallback,cef_callback_t,cef_completion_callback_t,}; -pub use interfaces::cef_client::{CefClient,cef_client_t,}; -pub use interfaces::cef_command_line::{CefCommandLine,cef_command_line_t,}; -pub use interfaces::cef_context_menu_handler::{CefContextMenuHandler,CefContextMenuParams,cef_context_menu_handler_t,cef_context_menu_params_t,}; -pub use interfaces::cef_cookie::{CefCookieManager,CefCookieVisitor,CefSetCookieCallback,CefDeleteCookiesCallback,cef_cookie_manager_t,cef_cookie_visitor_t,cef_set_cookie_callback_t,cef_delete_cookies_callback_t,}; -pub use interfaces::cef_dialog_handler::{CefFileDialogCallback,CefDialogHandler,cef_file_dialog_callback_t,cef_dialog_handler_t,}; -pub use interfaces::cef_display_handler::{CefDisplayHandler,cef_display_handler_t,}; -pub use interfaces::cef_dom::{CefDOMVisitor,CefDOMDocument,CefDOMNode,cef_domvisitor_t,cef_domdocument_t,cef_domnode_t,}; -pub use interfaces::cef_download_handler::{CefBeforeDownloadCallback,CefDownloadItemCallback,CefDownloadHandler,cef_before_download_callback_t,cef_download_item_callback_t,cef_download_handler_t,}; -pub use interfaces::cef_download_item::{CefDownloadItem,cef_download_item_t,}; -pub use interfaces::cef_drag_data::{CefDragData,cef_drag_data_t,}; -pub use interfaces::cef_drag_handler::{CefDragHandler,cef_drag_handler_t,}; -pub use interfaces::cef_find_handler::{CefFindHandler,cef_find_handler_t,}; -pub use interfaces::cef_focus_handler::{CefFocusHandler,cef_focus_handler_t,}; -pub use interfaces::cef_frame::{CefFrame,cef_frame_t,}; -pub use interfaces::cef_geolocation_handler::{CefGeolocationCallback,CefGeolocationHandler,cef_geolocation_callback_t,cef_geolocation_handler_t,}; -pub use interfaces::cef_geolocation::{CefGetGeolocationCallback,cef_get_geolocation_callback_t,}; -pub use interfaces::cef_jsdialog_handler::{CefJSDialogCallback,CefJSDialogHandler,cef_jsdialog_callback_t,cef_jsdialog_handler_t,}; -pub use interfaces::cef_keyboard_handler::{CefKeyboardHandler,cef_keyboard_handler_t,}; -pub use interfaces::cef_life_span_handler::{CefLifeSpanHandler,cef_life_span_handler_t,}; -pub use interfaces::cef_load_handler::{CefLoadHandler,cef_load_handler_t,}; -pub use interfaces::cef_menu_model::{CefMenuModel,cef_menu_model_t,}; -pub use interfaces::cef_navigation_entry::{CefNavigationEntry,cef_navigation_entry_t,}; -pub use interfaces::cef_origin_whitelist::{}; -pub use interfaces::cef_parser::{}; -pub use interfaces::cef_path_util::{}; -pub use interfaces::cef_print_handler::{CefPrintDialogCallback,CefPrintJobCallback,CefPrintHandler,cef_print_dialog_callback_t,cef_print_job_callback_t,cef_print_handler_t,}; -pub use interfaces::cef_print_settings::{CefPrintSettings,cef_print_settings_t,}; -pub use interfaces::cef_process_message::{CefProcessMessage,cef_process_message_t,}; -pub use interfaces::cef_process_util::{}; -pub use interfaces::cef_render_handler::{CefRenderHandler,cef_render_handler_t,}; -pub use interfaces::cef_render_process_handler::{CefRenderProcessHandler,cef_render_process_handler_t,}; -pub use interfaces::cef_request_context_handler::{CefRequestContextHandler,cef_request_context_handler_t,}; -pub use interfaces::cef_request_context::{CefRequestContext,cef_request_context_t,}; -pub use interfaces::cef_request_handler::{CefRequestCallback,CefRequestHandler,cef_request_callback_t,cef_request_handler_t,}; -pub use interfaces::cef_request::{CefRequest,CefPostData,CefPostDataElement,cef_request_t,cef_post_data_t,cef_post_data_element_t,}; -pub use interfaces::cef_resource_bundle_handler::{CefResourceBundleHandler,cef_resource_bundle_handler_t,}; -pub use interfaces::cef_resource_handler::{CefResourceHandler,cef_resource_handler_t,}; -pub use interfaces::cef_response::{CefResponse,cef_response_t,}; -pub use interfaces::cef_scheme::{CefSchemeRegistrar,CefSchemeHandlerFactory,cef_scheme_registrar_t,cef_scheme_handler_factory_t,}; -pub use interfaces::cef_ssl_info::{CefSSLCertPrincipal,CefSSLInfo,cef_sslcert_principal_t,cef_sslinfo_t,}; -pub use interfaces::cef_stream::{CefReadHandler,CefStreamReader,CefWriteHandler,CefStreamWriter,cef_read_handler_t,cef_stream_reader_t,cef_write_handler_t,cef_stream_writer_t,}; -pub use interfaces::cef_string_visitor::{CefStringVisitor,cef_string_visitor_t,}; -pub use interfaces::cef_task::{CefTask,CefTaskRunner,cef_task_t,cef_task_runner_t,}; -pub use interfaces::cef_trace::{CefEndTracingCallback,cef_end_tracing_callback_t,}; -pub use interfaces::cef_urlrequest::{CefURLRequest,CefURLRequestClient,cef_urlrequest_t,cef_urlrequest_client_t,}; -pub use interfaces::cef_v8::{CefV8Context,CefV8Handler,CefV8Accessor,CefV8Exception,CefV8Value,CefV8StackTrace,CefV8StackFrame,cef_v8context_t,cef_v8handler_t,cef_v8accessor_t,cef_v8exception_t,cef_v8value_t,cef_v8stack_trace_t,cef_v8stack_frame_t,}; -pub use interfaces::cef_values::{CefValue,CefBinaryValue,CefDictionaryValue,CefListValue,cef_value_t,cef_binary_value_t,cef_dictionary_value_t,cef_list_value_t,}; -pub use interfaces::cef_web_plugin::{CefWebPluginInfo,CefWebPluginInfoVisitor,CefWebPluginUnstableCallback,cef_web_plugin_info_t,cef_web_plugin_info_visitor_t,cef_web_plugin_unstable_callback_t,}; -pub use interfaces::cef_xml_reader::{CefXmlReader,cef_xml_reader_t,}; -pub use interfaces::cef_zip_reader::{CefZipReader,cef_zip_reader_t,}; -pub use types::{cef_string_map_t,cef_string_multimap_t,cef_string_list_t,cef_window_handle_t,cef_cursor_handle_t,cef_string_t,cef_string_userfree_t,cef_string_utf8_t,cef_string_userfree_utf8_t,cef_string_utf16_t,cef_string_userfree_utf16_t,cef_string_wide_t,cef_string_userfree_wide_t,cef_main_args_t,cef_color_t,cef_mouse_event_t,CefMouseEvent,cef_errorcode_t,cef_key_event_t,CefKeyEvent,cef_point_t,cef_draggable_region_t,CefValueType,CefProcessId,cef_settings_t,cef_base_t,CefBase,cef_window_info_t,CefWindowInfo,cef_time_t,cef_size_t,cef_page_range_t,cef_geoposition_t,CefGeoposition,cef_cookie_t,CefCookie,cef_popup_features_t,CefPopupFeatures,cef_screen_info_t,CefScreenInfo,cef_browser_settings_t,CefBrowserSettings,cef_cursor_info_t,CefCursorInfo,cef_request_context_settings_t,CefRequestContextSettings,cef_pdf_print_settings_t,CefPdfPrintSettings,cef_text_input_context_t,cef_event_handle_t,cef_json_parser_error_t,cef_state_t,cef_thread_id_t,cef_navigation_type_t,cef_mouse_button_type_t,cef_postdataelement_type_t,cef_urlrequest_flags_t,cef_urlrequest_status_t,cef_key_event_type_t,cef_paint_element_type_t,cef_dom_document_type_t,cef_file_dialog_mode_t,cef_value_type_t,cef_process_id_t,cef_log_severity_t,cef_menu_item_type_t,cef_context_menu_type_flags_t,cef_context_menu_media_type_t,cef_context_menu_media_state_flags_t,cef_context_menu_edit_state_flags_t,cef_event_flags_t,cef_dom_event_phase_t,cef_dom_node_type_t,cef_focus_source_t,cef_jsdialog_type_t,cef_duplex_mode_t,cef_color_model_t,cef_resource_type_t,cef_transition_type_t,cef_termination_status_t,cef_v8_accesscontrol_t,cef_v8_propertyattribute_t,cef_xml_node_type_t,cef_geoposition_error_code_t,cef_drag_operations_mask_t,cef_xml_encoding_type_t,cef_window_open_disposition_t,cef_cursor_type_t,cef_return_value_t,cef_pdf_print_margin_type_t,}; - - - -pub mod cef_app; -pub mod cef_auth_callback; -pub mod cef_browser_process_handler; -pub mod cef_browser; -pub mod cef_callback; -pub mod cef_client; -pub mod cef_command_line; -pub mod cef_context_menu_handler; -pub mod cef_cookie; -pub mod cef_dialog_handler; -pub mod cef_display_handler; -pub mod cef_dom; -pub mod cef_download_handler; -pub mod cef_download_item; -pub mod cef_drag_data; -pub mod cef_drag_handler; -pub mod cef_find_handler; -pub mod cef_focus_handler; -pub mod cef_frame; -pub mod cef_geolocation_handler; -pub mod cef_geolocation; -pub mod cef_jsdialog_handler; -pub mod cef_keyboard_handler; -pub mod cef_life_span_handler; -pub mod cef_load_handler; -pub mod cef_menu_model; -pub mod cef_navigation_entry; -pub mod cef_origin_whitelist; -pub mod cef_parser; -pub mod cef_path_util; -pub mod cef_print_handler; -pub mod cef_print_settings; -pub mod cef_process_message; -pub mod cef_process_util; -pub mod cef_render_handler; -pub mod cef_render_process_handler; -pub mod cef_request_context_handler; -pub mod cef_request_context; -pub mod cef_request_handler; -pub mod cef_request; -pub mod cef_resource_bundle_handler; -pub mod cef_resource_handler; -pub mod cef_response; -pub mod cef_scheme; -pub mod cef_ssl_info; -pub mod cef_stream; -pub mod cef_string_visitor; -pub mod cef_task; -pub mod cef_trace; -pub mod cef_urlrequest; -pub mod cef_v8; -pub mod cef_values; -pub mod cef_web_plugin; -pub mod cef_xml_reader; -pub mod cef_zip_reader; diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs deleted file mode 100644 index 269d106d167..00000000000 --- a/ports/cef/lib.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#![allow(non_camel_case_types)] -#![feature(core_intrinsics)] - -#[macro_use] -extern crate log; - -extern crate servo; -extern crate compositing; - -extern crate euclid; -extern crate gleam; -extern crate glutin_app; -extern crate script_traits; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_url; -extern crate style_traits; - -extern crate net_traits; -extern crate msg; -extern crate webrender_api; - -extern crate libc; - -#[cfg(target_os="macos")] -extern crate cocoa; -#[cfg(target_os="macos")] -#[macro_use] -extern crate objc; - -// Must come first. -pub mod macros; - -pub mod browser; -pub mod browser_host; -pub mod command_line; -pub mod cookie; -pub mod core; -pub mod drag_data; -pub mod eutil; -pub mod frame; -pub mod interfaces; -pub mod print_settings; -pub mod process_message; -pub mod render_handler; -pub mod request; -pub mod request_context; -pub mod response; -pub mod stream; -pub mod string; -pub mod string_list; -pub mod string_map; -pub mod string_multimap; -pub mod stubs; -pub mod switches; -pub mod task; -pub mod types; -pub mod urlrequest; -pub mod v8; -pub mod values; -pub mod window; -pub mod wrappers; -pub mod xml_reader; -pub mod zip_reader; diff --git a/ports/cef/macros.rs b/ports/cef/macros.rs deleted file mode 100644 index 908fd8cc8a8..00000000000 --- a/ports/cef/macros.rs +++ /dev/null @@ -1,156 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#![macro_use] - - -macro_rules! check_ptr_exist { - ($var:expr, $member:ident) => ( - unsafe { (*CefWrap::to_c($var)).$member.is_some() } - ); -} - -// Provides the implementation of a CEF class. An example follows: -// -// struct ServoCefThing { -// ... -// } -// -// cef_class_impl! { -// ServoCefThing : CefThing, cef_thing_t { -// // Declare method implementations using the *C* API. (This may change later, once we -// // have associated types in Rust.) -// // -// // Note that if the method returns unit, you must write `-> ()` explicitly. This is -// // due to limitations of Rust's macro system. -// fn foo(&this, a: isize, b: *mut cef_other_thing_t) -> () { -// // Inside here, `a` will have type `isize`, and `b` will have the type -// // `CefOtherThing` -- i.e. the Rust-wrapped version of `cef_other_thing_t`. -// ... -// } -// -// fn bar(&this, a: isize) -> *mut cef_other_thing_t { -// // Return types are automatically unwrapped from the Rust types (e.g. -// // `CefOtherThing`) into the corresponding C types (e.g. `*mut -// // cef_other_thing_t`). -// let x: CefOtherThing = ...; -// x -// } -// } -// } -macro_rules! cef_class_impl( - ($class_name:ident : $interface_name:ident, $c_interface_name:ident { - $( - fn $method_name:ident ( & $method_this:ident , - $( $method_arg_name:ident : $c_method_arg_type:ty ,)* ) - -> $method_return_type:ty {$method_body:block} - )* - }) => ( - full_cef_class_impl! { - $class_name : $interface_name, $c_interface_name { - $(fn $method_name(&$method_this, - $($method_arg_name : $c_method_arg_type [$c_method_arg_type],)*) - -> $method_return_type { - $method_body - })* - } - } - ) -); - -macro_rules! full_cef_class_impl( - ($class_name:ident : $interface_name:ident, $c_interface_name:ident { - $( - fn $method_name:ident ( & $method_this:ident , - $( $method_arg_name:ident : $c_method_arg_type:ty [$method_arg_type:ty] ,)* ) - -> $method_return_type:ty {$method_body:block} - )* - }) => ( - impl $class_name { - pub fn as_cef_interface(self) -> $interface_name { - let cef_object = unsafe { - // Calculate the offset of the reference count. This is the size of the - // structure. - let null: *const $c_interface_name = ::std::ptr::null(); - let offset: *const u32 = &(*null).ref_count; - let size = (offset as ::libc::size_t) - (null as ::libc::size_t); - $interface_name::from_c_object_addref( - ::eutil::create_cef_object::<$c_interface_name,$class_name>(size)) - }; - unsafe { - $((*cef_object.c_object()).$method_name = Some($method_name as extern "C" fn(*mut $c_interface_name, $($c_method_arg_type,)*) -> $method_return_type);)* - let extra_slot = - ::std::mem::transmute::<&mut u8, - &mut $class_name>(&mut (*cef_object.c_object()) - .extra); - ::std::ptr::write(extra_slot, self); - } - cef_object - } - } - - $( - extern "C" fn $method_name(raw_this: *mut $c_interface_name, - $($method_arg_name: $c_method_arg_type),*) - -> $method_return_type { - let $method_this = unsafe { - $interface_name::from_c_object_addref(raw_this) - }; - $( - let $method_arg_name: $method_arg_type = unsafe { - ::wrappers::CefWrap::to_rust($method_arg_name) - }; - )* - ::wrappers::CefWrap::to_c($method_body) - } - )* - - impl ::eutil::Downcast<$class_name> for $interface_name { - fn downcast(&self) -> &$class_name { - unsafe { - ::std::mem::transmute::<&u8,&$class_name>(&(*self.c_object()).extra) - } - } - } - ) -); - -macro_rules! cef_static_method_impls( - ( - $( - fn $method_name:ident ( $($method_arg_name:ident : $method_arg_type:ty ),* ) - -> $method_return_type:ty {$method_body:block} - )* - ) => ( - $( - #[no_mangle] - pub extern "C" fn $method_name($($method_arg_name: $method_arg_type),*) - -> $method_return_type { - $( - let $method_arg_name = unsafe { - ::wrappers::CefWrap::to_rust($method_arg_name) - }; - )* - ::wrappers::CefWrap::to_c($method_body) - } - )* - ) -); - -macro_rules! cef_stub_static_method_impls( - ( - $( - fn $method_name:ident ( $($method_arg_name:ident : $method_arg_type:ty ),* ) - -> $method_return_type:ty - )* - ) => ( - $( - #[no_mangle] - pub extern "C" fn $method_name($(_: $method_arg_type),*) - -> $method_return_type { - panic!("unimplemented static method: {}", stringify!($method_name)) - } - )* - ) -); diff --git a/ports/cef/print_settings.rs b/ports/cef/print_settings.rs deleted file mode 100644 index 91310c47806..00000000000 --- a/ports/cef/print_settings.rs +++ /dev/null @@ -1,9 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::cef_print_settings_t; - -cef_stub_static_method_impls! { - fn cef_print_settings_create() -> *mut cef_print_settings_t -} diff --git a/ports/cef/process_message.rs b/ports/cef/process_message.rs deleted file mode 100644 index ed3800d78a1..00000000000 --- a/ports/cef/process_message.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::cef_process_message_t; -use types::cef_string_t; - -cef_stub_static_method_impls! { - fn cef_process_message_create(name: *const cef_string_t) -> *mut cef_process_message_t -} - diff --git a/ports/cef/regen_interface_mod_rs.sh b/ports/cef/regen_interface_mod_rs.sh deleted file mode 100755 index aca6594b33d..00000000000 --- a/ports/cef/regen_interface_mod_rs.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/zsh - -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - -setopt extended_glob -echo \ -"/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -" >>| interfaces_mod.rs - -# loop all files in interfaces dir -for x in $(print interfaces/*.rs~interfaces/mod.rs) -do - # open the use statement - echo -n "pub use interfaces::$(basename $x .rs)::{" >>| interfaces_mod.rs - # append all pub struct names which do not begin with '_' - grep -E '^pub struct [^_]' $x|sed 's/.*struct \(.*\) .*/\1/'|tr '\n' ',' >>| interfaces_mod.rs - # append all pub types - grep -E '^pub type ' $x|sed 's/pub type \([^ ]*\) .*/\1/'|tr '\n' ',' >>| interfaces_mod.rs - # close the use statement - echo '};' >>| interfaces_mod.rs -done -# open use statement for manually-generated types.rs -echo -n "pub use types::{" >>| interfaces_mod.rs -# append all pub types -grep -E '^pub type ' types.rs|sed 's/pub type \([^ ]*\) .*/\1/'|uniq|tr '\n' ',' >>| interfaces_mod.rs -# append all pub enums -grep -E '^pub enum ' types.rs|sed 's/pub enum \([^ ]*\) .*/\1/'|uniq|tr '\n' ',' >>| interfaces_mod.rs -# close use statement -echo '};' >>| interfaces_mod.rs -# append all pub structs beginning with "Cef" to alias them from types:: -> interfaces:: -# some generated code from cef uses interfaces:: for types that it does not generate -grep -E '^pub struct Cef' types.rs|sed 's/pub struct \([^ ]*\) .*/pub use types::\1 as \1;/'|uniq >>| interfaces_mod.rs -# newline separators -echo -e '\n\n' >>| interfaces_mod.rs -# loop all files in interfaces dir again -for x in $(print interfaces/*.rs~interfaces/mod.rs) -do - # add mod statements for all interfaces - echo "pub mod $(basename $x .rs);" >>| interfaces_mod.rs -done diff --git a/ports/cef/render_handler.rs b/ports/cef/render_handler.rs deleted file mode 100644 index 01d2f51603c..00000000000 --- a/ports/cef/render_handler.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{CefBrowser, CefRenderHandler}; -use types::cef_paint_element_type_t::PET_VIEW; - -use std::ptr; - -pub trait CefRenderHandlerExtensions { - fn paint(&self, browser: CefBrowser, width: usize, height: usize); -} - -impl CefRenderHandlerExtensions for CefRenderHandler { - fn paint(&self, browser: CefBrowser, width: usize, height: usize) { - self.on_paint(browser, PET_VIEW, 0, ptr::null(), &mut (), width as i32, height as i32) - } -} - diff --git a/ports/cef/request.rs b/ports/cef/request.rs deleted file mode 100644 index 531575e5ae5..00000000000 --- a/ports/cef/request.rs +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_post_data_element_t, cef_post_data_t, cef_request_t}; - -cef_stub_static_method_impls! { - fn cef_request_create() -> *mut cef_request_t - fn cef_post_data_create() -> *mut cef_post_data_t - fn cef_post_data_element_create() -> *mut cef_post_data_element_t -} - diff --git a/ports/cef/request_context.rs b/ports/cef/request_context.rs deleted file mode 100644 index 2187e32b8f6..00000000000 --- a/ports/cef/request_context.rs +++ /dev/null @@ -1,16 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_request_context_handler_t, cef_request_context_t, cef_request_context_settings_t}; - -cef_stub_static_method_impls! { - fn cef_request_context_get_global_context() -> *mut cef_request_context_t - fn cef_request_context_create_context(_settings: *const cef_request_context_settings_t, - _handler: *mut cef_request_context_handler_t) - -> *mut cef_request_context_t - fn cef_request_context_create_context_shared(_other: *mut cef_request_context_t, - _handler: *mut cef_request_context_handler_t) - -> *mut cef_request_context_t -} - diff --git a/ports/cef/response.rs b/ports/cef/response.rs deleted file mode 100644 index 5c66e0acaa4..00000000000 --- a/ports/cef/response.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::cef_response_t; - -cef_stub_static_method_impls! { - fn cef_response_create() -> *mut cef_response_t -} - diff --git a/ports/cef/stream.rs b/ports/cef/stream.rs deleted file mode 100644 index 9ed02ee91db..00000000000 --- a/ports/cef/stream.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_read_handler_t, cef_stream_reader_t, cef_stream_writer_t}; -use interfaces::{cef_write_handler_t}; -use types::cef_string_t; - -use libc; - -cef_stub_static_method_impls! { - fn cef_stream_reader_create_for_file(_file_name: *const cef_string_t) - -> *mut cef_stream_reader_t - fn cef_stream_reader_create_for_data(_data: *mut (), _size: libc::size_t) - -> *mut cef_stream_reader_t - fn cef_stream_reader_create_for_handler(_handler: *mut cef_read_handler_t) - -> *mut cef_stream_reader_t - fn cef_stream_writer_create_for_file(_file_name: *const cef_string_t) - -> *mut cef_stream_writer_t - fn cef_stream_writer_create_for_handler(_handler: *mut cef_write_handler_t) - -> *mut cef_stream_writer_t -} - diff --git a/ports/cef/string.rs b/ports/cef/string.rs deleted file mode 100644 index f43b400c62d..00000000000 --- a/ports/cef/string.rs +++ /dev/null @@ -1,323 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -use eutil::slice_to_str; -use libc::{self, size_t, c_int, c_ushort, c_void, wchar_t}; -use std::char; -use std::cmp::Ordering; -use std::mem; -use std::ptr; -use std::slice; -use std::string; -use types::{cef_string_userfree_utf16_t, cef_string_userfree_utf8_t, cef_string_userfree_wide_t}; -use types::{cef_string_utf16_t, cef_string_utf8_t, cef_string_wide_t}; - -//cef_string - -#[no_mangle] -#[allow(private_no_mangle_fns)] -extern "C" fn string_wide_dtor(str: *mut wchar_t) { - unsafe { - libc::free(str as *mut c_void) - } -} - -#[no_mangle] -#[allow(private_no_mangle_fns)] -extern "C" fn string_utf8_dtor(str: *mut u8) { - unsafe { - libc::free(str as *mut c_void) - } -} - -#[no_mangle] -#[allow(private_no_mangle_fns)] -extern "C" fn string_utf16_dtor(str: *mut c_ushort) { - unsafe { - libc::free(str as *mut c_void) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_userfree_wide_free(cs: *mut cef_string_userfree_wide_t) { - cef_string_wide_clear(cs); - unsafe { - libc::free(cs as *mut c_void) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_userfree_utf8_free(cs: *mut cef_string_userfree_utf8_t) { - unsafe { - cef_string_utf8_clear(cs); - libc::free(cs as *mut c_void) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_userfree_utf16_free(cs: cef_string_userfree_utf16_t) { - unsafe { - cef_string_utf16_clear(cs); - libc::free(cs as *mut c_void) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf8_clear(cs: *mut cef_string_utf8_t) { - unsafe { - (*cs).dtor.map(|dtor| dtor((*cs).str)); - (*cs).length = 0; - (*cs).str = 0 as *mut u8; - (*cs).dtor = None; - } -} - -#[inline(never)] -#[no_mangle] -pub extern "C" fn cef_string_userfree_utf8_alloc() -> *mut cef_string_utf8_t { - unsafe { - libc::calloc(1, mem::size_of::<cef_string_utf8_t>()) as *mut cef_string_utf8_t - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *mut cef_string_utf8_t, copy: c_int) -> c_int { - cef_string_utf8_clear(output); - unsafe { - if copy != 0 { - if !src.is_null() && src_len > 0 { - (*output).str = libc::calloc(1, src_len + 1) as *mut u8; - if (*output).str.is_null() { - return 0; - } - - ptr::copy(src, (*output).str, src_len as usize); - (*output).length = src_len; - (*output).dtor = Some(string_utf8_dtor as extern "C" fn(*mut u8)); - } - } else { - (*output).str = src as *mut _; - (*output).length = src_len; - (*output).dtor = None; - } - } - return 1; -} - -#[no_mangle] -pub extern "C" fn cef_string_utf8_cmp(a: *const cef_string_utf8_t, b: *const cef_string_utf8_t) -> c_int { - unsafe { - let astr = (*a).str as *const u8; - let bstr = (*b).str as *const u8; - let astr = slice::from_raw_parts(astr, (*a).length as usize); - let bstr = slice::from_raw_parts(bstr, (*b).length as usize); - match astr.cmp(bstr) { - Ordering::Less => -1, - Ordering::Equal => 0, - Ordering::Greater => 1 - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf8_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int { - slice_to_str(src, src_len as usize, |result| { - let conv = result.encode_utf16().collect::<Vec<u16>>(); - cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1); - 1 - }) -} - -#[no_mangle] -pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int { - unsafe { - let ustr = slice::from_raw_parts(src, src_len as usize); - match string::String::from_utf16(ustr) { - Ok(str) => { - cef_string_utf8_set(str.as_bytes().as_ptr(), str.len() as size_t, output, 1); - 1 as c_int - }, - _ => 0 as c_int - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf16_clear(cs: *mut cef_string_utf16_t) { - unsafe { - (*cs).dtor.map(|dtor| dtor((*cs).str)); - (*cs).length = 0; - (*cs).str = 0 as *mut c_ushort; - (*cs).dtor = None; - } -} - -#[inline(never)] -#[no_mangle] -pub extern "C" fn cef_string_userfree_utf16_alloc() -> *mut cef_string_utf16_t { - unsafe { - libc::calloc(1, mem::size_of::<cef_string_utf16_t>()) as *mut cef_string_utf16_t - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, output: *mut cef_string_utf16_t, copy: c_int) -> c_int { - cef_string_utf16_clear(output); - unsafe { - if copy != 0 { - if !src.is_null() && src_len > 0 { - (*output).str = libc::calloc(1, (src_len + 1) * mem::size_of::<c_ushort>()) as - *mut u16; - if (*output).str.is_null() { - return 0; - } - - ptr::copy(src, (*output).str, src_len as usize); - (*output).length = src_len; - (*output).dtor = Some(string_utf16_dtor as extern "C" fn(*mut c_ushort)); - } - } else { - (*output).str = src as *mut _; - (*output).length = src_len; - (*output).dtor = None; - } - } - return 1; -} - -#[no_mangle] -pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const cef_string_utf16_t) -> c_int { - unsafe { - let astr = (*a).str as *const _; - let bstr = (*b).str as *const _; - let astr: &[u16] = slice::from_raw_parts(astr, (*a).length as usize); - let bstr: &[u16] = slice::from_raw_parts(bstr, (*b).length as usize); - match astr.cmp(bstr) { - Ordering::Less => -1, - Ordering::Equal => 0, - Ordering::Greater => 1 - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) { - unsafe { - (*cs).dtor.map(|dtor| dtor((*cs).str)); - (*cs).length = 0; - (*cs).str = 0 as *mut wchar_t; - (*cs).dtor = None; - } -} - -#[inline(never)] -#[no_mangle] -pub extern "C" fn cef_string_userfree_wide_alloc() -> *mut cef_string_wide_t { - unsafe { - libc::calloc(1, mem::size_of::<cef_string_wide_t>()) as *mut cef_string_wide_t - } -} - -#[no_mangle] -pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, output: *mut cef_string_wide_t, copy: c_int) -> c_int { - cef_string_wide_clear(output); - unsafe { - if copy != 0 { - if !src.is_null() && src_len > 0 { - (*output).str = libc::calloc(1, (src_len + 1) * mem::size_of::<wchar_t>()) as - *mut wchar_t; - if (*output).str.is_null() { - return 0; - } - - ptr::copy(src, (*output).str, src_len as usize); - (*output).length = src_len; - (*output).dtor = Some(string_wide_dtor as extern "C" fn(*mut wchar_t)); - } - } else { - (*output).str = src as *mut _; - (*output).length = src_len; - (*output).dtor = None; - } - } - return 1; -} - -#[no_mangle] -pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int { - unsafe { - let astr = (*a).str as *const wchar_t; - let bstr = (*b).str as *const wchar_t; - let astr = slice::from_raw_parts(astr, (*a).length as usize); - let bstr = slice::from_raw_parts(bstr, (*b).length as usize); - match astr.cmp(bstr) { - Ordering::Less => -1, - Ordering::Equal => 0, - Ordering::Greater => 1 - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { - if mem::size_of::<wchar_t>() == mem::size_of::<u16>() { - return cef_string_utf8_to_utf16(src, src_len, output as *mut cef_string_utf16_t); - } - slice_to_str(src, src_len as usize, |result| { - let conv = result.chars().map(|c| c as u32).collect::<Vec<u32>>(); - cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) - }) -} - -#[no_mangle] -pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int { - if mem::size_of::<wchar_t>() == mem::size_of::<u16>() { - return cef_string_utf16_to_utf8(src as *const u16, src_len, output); - } - unsafe { - let ustr = slice::from_raw_parts(src, src_len as usize); - let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\u{FFFD}')).collect::<String>(); - cef_string_utf8_set(conv.as_bytes().as_ptr(), conv.len() as size_t, output, 1) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_ascii_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int { - slice_to_str(src, src_len as usize, |result| { - let conv = result.encode_utf16().collect::<Vec<u16>>(); - cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1) - }) -} - -#[no_mangle] -pub extern "C" fn cef_string_ascii_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { - unsafe { - let ustr = slice::from_raw_parts(src, src_len as usize); - let conv = ustr.iter().map(|&c| c as u8).collect::<Vec<u8>>(); - cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) - } -} - -pub fn empty_utf16_string() -> cef_string_utf16_t { - cef_string_utf16_t { - str: ptr::null_mut(), - length: 0, - dtor: None, - } -} - -pub fn string_to_userfree_string(string: cef_string_utf16_t) -> cef_string_userfree_utf16_t { - unsafe { - let allocation = libc::malloc(mem::size_of::<cef_string_utf16_t>() as size_t) - as cef_string_userfree_utf16_t; - ptr::write(allocation, string); - allocation - } -} - -pub fn empty_utf16_userfree_string() -> cef_string_userfree_utf16_t { - string_to_userfree_string(empty_utf16_string()) -} - diff --git a/ports/cef/string_list.rs b/ports/cef/string_list.rs deleted file mode 100644 index f267bf7316a..00000000000 --- a/ports/cef/string_list.rs +++ /dev/null @@ -1,68 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use libc::{c_int}; -use std::slice; -use string::cef_string_utf16_set; -use types::{cef_string_list_t,cef_string_t}; - -//cef_string_list - -#[no_mangle] -pub extern "C" fn cef_string_list_alloc() -> *mut cef_string_list_t { - Box::into_raw(Box::new(vec!())) -} - -#[no_mangle] -pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int { - unsafe { - if lt.is_null() { return 0; } - (*lt).len() as c_int - } -} - -#[no_mangle] -pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) { - unsafe { - if lt.is_null() { return; } - (*lt).push(String::from_utf16(slice::from_raw_parts((*value).str, (*value).length as usize)).unwrap()); - } -} - -#[no_mangle] -pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if index < 0 || lt.is_null() { return 0; } - if index as usize > (*lt).len() - 1 { return 0; } - let ref string = (*lt)[index as usize]; - let utf16_chars: Vec<u16> = string.encode_utf16().collect(); - cef_string_utf16_set(utf16_chars.as_ptr(), utf16_chars.len(), value, 1) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) { - unsafe { - if lt.is_null() { return; } - (*lt).clear(); - } -} - -#[no_mangle] -pub extern "C" fn cef_string_list_free(lt: *mut cef_string_list_t) { - unsafe { - if lt.is_null() { return; } - cef_string_list_clear(lt); - drop(Box::from_raw(lt)); - } -} - -#[no_mangle] -pub extern "C" fn cef_string_list_copy(lt: *mut cef_string_list_t) -> *mut cef_string_list_t { - unsafe { - if lt.is_null() { return 0 as *mut cef_string_list_t; } - let copy = (*lt).clone(); - Box::into_raw(Box::new(copy)) - } -} diff --git a/ports/cef/string_map.rs b/ports/cef/string_map.rs deleted file mode 100644 index 78e237c5fd4..00000000000 --- a/ports/cef/string_map.rs +++ /dev/null @@ -1,107 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use eutil::slice_to_str; -use libc::{c_int}; -use std::collections::BTreeMap; -use string::{cef_string_userfree_utf16_alloc, cef_string_userfree_utf16_free}; -use string::{cef_string_utf16_set}; -use types::{cef_string_map_t, cef_string_t}; - -//cef_string_map - -#[no_mangle] -pub extern "C" fn cef_string_map_alloc() -> *mut cef_string_map_t { - Box::into_raw(Box::new(BTreeMap::new())) -} - -#[no_mangle] -pub extern "C" fn cef_string_map_size(sm: *mut cef_string_map_t) -> c_int { - unsafe { - if sm.is_null() { return 0; } - (*sm).len() as c_int - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_append(sm: *mut cef_string_map_t, key: *const cef_string_t, value: *const cef_string_t) -> c_int { - unsafe { - if sm.is_null() { return 0; } - slice_to_str((*key).str as *const u8, (*key).length as usize, |result| { - let csv = cef_string_userfree_utf16_alloc(); - cef_string_utf16_set((*value).str as *const u16, (*value).length, csv, 1); - (*sm).insert(result.to_owned(), csv); - 1 - }) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_find(sm: *mut cef_string_map_t, key: *const cef_string_t, value: *mut cef_string_t) -> c_int { - unsafe { - if sm.is_null() { return 0; } - slice_to_str((*key).str as *const u8, (*key).length as usize, |result| { - match (*sm).get(result) { - Some(s) => { - cef_string_utf16_set((**s).str as *const u16, (**s).length, value, 1) - } - None => 0 - } - }) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_key(sm: *mut cef_string_map_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if index < 0 || sm.is_null() { return 0; } - if index as usize > (*sm).len() - 1 { return 0; } - - match (*sm).keys().nth(index as usize) { - Some(k) => { - cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16, - k.len(), - value, - 1) - }, - None => 0, - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_value(sm: *mut cef_string_map_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if index < 0 || sm.is_null() { return 0; } - if index as usize > (*sm).len() - 1 { return 0; } - - match (*sm).values().nth(index as usize) { - Some(val) => { - cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1); - 1 - }, - None => 0, - } - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_clear(sm: *mut cef_string_map_t) { - unsafe { - if sm.is_null() { return; } - for val in (*sm).values() { - cef_string_userfree_utf16_free(*val); - } - (*sm).clear(); - } -} - -#[no_mangle] -pub extern "C" fn cef_string_map_free(sm: *mut cef_string_map_t) { - unsafe { - if sm.is_null() { return; } - cef_string_map_clear(sm); - drop(Box::from_raw(sm)); - } -} diff --git a/ports/cef/string_multimap.rs b/ports/cef/string_multimap.rs deleted file mode 100644 index a49eaf3c42c..00000000000 --- a/ports/cef/string_multimap.rs +++ /dev/null @@ -1,138 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use eutil::slice_to_str; -use libc::c_int; -use std::collections::BTreeMap; -use string::{cef_string_userfree_utf16_alloc, cef_string_userfree_utf16_free}; -use string::{cef_string_utf16_set}; -use types::{cef_string_multimap_t,cef_string_t}; - -//cef_string_multimap - -#[no_mangle] -pub extern "C" fn cef_string_multimap_alloc() -> *mut cef_string_multimap_t { - Box::into_raw(Box::new(BTreeMap::new())) -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_size(smm: *mut cef_string_multimap_t) -> c_int { - unsafe { - if smm.is_null() { return 0; } - // t1 : collections::btree::map::Values<'_, collections::string::String, collections::vec::Vec<*mut types::cef_string_utf16>>` - let t1 = (*smm).values(); - // t2 : collections::btree::map::BTreeMap<collections::string::String, collections::vec::Vec<*mut types::cef_string_utf16>> - let t2 : usize = t1.map(|val| (*val).len()).sum(); - t2 as c_int - } -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_find_count(smm: *mut cef_string_multimap_t, key: *const cef_string_t) -> c_int { - unsafe { - if smm.is_null() { return 0; } - slice_to_str((*key).str as *const u8, (*key).length as usize, |result| { - match (*smm).get(result) { - Some(s) => s.len() as c_int, - None => 0 - } - }) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_append(smm: *mut cef_string_multimap_t, key: *const cef_string_t, value: *const cef_string_t) -> c_int { - unsafe { - if smm.is_null() { return 0; } - slice_to_str((*key).str as *const u8, (*key).length as usize, |result| { - let csv = cef_string_userfree_utf16_alloc(); - cef_string_utf16_set((*value).str as *const u16, (*value).length, csv, 1); - match (*smm).get_mut(result) { - Some(vc) => (*vc).push(csv), - None => { (*smm).insert(result.to_owned(), vec!(csv)); } - } - 1 - }) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_enumerate(smm: *mut cef_string_multimap_t, key: *const cef_string_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if smm.is_null() { return 0; } - slice_to_str((*key).str as *const u8, (*key).length as usize, |result| { - match (*smm).get(result) { - Some(s) => { - if (*s).len() <= index as usize { - return 0; - } - let cs = (*s)[index as usize]; - cef_string_utf16_set((*cs).str as *const u16, (*cs).length, value, 1) - } - None => 0 - } - }) - } -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_key(smm: *mut cef_string_multimap_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if index < 0 || smm.is_null() { return 0; } - let mut rem = index as usize; - - for (key, val) in &(*smm) { - if rem < (*val).len() { - return cef_string_utf16_set((*key).as_bytes().as_ptr() as *const u16, - (*key).len(), - value, - 1); - } else { - rem -= (*val).len(); - } - } - } - 0 -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_value(smm: *mut cef_string_multimap_t, index: c_int, value: *mut cef_string_t) -> c_int { - unsafe { - if index < 0 || smm.is_null() { return 0; } - let mut rem = index as usize; - - for val in (*smm).values() { - if rem < (*val).len() { - let cs = (*val)[rem as usize]; - return cef_string_utf16_set((*cs).str as *const u16, (*cs).length, value, 1); - } else { - rem -= (*val).len(); - } - } - } - 0 -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_clear(smm: *mut cef_string_multimap_t) { - unsafe { - if smm.is_null() { return; } - if (*smm).is_empty() { return; } - for (_, val) in (*smm).iter_mut() { - while let Some(cs) = (*val).pop() { - cef_string_userfree_utf16_free(cs); - } - } - (*smm).clear(); - } -} - -#[no_mangle] -pub extern "C" fn cef_string_multimap_free(smm: *mut cef_string_multimap_t) { - unsafe { - if smm.is_null() { return; } - cef_string_multimap_clear(smm); - drop(Box::from_raw(smm)); - } -} diff --git a/ports/cef/stubs.rs b/ports/cef/stubs.rs deleted file mode 100644 index 8f4a9b73820..00000000000 --- a/ports/cef/stubs.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Just some stubs so that you can link against this library in place of the -//! Chromium version of CEF. If you call these functions you will assuredly -//! crash. - -macro_rules! stub( - ($name:ident) => ( - #[no_mangle] - #[allow(non_snake_case)] - pub extern "C" fn $name() { - println!("CEF stub function called: {}", stringify!($name)); - unsafe { - ::std::intrinsics::abort() - } - } - ) -); - -stub!(cef_add_cross_origin_whitelist_entry); -stub!(cef_add_web_plugin_directory); -stub!(cef_add_web_plugin_path); -stub!(cef_begin_tracing); -stub!(cef_clear_cross_origin_whitelist); -stub!(cef_clear_scheme_handler_factories); -stub!(cef_create_url); -stub!(cef_end_tracing); -stub!(cef_force_web_plugin_shutdown); -stub!(cef_get_current_platform_thread_handle); -stub!(cef_get_current_platform_thread_id); -stub!(cef_get_extensions_for_mime_type); -stub!(cef_get_geolocation); -stub!(cef_get_mime_type); -stub!(cef_get_path); -stub!(cef_is_web_plugin_unstable); -stub!(cef_launch_process); -stub!(cef_now_from_system_trace_time); -stub!(cef_parse_url); -stub!(cef_post_delayed_task); -stub!(cef_post_task); -stub!(cef_refresh_web_plugins); -stub!(cef_register_extension); -stub!(cef_register_scheme_handler_factory); -stub!(cef_register_web_plugin_crash); -stub!(cef_remove_cross_origin_whitelist_entry); -stub!(cef_remove_web_plugin_path); -stub!(cef_set_osmodal_loop); -stub!(cef_string_utf16_to_wide); -stub!(cef_string_wide_to_utf16); -stub!(cef_unregister_internal_web_plugin); -stub!(cef_visit_web_plugin_info); - -//from skia -stub!(gluCheckExtension); diff --git a/ports/cef/switches.rs b/ports/cef/switches.rs deleted file mode 100644 index 0638397ae65..00000000000 --- a/ports/cef/switches.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// values taken from chromium/base/base_switches.cc - -// Disables the crash reporting. -pub static KDISABLEBREAKPAD: &'static str = "disable-breakpad"; - -// Indicates that crash reporting should be enabled. On platforms where helper -// processes cannot access to files needed to make this decision, this flag is -// generated internally. -pub static KENABLECRASHREPORTER: &'static str = "enable-crash-reporter"; - -// Generates full memory crash dump. -pub static KFULLMEMORYCRASHREPORT: &'static str = "full-memory-crash-report"; - -// The value of this switch determines whether the process is started as a -// renderer or plugin host. If it's empty, it's the browser. -pub static KPROCESSTYPE: &'static str = "type"; - -// Suppresses all error dialogs when present. -pub static KNOERRDIALOGS: &'static str = "noerrdialogs"; - -// When running certain tests that spawn child processes, this switch indicates -// to the test framework that the current process is a child process. -pub static KTESTCHILDPROCESS: &'static str = "test-child-process"; - -// Gives the default maximal active V-logging level; 0 is the default. -// Normally positive values are used for V-logging levels. -pub static KV: &'static str = "v"; - -// Gives the per-module maximal V-logging levels to override the value -// given by --v. E.g. "my_module=2,foo*=3" would change the logging -// level for all code in source files "my_module.*" and "foo*.*" -// ("-inl" suffixes are also disregarded for this matching). -// -// Any pattern containing a forward or backward slash will be tested -// against the whole pathname and not just the module. E.g., -// "*/foo/bar/*=2" would change the logging level for all code in -// source files under a "foo/bar" directory. -pub static KVMODULE: &'static str = "vmodule"; - -// Will wait for 60 seconds for a debugger to come to attach to the process. -pub static KWAITFORDEBUGGER: &'static str = "wait-for-debugger"; - -// Sends a pretty-printed version of tracing info to the console. -pub static KTRACETOCONSOLE: &'static str = "trace-to-console"; - -// Configure whether chrome://profiler will contain timing information. This -// option is enabled by default. A value of "0" will disable profiler timing, -// while all other values will enable it. -pub static KPROFILERTIMING: &'static str = "profiler-timing"; -// Value of the --profiler-timing flag that will disable timing information for -// chrome://profiler. -pub static KPROFILERTIMINGDISABLEDVALUE: &'static str = "0"; diff --git a/ports/cef/task.rs b/ports/cef/task.rs deleted file mode 100644 index c8b03f69f7a..00000000000 --- a/ports/cef/task.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::cef_task_runner_t; -use types::cef_thread_id_t; - -use libc::c_int; - -//FIXME: this should check the current servo task I guess? -#[no_mangle] -pub extern "C" fn cef_currently_on(_tid: cef_thread_id_t) -> c_int { - 1 -} - -cef_stub_static_method_impls! { - fn cef_task_runner_get_for_current_thread() -> *mut cef_task_runner_t - fn cef_task_runner_get_for_thread(thread_id: cef_thread_id_t) -> *mut cef_task_runner_t -} diff --git a/ports/cef/types.rs b/ports/cef/types.rs deleted file mode 100644 index 2c7738d741d..00000000000 --- a/ports/cef/types.rs +++ /dev/null @@ -1,2029 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use libc::{c_uint, c_ushort, c_int, c_double, size_t, wchar_t}; -#[cfg(target_os="linux")] -use libc::c_ulong; -#[cfg(target_os="macos")] -use libc::c_void; - -use net_traits::net_error_list::NetError; - -pub use self::cef_rect as cef_rect_t; - -use std::collections::BTreeMap; - -pub type cef_string_map_t = BTreeMap<String, *mut cef_string_t>; -pub type cef_string_multimap_t = BTreeMap<String, Vec<*mut cef_string_t>>; -pub type cef_string_list_t = Vec<String>; -pub enum cef_text_input_context_t {} -pub enum cef_event_handle_t {} - -#[cfg(target_os="linux")] -pub type cef_window_handle_t = c_ulong; -#[cfg(target_os="macos")] -pub type cef_window_handle_t = *mut c_void; //NSView* -//#[cfg(target_os="win")] -//pub enum cef_window_handle_t {} //HWND -#[cfg(target_os="linux")] -pub type cef_cursor_handle_t = c_ulong; -#[cfg(target_os="macos")] -pub type cef_cursor_handle_t = *mut c_void; //NSCursor* -//#[cfg(target_os="win")] -//pub enum cef_cursor_handle_t {} //HCURSOR - -pub type cef_string_t = cef_string_utf16; //FIXME: this is #defined... -pub type cef_string_userfree_t = *mut cef_string_t; //FIXME: this is #defined... - -pub struct cef_string_utf8 { - pub str: *mut u8, - pub length: size_t, - pub dtor: Option<extern "C" fn(str: *mut u8)>, -} -pub type cef_string_utf8_t = cef_string_utf8; -pub type cef_string_userfree_utf8_t = cef_string_utf8; - -pub type cef_string_utf16_t = cef_string_utf16; -pub type cef_string_userfree_utf16_t = *mut cef_string_utf16; -pub struct cef_string_utf16 { - pub str: *mut c_ushort, - pub length: size_t, - pub dtor: Option<extern "C" fn(str: *mut c_ushort)>, -} - -pub type cef_string_wide_t = cef_string_wide; -pub type cef_string_userfree_wide_t = cef_string_wide; -pub struct cef_string_wide { - pub str: *mut wchar_t, - pub length: size_t, - pub dtor: Option<extern "C" fn(str: *mut wchar_t)>, -} - -pub type cef_main_args_t = cef_main_args; -pub struct cef_main_args { - pub argc: c_int, - pub argv: *const *const u8 -} - -pub type cef_color_t = c_uint; - -pub enum cef_json_parser_error_t { - JSON_NO_ERROR = 0, - JSON_INVALID_ESCAPE, - JSON_SYNTAX_ERROR, - JSON_UNEXPECTED_TOKEN, - JSON_TRAILING_COMMA, - JSON_TOO_MUCH_NESTING, - JSON_UNEXPECTED_DATA_AFTER_ROOT, - JSON_UNSUPPORTED_ENCODING, - JSON_UNQUOTED_DICTIONARY_KEY, - JSON_PARSE_ERROR_COUNT -} - -/// -// Represents the state of a setting. -/// -pub enum cef_state_t { - /// - // Use the default state for the setting. - /// - STATE_DEFAULT = 0, - - /// - // Enable or allow the setting. - /// - STATE_ENABLED, - - /// - // Disable or disallow the setting. - /// - STATE_DISABLED, -} -// -// Existing thread IDs. -// -pub enum cef_thread_id_t { -// BROWSER PROCESS THREADS -- Only available in the browser process. - - // - // The main thread in the browser. This will be the same as the main - // application thread if CefInitialize() is called with a - // CefSettings.multi_threaded_message_loop value of false. - // - TID_UI, - - // - // Used to interact with the database. - // - TID_DB, - - // - // Used to interact with the file system. - // - TID_FILE, - - // - // Used for file system operations that block user interactions. - // Responsiveness of this thread affects users. - // - TID_FILE_USER_BLOCKING, - - // - // Used to launch and terminate browser processes. - // - TID_PROCESS_LAUNCHER, - - // - // Used to handle slow HTTP cache operations. - // - TID_CACHE, - - // - // Used to process IPC and network messages. - // - TID_IO, - -// RENDER PROCESS THREADS -- Only available in the render process. - - // - // The main thread in the renderer. Used for all WebKit and V8 interaction. - // - TID_RENDERER, -} - -// -// Navigation types. -// -pub enum cef_navigation_type_t { - NAVIGATION_LINK_CLICKED = 0, - NAVIGATION_FORM_SUBMITTED, - NAVIGATION_BACK_FORWARD, - NAVIGATION_RELOAD, - NAVIGATION_FORM_RESUBMITTED, - NAVIGATION_OTHER, -} - -// -// Mouse button types. -// -pub enum cef_mouse_button_type_t { - MBT_LEFT = 0, - MBT_MIDDLE, - MBT_RIGHT, -} - -// -// Structure representing mouse event information. -// -pub type cef_mouse_event_t = cef_mouse_event; -pub type CefMouseEvent = cef_mouse_event_t; -pub struct cef_mouse_event { - // - // X coordinate relative to the left side of the view. - // - pub x: c_int, - - // - // Y coordinate relative to the top side of the view. - // - pub y: c_int, - - // - // Bit flags describing any pressed modifier keys. See - // cef_event_flags_t for values. - // - pub modifiers: c_uint, -} - -// -// Post data elements may represent either bytes or files. -// -pub enum cef_postdataelement_type_t { - PDE_TYPE_EMPTY = 0, - PDE_TYPE_BYTES, - PDE_TYPE_FILE, -} - -// -// Flags used to customize the behavior of CefURLRequest. -// -pub enum cef_urlrequest_flags_t { - // - // Default behavior. - // - UR_FLAG_NONE = 0, - - // - // If set the cache will be skipped when handling the request. - // - UR_FLAG_SKIP_CACHE = 1 << 0, - - // - // If set user name, password, and cookies may be sent with the request. - // - UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1, - - // - // If set cookies may be sent with the request and saved from the response. - // UR_FLAG_ALLOW_CACHED_CREDENTIALS must also be set. - // - UR_FLAG_ALLOW_COOKIES = 1 << 2, - - // - // If set upload progress events will be generated when a request has a body. - // - UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3, - - // - // If set load timing info will be collected for the request. - // - UR_FLAG_REPORT_LOAD_TIMING = 1 << 4, - - // - // If set the headers sent and received for the request will be recorded. - // - UR_FLAG_REPORT_RAW_HEADERS = 1 << 5, - - // - // If set the CefURLRequestClient::OnDownloadData method will not be called. - // - UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6, - - // - // If set 5XX redirect errors will be propagated to the observer instead of - // automatically re-tried. This currently only applies for requests - // originated in the browser process. - // - UR_FLAG_NO_RETRY_ON_5XX = 1 << 7, -} - - -// -// Flags that represent CefURLRequest status. -// -pub enum cef_urlrequest_status_t { - // - // Unknown status. - // - UR_UNKNOWN = 0, - - // - // Request succeeded. - // - UR_SUCCESS, - - // - // An IO request is pending, and the caller will be informed when it is - // completed. - // - UR_IO_PENDING, - - // - // Request was canceled programatically. - // - UR_CANCELED, - - // - // Request failed for some reason. - // - UR_FAILED, -} - - - -pub type cef_errorcode_t = NetError; - - -// -// Key event types. -// -pub enum cef_key_event_type_t { - KEYEVENT_RAWKEYDOWN = 0, - KEYEVENT_KEYDOWN, - KEYEVENT_KEYUP, - KEYEVENT_CHAR -} - -// -// Structure representing keyboard event information. -// -pub type cef_key_event_t = cef_key_event; -pub struct cef_key_event { - // - // The type of keyboard event. - // - pub t: cef_key_event_type_t, - - // - // Bit flags describing any pressed modifier keys. See - // cef_event_flags_t for values. - // - pub modifiers: c_uint, - - // - // The Windows key code for the key event. This value is used by the DOM - // specification. Sometimes it comes directly from the event (i.e. on - // Windows) and sometimes it's determined using a mapping function. See - // WebCore/platform/chromium/KeyboardCodes.h for the list of values. - // - pub windows_key_code: c_int, - - // - // The actual key code generated by the platform. - // - pub native_key_code: c_int, - - // - // Indicates whether the event is considered a "system key" event (see - // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details). - // This value will always be false on non-Windows platforms. - // - pub is_system_key: c_int, - - // - // The character generated by the keystroke. - // - pub character: c_ushort, //FIXME: can be wchar_t also? - - // - // Same as |character| but unmodified by any concurrently-held modifiers - // (except shift). This is useful for working out shortcut keys. - // - pub unmodified_character: c_ushort, //FIXME: can be wchar_t also? - - // - // True if the focus is currently on an editable field on the page. This is - // useful for determining if standard key events should be intercepted. - // - pub focus_on_editable_field: c_int, -} - -pub type CefKeyEvent = cef_key_event_t; - -// -// Structure representing a point. -// -pub type cef_point_t = cef_point; -pub struct cef_point { - pub x: c_int, - pub y: c_int, -} - -// -// Structure representing a rectangle. -// -#[derive(Default)] -pub struct cef_rect { - pub x: c_int, - pub y: c_int, - pub width: c_int, - pub height: c_int, -} - -impl cef_rect { - pub fn zero() -> cef_rect { - cef_rect { - x: 0, - y: 0, - width: 0, - height: 0, - } - } -} - -pub type cef_draggable_region_t = cef_draggable_region; -/// -// Structure representing a draggable region. -/// -pub struct cef_draggable_region { - /// - // Bounds of the region. - /// - pub bounds: cef_rect_t, - - /// - // True (1) this this region is draggable and false (0) otherwise. - /// - pub draggable: i32 -} - -// -// Paint element types. -// -pub enum cef_paint_element_type_t { - PET_VIEW = 0, - PET_POPUP, -} - -// -// DOM document types. -// -pub enum cef_dom_document_type_t { - DOM_DOCUMENT_TYPE_UNKNOWN = 0, - DOM_DOCUMENT_TYPE_HTML, - DOM_DOCUMENT_TYPE_XHTML, - DOM_DOCUMENT_TYPE_PLUGIN, -} - -// -// Supported file dialog modes. -// -pub enum cef_file_dialog_mode_t { - // - // Requires that the file exists before allowing the user to pick it. - // - FILE_DIALOG_OPEN = 0, - - // - // Like Open, but allows picking multiple files to open. - // - FILE_DIALOG_OPEN_MULTIPLE, - - // - // Allows picking a nonexistent file, and prompts to overwrite if the file - // already exists. - // - FILE_DIALOG_SAVE, -} - -// -// Supported value types. -// -pub enum cef_value_type_t { - VTYPE_INVALID = 0, - VTYPE_NULL, - VTYPE_BOOL, - VTYPE_INT, - VTYPE_DOUBLE, - VTYPE_STRING, - VTYPE_BINARY, - VTYPE_DICTIONARY, - VTYPE_LIST, -} - -pub type CefValueType = cef_value_type_t; - -// -// Existing process IDs. -// -pub enum cef_process_id_t { - // - // Browser process. - // - PID_BROWSER, - // - // Renderer process. - // - PID_RENDERER, -} -pub type CefProcessId = cef_process_id_t; - -// -// Log severity levels. -// -pub enum cef_log_severity_t { - // - // Default logging (currently INFO logging). - // - LOGSEVERITY_DEFAULT, - - // - // Verbose logging. - // - LOGSEVERITY_VERBOSE, - - // - // INFO logging. - // - LOGSEVERITY_INFO, - - // - // WARNING logging. - // - LOGSEVERITY_WARNING, - - // - // ERROR logging. - // - LOGSEVERITY_ERROR, - - // - // ERROR_REPORT logging. - // - LOGSEVERITY_ERROR_REPORT, - - // - // Completely disable logging. - // - LOGSEVERITY_DISABLE = 99 -} - - -// -// Initialization settings. Specify NULL or 0 to get the recommended default -// values. Many of these and other settings can also configured using command- -// line switches. -// -pub type cef_settings_t = cef_settings; - -#[repr(C)] -pub struct cef_settings { - // - // Size of this structure. - // - pub size: size_t, - - // - // Set to true (1) to use a single process for the browser and renderer. This - // run mode is not officially supported by Chromium and is less stable than - // the multi-process default. Also configurable using the "single-process" - // command-line switch. - // - pub single_process: c_int, - - // - // Set to true (1) to disable the sandbox for sub-processes. See - // cef_sandbox_win.h for requirements to enable the sandbox on Windows. Also - // configurable using the "no-sandbox" command-line switch. - // - pub no_sandbox: c_int, - - // - // The path to a separate executable that will be launched for sub-processes. - // By default the browser process executable is used. See the comments on - // CefExecuteProcess() for details. Also configurable using the - // "browser-subprocess-path" command-line switch. - // - pub browser_subprocess_path: cef_string_t, - - // - // Set to true (1) to have the browser process message loop run in a separate - // thread. If false (0) than the CefDoMessageLoopWork() function must be - // called from your application message loop. - // - pub multi_threaded_message_loop: c_int, - - - // - // Set to true (1) to enable windowless (off-screen) rendering support. Do not - // enable this value if the application does not use windowless rendering as - // it may reduce rendering performance on some systems. - // - pub windowless_rendering_enabled: c_int, - - // - // Set to true (1) to disable configuration of browser process features using - // standard CEF and Chromium command-line arguments. Configuration can still - // be specified using CEF data structures or via the - // CefApp::OnBeforeCommandLineProcessing() method. - // - pub command_line_args_disabled: c_int, - - // - // The location where cache data will be stored on disk. If empty an in-memory - // cache will be used for some features and a temporary disk cache for others. - // HTML5 databases such as localStorage will only persist across sessions if a - // cache path is specified. - // - pub cache_path: cef_string_t, - - // - // To persist session cookies (cookies without an expiry date or validity - // interval) by default when using the global cookie manager set this value to - // true. Session cookies are generally intended to be transient and most Web - // browsers do not persist them. A |cache_path| value must also be specified to - // enable this feature. Also configurable using the "persist-session-cookies" - // command-line switch. - // - pub persist_session_cookies: c_int, - - // - // Value that will be returned as the User-Agent HTTP header. If empty the - // default User-Agent string will be used. Also configurable using the - // "user-agent" command-line switch. - // - pub user_agent: cef_string_t, - - // - // Value that will be inserted as the product portion of the default - // User-Agent string. If empty the Chromium product version will be used. If - // |userAgent| is specified this value will be ignored. Also configurable - // using the "product-version" command-line switch. - // - pub product_version: cef_string_t, - - // - // The locale string that will be passed to WebKit. If empty the default - // locale of "en-US" will be used. This value is ignored on Linux where locale - // is determined using environment variable parsing with the precedence order: - // LANGUAGE, LC_ALL, LC_MESSAGES and LANG. Also configurable using the "lang" - // command-line switch. - // - pub locale: cef_string_t, - - // - // The directory and file name to use for the debug log. If empty, the - // default name of "debug.log" will be used and the file will be written - // to the application directory. Also configurable using the "log-file" - // command-line switch. - // - pub log_file: cef_string_t, - - // - // The log severity. Only messages of this severity level or higher will be - // logged. Also configurable using the "log-severity" command-line switch with - // a value of "verbose", "info", "warning", "error", "error-report" or - // "disable". - // - pub log_severity: cef_log_severity_t, - - // - // Custom flags that will be used when initializing the V8 JavaScript engine. - // The consequences of using custom flags may not be well tested. Also - // configurable using the "js-flags" command-line switch. - // - pub javascript_flags: cef_string_t, - - // - // The fully qualified path for the resources directory. If this value is - // empty the cef.pak and/or devtools_resources.pak files must be located in - // the module directory on Windows/Linux or the app bundle Resources directory - // on Mac OS X. Also configurable using the "resources-dir-path" command-line - // switch. - // - pub resources_dir_path: cef_string_t, - - // - // The fully qualified path for the locales directory. If this value is empty - // the locales directory must be located in the module directory. This value - // is ignored on Mac OS X where pack files are always loaded from the app - // bundle Resources directory. Also configurable using the "locales-dir-path" - // command-line switch. - // - pub locales_dir_path: cef_string_t, - - // - // Set to true (1) to disable loading of pack files for resources and locales. - // A resource bundle handler must be provided for the browser and render - // processes via CefApp::GetResourceBundleHandler() if loading of pack files - // is disabled. Also configurable using the "disable-pack-loading" command- - // line switch. - // - pub pack_loading_disabled: c_int, - - // - // Set to a value between 1024 and 65535 to enable remote debugging on the - // specified port. For example, if 8080 is specified the remote debugging URL - // will be http://localhost:8080. CEF can be remotely debugged from any CEF or - // Chrome browser window. Also configurable using the "remote-debugging-port" - // command-line switch. - // - pub remote_debugging_port: c_int, - - // - // The number of stack trace frames to capture for uncaught exceptions. - // Specify a positive value to enable the CefV8ContextHandler:: - // OnUncaughtException() callback. Specify 0 (default value) and - // OnUncaughtException() will not be called. Also configurable using the - // "uncaught-exception-stack-size" command-line switch. - // - pub uncaught_exception_stack_size: c_int, - - // - // By default CEF V8 references will be invalidated (the IsValid() method will - // return false) after the owning context has been released. This reduces the - // need for external record keeping and avoids crashes due to the use of V8 - // references after the associated context has been released. - // - // CEF currently offers two context safety implementations with different - // performance characteristics. The default implementation (value of 0) uses a - // map of hash values and should provide better performance in situations with - // a small number contexts. The alternate implementation (value of 1) uses a - // hidden value attached to each context and should provide better performance - // in situations with a large number of contexts. - // - // If you need better performance in the creation of V8 references and you - // plan to manually track context lifespan you can disable context safety by - // specifying a value of -1. - // - // Also configurable using the "context-safety-implementation" command-line - // switch. - // - pub context_safety_implementation: c_int, - - // - // Set to true (1) to ignore errors related to invalid SSL certificates. - // Enabling this setting can lead to potential security vulnerabilities like - // "man in the middle" attacks. Applications that load content from the - // internet should not enable this setting. Also configurable using the - // "ignore-certificate-errors" command-line switch. - // - pub ignore_certificate_errors: c_int, - - // - // Opaque background color used for accelerated content. By default the - // background color will be white. Only the RGB components of the specified - // value will be used. The alpha component must greater than 0 to enable use - // of the background color but will be otherwise ignored. - // - pub background_color: cef_color_t, -} - -// -// Structure defining the reference count implementation functions. All -// framework structures must include the cef_base_t structure first. -// -pub type cef_base_t = cef_base; -pub struct cef_base { - // - // Size of the data structure. - // - pub size: size_t, - - // - // Increment the reference count. - // - pub add_ref: Option<extern "C" fn(base: *mut cef_base) -> c_int>, - - // - // Decrement the reference count. Delete this object when no references - // remain. - // - pub release: Option<extern "C" fn(base: *mut cef_base) -> c_int>, - - // - // Returns the current number of references. - // - pub get_refct: Option<extern "C" fn(base: *mut cef_base) -> c_int>, -} - -pub type CefBase = *mut cef_base_t; - -// -// Class representing window information. -// -pub type cef_window_info_t = cef_window_info; - -#[cfg(target_os="linux")] -pub struct cef_window_info { - pub x: c_uint, - pub y: c_uint, - pub width: c_uint, - pub height: c_uint, - - // - // Pointer for the parent window. - // - pub parent_window: cef_window_handle_t, - - // - // Set to true (1) to create the browser using windowless (off-screen) - // rendering. No window will be created for the browser and all rendering will - // occur via the CefRenderHandler interface. The |parent_window| value will be - // used to identify monitor info and to act as the parent window for dialogs, - // context menus, etc. If |parent_window| is not provided then the main screen - // monitor will be used and some functionality that requires a parent window - // may not function correctly. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - // - pub windowless_rendering_enabled: c_int, - - // - // Set to true (1) to enable transparent painting in combination with - // windowless rendering. When this value is true a transparent background - // color will be used (RGBA=0x00000000). When this value is false the - // background will be white and opaque. - // - pub transparent_painting_enabled: c_int, - - // - // Pointer for the new browser window. Only used with windowed rendering. - // - pub window: cef_window_handle_t -} - -#[cfg(target_os="macos")] -pub struct cef_window_info { - pub window_name: cef_string_t, - pub x: c_uint, - pub y: c_uint, - pub width: c_uint, - pub height: c_uint, - - // - // Set to true (1) to create the view initially hidden. - // - pub hidden: c_int, - - // - // Pointer for the parent window. - // - pub parent_window: cef_window_handle_t, - - // - // Set to true (1) to create the browser using windowless (off-screen) - // rendering. No window will be created for the browser and all rendering will - // occur via the CefRenderHandler interface. The |parent_window| value will be - // used to identify monitor info and to act as the parent window for dialogs, - // context menus, etc. If |parent_window| is not provided then the main screen - // monitor will be used and some functionality that requires a parent window - // may not function correctly. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - // - pub windowless_rendering_enabled: c_int, - - // - // Set to true (1) to enable transparent painting in combination with - // windowless rendering. When this value is true a transparent background - // color will be used (RGBA=0x00000000). When this value is false the - // background will be white and opaque. - // - pub transparent_painting_enabled: c_int, - - // - // Pointer for the new browser window. Only used with windowed rendering. - // - pub window: cef_window_handle_t -} - -pub type CefWindowInfo = cef_window_info_t; - -// -// Supported menu item types. -// -pub enum cef_menu_item_type_t { - MENUITEMTYPE_NONE, - MENUITEMTYPE_COMMAND, - MENUITEMTYPE_CHECK, - MENUITEMTYPE_RADIO, - MENUITEMTYPE_SEPARATOR, - MENUITEMTYPE_SUBMENU, -} - -// -// Supported context menu type flags. -// -pub enum cef_context_menu_type_flags_t { - // - // No node is selected. - // - CM_TYPEFLAG_NONE = 0, - // - // The top page is selected. - // - CM_TYPEFLAG_PAGE = 1 << 0, - // - // A subframe page is selected. - // - CM_TYPEFLAG_FRAME = 1 << 1, - // - // A link is selected. - // - CM_TYPEFLAG_LINK = 1 << 2, - // - // A media node is selected. - // - CM_TYPEFLAG_MEDIA = 1 << 3, - // - // There is a textual or mixed selection that is selected. - // - CM_TYPEFLAG_SELECTION = 1 << 4, - // - // An editable element is selected. - // - CM_TYPEFLAG_EDITABLE = 1 << 5, -} - -// -// Supported context menu media types. -// -pub enum cef_context_menu_media_type_t { - // - // No special node is in context. - // - CM_MEDIATYPE_NONE, - // - // An image node is selected. - // - CM_MEDIATYPE_IMAGE, - // - // A video node is selected. - // - CM_MEDIATYPE_VIDEO, - // - // An audio node is selected. - // - CM_MEDIATYPE_AUDIO, - // - // A file node is selected. - // - CM_MEDIATYPE_FILE, - // - // A plugin node is selected. - // - CM_MEDIATYPE_PLUGIN, -} - -// -// Supported context menu media state bit flags. -// -pub enum cef_context_menu_media_state_flags_t { - CM_MEDIAFLAG_NONE = 0, - CM_MEDIAFLAG_ERROR = 1 << 0, - CM_MEDIAFLAG_PAUSED = 1 << 1, - CM_MEDIAFLAG_MUTED = 1 << 2, - CM_MEDIAFLAG_LOOP = 1 << 3, - CM_MEDIAFLAG_CAN_SAVE = 1 << 4, - CM_MEDIAFLAG_HAS_AUDIO = 1 << 5, - CM_MEDIAFLAG_HAS_VIDEO = 1 << 6, - CM_MEDIAFLAG_CONTROL_ROOT_ELEMENT = 1 << 7, - CM_MEDIAFLAG_CAN_PRINT = 1 << 8, - CM_MEDIAFLAG_CAN_ROTATE = 1 << 9, -} - -// -// Supported context menu edit state bit flags. -// -pub enum cef_context_menu_edit_state_flags_t { - CM_EDITFLAG_NONE = 0, - CM_EDITFLAG_CAN_UNDO = 1 << 0, - CM_EDITFLAG_CAN_REDO = 1 << 1, - CM_EDITFLAG_CAN_CUT = 1 << 2, - CM_EDITFLAG_CAN_COPY = 1 << 3, - CM_EDITFLAG_CAN_PASTE = 1 << 4, - CM_EDITFLAG_CAN_DELETE = 1 << 5, - CM_EDITFLAG_CAN_SELECT_ALL = 1 << 6, - CM_EDITFLAG_CAN_TRANSLATE = 1 << 7, -} - -// -// Supported event bit flags. -// -pub enum cef_event_flags_t { - EVENTFLAG_NONE = 0, - EVENTFLAG_CAPS_LOCK_ON = 1 << 0, - EVENTFLAG_SHIFT_DOWN = 1 << 1, - EVENTFLAG_CONTROL_DOWN = 1 << 2, - EVENTFLAG_ALT_DOWN = 1 << 3, - EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4, - EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5, - EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6, - // Mac OS-X command key. - EVENTFLAG_COMMAND_DOWN = 1 << 7, - EVENTFLAG_NUM_LOCK_ON = 1 << 8, - EVENTFLAG_IS_KEY_PAD = 1 << 9, - EVENTFLAG_IS_LEFT = 1 << 10, - EVENTFLAG_IS_RIGHT = 1 << 11, -} - -// -// Time information. Values should always be in UTC. -// -#[repr(C)] -pub struct _cef_time_t { - year: c_int, // Four digit year "2007" - month: c_int, // 1-based month (values 1 = January, etc.) - day_of_week: c_int, // 0-based day of week (0 = Sunday, etc.) - day_of_month: c_int, // 1-based day of month (1-31) - hour: c_int, // Hour within the current day (0-23) - minute: c_int, // Minute within the current hour (0-59) - second: c_int, // Second within the current minute (0-59 plus leap - // seconds which may take it up to 60). - millisecond: c_int, // Milliseconds within the current second (0-999) -} - -pub type cef_time_t = _cef_time_t; - -// -// DOM event processing phases. -// -pub enum cef_dom_event_phase_t { - DOM_EVENT_PHASE_UNKNOWN = 0, - DOM_EVENT_PHASE_CAPTURING, - DOM_EVENT_PHASE_AT_TARGET, - DOM_EVENT_PHASE_BUBBLING, -} - -// -// DOM node types. -// -pub enum cef_dom_node_type_t { - DOM_NODE_TYPE_UNSUPPORTED = 0, - DOM_NODE_TYPE_ELEMENT, - DOM_NODE_TYPE_ATTRIBUTE, - DOM_NODE_TYPE_TEXT, - DOM_NODE_TYPE_CDATA_SECTION, - DOM_NODE_TYPE_PROCESSING_INSTRUCTIONS, - DOM_NODE_TYPE_COMMENT, - DOM_NODE_TYPE_DOCUMENT, - DOM_NODE_TYPE_DOCUMENT_TYPE, - DOM_NODE_TYPE_DOCUMENT_FRAGMENT, -} - -// -// Focus sources. -// -pub enum cef_focus_source_t { - // - // The source is explicit navigation via the API (LoadURL(), etc). - // - FOCUS_SOURCE_NAVIGATION = 0, - // - // The source is a system-generated focus event. - // - FOCUS_SOURCE_SYSTEM, -} - -// -// Supported JavaScript dialog types. -// -pub enum cef_jsdialog_type_t { - JSDIALOGTYPE_ALERT = 0, - JSDIALOGTYPE_CONFIRM, - JSDIALOGTYPE_PROMPT, -} - -// -// Structure representing a size. -// -pub struct _cef_size_t { - pub width: c_int, - pub height: c_int, -} - -pub type cef_size_t = _cef_size_t; - -// -// Structure representing a print job page range. -// -pub struct _cef_page_range_t { - pub from: c_int, - pub to: c_int, -} - -pub type cef_page_range_t = _cef_page_range_t; - -// -// Print job duplex mode values. -// -pub enum cef_duplex_mode_t { - DUPLEX_MODE_UNKNOWN = -1, - DUPLEX_MODE_SIMPLEX = 0, - DUPLEX_MODE_LONG_EDGE = 1, - DUPLEX_MODE_SHORT_EDGE = 2, -} - -// -// Print job color mode values. -// -pub enum cef_color_model_t { - COLOR_MODEL_UNKNOWN, - COLOR_MODEL_GRAY, - COLOR_MODEL_COLOR, - COLOR_MODEL_CMYK, - COLOR_MODEL_CMY, - COLOR_MODEL_KCMY, - COLOR_MODEL_CMY_K, // CMY_K represents CMY+K. - COLOR_MODEL_BLACK, - COLOR_MODEL_GRAYSCALE, - COLOR_MODEL_RGB, - COLOR_MODEL_RGB16, - COLOR_MODEL_RGBA, - COLOR_MODEL_COLORMODE_COLOR, // Used in samsung printer ppds. - COLOR_MODEL_COLORMODE_MONOCHROME, // Used in samsung printer ppds. - COLOR_MODEL_HP_COLOR_COLOR, // Used in HP color printer ppds. - COLOR_MODEL_HP_COLOR_BLACK, // Used in HP color printer ppds. - COLOR_MODEL_PRINTOUTMODE_NORMAL, // Used in foomatic ppds. - COLOR_MODEL_PRINTOUTMODE_NORMAL_GRAY, // Used in foomatic ppds. - COLOR_MODEL_PROCESSCOLORMODEL_CMYK, // Used in canon printer ppds. - COLOR_MODEL_PROCESSCOLORMODEL_GREYSCALE, // Used in canon printer ppds. - COLOR_MODEL_PROCESSCOLORMODEL_RGB, // Used in canon printer ppds -} - -// -// Resource type for a request. -// -pub enum cef_resource_type_t { - // - // Top level page. - // - RT_MAIN_FRAME = 0, - - // - // Frame or iframe. - // - RT_SUB_FRAME, - - // - // CSS stylesheet. - // - RT_STYLESHEET, - - // - // External script. - // - RT_SCRIPT, - - // - // Image (jpg/gif/png/etc). - // - RT_IMAGE, - - // - // Font. - // - RT_FONT_RESOURCE, - - // - // Some other subresource. This is the default type if the actual type is - // unknown. - // - RT_SUB_RESOURCE, - - // - // Object (or embed) tag for a plugin, or a resource that a plugin requested. - // - RT_OBJECT, - - // - // Media resource. - // - RT_MEDIA, - - // - // Main resource of a dedicated worker. - // - RT_WORKER, - - // - // Main resource of a shared worker. - // - RT_SHARED_WORKER, - - // - // Explicitly requested prefetch. - // - RT_PREFETCH, - - // - // Favicon. - // - RT_FAVICON, - - // - // XMLHttpRequest. - // - RT_XHR, - - // - // A request for a <ping> - // - RT_PING, - - // - // Main resource of a service worker. - // - RT_SERVICE_WORKER, -} - -// -// Transition type for a request. Made up of one source value and 0 or more -// qualifiers. -// -pub enum cef_transition_type_t { - // - // Source is a link click or the JavaScript window.open function. This is - // also the default value for requests like sub-resource loads that are not - // navigations. - // - TT_LINK = 0, - - // - // Source is some other "explicit" navigation action such as creating a new - // browser or using the LoadURL function. This is also the default value - // for navigations where the actual type is unknown. - // - TT_EXPLICIT = 1, - - // - // Source is a subframe navigation. This is any content that is automatically - // loaded in a non-toplevel frame. For example, if a page consists of several - // frames containing ads, those ad URLs will have this transition type. - // The user may not even realize the content in these pages is a separate - // frame, so may not care about the URL. - // - TT_AUTO_SUBFRAME = 3, - - // - // Source is a subframe navigation explicitly requested by the user that will - // generate new navigation entries in the back/forward list. These are - // probably more important than frames that were automatically loaded in - // the background because the user probably cares about the fact that this - // link was loaded. - // - TT_MANUAL_SUBFRAME = 4, - - // - // Source is a form submission by the user. NOTE: In some situations - // submitting a form does not result in this transition type. This can happen - // if the form uses a script to submit the contents. - // - TT_FORM_SUBMIT = 7, - - // - // Source is a "reload" of the page via the Reload function or by re-visiting - // the same URL. NOTE: This is distinct from the concept of whether a - // particular load uses "reload semantics" (i.e. bypasses cached data). - // - TT_RELOAD = 8, - - // - // General mask defining the bits used for the source values. - // - TT_SOURCE_MASK = 0xFF, - - // Qualifiers. - // Any of the core values above can be augmented by one or more qualifiers. - // These qualifiers further define the transition. - - // - // Attempted to visit a URL but was blocked. - // - TT_BLOCKED_FLAG = 0x00800000, - - // - // Used the Forward or Back function to navigate among browsing history. - // - TT_FORWARD_BACK_FLAG = 0x01000000, - - // - // The beginning of a navigation chain. - // - TT_CHAIN_START_FLAG = 0x10000000, - - // - // The last transition in a redirect chain. - // - TT_CHAIN_END_FLAG = 0x20000000, - - // - // Redirects caused by JavaScript or a meta refresh tag on the page. - // - TT_CLIENT_REDIRECT_FLAG = 0x40000000, - - // - // Redirects sent from the server by HTTP headers. - // - TT_SERVER_REDIRECT_FLAG = 0x80000000, - - // - // Used to test whether a transition involves a redirect. - // - TT_IS_REDIRECT_MASK = 0xC0000000, - - // - // General mask defining the bits used for the qualifiers. - // - TT_QUALIFIER_MASK = 0xFFFFFF00, -} - -// -// Process termination status values. -// -pub enum cef_termination_status_t { - // - // Non-zero exit status. - // - TS_ABNORMAL_TERMINATION, - - // - // SIGKILL or task manager kill. - // - TS_PROCESS_WAS_KILLED, - - // - // Segmentation fault. - // - TS_PROCESS_CRASHED, -} - -// -// V8 access control values. -// -pub enum cef_v8_accesscontrol_t { - V8_ACCESS_CONTROL_DEFAULT = 0, - V8_ACCESS_CONTROL_ALL_CAN_READ = 1, - V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1, - V8_ACCESS_CONTROL_PROHIBITS_OVERWRITING = 1 << 2 -} - -// -// V8 property attribute values. -// -pub enum cef_v8_propertyattribute_t { - V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable, - // Configurable - V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable - V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable - V8_PROPERTY_ATTRIBUTE_DONTDELETE = 1 << 2 // Not configurable -} - -// -// XML node types. -// -pub enum cef_xml_node_type_t { - XML_NODE_UNSUPPORTED = 0, - XML_NODE_PROCESSING_INSTRUCTION, - XML_NODE_DOCUMENT_TYPE, - XML_NODE_ELEMENT_START, - XML_NODE_ELEMENT_END, - XML_NODE_ATTRIBUTE, - XML_NODE_TEXT, - XML_NODE_CDATA, - XML_NODE_ENTITY_REFERENCE, - XML_NODE_WHITESPACE, - XML_NODE_COMMENT, -} - -// -// Geoposition error codes. -// -pub enum cef_geoposition_error_code_t { - GEOPOSITON_ERROR_NONE = 0, - GEOPOSITON_ERROR_PERMISSION_DENIED, - GEOPOSITON_ERROR_POSITION_UNAVAILABLE, - GEOPOSITON_ERROR_TIMEOUT, -} - -// -// Structure representing geoposition information. The properties of this -// structure correspond to those of the JavaScript Position object although -// their types may differ. -// -pub struct _cef_geoposition_t { - // - // Latitude in decimal degrees north (WGS84 coordinate frame). - // - pub latitude: c_double, - - // - // Longitude in decimal degrees west (WGS84 coordinate frame). - // - pub longitude: c_double, - - // - // Altitude in meters (above WGS84 datum). - // - pub altitude: c_double, - - // - // Accuracy of horizontal position in meters. - // - pub accuracy: c_double, - - // - // Accuracy of altitude in meters. - // - pub altitude_accuracy: c_double, - - // - // Heading in decimal degrees clockwise from true north. - // - pub heading: c_double, - - // - // Horizontal component of device velocity in meters per second. - // - pub speed: c_double, - - // - // Time of position measurement in milliseconds since Epoch in UTC time. This - // is taken from the host computer's system clock. - // - pub timestamp: cef_time_t, - - // - // Error code, see enum above. - // - pub error_code: cef_geoposition_error_code_t, - - // - // Human-readable error message. - // - pub error_message: cef_string_t, -} - -pub type cef_geoposition_t = _cef_geoposition_t; - -pub type CefGeoposition = cef_geoposition_t; - -// -// Cookie information. -// -pub struct _cef_cookie_t { - // - // The cookie name. - // - pub name: cef_string_t, - - // - // The cookie value. - // - pub value: cef_string_t, - - // - // If |domain| is empty a host cookie will be created instead of a domain - // cookie. Domain cookies are stored with a leading "." and are visible to - // sub-domains whereas host cookies are not. - // - pub domain: cef_string_t, - - // - // If |path| is non-empty only URLs at or below the path will get the cookie - // value. - // - pub path: cef_string_t, - - // - // If |secure| is true the cookie will only be sent for HTTPS requests. - // - pub secure: c_int, - - // - // If |httponly| is true the cookie will only be sent for HTTP requests. - // - pub httponly: c_int, - - // - // The cookie creation date. This is automatically populated by the system on - // cookie creation. - // - pub creation: cef_time_t, - - // - // The cookie last access date. This is automatically populated by the system - // on access. - // - pub last_access: cef_time_t, - - // - // The cookie expiration date is only valid if |has_expires| is true. - // - pub has_expires: c_int, - pub expires: cef_time_t, -} - -pub type cef_cookie_t = _cef_cookie_t; - -pub type CefCookie = cef_cookie_t; - -// -// Popup window features. -// -pub struct _cef_popup_features_t { - pub x: c_int, - pub x_set: c_int, - pub y: c_int, - pub y_set: c_int, - pub width: c_int, - pub width_set: c_int, - pub height: c_int, - pub height_set: c_int, - - pub menu_bar_visible: c_int, - pub status_bar_visible: c_int, - pub tool_bar_visible: c_int, - pub location_bar_visible: c_int, - pub scrollbars_visible: c_int, - pub resizable: c_int, - - pub fullscreen: c_int, - pub dialog: c_int, - pub additional_features: cef_string_list_t, -} - -pub type cef_popup_features_t = _cef_popup_features_t; - -pub type CefPopupFeatures = cef_popup_features_t; - -// FIXME(pcwalton): Really should be a set of bitflags. -pub enum cef_drag_operations_mask_t { - DRAG_OPERATION_NONE = 0, - DRAG_OPERATION_COPY = 1, - DRAG_OPERATION_LINK = 2, - DRAG_OPERATION_GENERIC = 4, - DRAG_OPERATION_PRIVATE = 8, - DRAG_OPERATION_MOVE = 16, - DRAG_OPERATION_DELETE = 32, - DRAG_OPERATION_EVERY = 0xffffffff, -} - -pub enum cef_xml_encoding_type_t { - XML_ENCODING_NONE = 0, - XML_ENCODING_UTF8, - XML_ENCODING_UTF16LE, - XML_ENCODING_UTF16BE, - XML_ENCODING_ASCII, -} - -/// -// The manner in which a link click should be opened. -/// -pub enum cef_window_open_disposition_t { - WOD_UNKNOWN = 0, - WOD_SUPPRESS_OPEN, - WOD_CURRENT_TAB, - WOD_SINGLETON_TAB, - WOD_NEW_FOREGROUND_TAB, - WOD_NEW_BACKGROUND_TAB, - WOD_NEW_POPUP, - WOD_NEW_WINDOW, - WOD_SAVE_TO_DISK, - WOD_OFF_THE_RECORD, - WOD_IGNORE_ACTION -} - - -/// -// Cursor type values. -/// -pub enum cef_cursor_type_t { - CT_POINTER = 0, - CT_CROSS, - CT_HAND, - CT_IBEAM, - CT_WAIT, - CT_HELP, - CT_EASTRESIZE, - CT_NORTHRESIZE, - CT_NORTHEASTRESIZE, - CT_NORTHWESTRESIZE, - CT_SOUTHRESIZE, - CT_SOUTHEASTRESIZE, - CT_SOUTHWESTRESIZE, - CT_WESTRESIZE, - CT_NORTHSOUTHRESIZE, - CT_EASTWESTRESIZE, - CT_NORTHEASTSOUTHWESTRESIZE, - CT_NORTHWESTSOUTHEASTRESIZE, - CT_COLUMNRESIZE, - CT_ROWRESIZE, - CT_MIDDLEPANNING, - CT_EASTPANNING, - CT_NORTHPANNING, - CT_NORTHEASTPANNING, - CT_NORTHWESTPANNING, - CT_SOUTHPANNING, - CT_SOUTHEASTPANNING, - CT_SOUTHWESTPANNING, - CT_WESTPANNING, - CT_MOVE, - CT_VERTICALTEXT, - CT_CELL, - CT_CONTEXTMENU, - CT_ALIAS, - CT_PROGRESS, - CT_NODROP, - CT_COPY, - CT_NONE, - CT_NOTALLOWED, - CT_ZOOMIN, - CT_ZOOMOUT, - CT_GRAB, - CT_GRABBING, - CT_CUSTOM, -} - -/// -// Screen information used when window rendering is disabled. This structure is -// passed as a parameter to CefRenderHandler::GetScreenInfo and should be filled -// in by the client. -/// -#[derive(Default)] -pub struct _cef_screen_info { - /// - // Device scale factor. Specifies the ratio between physical and logical - // pixels. - /// - pub device_scale_factor: f32, - - /// - // The screen depth in bits per pixel. - /// - pub depth: i32, - - /// - // The bits per color component. This assumes that the colors are balanced - // equally. - /// - pub depth_per_component: i32, - - /// - // This can be true for black and white printers. - /// - pub is_monochrome: i32, - - /// - // This is set from the rcMonitor member of MONITORINFOEX, to whit: - // "A RECT structure that specifies the display monitor rectangle, - // expressed in virtual-screen coordinates. Note that if the monitor - // is not the primary display monitor, some of the rectangle's - // coordinates may be negative values." - // - // The |rect| and |available_rect| properties are used to determine the - // available surface for rendering popup views. - /// - pub rect: cef_rect_t, - - /// - // This is set from the rcWork member of MONITORINFOEX, to whit: - // "A RECT structure that specifies the work area rectangle of the - // display monitor that can be used by applications, expressed in - // virtual-screen coordinates. Windows uses this rectangle to - // maximize an application on the monitor. The rest of the area in - // rcMonitor contains system windows such as the task bar and side - // bars. Note that if the monitor is not the primary display monitor, - // some of the rectangle's coordinates may be negative values". - // - // The |rect| and |available_rect| properties are used to determine the - // available surface for rendering popup views. - /// - pub available_rect: cef_rect_t, -} - -pub type cef_screen_info_t = _cef_screen_info; -pub type CefScreenInfo = cef_screen_info_t; - -/// -// Browser initialization settings. Specify NULL or 0 to get the recommended -// default values. The consequences of using custom values may not be well -// tested. Many of these and other settings can also configured using command- -// line switches. -/// -pub struct _cef_browser_settings { - /// - // Size of this structure. - /// - pub size: u64, - - /// - // The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint - // will be called for a windowless browser. The actual fps may be lower if - // the browser cannot generate frames at the requested rate. The minimum - // value is 1 and the maximum value is 60 (default 30). - /// - pub windowless_frame_rate: i32, - - // The below values map to WebPreferences settings. - - /// - // Font settings. - /// - pub standard_font_family: cef_string_t, - pub fixed_font_family: cef_string_t, - pub serif_font_family: cef_string_t, - pub sans_serif_font_family: cef_string_t, - pub cursive_font_family: cef_string_t, - pub fantasy_font_family: cef_string_t, - pub default_font_size: i32, - pub default_fixed_font_size: i32, - pub minimum_font_size: i32, - pub minimum_logical_font_size: i32, - - /// - // Default encoding for Web content. If empty "ISO-8859-1" will be used. Also - // configurable using the "default-encoding" command-line switch. - /// - pub default_encoding: cef_string_t, - - /// - // Controls the loading of fonts from remote sources. Also configurable using - // the "disable-remote-fonts" command-line switch. - /// - pub remote_fonts: cef_state_t, - - /// - // Controls whether JavaScript can be executed. Also configurable using the - // "disable-javascript" command-line switch. - /// - pub javascript: cef_state_t, - - /// - // Controls whether JavaScript can be used for opening windows. Also - // configurable using the "disable-javascript-open-windows" command-line - // switch. - /// - pub javascript_open_windows: cef_state_t, - - /// - // Controls whether JavaScript can be used to close windows that were not - // opened via JavaScript. JavaScript can still be used to close windows that - // were opened via JavaScript or that have no back/forward history. Also - // configurable using the "disable-javascript-close-windows" command-line - // switch. - /// - pub javascript_close_windows: cef_state_t, - - /// - // Controls whether JavaScript can access the clipboard. Also configurable - // using the "disable-javascript-access-clipboard" command-line switch. - /// - pub javascript_access_clipboard: cef_state_t, - - /// - // Controls whether DOM pasting is supported in the editor via - // execCommand("paste"). The |javascript_access_clipboard| setting must also - // be enabled. Also configurable using the "disable-javascript-dom-paste" - // command-line switch. - /// - pub javascript_dom_paste: cef_state_t, - - /// - // Controls whether the caret position will be drawn. Also configurable using - // the "enable-caret-browsing" command-line switch. - /// - pub caret_browsing: cef_state_t, - - /// - // Controls whether the Java plugin will be loaded. Also configurable using - // the "disable-java" command-line switch. - /// - pub java: cef_state_t, - - /// - // Controls whether any plugins will be loaded. Also configurable using the - // "disable-plugins" command-line switch. - /// - pub plugins: cef_state_t, - - /// - // Controls whether file URLs will have access to all URLs. Also configurable - // using the "allow-universal-access-from-files" command-line switch. - /// - pub universal_access_from_file_urls: cef_state_t, - - /// - // Controls whether file URLs will have access to other file URLs. Also - // configurable using the "allow-access-from-files" command-line switch. - /// - pub file_access_from_file_urls: cef_state_t, - - /// - // Controls whether web security restrictions (same-origin policy) will be - // enforced. Disabling this setting is not recommend as it will allow risky - // security behavior such as cross-site scripting (XSS). Also configurable - // using the "disable-web-security" command-line switch. - /// - pub web_security: cef_state_t, - - /// - // Controls whether image URLs will be loaded from the network. A cached image - // will still be rendered if requested. Also configurable using the - // "disable-image-loading" command-line switch. - /// - pub image_loading: cef_state_t, - - /// - // Controls whether standalone images will be shrunk to fit the page. Also - // configurable using the "image-shrink-standalone-to-fit" command-line - // switch. - /// - pub image_shrink_standalone_to_fit: cef_state_t, - - /// - // Controls whether text areas can be resized. Also configurable using the - // "disable-text-area-resize" command-line switch. - /// - pub text_area_resize: cef_state_t, - - /// - // Controls whether the tab key can advance focus to links. Also configurable - // using the "disable-tab-to-links" command-line switch. - /// - pub tab_to_links: cef_state_t, - - /// - // Controls whether local storage can be used. Also configurable using the - // "disable-local-storage" command-line switch. - /// - pub local_storage: cef_state_t, - - /// - // Controls whether databases can be used. Also configurable using the - // "disable-databases" command-line switch. - /// - pub databases: cef_state_t, - - /// - // Controls whether the application cache can be used. Also configurable using - // the "disable-application-cache" command-line switch. - /// - pub application_cache: cef_state_t, - - /// - // Controls whether WebGL can be used. Note that WebGL requires hardware - // support and may not work on all systems even when enabled. Also - // configurable using the "disable-webgl" command-line switch. - /// - pub webgl: cef_state_t, - - /// - // Opaque background color used for the browser before a document is loaded - // and when no document color is specified. By default the background color - // will be the same as CefSettings.background_color. Only the RGB compontents - // of the specified value will be used. The alpha component must greater than - // 0 to enable use of the background color but will be otherwise ignored. - /// - pub background_color: cef_color_t, - - /// - // Comma delimited ordered list of language codes without any whitespace that - // will be used in the "Accept-Language" HTTP header. May be set globally - // using the CefBrowserSettings.accept_language_list value. If both values are - // empty then "en-US,en" will be used. - /// - pub accept_language_list: cef_string_t, -} - -pub type cef_browser_settings_t = _cef_browser_settings; -pub type CefBrowserSettings = cef_browser_settings_t; - - -/// -// Structure representing cursor information. |buffer| will be -// |size.width|*|size.height|*4 bytes in size and represents a BGRA image with -// an upper-left origin. -/// -pub struct _cef_cursor_info { - pub hotspot: cef_point_t, - pub image_scale_factor: f32, - pub buffer: *mut isize, - pub size: cef_size_t, -} - -pub type cef_cursor_info_t = _cef_cursor_info; -pub type CefCursorInfo = cef_cursor_info_t; - -/// -// Return value types. -/// -pub enum cef_return_value_t { - /// - // Cancel immediately. - /// - RV_CANCEL = 0, - - /// - // Continue immediately. - /// - RV_CONTINUE, - - /// - // Continue asynchronously (usually via a callback). - /// - RV_CONTINUE_ASYNC, -} - - - -/// -// Request context initialization settings. Specify NULL or 0 to get the -// recommended default values. -/// -pub struct _cef_request_context_settings { - /// - // Size of this structure. - /// - pub size: size_t, - - /// - // The location where cache data will be stored on disk. If empty then - // browsers will be created in "incognito mode" where in-memory caches are - // used for storage and no data is persisted to disk. HTML5 databases such as - // localStorage will only persist across sessions if a cache path is - // specified. To share the global browser cache and related configuration set - // this value to match the CefSettings.cache_path value. - /// - pub cache_path: cef_string_t, - - /// - // To persist session cookies (cookies without an expiry date or validity - // interval) by default when using the global cookie manager set this value to - // true. Session cookies are generally intended to be transient and most Web - // browsers do not persist them. Can be set globally using the - // CefSettings.persist_session_cookies value. This value will be ignored if - // |cache_path| is empty or if it matches the CefSettings.cache_path value. - /// - pub persist_session_cookies: i32, - - /// - // Set to true (1) to ignore errors related to invalid SSL certificates. - // Enabling this setting can lead to potential security vulnerabilities like - // "man in the middle" attacks. Applications that load content from the - // internet should not enable this setting. Can be set globally using the - // CefSettings.ignore_certificate_errors value. This value will be ignored if - // |cache_path| matches the CefSettings.cache_path value. - /// - pub ignore_certificate_errors: i32, - - /// - // Comma delimited ordered list of language codes without any whitespace that - // will be used in the "Accept-Language" HTTP header. Can be set globally - // using the CefSettings.accept_language_list value or overridden on a per- - // browser basis using the CefBrowserSettings.accept_language_list value. If - // all values are empty then "en-US,en" will be used. This value will be - // ignored if |cache_path| matches the CefSettings.cache_path value. - /// - pub accept_language_list: cef_string_t, -} - -pub type cef_request_context_settings_t = _cef_request_context_settings; -pub type CefRequestContextSettings = cef_request_context_settings_t; - -/// -// Margin type for PDF printing. -/// -pub enum cef_pdf_print_margin_type_t { - /// - // Default margins. - /// - PDF_PRINT_MARGIN_DEFAULT = 0, - - /// - // No margins. - /// - PDF_PRINT_MARGIN_NONE, - - /// - // Minimum margins. - /// - PDF_PRINT_MARGIN_MINIMUM, - - /// - // Custom margins using the |margin_*| values from cef_pdf_print_settings_t. - /// - PDF_PRINT_MARGIN_CUSTOM, -} - -/// -// Structure representing PDF print settings. -/// -pub struct cef_pdf_print_settings { - /// - // Page title to display in the header. Only used if |header_footer_enabled| - // is set to true (1). - /// - pub header_footer_title: cef_string_t, - - /// - // URL to display in the footer. Only used if |header_footer_enabled| is set - // to true (1). - /// - pub header_footer_url: cef_string_t, - - /// - // Output page size in microns. If either of these values is less than or - // equal to zero then the default paper size (A4) will be used. - /// - pub page_width: i32, - pub page_height: i32, - - /// - // Margins in millimeters. Only used if |margin_type| is set to - // PDF_PRINT_MARGIN_CUSTOM. - /// - pub margin_top: f64, - pub margin_right: f64, - pub margin_bottom: f64, - pub margin_left: f64, - - /// - // Margin type. - /// - pub margin_type: cef_pdf_print_margin_type_t, - - /// - // Set to true (1) to print headers and footers or false (0) to not print - // headers and footers. - /// - pub header_footer_enabled: i32, - - /// - // Set to true (1) to print the selection only or false (0) to print all. - /// - pub selection_only: i32, - - /// - // Set to true (1) for landscape mode or false (0) for portrait mode. - /// - pub landscape: i32, - - /// - // Set to true (1) to print background graphics or false (0) to not print - // background graphics. - /// - pub backgrounds_enabled: i32, -} -pub type cef_pdf_print_settings_t = cef_pdf_print_settings; -pub type CefPdfPrintSettings = cef_pdf_print_settings; diff --git a/ports/cef/urlrequest.rs b/ports/cef/urlrequest.rs deleted file mode 100644 index 99d8cb53eee..00000000000 --- a/ports/cef/urlrequest.rs +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_request_t, cef_request_context_t, cef_urlrequest_client_t, cef_urlrequest_t}; - -#[no_mangle] -pub extern "C" fn cef_urlrequest_create(_request: *mut cef_request_t, - _client: *mut cef_urlrequest_client_t, - _context: *mut cef_request_context_t) - -> *mut cef_urlrequest_t { - 0 as *mut cef_urlrequest_t -} diff --git a/ports/cef/v8.rs b/ports/cef/v8.rs deleted file mode 100644 index b046c7d1231..00000000000 --- a/ports/cef/v8.rs +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_v8accessor_t, cef_v8context_t, cef_v8handler_t, cef_v8stack_trace_t}; -use interfaces::{cef_v8value_t}; -use types::{cef_string_t, cef_time_t}; - -use libc::{self, c_double, c_int}; - -cef_stub_static_method_impls! { - fn cef_v8context_get_current_context() -> *mut cef_v8context_t - fn cef_v8context_get_entered_context() -> *mut cef_v8context_t - fn cef_v8context_in_context() -> libc::c_int - fn cef_v8value_create_undefined() -> *mut cef_v8value_t - fn cef_v8value_create_null() -> *mut cef_v8value_t - fn cef_v8value_create_bool(_value: c_int) -> *mut cef_v8value_t - fn cef_v8value_create_int(_value: i32) -> *mut cef_v8value_t - fn cef_v8value_create_uint(_value: u32) -> *mut cef_v8value_t - fn cef_v8value_create_double(_value: c_double) -> *mut cef_v8value_t - fn cef_v8value_create_date(_date: *const cef_time_t) -> *mut cef_v8value_t - fn cef_v8value_create_string(_value: *const cef_string_t) -> *mut cef_v8value_t - fn cef_v8value_create_object(_accessor: *mut cef_v8accessor_t) -> *mut cef_v8value_t - fn cef_v8value_create_array(_length: libc::c_int) -> *mut cef_v8value_t - fn cef_v8value_create_function(_name: *const cef_string_t, _handler: *mut cef_v8handler_t) - -> *mut cef_v8value_t - fn cef_v8stack_trace_get_current(_frame_limit: libc::c_int) -> *mut cef_v8stack_trace_t -} - diff --git a/ports/cef/values.rs b/ports/cef/values.rs deleted file mode 100644 index b7779699db0..00000000000 --- a/ports/cef/values.rs +++ /dev/null @@ -1,15 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_binary_value_t, cef_dictionary_value_t, cef_list_value_t, cef_value_t}; - -use libc; - -cef_stub_static_method_impls! { - fn cef_binary_value_create(_data: *const (), _size: libc::size_t) -> *mut cef_binary_value_t - fn cef_dictionary_value_create() -> *mut cef_dictionary_value_t - fn cef_list_value_create() -> *mut cef_list_value_t - fn cef_value_create() -> *mut cef_value_t -} - diff --git a/ports/cef/window.rs b/ports/cef/window.rs deleted file mode 100644 index de705adcf8d..00000000000 --- a/ports/cef/window.rs +++ /dev/null @@ -1,583 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! Off-screen windows. -//! -//! This is used for off-screen rendering mode only; on-screen windows (the default embedding mode) -//! are managed by a platform toolkit (Glutin). - -#[cfg(target_os="linux")] -use core::CEF_APP; -use eutil::Downcast; -#[cfg(target_os="linux")] -use interfaces::CefApp; -use interfaces::CefBrowser; -use render_handler::CefRenderHandlerExtensions; -use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t, CefScreenInfo}; -use wrappers::CefWrap; - -use compositing::compositor_thread::EventLoopWaker; -use compositing::windowing::{WindowEvent, WindowMethods}; -use euclid::{Point2D, TypedPoint2D, Size2D, TypedSize2D, TypedScale}; -use gleam::gl; -use msg::constellation_msg::{Key, KeyModifiers}; -use net_traits::net_error_list::NetError; -use script_traits::LoadData; -use servo::BrowserId; -use servo::ipc_channel::ipc::IpcSender; -use servo_geometry::DeviceIndependentPixel; -use std::cell::RefCell; -use std::ffi::CString; -use std::os::raw::{c_char, c_void}; -use std::ptr; -use std::rc::Rc; -use servo_url::ServoUrl; -use style_traits::cursor::CursorKind; -use style_traits::DevicePixel; -#[cfg(target_os="linux")] -extern crate x11; -#[cfg(target_os="linux")] -use self::x11::xlib::{XInitThreads,XOpenDisplay}; -use webrender_api::{DeviceUintSize, DeviceUintRect}; - -#[cfg(target_os="linux")] -pub static mut DISPLAY: *mut c_void = 0 as *mut c_void; - -/// The type of an off-screen window. -#[derive(Clone)] -pub struct Window { - cef_browser: RefCell<Option<CefBrowser>>, - size: DeviceUintSize, - gl: Rc<gl::Gl>, -} - -#[cfg(target_os="macos")] -fn load_gl() -> Rc<gl::Gl> { - const RTLD_DEFAULT: *mut c_void = (-2isize) as usize as *mut c_void; - - extern { - fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; - } - - unsafe { - gl::GlFns::load_with(|s| { - let c_str = CString::new(s).unwrap(); - dlsym(RTLD_DEFAULT, c_str.as_ptr()) as *const c_void - }) - } -} - -#[cfg(target_os="linux")] -fn load_gl() -> Rc<gl::Gl> { - extern { - fn glXGetProcAddress(symbol: *const c_char) -> *mut c_void; - } - - unsafe { - gl::GlFns::load_with(|s| { - let c_str = CString::new(s).unwrap(); - glXGetProcAddress(c_str.as_ptr()) as *const c_void - }) - } -} - -impl Window { - /// Creates a new window. - pub fn new(width: u32, height: u32) -> Rc<Window> { - let gl = load_gl(); - - Rc::new(Window { - cef_browser: RefCell::new(None), - size: TypedSize2D::new(width, height), - gl: gl, - }) - } - - /// Sets the current browser. - pub fn set_browser(&self, browser: CefBrowser) { - *self.cef_browser.borrow_mut() = Some(browser) - } - - /// Currently unimplemented. - pub fn wait_events(&self) -> Vec<WindowEvent> { - vec![WindowEvent::Idle] - } - - fn cursor_type_for_cursor(&self, cursor: CursorKind) -> cef_cursor_type_t { - match cursor { - CursorKind::None => cef_cursor_type_t::CT_NONE, - CursorKind::ContextMenu => cef_cursor_type_t::CT_CONTEXTMENU, - CursorKind::Grabbing => cef_cursor_type_t::CT_GRABBING, - CursorKind::Crosshair => cef_cursor_type_t::CT_CROSS, - CursorKind::Copy => cef_cursor_type_t::CT_COPY, - CursorKind::Alias => cef_cursor_type_t::CT_ALIAS, - CursorKind::Text => cef_cursor_type_t::CT_IBEAM, - CursorKind::Grab | CursorKind::AllScroll => cef_cursor_type_t::CT_GRAB, - CursorKind::NoDrop => cef_cursor_type_t::CT_NODROP, - CursorKind::NotAllowed => cef_cursor_type_t::CT_NOTALLOWED, - CursorKind::Pointer => cef_cursor_type_t::CT_POINTER, - CursorKind::SResize => cef_cursor_type_t::CT_SOUTHRESIZE, - CursorKind::WResize => cef_cursor_type_t::CT_WESTRESIZE, - CursorKind::EwResize => cef_cursor_type_t::CT_EASTWESTRESIZE, - CursorKind::ColResize => cef_cursor_type_t::CT_COLUMNRESIZE, - CursorKind::EResize => cef_cursor_type_t::CT_EASTRESIZE, - CursorKind::NResize => cef_cursor_type_t::CT_NORTHRESIZE, - CursorKind::NsResize => cef_cursor_type_t::CT_NORTHSOUTHRESIZE, - CursorKind::RowResize => cef_cursor_type_t::CT_ROWRESIZE, - CursorKind::VerticalText => cef_cursor_type_t::CT_VERTICALTEXT, - _ => cef_cursor_type_t::CT_POINTER, - } - } - - /// Returns the Cocoa cursor for a CSS cursor. These match Firefox, except where Firefox - /// bundles custom resources (which we don't yet do). - #[cfg(target_os="macos")] - fn cursor_handle_for_cursor(&self, cursor: CursorKind) -> cef_cursor_handle_t { - use cocoa::base::class; - - unsafe { - match cursor { - CursorKind::None => return 0 as cef_cursor_handle_t, - CursorKind::ContextMenu => msg_send![class("NSCursor"), contextualMenuCursor], - CursorKind::Grabbing => msg_send![class("NSCursor"), closedHandCursor], - CursorKind::Crosshair => msg_send![class("NSCursor"), crosshairCursor], - CursorKind::Copy => msg_send![class("NSCursor"), dragCopyCursor], - CursorKind::Alias => msg_send![class("NSCursor"), dragLinkCursor], - CursorKind::Text => msg_send![class("NSCursor"), IBeamCursor], - CursorKind::Grab | CursorKind::AllScroll => - msg_send![class("NSCursor"), openHandCursor], - CursorKind::NoDrop | CursorKind::NotAllowed => - msg_send![class("NSCursor"), operationNotAllowedCursor], - CursorKind::Pointer => msg_send![class("NSCursor"), pointingHandCursor], - CursorKind::SResize => msg_send![class("NSCursor"), resizeDownCursor], - CursorKind::WResize => msg_send![class("NSCursor"), resizeLeftCursor], - CursorKind::EwResize | CursorKind::ColResize => - msg_send![class("NSCursor"), resizeLeftRightCursor], - CursorKind::EResize => msg_send![class("NSCursor"), resizeRightCursor], - CursorKind::NResize => msg_send![class("NSCursor"), resizeUpCursor], - CursorKind::NsResize | CursorKind::RowResize => - msg_send![class("NSCursor"), resizeUpDownCursor], - CursorKind::VerticalText => msg_send![class("NSCursor"), IBeamCursorForVerticalLayout], - _ => msg_send![class("NSCursor"), arrowCursor], - } - } - } - - #[cfg(not(target_os="macos"))] - fn cursor_handle_for_cursor(&self, _: CursorKind) -> cef_cursor_handle_t { - 0 - } - - fn screen_info(&self) -> CefScreenInfo { - let mut screen_info = CefScreenInfo::default(); - let browser = self.cef_browser.borrow(); - if let Some(ref browser) = *browser { - browser.get_host() - .get_client() - .get_render_handler() - .get_screen_info(browser.clone(), &mut screen_info); - } - screen_info - } - -} - -impl WindowMethods for Window { - fn gl(&self) -> Rc<gl::Gl> { - self.gl.clone() - } - - fn framebuffer_size(&self) -> DeviceUintSize { - let browser = self.cef_browser.borrow(); - match *browser { - None => self.size, - Some(ref browser) => { - if browser.downcast().callback_executed.get() != true { - self.size - } else { - let mut rect = cef_rect_t::zero(); - rect.width = self.size.width as i32; - rect.height = self.size.height as i32; - if cfg!(target_os="macos") { - // osx relies on virtual pixel scaling to provide sizes different from actual - // pixel size on screen. other platforms are just 1.0 unless the desktop/toolkit says otherwise - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) { - browser.get_host() - .get_client() - .get_render_handler() - .get_backing_rect((*browser).clone(), &mut rect); - } - } else { - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) { - browser.get_host() - .get_client() - .get_render_handler() - .get_view_rect((*browser).clone(), &mut rect); - } - } - - DeviceUintSize::new(rect.width as u32, rect.height as u32) - } - } - } - } - - fn window_rect(&self) -> DeviceUintRect { - let size = self.framebuffer_size(); - let origin = TypedPoint2D::zero(); - DeviceUintRect::new(origin, size) - } - - fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> { - let browser = self.cef_browser.borrow(); - match *browser { - None => TypedSize2D::new(400.0, 300.0), - Some(ref browser) => { - let mut rect = cef_rect_t::zero(); - browser.get_host() - .get_client() - .get_render_handler() - .get_view_rect((*browser).clone(), &mut rect); - TypedSize2D::new(rect.width as f32, rect.height as f32) - } - } - } - - fn client_window(&self, _: BrowserId) -> (Size2D<u32>, Point2D<i32>) { - let size = self.size().to_untyped(); - let width = size.width as u32; - let height = size.height as u32; - //TODO get real window position - (Size2D::new(width, height), Point2D::zero()) - } - - fn set_inner_size(&self, _: BrowserId, _size: Size2D<u32>) { - - } - - fn set_position(&self, _: BrowserId, _point: Point2D<i32>) { - - } - - fn set_fullscreen_state(&self, _: BrowserId, _state: bool) { - } - - fn present(&self) { - let browser = self.cef_browser.borrow(); - if let Some(ref browser) = *browser { - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_present) { - browser.get_host().get_client().get_render_handler().on_present(browser.clone()); - } - } - } - - fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> { - if cfg!(target_os="macos") { - let browser = self.cef_browser.borrow(); - match *browser { - None => TypedScale::new(1.0), - Some(ref browser) => { - let mut view_rect = cef_rect_t::zero(); - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) { - browser.get_host() - .get_client() - .get_render_handler() - .get_view_rect((*browser).clone(), &mut view_rect); - } - let mut backing_rect = cef_rect_t::zero(); - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) { - browser.get_host() - .get_client() - .get_render_handler() - .get_backing_rect((*browser).clone(), &mut backing_rect); - } - TypedScale::new(backing_rect.width as f32 / view_rect.width as f32) - } - } - } else { - // FIXME(zmike) - // need to figure out a method for actually getting the scale factor instead of this nonsense - TypedScale::new(1.0 as f32) - } - } - - fn create_event_loop_waker(&self) -> Box<EventLoopWaker> { - struct CefEventLoopWaker; - impl EventLoopWaker for CefEventLoopWaker { - fn wake(&self) { - app_wakeup(); - } - fn clone(&self) -> Box<EventLoopWaker + Send> { - Box::new(CefEventLoopWaker) - } - } - Box::new(CefEventLoopWaker) - } - - fn prepare_for_composite(&self, width: usize, height: usize) -> bool { - let browser = self.cef_browser.borrow(); - match *browser { - None => { - panic!("No browser?!?"); - } - Some(ref browser) => { - if browser.downcast().host.downcast().composite_ok.get() == true { - true - } else { - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_paint) { - browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height); - } - false - } - } - } - } - - fn set_favicon(&self, _: BrowserId, url: ServoUrl) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - browser.downcast().favicons.borrow_mut().push(url.into_string()); - } - - fn status(&self, _: BrowserId, info: Option<String>) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - let str = match info { - Some(s) => s.encode_utf16().collect::<Vec<u16>>(), - None => vec![] - }; - - if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) && - check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_status_message) { - browser.get_host().get_client().get_display_handler().on_status_message((*browser).clone(), str.as_slice()); - } - } - - fn load_start(&self, _: BrowserId) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - let back = browser.downcast().back.get(); - let forward = browser.downcast().forward.get(); - browser.downcast().loading.set(true); - browser.downcast().favicons.borrow_mut().clear(); - if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && - check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) { - browser.get_host() - .get_client() - .get_load_handler() - .on_loading_state_change((*browser).clone(), 1i32, back as i32, forward as i32); - } - } - - fn load_end(&self, _: BrowserId) { - // FIXME(pcwalton): The status code 200 is a lie. - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - let back = browser.downcast().back.get(); - let forward = browser.downcast().forward.get(); - browser.downcast().loading.set(false); - if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && - check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) { - browser.get_host() - .get_client() - .get_load_handler() - .on_loading_state_change((*browser).clone(), 0i32, back as i32, forward as i32); - } - if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && - check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_end) { - browser.get_host() - .get_client() - .get_load_handler() - .on_load_end((*browser).clone(), browser.get_main_frame(), 200); - } - } - - fn load_error(&self, _: BrowserId, code: NetError, url: String) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && - check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_error) { - let utf16_chars: Vec<u16> = url.encode_utf16().collect(); - browser.get_host() - .get_client() - .get_load_handler() - .on_load_error((*browser).clone(), browser.get_main_frame(), - code, &[], utf16_chars.as_slice()); - } - } - - fn head_parsed(&self, _: BrowserId) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) && - check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_favicon_urlchange) { - browser.get_host().get_client().get_display_handler().on_favicon_urlchange((*browser).clone(), &browser.downcast().favicons.borrow()); - } - } - - fn set_page_title(&self, _: BrowserId, string: Option<String>) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - let frame = browser.get_main_frame(); - let frame = frame.downcast(); - let str = match string { - Some(s) => s.encode_utf16().collect(), - None => vec![] - }; - - if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) && - check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_title_change) { - browser.get_host().get_client().get_display_handler().on_title_change((*browser).clone(), str.as_slice()); - } - - *frame.title.borrow_mut() = str; - } - - fn history_changed(&self, _: BrowserId, history: Vec<LoadData>, current: usize) { - let browser = self.cef_browser.borrow(); - let browser = match *browser { - None => return, - Some(ref browser) => browser, - }; - - let can_go_back = current > 0; - let can_go_forward = current < history.len() - 1; - - browser.downcast().back.set(can_go_back); - browser.downcast().forward.set(can_go_forward); - let frame = browser.get_main_frame(); - let mut frame_url = frame.downcast().url.borrow_mut(); - *frame_url = history[current].url.to_string(); - let utf16_chars: Vec<u16> = frame_url.encode_utf16().collect(); - if check_ptr_exist!(browser.get_host().get_client(), get_display_handler) && - check_ptr_exist!(browser.get_host().get_client().get_display_handler(), on_address_change) { - browser.get_host().get_client().get_display_handler().on_address_change((*browser).clone(), frame.clone(), utf16_chars.as_slice()); - } - } - - fn handle_key(&self, _: Option<BrowserId>, _: Option<char>, _: Key, _: KeyModifiers) { - // TODO(negge) - } - - fn set_cursor(&self, cursor: CursorKind) { - use types::{CefCursorInfo,cef_point_t,cef_size_t}; - let browser = self.cef_browser.borrow(); - if let Some(ref browser) = *browser { - let cursor_handle = self.cursor_handle_for_cursor(cursor); - let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } }; - if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && - check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_cursor_change) { - browser.get_host() - .get_client() - .get_render_handler() - .on_cursor_change(browser.clone(), cursor_handle, - self.cursor_type_for_cursor(cursor), &info); - } - } - } - - fn allow_navigation(&self, _: BrowserId, _: ServoUrl, response_chan: IpcSender<bool>) { - if let Err(e) = response_chan.send(true) { - warn!("Failed to send allow_navigation() response: {}", e); - }; - } - - fn supports_clipboard(&self) -> bool { - false - } - - fn screen_size(&self, _: BrowserId) -> Size2D<u32> { - let screen_info = self.screen_info(); - Size2D::new(screen_info.rect.width as u32, screen_info.rect.height as u32) - } - - fn screen_avail_size(&self, _: BrowserId) -> Size2D<u32> { - let screen_info = self.screen_info(); - Size2D::new(screen_info.available_rect.width as u32, screen_info.available_rect.height as u32) - } -} - -#[cfg(target_os="macos")] -pub fn app_wakeup() { - use cocoa::appkit::{NSApp, NSApplication, NSApplicationDefined}; - use cocoa::appkit::{NSEvent, NSEventModifierFlags, NSEventSubtype}; - use cocoa::base::nil; - use cocoa::foundation::{NSAutoreleasePool, NSPoint}; - - unsafe { - let pool = NSAutoreleasePool::new(nil); - let event = - NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_( - nil, - NSApplicationDefined, - NSPoint::new(0.0, 0.0), - NSEventModifierFlags::empty(), - 0.0, - 0, - nil, - NSEventSubtype::NSWindowExposedEventType, - 0, - 0); - NSApp().postEvent_atStart_(event, 0); - pool.drain(); - } -} - -#[cfg(target_os="linux")] -pub fn app_wakeup() { - unsafe { if CEF_APP.is_null() { return; } } - let capp = unsafe { CefApp::from_c_object_addref(CEF_APP) }; - if unsafe { (*CEF_APP).get_browser_process_handler.is_some() } && - check_ptr_exist!(capp.get_browser_process_handler(), on_work_available) { - capp.get_browser_process_handler().on_work_available(); - } -} - -#[cfg(target_os="linux")] -pub fn init_window() { - unsafe { - assert_ne!(XInitThreads(), 0); - DISPLAY = XOpenDisplay(ptr::null()) as *mut c_void; - } -} -#[cfg(not(target_os="linux"))] -pub fn init_window() {} - -#[cfg(target_os="linux")] -#[no_mangle] -pub extern "C" fn cef_get_xdisplay() -> *mut c_void { - unsafe { DISPLAY } -} -#[cfg(not(target_os="linux"))] -#[no_mangle] -pub extern "C" fn cef_get_xdisplay() -> *mut c_void { - ptr::null_mut() -} diff --git a/ports/cef/wrappers.rs b/ports/cef/wrappers.rs deleted file mode 100644 index 707ad0e2355..00000000000 --- a/ports/cef/wrappers.rs +++ /dev/null @@ -1,303 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{CefV8Value}; -use interfaces::{cef_app_t, CefApp, cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement}; -use interfaces::{cef_dialog_handler_t, cef_focus_handler_t}; -use interfaces::{cef_download_handler_t, cef_drag_handler_t, cef_context_menu_handler_t}; -use interfaces::{cef_geolocation_handler_t, cef_jsdialog_handler_t, cef_keyboard_handler_t}; -use interfaces::{cef_load_handler_t, cef_request_handler_t}; -use types::{cef_base_t, cef_browser_settings_t, CefBrowserSettings, cef_color_model_t}; -use types::{cef_context_menu_edit_state_flags_t}; -use types::{cef_context_menu_media_state_flags_t}; -use types::{cef_context_menu_media_type_t, cef_context_menu_type_flags_t, cef_cookie_t, cef_cursor_info_t, CefCursorInfo, cef_cursor_type_t}; -use types::{cef_dom_document_type_t, cef_dom_node_type_t}; -use types::{cef_drag_operations_mask_t, cef_draggable_region_t, cef_duplex_mode_t}; -use types::{cef_errorcode_t, cef_event_flags_t, cef_event_handle_t}; -use types::{cef_file_dialog_mode_t, cef_focus_source_t}; -use types::{cef_geoposition_t}; -use types::{cef_jsdialog_type_t}; -use types::{cef_key_event}; -use types::{cef_menu_item_type_t, cef_mouse_button_type_t}; -use types::{cef_mouse_event, cef_navigation_type_t}; -use types::{cef_page_range_t, cef_paint_element_type_t, cef_point_t, cef_postdataelement_type_t}; -use types::{cef_pdf_print_settings_t}; -use types::{cef_popup_features_t, cef_process_id_t}; -use types::{cef_rect_t, cef_request_context_settings_t, CefRequestContextSettings}; -use types::{cef_resource_type_t, cef_return_value_t}; -use types::{cef_screen_info_t, CefScreenInfo, cef_size_t, cef_string_t, cef_string_userfree_t}; -use types::{cef_string_list_t, cef_string_map_t, cef_string_multimap_t, cef_string_utf16}; -use types::{cef_termination_status_t, cef_text_input_context_t, cef_thread_id_t}; -use types::{cef_time_t, cef_transition_type_t, cef_urlrequest_status_t}; -use types::{cef_v8_accesscontrol_t, cef_v8_propertyattribute_t, cef_value_type_t}; -use types::{cef_window_info_t, cef_window_open_disposition_t, cef_xml_encoding_type_t, cef_xml_node_type_t}; - -use libc::{self, c_char, c_int, c_ushort, c_void}; -use std::collections::HashMap; -use std::mem; -use std::ptr; -use std::slice; - -pub trait CefWrap<CObject> { - fn to_c(rust_object: Self) -> CObject; - unsafe fn to_rust(c_object: CObject) -> Self; -} - -macro_rules! cef_noop_wrapper( - ($ty:ty) => ( - impl CefWrap<$ty> for $ty { - fn to_c(rust_object: $ty) -> $ty { - rust_object - } - unsafe fn to_rust(c_object: $ty) -> $ty { - c_object - } - } - ) -); - -macro_rules! cef_pointer_wrapper( - ($ty:ty) => ( - impl<'a> CefWrap<*const $ty> for &'a $ty { - fn to_c(rust_object: &'a $ty) -> *const $ty { - rust_object - } - unsafe fn to_rust(c_object: *const $ty) -> &'a $ty { - &*c_object - } - } - impl<'a> CefWrap<*mut $ty> for &'a mut $ty { - fn to_c(rust_object: &'a mut $ty) -> *mut $ty { - rust_object - } - unsafe fn to_rust(c_object: *mut $ty) -> &'a mut $ty { - &mut *c_object - } - } - cef_noop_wrapper!(*const $ty); - cef_noop_wrapper!(*mut $ty); - ) -); - -macro_rules! cef_unimplemented_wrapper( - ($c_type:ty, $rust_type:ty) => ( - impl CefWrap<$c_type> for $rust_type { - fn to_c(_: $rust_type) -> $c_type { - panic!("unimplemented CEF type conversion: {}", stringify!($c_type)) - } - unsafe fn to_rust(_: $c_type) -> $rust_type { - panic!("unimplemented CEF type conversion: {}", stringify!($c_type)) - } - } - ) -); - -cef_pointer_wrapper!(()); -cef_pointer_wrapper!(*mut ()); -cef_pointer_wrapper!(*mut c_void); -cef_pointer_wrapper!(c_void); -cef_pointer_wrapper!(cef_app_t); -cef_pointer_wrapper!(cef_base_t); -cef_pointer_wrapper!(cef_browser_settings_t); -cef_pointer_wrapper!(cef_cookie_t); -cef_pointer_wrapper!(cef_cursor_info_t); -cef_pointer_wrapper!(cef_draggable_region_t); -cef_pointer_wrapper!(cef_geoposition_t); -cef_pointer_wrapper!(cef_key_event); -cef_pointer_wrapper!(cef_mouse_event); -cef_pointer_wrapper!(cef_page_range_t); -cef_pointer_wrapper!(cef_pdf_print_settings_t); -cef_pointer_wrapper!(cef_point_t); -cef_pointer_wrapper!(cef_popup_features_t); -cef_pointer_wrapper!(cef_rect_t); -cef_pointer_wrapper!(cef_request_context_settings_t); -cef_pointer_wrapper!(cef_screen_info_t); -cef_pointer_wrapper!(cef_size_t); -cef_pointer_wrapper!(cef_time_t); -cef_pointer_wrapper!(cef_window_info_t); -cef_pointer_wrapper!(i32); -cef_pointer_wrapper!(i64); -cef_pointer_wrapper!(u32); -cef_pointer_wrapper!(u64); -cef_pointer_wrapper!(usize); - -cef_noop_wrapper!(()); -cef_noop_wrapper!(*const cef_geolocation_handler_t); -cef_noop_wrapper!(*const cef_string_utf16); -cef_noop_wrapper!(*mut cef_context_menu_handler_t); -cef_noop_wrapper!(*mut cef_dialog_handler_t); -cef_noop_wrapper!(*mut cef_download_handler_t); -cef_noop_wrapper!(*mut cef_drag_data_t); -cef_noop_wrapper!(*mut cef_drag_handler_t); -cef_noop_wrapper!(*mut cef_event_handle_t); -cef_noop_wrapper!(*mut cef_focus_handler_t); -cef_noop_wrapper!(*mut cef_geolocation_handler_t); -cef_noop_wrapper!(*mut cef_jsdialog_handler_t); -cef_noop_wrapper!(*mut cef_keyboard_handler_t); -cef_noop_wrapper!(*mut cef_load_handler_t); -cef_noop_wrapper!(*mut cef_request_handler_t); -cef_noop_wrapper!(*mut cef_string_utf16); -cef_noop_wrapper!(c_int); -cef_noop_wrapper!(CefApp); -cef_noop_wrapper!(CefBrowserSettings); -cef_noop_wrapper!(CefScreenInfo); -cef_noop_wrapper!(CefRequestContextSettings); -cef_noop_wrapper!(CefCursorInfo); -cef_noop_wrapper!(cef_color_model_t); -cef_noop_wrapper!(cef_context_menu_edit_state_flags_t); -cef_noop_wrapper!(cef_context_menu_media_state_flags_t); -cef_noop_wrapper!(cef_context_menu_media_type_t); -cef_noop_wrapper!(cef_context_menu_type_flags_t); -cef_noop_wrapper!(cef_cursor_type_t); -cef_noop_wrapper!(cef_dom_document_type_t); -cef_noop_wrapper!(cef_dom_node_type_t); -cef_noop_wrapper!(cef_drag_operations_mask_t); -cef_noop_wrapper!(cef_duplex_mode_t); -cef_noop_wrapper!(cef_errorcode_t); -cef_noop_wrapper!(cef_event_flags_t); -cef_noop_wrapper!(cef_event_handle_t); -cef_noop_wrapper!(cef_file_dialog_mode_t); -cef_noop_wrapper!(cef_focus_source_t); -cef_noop_wrapper!(cef_jsdialog_handler_t); -cef_noop_wrapper!(cef_jsdialog_type_t); -cef_noop_wrapper!(cef_key_event); -cef_noop_wrapper!(cef_menu_item_type_t); -cef_noop_wrapper!(cef_mouse_button_type_t); -cef_noop_wrapper!(cef_navigation_type_t); -cef_noop_wrapper!(cef_paint_element_type_t); -cef_noop_wrapper!(cef_postdataelement_type_t); -cef_noop_wrapper!(cef_process_id_t); -cef_noop_wrapper!(cef_resource_type_t); -cef_noop_wrapper!(cef_return_value_t); -cef_noop_wrapper!(cef_size_t); -cef_noop_wrapper!(cef_termination_status_t); -cef_noop_wrapper!(cef_text_input_context_t); -cef_noop_wrapper!(cef_thread_id_t); -cef_noop_wrapper!(cef_time_t); -cef_noop_wrapper!(cef_transition_type_t); -cef_noop_wrapper!(cef_urlrequest_status_t); -cef_noop_wrapper!(cef_v8_accesscontrol_t); -cef_noop_wrapper!(cef_v8_propertyattribute_t); -cef_noop_wrapper!(cef_value_type_t); -cef_noop_wrapper!(cef_window_open_disposition_t); -cef_noop_wrapper!(cef_xml_encoding_type_t); -cef_noop_wrapper!(cef_xml_node_type_t); -cef_noop_wrapper!(f64); -cef_noop_wrapper!(i64); -cef_noop_wrapper!(u32); -cef_noop_wrapper!(u64); -cef_noop_wrapper!(usize); -cef_noop_wrapper!(cef_string_list_t); - -cef_unimplemented_wrapper!(*const *mut cef_v8value_t, *const CefV8Value); -cef_unimplemented_wrapper!(*mut *mut cef_post_data_element_t, *mut CefPostDataElement); -cef_unimplemented_wrapper!(cef_string_map_t, HashMap<String,String>); -cef_unimplemented_wrapper!(cef_string_multimap_t, HashMap<String,Vec<String>>); -cef_unimplemented_wrapper!(cef_string_t, String); - -impl<'a> CefWrap<*const cef_string_t> for &'a [u16] { - fn to_c(buffer: &'a [u16]) -> *const cef_string_t { - unsafe { - let ptr = libc::malloc((buffer.len() + 1) * 2) as *mut c_ushort; - ptr::copy(buffer.as_ptr(), ptr, buffer.len()); - *ptr.offset(buffer.len() as isize) = 0; - - // FIXME(pcwalton): This leaks!! We should instead have the caller pass some scratch - // stack space to create the object in. What a botch. - Box::into_raw(Box::new(cef_string_utf16 { - str: ptr, - length: buffer.len(), - dtor: Some(free_boxed_utf16_string as extern "C" fn(*mut c_ushort)), - })) as *const _ - } - } - unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] { - slice::from_raw_parts((*cef_string).str, (*cef_string).length as usize) - } -} - -extern "C" fn free_boxed_utf16_string(string: *mut c_ushort) { - unsafe { - libc::free(string as *mut c_void) - } -} - -impl<'a> CefWrap<*mut cef_string_t> for &'a mut [u16] { - fn to_c(_: &'a mut [u16]) -> *mut cef_string_t { - panic!("unimplemented CEF type conversion: &'a str") - } - unsafe fn to_rust(_: *mut cef_string_t) -> &'a mut [u16] { - panic!("unimplemented CEF type conversion: *mut cef_string_t") - } -} - -// FIXME(pcwalton): This is pretty bogus, but it's only used for `init_from_argv`, which should -// never be called by Rust programs anyway. We should fix the wrapper generation though. -impl<'a,'b> CefWrap<*const *const c_char> for &'a &'b str { - fn to_c(_: &'a &'b str) -> *const *const c_char { - panic!("unimplemented CEF type conversion: &'a &'b str") - } - unsafe fn to_rust(_: *const *const c_char) -> &'a &'b str { - panic!("unimplemented CEF type conversion: *const *const cef_string_t") - } -} - -impl<'a,'b> CefWrap<*mut *const c_char> for &'a mut &'b str { - fn to_c(_: &'a mut &'b str) -> *mut *const c_char { - panic!("unimplemented CEF type conversion: &'a mut &'b str") - } - unsafe fn to_rust(_: *mut *const c_char) -> &'a mut &'b str { - panic!("unimplemented CEF type conversion: *mut *const c_char") - } -} - -impl<'a> CefWrap<cef_string_userfree_t> for String { - fn to_c(string: String) -> cef_string_userfree_t { - let utf16_chars: Vec<u16> = string.encode_utf16().collect(); - - let boxed_string; - unsafe { - let buffer = libc::malloc((mem::size_of::<c_ushort>() as libc::size_t) * - ((utf16_chars.len() + 1) as libc::size_t)) as *mut u16; - for (i, ch) in utf16_chars.iter().enumerate() { - *buffer.offset(i as isize) = *ch - } - *buffer.offset(utf16_chars.len() as isize) = 0; - - boxed_string = libc::malloc(mem::size_of::<cef_string_utf16>() as libc::size_t) as - *mut cef_string_utf16; - ptr::write(&mut (*boxed_string).str, buffer); - ptr::write(&mut (*boxed_string).length, utf16_chars.len()); - ptr::write(&mut (*boxed_string).dtor, Some(free_utf16_buffer as extern "C" fn(*mut c_ushort))); - } - boxed_string - } - unsafe fn to_rust(_: cef_string_userfree_t) -> String { - panic!("unimplemented CEF type conversion: cef_string_userfree_t") - } -} - -extern "C" fn free_utf16_buffer(buffer: *mut c_ushort) { - unsafe { - libc::free(buffer as *mut c_void) - } -} - -impl<'a> CefWrap<cef_string_t> for &'a mut String { - fn to_c(_: &'a mut String) -> cef_string_t { - panic!("unimplemented CEF type conversion: &'a mut String"); - } - unsafe fn to_rust(_: cef_string_t) -> &'a mut String { - panic!("unimplemented CEF type conversion: cef_string_t"); - } -} - -impl<'a> CefWrap<&'a cef_string_list_t> for &'a cef_string_list_t { - fn to_c(stringlist: &'a cef_string_list_t) -> &'a cef_string_list_t { - stringlist - } - unsafe fn to_rust(_: &'a cef_string_list_t) -> &'a cef_string_list_t { - panic!("unimplemented CEF type conversion: cef_string_t"); - } -} diff --git a/ports/cef/xml_reader.rs b/ports/cef/xml_reader.rs deleted file mode 100644 index 2b758a96a08..00000000000 --- a/ports/cef/xml_reader.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_stream_reader_t, cef_xml_reader_t}; -use types::{cef_string_t, cef_xml_encoding_type_t}; - -cef_stub_static_method_impls! { - fn cef_xml_reader_create(stream: *mut cef_stream_reader_t, - encoding_type: cef_xml_encoding_type_t, - uri: *const cef_string_t) - -> *mut cef_xml_reader_t -} - diff --git a/ports/cef/zip_reader.rs b/ports/cef/zip_reader.rs deleted file mode 100644 index 0b8793122f5..00000000000 --- a/ports/cef/zip_reader.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use interfaces::{cef_stream_reader_t, cef_zip_reader_t}; - -cef_stub_static_method_impls! { - fn cef_zip_reader_create(stream: *mut cef_stream_reader_t) -> *mut cef_zip_reader_t -} - diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml deleted file mode 100644 index fbd7300dc01..00000000000 --- a/ports/glutin/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "glutin_app" -version = "0.0.1" -authors = ["The Servo Project Developers"] -license = "MPL-2.0" - -[lib] -name = "glutin_app" -path = "lib.rs" - -[dependencies] -bitflags = "1.0" -compositing = {path = "../../components/compositing"} -euclid = "0.16" -gleam = "0.4" -libservo = {path = "../../components/servo"} -log = "0.3.5" -msg = {path = "../../components/msg"} -net_traits = {path = "../../components/net_traits"} -script_traits = {path = "../../components/script_traits"} -servo-glutin = "0.14" -servo_geometry = {path = "../../components/geometry"} -servo_config = {path = "../../components/config"} -servo_url = {path = "../../components/url"} -style_traits = {path = "../../components/style_traits"} -webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} - -[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] -osmesa-sys = "0.1.2" - -[target.'cfg(target_os = "linux")'.dependencies] -x11 = "2.0.0" - -[target.'cfg(target_os = "android")'.dependencies] -servo-egl = "0.2" - -[target.'cfg(target_os = "windows")'.dependencies] -winapi = "0.2" -user32-sys = "0.2" -gdi32-sys = "0.2" - -[target.'cfg(target_os = "macos")'.dependencies] -osmesa-src = {git = "https://github.com/servo/osmesa-src"} - -[target.x86_64-unknown-linux-gnu.dependencies] -osmesa-src = {git = "https://github.com/servo/osmesa-src"} diff --git a/ports/glutin/lib.rs b/ports/glutin/lib.rs deleted file mode 100644 index fdc799aad0b..00000000000 --- a/ports/glutin/lib.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//! A simple application that uses glutin to open a window for Servo to display in. - - -#[macro_use] extern crate bitflags; -extern crate compositing; -extern crate euclid; -extern crate gleam; -extern crate glutin; -#[macro_use] extern crate log; -extern crate msg; -extern crate net_traits; -#[cfg(any(target_os = "linux", target_os = "macos"))] extern crate osmesa_sys; -extern crate script_traits; -extern crate servo; -extern crate servo_config; -extern crate servo_geometry; -extern crate servo_url; -extern crate style_traits; -extern crate webrender_api; - -#[cfg(target_os = "windows")] extern crate winapi; -#[cfg(target_os = "windows")] extern crate user32; -#[cfg(target_os = "windows")] extern crate gdi32; - -use compositing::windowing::WindowEvent; -use servo_config::opts; -use std::rc::Rc; -use window::Window; - -pub mod window; - -pub type WindowID = glutin::WindowID; - -pub trait NestedEventLoopListener { - fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool; -} - -pub fn create_window(parent: Option<WindowID>) -> Rc<Window> { - // Read command-line options. - let opts = opts::get(); - let foreground = opts.output_file.is_none() && !opts.headless; - - // Open a window. - Window::new(foreground, opts.initial_window_size, parent) -} diff --git a/ports/servo/Cargo.toml b/ports/servo/Cargo.toml index e872da5fe11..b2632a3731f 100644 --- a/ports/servo/Cargo.toml +++ b/ports/servo/Cargo.toml @@ -27,12 +27,42 @@ unstable = ["libservo/unstable"] [dependencies] backtrace = "0.3" browserhtml = {git = "https://github.com/browserhtml/browserhtml", branch = "crate"} -glutin_app = {path = "../../ports/glutin"} -log = "0.3" +bitflags = "1.0" +compositing = {path = "../../components/compositing"} +euclid = "0.16" +gleam = "0.4" libservo = {path = "../../components/servo"} +log = "0.3.5" +msg = {path = "../../components/msg"} +net_traits = {path = "../../components/net_traits"} +script_traits = {path = "../../components/script_traits"} +servo-glutin = "0.14" +servo_geometry = {path = "../../components/geometry"} +servo_config = {path = "../../components/config"} +servo_url = {path = "../../components/url"} +style_traits = {path = "../../components/style_traits"} +webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} [target.'cfg(not(target_os = "android"))'.dependencies] sig = "0.1" +[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] +osmesa-sys = "0.1.2" + +[target.'cfg(target_os = "linux")'.dependencies] +x11 = "2.0.0" + [target.'cfg(target_os = "android")'.dependencies] android_injected_glue = "0.2" +servo-egl = "0.2" + +[target.'cfg(target_os = "windows")'.dependencies] +winapi = "0.2" +user32-sys = "0.2" +gdi32-sys = "0.2" + +[target.'cfg(target_os = "macos")'.dependencies] +osmesa-src = {git = "https://github.com/servo/osmesa-src"} + +[target.x86_64-unknown-linux-gnu.dependencies] +osmesa-src = {git = "https://github.com/servo/osmesa-src"} diff --git a/ports/servo/glutin_app/mod.rs b/ports/servo/glutin_app/mod.rs new file mode 100644 index 00000000000..48819d2ce17 --- /dev/null +++ b/ports/servo/glutin_app/mod.rs @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! A simple application that uses glutin to open a window for Servo to display in. + +pub mod window; + +use compositing::windowing::WindowEvent; +use servo_config::opts; +use std::rc::Rc; + +pub trait NestedEventLoopListener { + fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool; +} + +pub fn create_window() -> Rc<window::Window> { + // Read command-line options. + let opts = opts::get(); + let foreground = opts.output_file.is_none() && !opts.headless; + + // Open a window. + window::Window::new(foreground, opts.initial_window_size) +} diff --git a/ports/glutin/window.rs b/ports/servo/glutin_app/window.rs index 9ce4f28bb83..d024429aca8 100644 --- a/ports/glutin/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -4,7 +4,6 @@ //! A windowing implementation using glutin. -use NestedEventLoopListener; use compositing::compositor_thread::EventLoopWaker; use compositing::windowing::{AnimationState, MouseWindowEvent}; use compositing::windowing::{WebRenderDebugOption, WindowEvent, WindowMethods}; @@ -43,6 +42,7 @@ use std::thread; use std::time; use style_traits::DevicePixel; use style_traits::cursor::CursorKind; +use super::NestedEventLoopListener; #[cfg(target_os = "windows")] use user32; use webrender_api::{DeviceUintRect, DeviceUintSize, ScrollLocation}; @@ -228,8 +228,7 @@ impl Window { } pub fn new(is_foreground: bool, - window_size: TypedSize2D<u32, DeviceIndependentPixel>, - parent: Option<glutin::WindowID>) -> Rc<Window> { + window_size: TypedSize2D<u32, DeviceIndependentPixel>) -> Rc<Window> { let win_size: TypedSize2D<u32, DevicePixel> = (window_size.to_f32() * window_creation_scale_factor()) .to_usize().cast().expect("Window size should fit in u32"); @@ -252,7 +251,6 @@ impl Window { .with_dimensions(width, height) .with_gl(Window::gl_version()) .with_visibility(visible) - .with_parent(parent) .with_multitouch(); if let Ok(mut icon_path) = resource_files::resources_dir_path() { @@ -340,17 +338,6 @@ impl Window { Rc::new(window) } - pub fn platform_window(&self) -> glutin::WindowID { - match self.kind { - WindowKind::Window(ref window) => { - unsafe { glutin::WindowID::new(window.platform_window()) } - } - WindowKind::Headless(..) => { - unreachable!(); - } - } - } - fn nested_window_resize(_width: u32, _height: u32) { unsafe { if let Some(listener) = G_NESTED_EVENT_LOOP_LISTENER { @@ -1473,48 +1460,3 @@ fn filter_nonprintable(ch: char, key_code: VirtualKeyCode) -> Option<char> { None } } - -// These functions aren't actually called. They are here as a link -// hack because Skia references them. - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glBindVertexArrayOES(_array: usize) -{ - unimplemented!() -} - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glDeleteVertexArraysOES(_n: isize, _arrays: *const ()) -{ - unimplemented!() -} - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glGenVertexArraysOES(_n: isize, _arrays: *const ()) -{ - unimplemented!() -} - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glRenderbufferStorageMultisampleIMG(_: isize, _: isize, _: isize, _: isize, _: isize) -{ - unimplemented!() -} - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glFramebufferTexture2DMultisampleIMG(_: isize, _: isize, _: isize, _: isize, _: isize, _: isize) -{ - unimplemented!() -} - -#[allow(non_snake_case)] -#[no_mangle] -pub extern "C" fn glDiscardFramebufferEXT(_: isize, _: isize, _: *const ()) -{ - unimplemented!() -} diff --git a/ports/servo/main.rs b/ports/servo/main.rs index 529da519ac7..1b34745eee3 100644 --- a/ports/servo/main.rs +++ b/ports/servo/main.rs @@ -20,15 +20,31 @@ #[cfg(target_os = "android")] extern crate android_injected_glue; extern crate backtrace; +#[macro_use] extern crate bitflags; +extern crate compositing; +extern crate euclid; +#[cfg(target_os = "windows")] extern crate gdi32; +extern crate gleam; +extern crate glutin; // The window backed by glutin -extern crate glutin_app as app; -#[macro_use] -extern crate log; -// The Servo engine +#[macro_use] extern crate log; +extern crate msg; +extern crate net_traits; +#[cfg(any(target_os = "linux", target_os = "macos"))] extern crate osmesa_sys; +extern crate script_traits; extern crate servo; +extern crate servo_config; +extern crate servo_geometry; +extern crate servo_url; #[cfg(all(feature = "unstable", not(target_os = "android")))] #[macro_use] extern crate sig; +extern crate style_traits; +extern crate webrender_api; +#[cfg(target_os = "windows")] extern crate winapi; +#[cfg(target_os = "windows")] extern crate user32; + +mod glutin_app; use backtrace::Backtrace; use servo::Servo; @@ -144,7 +160,7 @@ fn main() { process::exit(0); } - let window = app::create_window(None); + let window = glutin_app::create_window(); // If the url is not provided, we fallback to the homepage in PREFS, // or a blank page in case the homepage is not set either. @@ -188,23 +204,23 @@ fn main() { platform::deinit() } -fn register_glutin_resize_handler(window: &Rc<app::window::Window>, browser: &mut ServoWrapper) { +fn register_glutin_resize_handler(window: &Rc<glutin_app::window::Window>, browser: &mut ServoWrapper) { unsafe { window.set_nested_event_loop_listener(browser); } } -fn unregister_glutin_resize_handler(window: &Rc<app::window::Window>) { +fn unregister_glutin_resize_handler(window: &Rc<glutin_app::window::Window>) { unsafe { window.remove_nested_event_loop_listener(); } } struct ServoWrapper { - servo: Servo<app::window::Window>, + servo: Servo<glutin_app::window::Window>, } -impl app::NestedEventLoopListener for ServoWrapper { +impl glutin_app::NestedEventLoopListener for ServoWrapper { fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool { let is_resize = match event { WindowEvent::Resize => true, @@ -281,3 +297,48 @@ fn args() -> Vec<String> { pub extern "C" fn android_main(app: *mut ()) { android_injected_glue::android_main2(app as *mut _, move |_, _| main()); } + +// These functions aren't actually called. They are here as a link +// hack because Skia references them. + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glBindVertexArrayOES(_array: usize) +{ + unimplemented!() +} + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glDeleteVertexArraysOES(_n: isize, _arrays: *const ()) +{ + unimplemented!() +} + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glGenVertexArraysOES(_n: isize, _arrays: *const ()) +{ + unimplemented!() +} + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glRenderbufferStorageMultisampleIMG(_: isize, _: isize, _: isize, _: isize, _: isize) +{ + unimplemented!() +} + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glFramebufferTexture2DMultisampleIMG(_: isize, _: isize, _: isize, _: isize, _: isize, _: isize) +{ + unimplemented!() +} + +#[allow(non_snake_case)] +#[no_mangle] +pub extern "C" fn glDiscardFramebufferEXT(_: isize, _: isize, _: *const ()) +{ + unimplemented!() +} diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 22e716a29a1..967e8c35509 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -24,7 +24,7 @@ from mach.decorators import ( Command, ) -from servo.command_base import CommandBase, cd, call, check_call, BIN_SUFFIX, is_macosx +from servo.command_base import CommandBase, cd, call, check_call, BIN_SUFFIX from servo.util import host_triple @@ -389,63 +389,6 @@ class MachCommands(CommandBase): print("Build %s in %s" % ("Completed" if status == 0 else "FAILED", format_duration(elapsed))) return status - @Command('build-cef', - description='Build the Chromium Embedding Framework library', - category='build') - @CommandArgument('--jobs', '-j', - default=None, - help='Number of jobs to run in parallel') - @CommandArgument('--verbose', '-v', - action='store_true', - help='Print verbose output') - @CommandArgument('--release', '-r', - action='store_true', - help='Build in release mode') - @CommandArgument('--with-debug-assertions', - default=None, - action='store_true', - help='Enable debug assertions in release') - def build_cef(self, jobs=None, verbose=False, release=False, - with_debug_assertions=False): - self.ensure_bootstrapped() - self.ensure_clobbered() - - ret = None - opts = ["-p", "embedding"] - - if jobs is not None: - opts += ["-j", jobs] - if verbose: - opts += ["-v"] - if release: - opts += ["--release"] - - servo_features = self.servo_features() - if servo_features: - opts += ["--features", "%s" % ' '.join(servo_features)] - - build_start = time() - env = self.build_env(is_build=True) - - if with_debug_assertions: - env["RUSTFLAGS"] = "-C debug_assertions" - - if is_macosx(): - # Unlike RUSTFLAGS, these are only passed in the final rustc invocation - # so that `./mach build` followed by `./mach build-cef` both build - # common dependencies with the same flags. - opts += ["--", "-Clink-args=-Xlinker -undefined -Xlinker dynamic_lookup"] - - ret = self.call_rustup_run(["cargo", "rustc"] + opts, env=env, verbose=verbose) - elapsed = time() - build_start - - # Generate Desktop Notification if elapsed-time > some threshold value - notify_build_done(self.config, elapsed) - - print("CEF build completed in %s" % format_duration(elapsed)) - - return ret - @Command('build-geckolib', description='Build a static library of components used by Gecko', category='build') diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 360fe1a2701..8cc307bfb51 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -531,9 +531,6 @@ class CommandBase(object): def geckolib_manifest(self): return path.join(self.context.topdir, "ports", "geckolib", "Cargo.toml") - def cef_manifest(self): - return path.join(self.context.topdir, "ports", "cef", "Cargo.toml") - def servo_features(self): """Return a list of optional features to enable for the Servo crate""" features = [] diff --git a/servo-tidy.toml b/servo-tidy.toml index a7230e35aee..5a2a5940f68 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -81,7 +81,6 @@ directories = [ "./components/hashglobe/src", # Generated and upstream code combined with our own. Could use cleanup "./target", - "./ports/cef", ] # Directories that are checked for correct file extension |