diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 11:40:08 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 11:40:08 +0000 |
commit | 352104ee28f47810b5d2dc5fd6193c60d2cd2e95 (patch) | |
tree | 1d4d26928b9951a3d5f54688c550835740849837 /chrome/browser/content_setting_image_model.cc | |
parent | ff039f0833a278d7ca80aeb8987e73b6c258f305 (diff) | |
download | chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.zip chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.tar.gz chromium_src-352104ee28f47810b5d2dc5fd6193c60d2cd2e95.tar.bz2 |
Renames ContentBlockedImageView to ContentSettingImageView.
Adds ContentSettingImageModel to provide icon and tooltips for platform-specific ContentBlockedImageView.
(in preparation for:
http://codereview.chromium.org/650180/show
)
TEST=chrome/browser/content_setting_image_model_unittest.cc
Review URL: http://codereview.chromium.org/660279
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_image_model.cc')
-rw-r--r-- | chrome/browser/content_setting_image_model.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc new file mode 100644 index 0000000..96430f7 --- /dev/null +++ b/chrome/browser/content_setting_image_model.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/content_setting_image_model.h" + +#include "app/l10n_util.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" + +class ContentSettingBlockedImageModel : public ContentSettingImageModel { + public: + explicit ContentSettingBlockedImageModel( + ContentSettingsType content_settings_type) + : ContentSettingImageModel(content_settings_type) { + } + + virtual void UpdateFromTabContents(const TabContents* tab_contents) { + if (tab_contents && + tab_contents->IsContentBlocked(get_content_settings_type())) { + set_icon(kBlockedIconIDs[get_content_settings_type()]); + set_tooltip( + l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()])); + set_visible(true); + } else { + set_visible(false); + } + } + + private: + static const int kBlockedIconIDs[]; + static const int kTooltipIDs[]; + +}; + +ContentSettingImageModel::ContentSettingImageModel( + ContentSettingsType content_settings_type) + : content_settings_type_(content_settings_type), + is_visible_(false), + icon_(0) { +} + +// static +ContentSettingImageModel* ContentSettingImageModel:: + CreateContentSettingImageModel(ContentSettingsType content_settings_type) { + return new ContentSettingBlockedImageModel(content_settings_type); +} + +const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = { + IDR_BLOCKED_COOKIES, + IDR_BLOCKED_IMAGES, + IDR_BLOCKED_JAVASCRIPT, + IDR_BLOCKED_PLUGINS, + IDR_BLOCKED_POPUPS, +}; + +const int ContentSettingBlockedImageModel::kTooltipIDs[] = { + IDS_BLOCKED_COOKIES_TITLE, + IDS_BLOCKED_IMAGES_TITLE, + IDS_BLOCKED_JAVASCRIPT_TITLE, + IDS_BLOCKED_PLUGINS_TITLE, + IDS_BLOCKED_POPUPS_TOOLTIP, +}; |