Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/ui/views/content_setting_bubble_contents.cc

Issue 5564007: Update Content Settings Bubbles (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/content_setting_bubble_contents.h" 5 #include "chrome/browser/views/content_setting_bubble_contents.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #endif 9 #endif
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 ContentSettingBubbleContents::ContentSettingBubbleContents( 110 ContentSettingBubbleContents::ContentSettingBubbleContents(
111 ContentSettingBubbleModel* content_setting_bubble_model, 111 ContentSettingBubbleModel* content_setting_bubble_model,
112 Profile* profile, 112 Profile* profile,
113 TabContents* tab_contents) 113 TabContents* tab_contents)
114 : content_setting_bubble_model_(content_setting_bubble_model), 114 : content_setting_bubble_model_(content_setting_bubble_model),
115 profile_(profile), 115 profile_(profile),
116 tab_contents_(tab_contents), 116 tab_contents_(tab_contents),
117 info_bubble_(NULL), 117 info_bubble_(NULL),
118 close_button_(NULL), 118 close_button_(NULL),
119 manage_link_(NULL), 119 manage_link_(NULL),
120 clear_link_(NULL), 120 info_link_(NULL) {
121 info_link_(NULL),
122 load_plugins_link_(NULL) {
123 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 121 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
124 Source<TabContents>(tab_contents)); 122 Source<TabContents>(tab_contents));
125 } 123 }
126 124
127 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 125 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
128 } 126 }
129 127
130 gfx::Size ContentSettingBubbleContents::GetPreferredSize() { 128 gfx::Size ContentSettingBubbleContents::GetPreferredSize() {
131 gfx::Size preferred_size(views::View::GetPreferredSize()); 129 gfx::Size preferred_size(views::View::GetPreferredSize());
132 int preferred_width = 130 int preferred_width =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 162
165 void ContentSettingBubbleContents::LinkActivated(views::Link* source, 163 void ContentSettingBubbleContents::LinkActivated(views::Link* source,
166 int event_flags) { 164 int event_flags) {
167 if (source == manage_link_) { 165 if (source == manage_link_) {
168 info_bubble_->set_fade_away_on_close(true); 166 info_bubble_->set_fade_away_on_close(true);
169 content_setting_bubble_model_->OnManageLinkClicked(); 167 content_setting_bubble_model_->OnManageLinkClicked();
170 // CAREFUL: Showing the settings window activates it, which deactivates the 168 // CAREFUL: Showing the settings window activates it, which deactivates the
171 // info bubble, which causes it to close, which deletes us. 169 // info bubble, which causes it to close, which deletes us.
172 return; 170 return;
173 } 171 }
174 if (source == clear_link_) {
175 content_setting_bubble_model_->OnClearLinkClicked();
176 info_bubble_->set_fade_away_on_close(true);
177 info_bubble_->Close(); // CAREFUL: This deletes us.
178 return;
179 }
180 if (source == info_link_) { 172 if (source == info_link_) {
181 content_setting_bubble_model_->OnInfoLinkClicked(); 173 content_setting_bubble_model_->OnInfoLinkClicked();
182 info_bubble_->set_fade_away_on_close(true); 174 info_bubble_->set_fade_away_on_close(true);
183 info_bubble_->Close(); // CAREFUL: This deletes us. 175 info_bubble_->Close(); // CAREFUL: This deletes us.
184 return; 176 return;
185 } 177 }
186 if (source == load_plugins_link_) {
187 content_setting_bubble_model_->OnLoadPluginsLinkClicked();
188 info_bubble_->set_fade_away_on_close(true);
189 info_bubble_->Close(); // CAREFUL: This deletes us.
190 return;
191 }
192 178
193 PopupLinks::const_iterator i(popup_links_.find(source)); 179 PopupLinks::const_iterator i(popup_links_.find(source));
194 DCHECK(i != popup_links_.end()); 180 DCHECK(i != popup_links_.end());
195 content_setting_bubble_model_->OnPopupClicked(i->second); 181 content_setting_bubble_model_->OnPopupClicked(i->second);
196 } 182 }
197 183
198 void ContentSettingBubbleContents::Observe(NotificationType type, 184 void ContentSettingBubbleContents::Observe(NotificationType type,
199 const NotificationSource& source, 185 const NotificationSource& source,
200 const NotificationDetails& details) { 186 const NotificationDetails& details) {
201 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); 187 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED);
(...skipping 13 matching lines...) Expand all
215 GridLayout::USE_PREF, 0, 0); 201 GridLayout::USE_PREF, 0, 0);
216 202
217 const ContentSettingBubbleModel::BubbleContent& bubble_content = 203 const ContentSettingBubbleModel::BubbleContent& bubble_content =
218 content_setting_bubble_model_->bubble_content(); 204 content_setting_bubble_model_->bubble_content();
219 205
220 if (!bubble_content.title.empty()) { 206 if (!bubble_content.title.empty()) {
221 views::Label* title_label = new views::Label(UTF8ToWide( 207 views::Label* title_label = new views::Label(UTF8ToWide(
222 bubble_content.title)); 208 bubble_content.title));
223 layout->StartRow(0, single_column_set_id); 209 layout->StartRow(0, single_column_set_id);
224 layout->AddView(title_label); 210 layout->AddView(title_label);
225 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
226 } 211 }
227 212
228 const std::set<std::string>& plugins = bubble_content.resource_identifiers; 213 const std::set<std::string>& plugins = bubble_content.resource_identifiers;
229 if (!plugins.empty()) { 214 if (!plugins.empty()) {
215 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
Peter Kasting 2010/12/07 17:53:00 Seems like we need to be a little more careful in
230 for (std::set<std::string>::const_iterator it = plugins.begin(); 216 for (std::set<std::string>::const_iterator it = plugins.begin();
231 it != plugins.end(); ++it) { 217 it != plugins.end(); ++it) {
232 std::wstring name; 218 std::wstring name;
233 NPAPI::PluginList::PluginMap groups; 219 NPAPI::PluginList::PluginMap groups;
234 NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups); 220 NPAPI::PluginList::Singleton()->GetPluginGroups(false, &groups);
235 if (groups.find(*it) != groups.end()) 221 if (groups.find(*it) != groups.end())
236 name = UTF16ToWide(groups[*it]->GetGroupName()); 222 name = UTF16ToWide(groups[*it]->GetGroupName());
237 else 223 else
238 name = UTF8ToWide(*it); 224 name = UTF8ToWide(*it);
239 layout->StartRow(0, single_column_set_id); 225 layout->StartRow(0, single_column_set_id);
240 layout->AddView(new views::Label(name)); 226 layout->AddView(new views::Label(name));
241 } 227 }
242 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
243 } 228 }
244 229
245 if (content_setting_bubble_model_->content_type() == 230 if (content_setting_bubble_model_->content_type() ==
246 CONTENT_SETTINGS_TYPE_POPUPS) { 231 CONTENT_SETTINGS_TYPE_POPUPS) {
247 const int popup_column_set_id = 2; 232 const int popup_column_set_id = 2;
248 views::ColumnSet* popup_column_set = 233 views::ColumnSet* popup_column_set =
249 layout->AddColumnSet(popup_column_set_id); 234 layout->AddColumnSet(popup_column_set_id);
250 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0, 235 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
251 GridLayout::USE_PREF, 0, 0); 236 GridLayout::USE_PREF, 0, 0);
252 popup_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 237 popup_column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
253 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 238 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
254 GridLayout::USE_PREF, 0, 0); 239 GridLayout::USE_PREF, 0, 0);
255 240
256 for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator 241 for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator
257 i(bubble_content.popup_items.begin()); 242 i(bubble_content.popup_items.begin());
258 i != bubble_content.popup_items.end(); ++i) { 243 i != bubble_content.popup_items.end(); ++i) {
259 if (i != bubble_content.popup_items.begin()) 244 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
260 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
261 layout->StartRow(0, popup_column_set_id); 245 layout->StartRow(0, popup_column_set_id);
262 246
263 views::Link* link = new views::Link(UTF8ToWide(i->title)); 247 views::Link* link = new views::Link(UTF8ToWide(i->title));
264 link->SetController(this); 248 link->SetController(this);
265 link->SetElideInMiddle(true); 249 link->SetElideInMiddle(true);
266 popup_links_[link] = i - bubble_content.popup_items.begin(); 250 popup_links_[link] = i - bubble_content.popup_items.begin();
267 layout->AddView(new Favicon((*i).bitmap, this, link)); 251 layout->AddView(new Favicon((*i).bitmap, this, link));
268 layout->AddView(link); 252 layout->AddView(link);
269 } 253 }
270 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
271
272 views::Separator* separator = new views::Separator;
273 layout->StartRow(0, single_column_set_id);
274 layout->AddView(separator);
275 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
276 } 254 }
277 255
278 const ContentSettingBubbleModel::RadioGroup& radio_group = 256 const ContentSettingBubbleModel::RadioGroup& radio_group =
279 bubble_content.radio_group; 257 bubble_content.radio_group;
280 for (ContentSettingBubbleModel::RadioItems::const_iterator i = 258 if (!radio_group.radio_items.empty()) {
281 radio_group.radio_items.begin(); 259 for (ContentSettingBubbleModel::RadioItems::const_iterator i =
282 i != radio_group.radio_items.end(); ++i) { 260 radio_group.radio_items.begin();
283 views::RadioButton* radio = new views::RadioButton(UTF8ToWide(*i), 0); 261 i != radio_group.radio_items.end(); ++i) {
284 radio->set_listener(this); 262 views::RadioButton* radio = new views::RadioButton(UTF8ToWide(*i), 0);
285 radio_group_.push_back(radio); 263 radio->set_listener(this);
286 layout->StartRow(0, single_column_set_id); 264 radio_group_.push_back(radio);
287 layout->AddView(radio); 265 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
288 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 266 layout->StartRow(0, single_column_set_id);
289 } 267 layout->AddView(radio);
290 if (!radio_group_.empty()) { 268 }
291 views::Separator* separator = new views::Separator; 269 DCHECK(!radio_group_.empty());
292 layout->StartRow(0, single_column_set_id);
293 layout->AddView(separator, 1, 1, GridLayout::FILL, GridLayout::FILL);
294 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
295 // Now that the buttons have been added to the view hierarchy, it's safe 270 // Now that the buttons have been added to the view hierarchy, it's safe
296 // to call SetChecked() on them. 271 // to call SetChecked() on them.
297 radio_group_[radio_group.default_item]->SetChecked(true); 272 radio_group_[radio_group.default_item]->SetChecked(true);
298 } 273 }
299 274
300 gfx::Font domain_font = 275 gfx::Font domain_font =
301 views::Label().font().DeriveFont(0, gfx::Font::BOLD); 276 views::Label().font().DeriveFont(0, gfx::Font::BOLD);
302 const int indented_single_column_set_id = 3; 277 const int indented_single_column_set_id = 3;
303 // Insert a column set to indent the domain list. 278 // Insert a column set to indent the domain list.
304 views::ColumnSet* indented_single_column_set = 279 views::ColumnSet* indented_single_column_set =
305 layout->AddColumnSet(indented_single_column_set_id); 280 layout->AddColumnSet(indented_single_column_set_id);
306 indented_single_column_set->AddPaddingColumn(0, kPanelHorizIndentation); 281 indented_single_column_set->AddPaddingColumn(0, kPanelHorizIndentation);
307 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 282 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
308 1, GridLayout::USE_PREF, 0, 0); 283 1, GridLayout::USE_PREF, 0, 0);
309 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i = 284 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i =
310 bubble_content.domain_lists.begin(); 285 bubble_content.domain_lists.begin();
311 i != bubble_content.domain_lists.end(); ++i) { 286 i != bubble_content.domain_lists.end(); ++i) {
312 layout->StartRow(0, single_column_set_id); 287 layout->StartRow(0, single_column_set_id);
313 views::Label* section_title = new views::Label(UTF8ToWide(i->title)); 288 views::Label* section_title = new views::Label(UTF8ToWide(i->title));
314 section_title->SetMultiLine(true); 289 section_title->SetMultiLine(true);
315 section_title->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 290 section_title->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
316 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING); 291 layout->AddView(section_title, 1, 1, GridLayout::FILL, GridLayout::LEADING);
317 for (std::set<std::string>::const_iterator j = i->hosts.begin(); 292 for (std::set<std::string>::const_iterator j = i->hosts.begin();
318 j != i->hosts.end(); ++j) { 293 j != i->hosts.end(); ++j) {
319 layout->StartRow(0, indented_single_column_set_id); 294 layout->StartRow(0, indented_single_column_set_id);
320 layout->AddView(new views::Label(UTF8ToWide(*j), domain_font)); 295 layout->AddView(new views::Label(UTF8ToWide(*j), domain_font));
321 } 296 }
322 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
323 }
324
325 if (!bubble_content.clear_link.empty()) {
326 clear_link_ = new views::Link(UTF8ToWide(bubble_content.clear_link));
327 clear_link_->SetController(this);
328 layout->StartRow(0, single_column_set_id);
329 layout->AddView(clear_link_);
330
331 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
332 layout->StartRow(0, single_column_set_id);
333 layout->AddView(new views::Separator, 1, 1,
334 GridLayout::FILL, GridLayout::FILL);
335 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
336 } 297 }
337 298
338 if (!bubble_content.info_link.empty()) { 299 if (!bubble_content.info_link.empty()) {
339 info_link_ = new views::Link(UTF8ToWide(bubble_content.info_link)); 300 info_link_ = new views::Link(UTF8ToWide(bubble_content.info_link));
301 info_link_->SetEnabled(bubble_content.info_link_enabled);
340 info_link_->SetController(this); 302 info_link_->SetController(this);
303 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
341 layout->StartRow(0, single_column_set_id); 304 layout->StartRow(0, single_column_set_id);
342 layout->AddView(info_link_); 305 layout->AddView(info_link_);
343
344 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
345 layout->StartRow(0, single_column_set_id);
346 layout->AddView(new views::Separator, 1, 1,
347 GridLayout::FILL, GridLayout::FILL);
348 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
349 } 306 }
350 307
351 if (!bubble_content.load_plugins_link_title.empty()) { 308 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
352 load_plugins_link_ = new views::Link( 309 layout->StartRow(0, single_column_set_id);
353 UTF8ToWide(bubble_content.load_plugins_link_title)); 310 layout->AddView(new views::Separator, 1, 1,
354 load_plugins_link_->SetEnabled(bubble_content.load_plugins_link_enabled); 311 GridLayout::FILL, GridLayout::FILL);
355 load_plugins_link_->SetController(this); 312 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
356 layout->StartRow(0, single_column_set_id);
357 layout->AddView(load_plugins_link_);
358
359 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
360 layout->StartRow(0, single_column_set_id);
361 layout->AddView(new views::Separator, 1, 1,
362 GridLayout::FILL, GridLayout::FILL);
363 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
364 }
365 313
366 const int double_column_set_id = 1; 314 const int double_column_set_id = 1;
367 views::ColumnSet* double_column_set = 315 views::ColumnSet* double_column_set =
368 layout->AddColumnSet(double_column_set_id); 316 layout->AddColumnSet(double_column_set_id);
369 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, 317 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
370 GridLayout::USE_PREF, 0, 0); 318 GridLayout::USE_PREF, 0, 0);
371 double_column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing); 319 double_column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
372 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 320 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
373 GridLayout::USE_PREF, 0, 0); 321 GridLayout::USE_PREF, 0, 0);
374 322
375 layout->StartRow(0, double_column_set_id); 323 layout->StartRow(0, double_column_set_id);
376 manage_link_ = new views::Link(UTF8ToWide(bubble_content.manage_link)); 324 manage_link_ = new views::Link(UTF8ToWide(bubble_content.manage_link));
377 manage_link_->SetController(this); 325 manage_link_->SetController(this);
378 layout->AddView(manage_link_); 326 layout->AddView(manage_link_);
379 327
380 close_button_ = 328 close_button_ =
381 new views::NativeButton(this, l10n_util::GetString(IDS_DONE)); 329 new views::NativeButton(this, l10n_util::GetString(IDS_DONE));
382 layout->AddView(close_button_); 330 layout->AddView(close_button_);
383 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698