Add new CefDisplayHandler::OnFaviconURLChange callback (issue #779).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1013 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-01-17 21:13:43 +00:00
parent df3ca9e022
commit 5e014e1f34
7 changed files with 118 additions and 0 deletions

View File

@ -81,6 +81,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 Favicon URL for a page 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

@ -83,6 +83,13 @@ class CefDisplayHandler : public virtual CefBase {
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {}
///
// Called when the Favicon URL for a page changes.
///
/*--cef()--*/
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

@ -41,6 +41,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIconURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
@ -180,6 +181,15 @@ WebWidget* BrowserWebViewDelegate::createPopupMenu(WebPopupType popup_type) {
return browser_->UIT_CreatePopupWidget();
}
void BrowserWebViewDelegate::didStopLoading() {
WebView* view = browser_->UIT_GetWebView();
if (view) {
WebFrame* mainFrame = view->mainFrame();
if (mainFrame)
OnFaviconURLChange(mainFrame);
}
}
WebStorageNamespace* BrowserWebViewDelegate::createSessionStorageNamespace(
unsigned quota) {
return BrowserDomStorageSystem::instance().CreateSessionStorageNamespace();
@ -955,6 +965,12 @@ void BrowserWebViewDelegate::didReceiveTitle(
}
}
void BrowserWebViewDelegate::didChangeIcon(WebKit::WebFrame* frame,
WebKit::WebIconURL::Type iconType) {
if (iconType == WebKit::WebIconURL::TypeFavicon && frame->parent() == NULL)
OnFaviconURLChange(frame);
}
void BrowserWebViewDelegate::didFailLoad(
WebFrame* frame, const WebURLError& error) {
LocationChangeDone(frame);
@ -1338,3 +1354,27 @@ bool BrowserWebViewDelegate::OnBeforeMenu(
return false;
}
void BrowserWebViewDelegate::OnFaviconURLChange(WebKit::WebFrame* frame) {
WebVector<WebKit::WebIconURL> web_icon_urls =
frame->iconURLs(WebKit::WebIconURL::TypeFavicon);
if (web_icon_urls.isEmpty())
return;
std::vector<CefString> icon_urls;
for (size_t i = 0; i < web_icon_urls.size(); ++i) {
if (!web_icon_urls[i].iconURL().isEmpty()) {
const std::string& urlStr = web_icon_urls[i].iconURL().spec();
icon_urls.push_back(urlStr);
}
}
if (icon_urls.empty())
return;
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefDisplayHandler> handler = client->GetDisplayHandler();
if (handler.get())
handler->OnFaviconURLChange(browser_, icon_urls);
}
}

View File

@ -75,6 +75,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual WebKit::WebExternalPopupMenu* createExternalPopupMenu(
const WebKit::WebPopupMenuInfo& info,
WebKit::WebExternalPopupMenuClient* client) OVERRIDE;
virtual void didStopLoading() OVERRIDE;
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
unsigned quota) OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(
@ -191,6 +192,8 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
virtual void didReceiveTitle(
WebKit::WebFrame*, const WebKit::WebString& title,
WebKit::WebTextDirection direction) OVERRIDE;
virtual void didChangeIcon(
WebKit::WebFrame*, WebKit::WebIconURL::Type) OVERRIDE;
virtual void didFailLoad(
WebKit::WebFrame*, const WebKit::WebURLError&) OVERRIDE;
virtual void didFinishLoad(WebKit::WebFrame*) OVERRIDE;
@ -337,6 +340,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
int mouse_y,
int& edit_flags,
int& type_flags);
void OnFaviconURLChange(WebKit::WebFrame* frame);
private:
// Causes navigation actions just printout the intended navigation instead

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.
@ -110,6 +111,33 @@ 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;
// Verify param: icon_urls; type: string_vec_byref_const
DCHECK(icon_urls);
if (!icon_urls)
return;
// 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
@ -192,6 +220,7 @@ CefDisplayHandlerCppToC::CefDisplayHandlerCppToC(CefDisplayHandler* cls)
struct_.struct_.on_contents_size_change =
display_handler_on_contents_size_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.
@ -107,6 +108,34 @@ 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;
// 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"
@ -42,6 +43,8 @@ class CefDisplayHandlerCToCpp
CefRefPtr<CefFrame> frame, int width, int height) OVERRIDE;
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) OVERRIDE;
virtual void OnFaviconURLChange(CefRefPtr<CefBrowser> browser,
const std::vector<CefString>& icon_urls) OVERRIDE;
virtual bool OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text) OVERRIDE;
virtual void OnStatusMessage(CefRefPtr<CefBrowser> browser,