Skip to content

Commit

Permalink
implement cef_display_handler::on_favicon_urlchange
Browse files Browse the repository at this point in the history
also fixes #6166 but with more fix than last fix
  • Loading branch information
Mike Blumenkrantz committed Jun 3, 2015
1 parent 12f20f1 commit 5d99933
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ports/cef/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ pub struct ServoCefBrowser {
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,

Expand Down Expand Up @@ -154,6 +156,7 @@ impl ServoCefBrowser {
back: Cell::new(false),
forward: Cell::new(false),
loading: Cell::new(false),
favicons: RefCell::new(vec!()),
window_handle: window_handle,
}
}
Expand Down
14 changes: 12 additions & 2 deletions ports/cef/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,16 @@ impl WindowMethods for Window {
}
}

fn set_favicon(&self, _: Url) {
fn set_favicon(&self, url: Url) {
let browser = self.cef_browser.borrow();
let browser = match *browser {
None => return,
Some(ref browser) => browser,
};
browser.downcast().favicons.borrow_mut().push(url.to_string().clone());
}

fn load_start(&self, back: bool, forward: bool) {
// FIXME(pcwalton): The status code 200 is a lie.
let browser = self.cef_browser.borrow();
let browser = match *browser {
None => return,
Expand All @@ -329,6 +334,7 @@ impl WindowMethods for Window {
browser.downcast().loading.set(true);
browser.downcast().back.set(back);
browser.downcast().forward.set(forward);
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()
Expand All @@ -348,6 +354,10 @@ impl WindowMethods for Window {
browser.downcast().loading.set(false);
browser.downcast().back.set(back);
browser.downcast().forward.set(forward);
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().clone());
}
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()
Expand Down

0 comments on commit 5d99933

Please sign in to comment.