| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 
| 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| 11 #include "components/content_settings/core/common/content_settings_types.h" | 11 #include "components/content_settings/core/common/content_settings_types.h" | 
|  | 12 #include "ui/gfx/image/image.h" | 
| 12 | 13 | 
| 13 namespace content { | 14 namespace content { | 
| 14 class WebContents; | 15 class WebContents; | 
| 15 } | 16 } | 
| 16 | 17 | 
|  | 18 namespace gfx { | 
|  | 19 enum class VectorIconId; | 
|  | 20 } | 
|  | 21 | 
| 17 // This model provides data (icon ids and tooltip) for the content setting icons | 22 // This model provides data (icon ids and tooltip) for the content setting icons | 
| 18 // that are displayed in the location bar. | 23 // that are displayed in the location bar. | 
| 19 class ContentSettingImageModel { | 24 class ContentSettingImageModel { | 
| 20  public: | 25  public: | 
| 21   virtual ~ContentSettingImageModel() {} | 26   virtual ~ContentSettingImageModel() {} | 
| 22 | 27 | 
| 23   // Factory function. | 28   // Factory function. | 
| 24   static ContentSettingImageModel* CreateContentSettingImageModel( | 29   static ContentSettingImageModel* CreateContentSettingImageModel( | 
| 25      ContentSettingsType content_settings_type); | 30      ContentSettingsType content_settings_type); | 
| 26 | 31 | 
| 27   // Notifies this model that its setting might have changed and it may need to | 32   // Notifies this model that its setting might have changed and it may need to | 
| 28   // update its visibility, icon and tooltip. | 33   // update its visibility, icon and tooltip. | 
| 29   virtual void UpdateFromWebContents(content::WebContents* web_contents) = 0; | 34   virtual void UpdateFromWebContents(content::WebContents* web_contents) = 0; | 
| 30 | 35 | 
| 31   ContentSettingsType get_content_settings_type() const { | 36   ContentSettingsType get_content_settings_type() const { | 
| 32     return content_settings_type_; | 37     return content_settings_type_; | 
| 33   } | 38   } | 
| 34   bool is_visible() const { return is_visible_; } | 39   bool is_visible() const { return is_visible_; } | 
| 35   int get_icon() const { return icon_; } | 40   const gfx::Image& icon() const { return icon_; } | 
|  | 41 #if defined(OS_MACOSX) | 
|  | 42   int icon_id() const { return icon_id_; } | 
|  | 43 #endif | 
| 36   // Returns the resource ID of a string to show when the icon appears, or 0 if | 44   // Returns the resource ID of a string to show when the icon appears, or 0 if | 
| 37   // we don't wish to show anything. | 45   // we don't wish to show anything. | 
| 38   int explanatory_string_id() const { return explanatory_string_id_; } | 46   int explanatory_string_id() const { return explanatory_string_id_; } | 
| 39   std::string get_tooltip() const { return tooltip_; } | 47   std::string get_tooltip() const { return tooltip_; } | 
| 40 | 48 | 
| 41  protected: | 49  protected: | 
| 42   explicit ContentSettingImageModel(ContentSettingsType content_settings_type); | 50   explicit ContentSettingImageModel(ContentSettingsType content_settings_type); | 
|  | 51   void SetIconByResourceId(int id); | 
|  | 52 #if !defined(OS_MACOSX) | 
|  | 53   void SetIconByVectorId(gfx::VectorIconId id, bool blocked); | 
|  | 54 #endif | 
| 43   void set_visible(bool visible) { is_visible_ = visible; } | 55   void set_visible(bool visible) { is_visible_ = visible; } | 
| 44   void set_icon(int icon) { icon_ = icon; } |  | 
| 45   void set_explanatory_string_id(int text_id) { | 56   void set_explanatory_string_id(int text_id) { | 
| 46     explanatory_string_id_ = text_id; | 57     explanatory_string_id_ = text_id; | 
| 47   } | 58   } | 
| 48   void set_tooltip(const std::string& tooltip) { tooltip_ = tooltip; } | 59   void set_tooltip(const std::string& tooltip) { tooltip_ = tooltip; } | 
| 49 | 60 | 
| 50  private: | 61  private: | 
| 51   const ContentSettingsType content_settings_type_; | 62   const ContentSettingsType content_settings_type_; | 
| 52   bool is_visible_; | 63   bool is_visible_; | 
| 53   int icon_; | 64   int icon_id_; | 
|  | 65   gfx::Image icon_; | 
| 54   int explanatory_string_id_; | 66   int explanatory_string_id_; | 
| 55   std::string tooltip_; | 67   std::string tooltip_; | 
| 56 | 68 | 
| 57   DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModel); | 69   DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModel); | 
| 58 }; | 70 }; | 
| 59 | 71 | 
| 60 #endif  // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 72 #endif  // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 
| OLD | NEW | 
|---|