mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Implement window.openURLInDefaultBrowser() (fixes #11292)
This commit is contained in:
parent
8003687deb
commit
056bdc5514
8 changed files with 39 additions and 5 deletions
|
@ -43,6 +43,7 @@ msg = {path = "../msg"}
|
||||||
net_traits = {path = "../net_traits"}
|
net_traits = {path = "../net_traits"}
|
||||||
num-traits = "0.1.32"
|
num-traits = "0.1.32"
|
||||||
offscreen_gl_context = "0.1.2"
|
offscreen_gl_context = "0.1.2"
|
||||||
|
open = "1.1.1"
|
||||||
phf = "0.7.13"
|
phf = "0.7.13"
|
||||||
phf_macros = "0.7.13"
|
phf_macros = "0.7.13"
|
||||||
plugins = {path = "../plugins"}
|
plugins = {path = "../plugins"}
|
||||||
|
|
|
@ -146,16 +146,16 @@ interface BrowserElementPrivileged {
|
||||||
// unsigned long count,
|
// unsigned long count,
|
||||||
// unsigned long modifiers);
|
// unsigned long modifiers);
|
||||||
|
|
||||||
[Func="Window::global_is_mozbrowser", Throws]
|
[Throws]
|
||||||
void goBack();
|
void goBack();
|
||||||
|
|
||||||
[Func="Window::global_is_mozbrowser", Throws]
|
[Throws]
|
||||||
void goForward();
|
void goForward();
|
||||||
|
|
||||||
[Func="Window::global_is_mozbrowser", Throws]
|
[Throws]
|
||||||
void reload(optional boolean hardReload = false);
|
void reload(optional boolean hardReload = false);
|
||||||
|
|
||||||
[Func="Window::global_is_mozbrowser", Throws]
|
[Throws]
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
//[Throws,
|
//[Throws,
|
||||||
|
|
|
@ -159,6 +159,8 @@ partial interface Window {
|
||||||
void debug(DOMString arg);
|
void debug(DOMString arg);
|
||||||
void gc();
|
void gc();
|
||||||
void trap();
|
void trap();
|
||||||
|
[Func="Window::global_is_mozbrowser", Throws]
|
||||||
|
void openURLInDefaultBrowser(DOMString href);
|
||||||
};
|
};
|
||||||
|
|
||||||
// WebDriver extensions
|
// WebDriver extensions
|
||||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNo
|
||||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
|
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
|
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
|
||||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception};
|
||||||
use dom::bindings::global::{GlobalRef, global_root_from_object};
|
use dom::bindings::global::{GlobalRef, global_root_from_object};
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
|
@ -52,6 +52,7 @@ use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||||
use net_traits::storage_thread::StorageType;
|
use net_traits::storage_thread::StorageType;
|
||||||
use net_traits::{ResourceThreads, CustomResponseSender};
|
use net_traits::{ResourceThreads, CustomResponseSender};
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
|
use open;
|
||||||
use profile_traits::mem;
|
use profile_traits::mem;
|
||||||
use profile_traits::time::{ProfilerCategory, TimerMetadata, TimerMetadataFrameType};
|
use profile_traits::time::{ProfilerCategory, TimerMetadata, TimerMetadataFrameType};
|
||||||
use profile_traits::time::{ProfilerChan, TimerMetadataReflowType, profile};
|
use profile_traits::time::{ProfilerChan, TimerMetadataReflowType, profile};
|
||||||
|
@ -839,6 +840,17 @@ impl WindowMethods for Window {
|
||||||
fn SetStatus(&self, status: DOMString) {
|
fn SetStatus(&self, status: DOMString) {
|
||||||
*self.status.borrow_mut() = status
|
*self.status.borrow_mut() = status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check-tidy: no specs after this line
|
||||||
|
fn OpenURLInDefaultBrowser(&self, href: DOMString) -> ErrorResult {
|
||||||
|
let url = try!(Url::parse(&href).map_err(|e| {
|
||||||
|
Error::Type(format!("Couldn't parse URL: {}", e))
|
||||||
|
}));
|
||||||
|
match open::that(url.as_str()) {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(Error::Type(format!("Couldn't open URL: {}", e))),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ScriptHelpers {
|
pub trait ScriptHelpers {
|
||||||
|
|
|
@ -59,6 +59,7 @@ extern crate msg;
|
||||||
extern crate net_traits;
|
extern crate net_traits;
|
||||||
extern crate num_traits;
|
extern crate num_traits;
|
||||||
extern crate offscreen_gl_context;
|
extern crate offscreen_gl_context;
|
||||||
|
extern crate open;
|
||||||
extern crate phf;
|
extern crate phf;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate profile_traits;
|
extern crate profile_traits;
|
||||||
|
|
6
components/servo/Cargo.lock
generated
6
components/servo/Cargo.lock
generated
|
@ -1565,6 +1565,11 @@ dependencies = [
|
||||||
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
|
@ -1877,6 +1882,7 @@ dependencies = [
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
|
|
6
ports/cef/Cargo.lock
generated
6
ports/cef/Cargo.lock
generated
|
@ -1443,6 +1443,11 @@ dependencies = [
|
||||||
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
|
@ -1735,6 +1740,7 @@ dependencies = [
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
|
|
6
ports/gonk/Cargo.lock
generated
6
ports/gonk/Cargo.lock
generated
|
@ -1431,6 +1431,11 @@ dependencies = [
|
||||||
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "open"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.7.13"
|
version = "0.7.13"
|
||||||
|
@ -1723,6 +1728,7 @@ dependencies = [
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"offscreen_gl_context 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"open 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_macros 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue