mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Drop CEF support
This commit is contained in:
parent
e94a25949c
commit
2282292fa4
106 changed files with 151 additions and 38350 deletions
74
Cargo.lock
generated
74
Cargo.lock
generated
|
@ -744,31 +744,6 @@ name = "either"
|
|||
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"
|
||||
|
@ -1077,34 +1052,6 @@ name = "glob"
|
|||
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"
|
||||
|
@ -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]]
|
||||
|
|
|
@ -5,8 +5,6 @@ members = [
|
|||
|
||||
"ports/geckolib",
|
||||
"ports/geckolib/tests",
|
||||
|
||||
"ports/cef",
|
||||
]
|
||||
default-members = [
|
||||
"ports/servo",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
}}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
|
@ -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;
|
|
@ -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))
|
||||
}
|
||||
)*
|
||||
)
|
||||
);
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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())
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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);
|
|
@ -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";
|
|
@ -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
|
||||
}
|
2029
ports/cef/types.rs
2029
ports/cef/types.rs
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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"}
|
|
@ -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)
|
||||
}
|
|
@ -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"}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue