summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormichaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 18:02:13 +0000
committermichaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 18:02:13 +0000
commit42054a25f34cbdd76877b52cca653443ea51c447 (patch)
tree3fec2965dd97b7219082f65bc3bcbcb5c0ebfc3e /chrome
parent18cb0c4ef00c8b4c563b38a7401e1c2c0bce4710 (diff)
downloadchromium_src-42054a25f34cbdd76877b52cca653443ea51c447.zip
chromium_src-42054a25f34cbdd76877b52cca653443ea51c447.tar.gz
chromium_src-42054a25f34cbdd76877b52cca653443ea51c447.tar.bz2
Adapt to new icon interface from WebFrame
- Adapt to the new icon methods from both WebFrame and WebFrameClient. - Touch icons will be fetched and stored if kEnableTouchIcon=1, Currently it is disabled by default. - Moved the kEnableTouchIcon definition to chrome_constants so it could be seen in both browser and renderer code. BUG=71571 TEST=Tested by existent unit test. Review URL: http://codereview.chromium.org/7032013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/defaults.cc2
-rw-r--r--chrome/browser/defaults.h3
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc4
-rw-r--r--chrome/common/chrome_constants.cc2
-rw-r--r--chrome/common/chrome_constants.h3
-rw-r--r--chrome/renderer/chrome_render_view_observer.cc47
-rw-r--r--chrome/renderer/chrome_render_view_observer.h3
7 files changed, 49 insertions, 15 deletions
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
index f5a0c0f..9cb34d7 100644
--- a/chrome/browser/defaults.cc
+++ b/chrome/browser/defaults.cc
@@ -68,8 +68,6 @@ const bool kAlwaysOpenIncognitoWindow = false;
const bool kShowCancelButtonInTaskManager = false;
#endif
-const bool kEnableTouchIcon = false;
-
#if defined(OS_MACOSX)
const bool kBrowserAliveWithNoWindows = true;
#else
diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h
index e733675..c0e8d3d 100644
--- a/chrome/browser/defaults.h
+++ b/chrome/browser/defaults.h
@@ -68,9 +68,6 @@ extern const bool kAlwaysOpenIncognitoWindow;
// Should the close button be shown in the Task Manager dialog?
extern const bool kShowCancelButtonInTaskManager;
-// Are touch icons enabled? False by default.
-extern const bool kEnableTouchIcon;
-
//=============================================================================
// Runtime "const" - set only once after parsing command line option and should
// never be modified after that.
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index ecaa29b..afd9b1c 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -4,10 +4,10 @@
#include "chrome/browser/favicon/favicon_tab_helper.h"
-#include "chrome/browser/defaults.h"
#include "chrome/browser/favicon/favicon_handler.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/icon_messages.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/webui/web_ui.h"
@@ -17,7 +17,7 @@ FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents)
: TabContentsObserver(tab_contents) {
favicon_handler_.reset(new FaviconHandler(tab_contents,
FaviconHandler::FAVICON));
- if (browser_defaults::kEnableTouchIcon)
+ if (chrome::kEnableTouchIcon)
touch_icon_handler_.reset(new FaviconHandler(tab_contents,
FaviconHandler::TOUCH));
}
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 6cd9514..ff21c5a 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -133,6 +133,8 @@ const char* const kUnknownLanguageCode = "und";
const int kJavascriptMessageExpectedDelay = 1000;
+const bool kEnableTouchIcon = false;
+
} // namespace chrome
#undef FPL
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index e6d8fbe..d0e2652 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -94,6 +94,9 @@ extern const char* const kUnknownLanguageCode;
// contents.
extern const int kJavascriptMessageExpectedDelay;
+// Are touch icons enabled? False by default.
+extern const bool kEnableTouchIcon;
+
} // namespace chrome
#endif // CHROME_COMMON_CHROME_CONSTANTS_H_
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index e05503b..113dc62 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/icon_messages.h"
#include "chrome/common/render_messages.h"
@@ -50,6 +51,7 @@
using WebKit::WebCString;
using WebKit::WebDataSource;
using WebKit::WebFrame;
+using WebKit::WebIconURL;
using WebKit::WebPageSerializer;
using WebKit::WebPageSerializerClient;
using WebKit::WebRect;
@@ -113,6 +115,20 @@ static double CalculateBoringScore(SkBitmap* bitmap) {
return static_cast<double>(color_count) / pixel_count;
}
+static FaviconURL::IconType ToFaviconType(WebIconURL::Type type) {
+ switch (type) {
+ case WebIconURL::TypeFavicon:
+ return FaviconURL::FAVICON;
+ case WebIconURL::TypeTouch:
+ return FaviconURL::TOUCH_ICON;
+ case WebIconURL::TypeTouchPrecomposed:
+ return FaviconURL::TOUCH_PRECOMPOSED_ICON;
+ case WebIconURL::TypeInvalid:
+ return FaviconURL::INVALID_ICON;
+ }
+ return FaviconURL::INVALID_ICON;
+}
+
ChromeRenderViewObserver::ChromeRenderViewObserver(
RenderView* render_view,
ContentSettingsObserver* content_settings,
@@ -390,22 +406,39 @@ void ChromeRenderViewObserver::DidStopLoading() {
search_provider::AUTODETECTED_PROVIDER));
}
- // TODO : Get both favicon and touch icon url, and send them to the browser.
- GURL favicon_url(render_view()->webview()->mainFrame()->favIconURL());
- if (!favicon_url.is_empty()) {
- std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(favicon_url, FaviconURL::FAVICON));
+ int icon_types = WebIconURL::TypeFavicon;
+ if (chrome::kEnableTouchIcon)
+ icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch;
+
+ WebVector<WebIconURL> icon_urls =
+ render_view()->webview()->mainFrame()->iconURLs(icon_types);
+ std::vector<FaviconURL> urls;
+ for (size_t i = 0; i < icon_urls.size(); i++) {
+ WebURL url = icon_urls[i].iconURL();
+ if (!url.isEmpty())
+ urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType())));
+ }
+ if (!urls.empty()) {
Send(new IconHostMsg_UpdateFaviconURL(
routing_id(), render_view()->page_id(), urls));
}
}
-void ChromeRenderViewObserver::DidChangeIcons(WebFrame* frame) {
+void ChromeRenderViewObserver::DidChangeIcon(WebFrame* frame,
+ WebIconURL::Type icon_type) {
if (frame->parent())
return;
+ if (!chrome::kEnableTouchIcon &&
+ icon_type != WebIconURL::TypeFavicon)
+ return;
+
+ WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type);
std::vector<FaviconURL> urls;
- urls.push_back(FaviconURL(frame->favIconURL(), FaviconURL::FAVICON));
+ for (size_t i = 0; i < icon_urls.size(); i++) {
+ urls.push_back(FaviconURL(icon_urls[i].iconURL(),
+ ToFaviconType(icon_urls[i].iconType())));
+ }
Send(new IconHostMsg_UpdateFaviconURL(
routing_id(), render_view()->page_id(), urls));
}
diff --git a/chrome/renderer/chrome_render_view_observer.h b/chrome/renderer/chrome_render_view_observer.h
index 6fe6c11..bd71b08 100644
--- a/chrome/renderer/chrome_render_view_observer.h
+++ b/chrome/renderer/chrome_render_view_observer.h
@@ -53,7 +53,8 @@ class ChromeRenderViewObserver : public RenderViewObserver,
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void DidStopLoading() OVERRIDE;
- virtual void DidChangeIcons(WebKit::WebFrame* frame) OVERRIDE;
+ virtual void DidChangeIcon(WebKit::WebFrame* frame,
+ WebKit::WebIconURL::Type icon_type) OVERRIDE;
virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
bool is_new_navigation) OVERRIDE;
virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;