| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" | 12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" |
| 13 #include "components/content_settings/core/common/content_settings_types.h" | 13 #include "components/content_settings/core/common/content_settings_types.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class WebContents; | 17 class WebContents; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 enum class VectorIconId; | 21 struct VectorIcon; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // This model provides data (icon ids and tooltip) for the content setting icons | 24 // This model provides data (icon ids and tooltip) for the content setting icons |
| 25 // that are displayed in the location bar. | 25 // that are displayed in the location bar. |
| 26 class ContentSettingImageModel { | 26 class ContentSettingImageModel { |
| 27 public: | 27 public: |
| 28 virtual ~ContentSettingImageModel() {} | 28 virtual ~ContentSettingImageModel() {} |
| 29 | 29 |
| 30 // Generates a vector of all image models to be used within one window. | 30 // Generates a vector of all image models to be used within one window. |
| 31 static std::vector<std::unique_ptr<ContentSettingImageModel>> | 31 static std::vector<std::unique_ptr<ContentSettingImageModel>> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 gfx::Image GetIcon(SkColor nearby_text_color) const; | 65 gfx::Image GetIcon(SkColor nearby_text_color) const; |
| 66 | 66 |
| 67 // Returns the resource ID of a string to show when the icon appears, or 0 if | 67 // Returns the resource ID of a string to show when the icon appears, or 0 if |
| 68 // we don't wish to show anything. | 68 // we don't wish to show anything. |
| 69 int explanatory_string_id() const { return explanatory_string_id_; } | 69 int explanatory_string_id() const { return explanatory_string_id_; } |
| 70 const base::string16& get_tooltip() const { return tooltip_; } | 70 const base::string16& get_tooltip() const { return tooltip_; } |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 ContentSettingImageModel(); | 73 ContentSettingImageModel(); |
| 74 | 74 |
| 75 void set_icon_by_vector_id(gfx::VectorIconId id, gfx::VectorIconId badge_id) { | 75 void set_icon(const gfx::VectorIcon& icon, const gfx::VectorIcon& badge) { |
| 76 icon_id_ = id; | 76 icon_ = &icon; |
| 77 icon_badge_id_ = badge_id; | 77 icon_badge_ = &badge; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void set_visible(bool visible) { is_visible_ = visible; } | 80 void set_visible(bool visible) { is_visible_ = visible; } |
| 81 void set_explanatory_string_id(int text_id) { | 81 void set_explanatory_string_id(int text_id) { |
| 82 explanatory_string_id_ = text_id; | 82 explanatory_string_id_ = text_id; |
| 83 } | 83 } |
| 84 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } | 84 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 bool is_visible_; | 87 bool is_visible_; |
| 88 | 88 |
| 89 gfx::VectorIconId icon_id_; | 89 const gfx::VectorIcon* icon_; |
| 90 gfx::VectorIconId icon_badge_id_; | 90 const gfx::VectorIcon* icon_badge_; |
| 91 int explanatory_string_id_; | 91 int explanatory_string_id_; |
| 92 base::string16 tooltip_; | 92 base::string16 tooltip_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModel); | 94 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModel); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // A subclass for an image model tied to a single content type. | 97 // A subclass for an image model tied to a single content type. |
| 98 class ContentSettingSimpleImageModel : public ContentSettingImageModel { | 98 class ContentSettingSimpleImageModel : public ContentSettingImageModel { |
| 99 public: | 99 public: |
| 100 explicit ContentSettingSimpleImageModel(ContentSettingsType content_type); | 100 explicit ContentSettingSimpleImageModel(ContentSettingsType content_type); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 Profile* profile) override; | 134 Profile* profile) override; |
| 135 | 135 |
| 136 bool ShouldRunAnimation(content::WebContents* web_contents) override; | 136 bool ShouldRunAnimation(content::WebContents* web_contents) override; |
| 137 void SetAnimationHasRun(content::WebContents* web_contents) override; | 137 void SetAnimationHasRun(content::WebContents* web_contents) override; |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterImageModel); | 140 DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterImageModel); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ | 143 #endif // CHROME_BROWSER_UI_CONTENT_SETTINGS_CONTENT_SETTING_IMAGE_MODEL_H_ |
| OLD | NEW |