diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 11:34:51 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 11:34:51 +0000 |
commit | 5ec40cfbe054961db55591c94e46979c4c4d53d7 (patch) | |
tree | 9412e0b34a4da5569e5d2c5d06edb4885f9a9d3d /chrome/browser/content_setting_bubble_model.h | |
parent | d6d0cf6a3dea6ec00a70781cca4902e133090647 (diff) | |
download | chromium_src-5ec40cfbe054961db55591c94e46979c4c4d53d7.zip chromium_src-5ec40cfbe054961db55591c94e46979c4c4d53d7.tar.gz chromium_src-5ec40cfbe054961db55591c94e46979c4c4d53d7.tar.bz2 |
Adds ContentSettingBubbleModel.
Review URL: http://codereview.chromium.org/668075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_bubble_model.h')
-rw-r--r-- | chrome/browser/content_setting_bubble_model.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/chrome/browser/content_setting_bubble_model.h b/chrome/browser/content_setting_bubble_model.h new file mode 100644 index 0000000..dcbafb7 --- /dev/null +++ b/chrome/browser/content_setting_bubble_model.h @@ -0,0 +1,94 @@ +// 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. + +#ifndef CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ +#define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ + +#include <string> +#include <vector> + +#include "chrome/common/content_settings.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" +#include "third_party/skia/include/core/SkBitmap.h" + +class Profile; +class SkBitmap; +class TabContents; + +// This model provides data for ContentSettingBubble, and also controls +// the action triggered when the allow / block radio buttons are triggered. +class ContentSettingBubbleModel : public NotificationObserver { + public: + virtual ~ContentSettingBubbleModel(); + + static ContentSettingBubbleModel* CreateContentSettingBubbleModel( + TabContents* tab_contents, + Profile* profile, + ContentSettingsType content_type); + + ContentSettingsType content_type() const { return content_type_; } + + struct PopupItem { + SkBitmap bitmap; + std::string title; + TabContents* tab_contents; + }; + typedef std::vector<PopupItem> PopupItems; + + typedef std::vector<std::string> RadioItems; + struct RadioGroup { + std::string host; + std::string title; + RadioItems radio_items; + int default_item; + }; + typedef std::vector<RadioGroup> RadioGroups; + + struct BubbleContent { + std::string title; + PopupItems popup_items; + RadioGroups radio_groups; + std::string manage_link; + }; + + const BubbleContent& bubble_content() const { return bubble_content_; } + + // NotificationObserver: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + virtual void OnRadioClicked(int radio_group, int radio_index) {} + virtual void OnPopupClicked(int index) {} + virtual void OnManageLinkClicked() {} + + protected: + ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile, + ContentSettingsType content_type); + + TabContents* tab_contents() const { return tab_contents_; } + Profile* profile() const { return profile_; } + + void set_title(const std::string& title) { bubble_content_.title = title; } + void add_popup(const PopupItem& popup) { + bubble_content_.popup_items.push_back(popup); + } + void add_radio_group(const RadioGroup& radio_group) { + bubble_content_.radio_groups.push_back(radio_group); + } + void set_manage_link(const std::string& link) { + bubble_content_.manage_link = link; + } + + private: + TabContents* tab_contents_; + Profile* profile_; + ContentSettingsType content_type_; + BubbleContent bubble_content_; + // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. + NotificationRegistrar registrar_; +}; + +#endif // CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_ |