summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_setting_image_model.cc
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 19:56:14 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 19:56:14 +0000
commitf72298c8e0ce1427e8ed682ca5dad0573d6c2763 (patch)
tree842b5af9151d68cb51acf5c113d09e43fca703a8 /chrome/browser/content_setting_image_model.cc
parent6d81b488e8cc5e10eaeca0a4ee4819dc3f469a24 (diff)
downloadchromium_src-f72298c8e0ce1427e8ed682ca5dad0573d6c2763.zip
chromium_src-f72298c8e0ce1427e8ed682ca5dad0573d6c2763.tar.gz
chromium_src-f72298c8e0ce1427e8ed682ca5dad0573d6c2763.tar.bz2
Add an icon to the omnibox when a page is prerendered.
This will only show up for users who have prerendering enabled (mainly via about:flags) This CL does not include the logic for displaying whether prerender failed on the referring page. BUG=73065 TEST=Start Chrome with prerendering enabled, go to a page with a <link rel=prefetch> element, navigate to the referred page, and see icon appear. Review URL: http://codereview.chromium.org/6529031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_image_model.cc')
-rw-r--r--chrome/browser/content_setting_image_model.cc43
1 files changed, 36 insertions, 7 deletions
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index d533ec2..f20e1eb 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -32,14 +32,21 @@ class ContentSettingGeolocationImageModel : public ContentSettingImageModel {
public:
ContentSettingGeolocationImageModel();
- virtual void UpdateFromTabContents(TabContents* tab_contents);
+ virtual void UpdateFromTabContents(TabContents* tab_contents) OVERRIDE;
};
class ContentSettingNotificationsImageModel : public ContentSettingImageModel {
public:
ContentSettingNotificationsImageModel();
- virtual void UpdateFromTabContents(TabContents* tab_contents);
+ virtual void UpdateFromTabContents(TabContents* tab_contents) OVERRIDE;
+};
+
+class ContentSettingPrerenderImageModel : public ContentSettingImageModel {
+ public:
+ ContentSettingPrerenderImageModel();
+
+ virtual void UpdateFromTabContents(TabContents* tab_contents) OVERRIDE;
};
const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = {
@@ -164,6 +171,23 @@ void ContentSettingNotificationsImageModel::UpdateFromTabContents(
set_visible(false);
}
+ContentSettingPrerenderImageModel::ContentSettingPrerenderImageModel()
+ : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_PRERENDER) {
+ set_tooltip(l10n_util::GetStringUTF8(IDS_PRERENDER_SUCCEED_TOOLTIP));
+}
+
+void ContentSettingPrerenderImageModel::UpdateFromTabContents(
+ TabContents* tab_contents) {
+ bool visible = tab_contents && tab_contents->was_prerendered();
+ set_visible(visible);
+ // ContentSettingPrerenderImageView expects icon to transition from 0 to
+ // valid each time it wants to be displayed.
+ if (visible)
+ set_icon(IDR_PRERENDER_SUCCEED_ICON);
+ else
+ set_icon(0);
+}
+
ContentSettingImageModel::ContentSettingImageModel(
ContentSettingsType content_settings_type)
: content_settings_type_(content_settings_type),
@@ -176,9 +200,14 @@ ContentSettingImageModel::ContentSettingImageModel(
ContentSettingImageModel*
ContentSettingImageModel::CreateContentSettingImageModel(
ContentSettingsType content_settings_type) {
- if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
- return new ContentSettingGeolocationImageModel();
- if (content_settings_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
- return new ContentSettingNotificationsImageModel();
- return new ContentSettingBlockedImageModel(content_settings_type);
+ switch (content_settings_type) {
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION:
+ return new ContentSettingGeolocationImageModel();
+ case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
+ return new ContentSettingNotificationsImageModel();
+ case CONTENT_SETTINGS_TYPE_PRERENDER:
+ return new ContentSettingPrerenderImageModel();
+ default:
+ return new ContentSettingBlockedImageModel(content_settings_type);
+ }
}