| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/views/collected_cookies_views.h" | 5 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 content_ = new views::View; | 85 content_ = new views::View; |
| 86 SkColor border_color = SK_ColorGRAY; | 86 SkColor border_color = SK_ColorGRAY; |
| 87 content_->SetBorder( | 87 content_->SetBorder( |
| 88 views::Border::CreateSolidBorder(kInfobarBorderSize, border_color)); | 88 views::Border::CreateSolidBorder(kInfobarBorderSize, border_color)); |
| 89 | 89 |
| 90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 91 info_image_ = new views::ImageView(); | 91 info_image_ = new views::ImageView(); |
| 92 info_image_->SetImage(rb.GetImageSkiaNamed(IDR_INFO)); | 92 info_image_->SetImage(rb.GetImageSkiaNamed(IDR_INFO)); |
| 93 label_ = new views::Label(); | 93 label_ = new views::Label(); |
| 94 } | 94 } |
| 95 virtual ~InfobarView() {} | 95 ~InfobarView() override {} |
| 96 | 96 |
| 97 // Update the visibility of the infobar. If |is_visible| is true, a rule for | 97 // Update the visibility of the infobar. If |is_visible| is true, a rule for |
| 98 // |setting| on |domain_name| was created. | 98 // |setting| on |domain_name| was created. |
| 99 void UpdateVisibility(bool is_visible, | 99 void UpdateVisibility(bool is_visible, |
| 100 ContentSetting setting, | 100 ContentSetting setting, |
| 101 const base::string16& domain_name) { | 101 const base::string16& domain_name) { |
| 102 if (!is_visible) { | 102 if (!is_visible) { |
| 103 SetVisible(false); | 103 SetVisible(false); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 new views::BoxLayout(views::BoxLayout::kHorizontal, | 137 new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 138 kInfobarHorizontalPadding, | 138 kInfobarHorizontalPadding, |
| 139 kInfobarVerticalPadding, | 139 kInfobarVerticalPadding, |
| 140 views::kRelatedControlSmallHorizontalSpacing)); | 140 views::kRelatedControlSmallHorizontalSpacing)); |
| 141 content_->AddChildView(info_image_); | 141 content_->AddChildView(info_image_); |
| 142 content_->AddChildView(label_); | 142 content_->AddChildView(label_); |
| 143 UpdateVisibility(false, CONTENT_SETTING_BLOCK, base::string16()); | 143 UpdateVisibility(false, CONTENT_SETTING_BLOCK, base::string16()); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // views::View overrides. | 146 // views::View overrides. |
| 147 virtual gfx::Size GetPreferredSize() const override { | 147 gfx::Size GetPreferredSize() const override { |
| 148 if (!visible()) | 148 if (!visible()) |
| 149 return gfx::Size(); | 149 return gfx::Size(); |
| 150 | 150 |
| 151 // Add space around the banner. | 151 // Add space around the banner. |
| 152 gfx::Size size(content_->GetPreferredSize()); | 152 gfx::Size size(content_->GetPreferredSize()); |
| 153 size.Enlarge(0, 2 * views::kRelatedControlVerticalSpacing); | 153 size.Enlarge(0, 2 * views::kRelatedControlVerticalSpacing); |
| 154 return size; | 154 return size; |
| 155 } | 155 } |
| 156 | 156 |
| 157 virtual void Layout() override { | 157 void Layout() override { |
| 158 content_->SetBounds( | 158 content_->SetBounds( |
| 159 0, views::kRelatedControlVerticalSpacing, | 159 0, views::kRelatedControlVerticalSpacing, |
| 160 width(), height() - views::kRelatedControlVerticalSpacing); | 160 width(), height() - views::kRelatedControlVerticalSpacing); |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual void ViewHierarchyChanged( | 163 void ViewHierarchyChanged( |
| 164 const ViewHierarchyChangedDetails& details) override { | 164 const ViewHierarchyChangedDetails& details) override { |
| 165 if (details.is_add && details.child == this) | 165 if (details.is_add && details.child == this) |
| 166 Init(); | 166 Init(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Holds the info icon image and text label and renders the border. | 169 // Holds the info icon image and text label and renders the border. |
| 170 views::View* content_; | 170 views::View* content_; |
| 171 // Info icon image. | 171 // Info icon image. |
| 172 views::ImageView* info_image_; | 172 views::ImageView* info_image_; |
| 173 // The label responsible for rendering the text. | 173 // The label responsible for rendering the text. |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 /////////////////////////////////////////////////////////////////////////////// | 532 /////////////////////////////////////////////////////////////////////////////// |
| 533 // CollectedCookiesViews, content::NotificationObserver implementation: | 533 // CollectedCookiesViews, content::NotificationObserver implementation: |
| 534 | 534 |
| 535 void CollectedCookiesViews::Observe( | 535 void CollectedCookiesViews::Observe( |
| 536 int type, | 536 int type, |
| 537 const content::NotificationSource& source, | 537 const content::NotificationSource& source, |
| 538 const content::NotificationDetails& details) { | 538 const content::NotificationDetails& details) { |
| 539 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 539 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
| 540 GetWidget()->Close(); | 540 GetWidget()->Close(); |
| 541 } | 541 } |
| OLD | NEW |