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/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 WebContents* web_contents, | 101 WebContents* web_contents, |
102 views::View* anchor_view, | 102 views::View* anchor_view, |
103 views::BubbleBorder::ArrowLocation arrow_location) | 103 views::BubbleBorder::ArrowLocation arrow_location) |
104 : BubbleDelegateView(anchor_view, arrow_location), | 104 : BubbleDelegateView(anchor_view, arrow_location), |
105 content_setting_bubble_model_(content_setting_bubble_model), | 105 content_setting_bubble_model_(content_setting_bubble_model), |
106 profile_(profile), | 106 profile_(profile), |
107 web_contents_(web_contents), | 107 web_contents_(web_contents), |
108 custom_link_(NULL), | 108 custom_link_(NULL), |
109 manage_link_(NULL), | 109 manage_link_(NULL), |
110 close_button_(NULL) { | 110 close_button_(NULL) { |
| 111 // Compensate for built-in vertical padding in the anchor view's image. |
| 112 set_anchor_insets(gfx::Insets(5, 0, 5, 0)); |
| 113 |
111 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 114 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
112 content::Source<WebContents>(web_contents)); | 115 content::Source<WebContents>(web_contents)); |
113 } | 116 } |
114 | 117 |
115 ContentSettingBubbleContents::~ContentSettingBubbleContents() { | 118 ContentSettingBubbleContents::~ContentSettingBubbleContents() { |
116 } | 119 } |
117 | 120 |
118 gfx::Size ContentSettingBubbleContents::GetPreferredSize() { | 121 gfx::Size ContentSettingBubbleContents::GetPreferredSize() { |
119 gfx::Size preferred_size(views::View::GetPreferredSize()); | 122 gfx::Size preferred_size(views::View::GetPreferredSize()); |
120 int preferred_width = | 123 int preferred_width = |
121 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && | 124 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && |
122 (kMinMultiLineContentsWidth > preferred_size.width())) ? | 125 (kMinMultiLineContentsWidth > preferred_size.width())) ? |
123 kMinMultiLineContentsWidth : preferred_size.width(); | 126 kMinMultiLineContentsWidth : preferred_size.width(); |
124 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); | 127 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); |
125 return preferred_size; | 128 return preferred_size; |
126 } | 129 } |
127 | 130 |
128 gfx::Rect ContentSettingBubbleContents::GetAnchorRect() { | |
129 gfx::Rect rect(BubbleDelegateView::GetAnchorRect()); | |
130 rect.Inset(0, anchor_view() ? 5 : 0); | |
131 return rect; | |
132 } | |
133 | |
134 void ContentSettingBubbleContents::Init() { | 131 void ContentSettingBubbleContents::Init() { |
135 using views::GridLayout; | 132 using views::GridLayout; |
136 | 133 |
137 GridLayout* layout = new views::GridLayout(this); | 134 GridLayout* layout = new views::GridLayout(this); |
138 SetLayoutManager(layout); | 135 SetLayoutManager(layout); |
139 | 136 |
140 const int single_column_set_id = 0; | 137 const int single_column_set_id = 0; |
141 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id); | 138 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id); |
142 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 139 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
143 GridLayout::USE_PREF, 0, 0); | 140 GridLayout::USE_PREF, 0, 0); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 321 } |
325 | 322 |
326 void ContentSettingBubbleContents::Observe( | 323 void ContentSettingBubbleContents::Observe( |
327 int type, | 324 int type, |
328 const content::NotificationSource& source, | 325 const content::NotificationSource& source, |
329 const content::NotificationDetails& details) { | 326 const content::NotificationDetails& details) { |
330 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); | 327 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); |
331 DCHECK(source == content::Source<WebContents>(web_contents_)); | 328 DCHECK(source == content::Source<WebContents>(web_contents_)); |
332 web_contents_ = NULL; | 329 web_contents_ = NULL; |
333 } | 330 } |
OLD | NEW |