Add CefDisplayHandler::OnFaviconURLChange callback (issue #964).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1965 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2015-01-12 19:37:52 +00:00
parent 054300874d
commit ad536f769f
8 changed files with 90 additions and 0 deletions

View File

@ -26,3 +26,4 @@ Corey Lucier <clucier@adobe.com>
Mihai Tica <mitica@adobe.com>
Czarek Tomczak <czarek.tomczak@gmail.com>
Felix Bruns <felixbruns@spotify.com>
YuTeh Shen <shenyute@gmail.com>

View File

@ -70,6 +70,12 @@ typedef struct _cef_display_handler_t {
void (CEF_CALLBACK *on_title_change)(struct _cef_display_handler_t* self,
struct _cef_browser_t* browser, const cef_string_t* title);
///
// Called when the page icon changes.
///
void (CEF_CALLBACK *on_favicon_urlchange)(struct _cef_display_handler_t* self,
struct _cef_browser_t* browser, cef_string_list_t icon_urls);
///
// 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

View File

@ -64,6 +64,13 @@ class CefDisplayHandler : public virtual CefBase {
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {}
///
// Called when the page icon changes.
///
/*--cef(optional_param=icon_urls)--*/
virtual void OnFaviconURLChange(CefRefPtr<CefBrowser> browser,
const std::vector<CefString>& icon_urls) {}
///
// 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

View File

@ -2490,6 +2490,21 @@ void CefBrowserHostImpl::PluginCrashed(const base::FilePath& plugin_path,
}
}
void CefBrowserHostImpl::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) {
if (client_.get()) {
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
if (handler.get()) {
std::vector<CefString> icon_urls;
std::vector<content::FaviconURL>::const_iterator it =
candidates.begin();
for (; it != candidates.end(); ++it)
icon_urls.push_back(it->icon_url.spec());
handler->OnFaviconURLChange(this, icon_urls);
}
}
}
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
// Handle the cursor message here if mouse cursor change is disabled instead
// of propegating the message to the normal handler.

View File

@ -427,6 +427,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::RenderFrameHost* render_frame_host) override;
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
void DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) override;
bool OnMessageReceived(const IPC::Message& message) override;
// Override to provide a thread safe implementation.
bool Send(IPC::Message* message) override;

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
@ -65,6 +66,30 @@ void CEF_CALLBACK display_handler_on_title_change(
CefString(title));
}
void CEF_CALLBACK display_handler_on_favicon_urlchange(
struct _cef_display_handler_t* self, cef_browser_t* browser,
cef_string_list_t icon_urls) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Unverified params: icon_urls
// Translate param: icon_urls; type: string_vec_byref_const
std::vector<CefString> icon_urlsList;
transfer_string_list_contents(icon_urls, icon_urlsList);
// Execute
CefDisplayHandlerCppToC::Get(self)->OnFaviconURLChange(
CefBrowserCToCpp::Wrap(browser),
icon_urlsList);
}
int CEF_CALLBACK display_handler_on_tooltip(struct _cef_display_handler_t* self,
cef_browser_t* browser, cef_string_t* text) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -143,6 +168,7 @@ CefDisplayHandlerCppToC::CefDisplayHandlerCppToC(CefDisplayHandler* cls)
cef_display_handler_t>(cls) {
struct_.struct_.on_address_change = display_handler_on_address_change;
struct_.struct_.on_title_change = display_handler_on_title_change;
struct_.struct_.on_favicon_urlchange = display_handler_on_favicon_urlchange;
struct_.struct_.on_tooltip = display_handler_on_tooltip;
struct_.struct_.on_status_message = display_handler_on_status_message;
struct_.struct_.on_console_message = display_handler_on_console_message;

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
@ -63,6 +64,35 @@ void CefDisplayHandlerCToCpp::OnTitleChange(CefRefPtr<CefBrowser> browser,
title.GetStruct());
}
void CefDisplayHandlerCToCpp::OnFaviconURLChange(CefRefPtr<CefBrowser> browser,
const std::vector<CefString>& icon_urls) {
if (CEF_MEMBER_MISSING(struct_, on_favicon_urlchange))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Unverified params: icon_urls
// Translate param: icon_urls; type: string_vec_byref_const
cef_string_list_t icon_urlsList = cef_string_list_alloc();
DCHECK(icon_urlsList);
if (icon_urlsList)
transfer_string_list_contents(icon_urls, icon_urlsList);
// Execute
struct_->on_favicon_urlchange(struct_,
CefBrowserCppToC::Wrap(browser),
icon_urlsList);
// Restore param:icon_urls; type: string_vec_byref_const
if (icon_urlsList)
cef_string_list_free(icon_urlsList);
}
bool CefDisplayHandlerCToCpp::OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text) {
if (CEF_MEMBER_MISSING(struct_, on_tooltip))

View File

@ -18,6 +18,7 @@
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include <vector>
#include "include/cef_display_handler.h"
#include "include/capi/cef_display_handler_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
@ -37,6 +38,8 @@ class CefDisplayHandlerCToCpp
const CefString& url) override;
void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) override;
void OnFaviconURLChange(CefRefPtr<CefBrowser> browser,
const std::vector<CefString>& icon_urls) override;
bool OnTooltip(CefRefPtr<CefBrowser> browser, CefString& text) override;
void OnStatusMessage(CefRefPtr<CefBrowser> browser,
const CefString& value) override;