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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (i->second.disabled) | 330 if (i->second.disabled) |
331 menu_button->SetEnabled(false); | 331 menu_button->SetEnabled(false); |
332 | 332 |
333 layout->AddView(label); | 333 layout->AddView(label); |
334 layout->AddView(menu_button); | 334 layout->AddView(menu_button); |
335 | 335 |
336 bubble_content_empty = false; | 336 bubble_content_empty = false; |
337 } | 337 } |
338 } | 338 } |
339 | 339 |
340 UpdateMenuButtonSizes(GetNativeTheme()); | 340 UpdateMenuButtonSizes(); |
341 | 341 |
342 const gfx::FontList& domain_font = | 342 const gfx::FontList& domain_font = |
343 ui::ResourceBundle::GetSharedInstance().GetFontList( | 343 ui::ResourceBundle::GetSharedInstance().GetFontList( |
344 ui::ResourceBundle::BoldFont); | 344 ui::ResourceBundle::BoldFont); |
345 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( | 345 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( |
346 bubble_content.domain_lists.begin()); | 346 bubble_content.domain_lists.begin()); |
347 i != bubble_content.domain_lists.end(); ++i) { | 347 i != bubble_content.domain_lists.end(); ++i) { |
348 layout->StartRow(0, kSingleColumnSetId); | 348 layout->StartRow(0, kSingleColumnSetId); |
349 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); | 349 views::Label* section_title = new views::Label(base::UTF8ToUTF16(i->title)); |
350 section_title->SetMultiLine(true); | 350 section_title->SetMultiLine(true); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 void ContentSettingBubbleContents::DidNavigateMainFrame( | 403 void ContentSettingBubbleContents::DidNavigateMainFrame( |
404 const content::LoadCommittedDetails& details, | 404 const content::LoadCommittedDetails& details, |
405 const content::FrameNavigateParams& params) { | 405 const content::FrameNavigateParams& params) { |
406 // Content settings are based on the main frame, so if it switches then | 406 // Content settings are based on the main frame, so if it switches then |
407 // close up shop. | 407 // close up shop. |
408 content_setting_bubble_model_->OnDoneClicked(); | 408 content_setting_bubble_model_->OnDoneClicked(); |
409 GetWidget()->Close(); | 409 GetWidget()->Close(); |
410 } | 410 } |
411 | 411 |
412 void ContentSettingBubbleContents::OnNativeThemeChanged( | |
413 const ui::NativeTheme* theme) { | |
414 views::BubbleDelegateView::OnNativeThemeChanged(theme); | |
415 UpdateMenuButtonSizes(theme); | |
416 } | |
417 | |
418 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, | 412 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, |
419 const ui::Event& event) { | 413 const ui::Event& event) { |
420 RadioGroup::const_iterator i( | 414 RadioGroup::const_iterator i( |
421 std::find(radio_group_.begin(), radio_group_.end(), sender)); | 415 std::find(radio_group_.begin(), radio_group_.end(), sender)); |
422 if (i != radio_group_.end()) { | 416 if (i != radio_group_.end()) { |
423 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); | 417 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); |
424 return; | 418 return; |
425 } | 419 } |
426 DCHECK_EQ(sender, close_button_); | 420 DCHECK_EQ(sender, close_button_); |
427 content_setting_bubble_model_->OnDoneClicked(); | 421 content_setting_bubble_model_->OnDoneClicked(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 gfx::Point screen_location; | 459 gfx::Point screen_location; |
466 views::View::ConvertPointToScreen(j->first, &screen_location); | 460 views::View::ConvertPointToScreen(j->first, &screen_location); |
467 ignore_result( | 461 ignore_result( |
468 menu_runner_->RunMenuAt(source->GetWidget(), | 462 menu_runner_->RunMenuAt(source->GetWidget(), |
469 j->first, | 463 j->first, |
470 gfx::Rect(screen_location, j->first->size()), | 464 gfx::Rect(screen_location, j->first->size()), |
471 views::MENU_ANCHOR_TOPLEFT, | 465 views::MENU_ANCHOR_TOPLEFT, |
472 ui::MENU_SOURCE_NONE)); | 466 ui::MENU_SOURCE_NONE)); |
473 } | 467 } |
474 | 468 |
475 void ContentSettingBubbleContents::UpdateMenuButtonSizes( | 469 void ContentSettingBubbleContents::UpdateMenuButtonSizes() { |
476 const ui::NativeTheme* theme) { | 470 const views::MenuConfig& config = views::MenuConfig::instance(); |
477 const views::MenuConfig config = views::MenuConfig(theme); | |
478 const int margins = config.item_left_margin + config.check_width + | 471 const int margins = config.item_left_margin + config.check_width + |
479 config.label_to_arrow_padding + config.arrow_width + | 472 config.label_to_arrow_padding + config.arrow_width + |
480 config.arrow_to_edge_padding; | 473 config.arrow_to_edge_padding; |
481 | 474 |
482 // The preferred media menu size sort of copies the logic in | 475 // The preferred media menu size sort of copies the logic in |
483 // MenuItemView::CalculateDimensions(). When this was using TextButton, it | 476 // MenuItemView::CalculateDimensions(). When this was using TextButton, it |
484 // completely coincidentally matched the logic in MenuItemView. We now need | 477 // completely coincidentally matched the logic in MenuItemView. We now need |
485 // to redo this manually. | 478 // to redo this manually. |
486 int menu_width = 0; | 479 int menu_width = 0; |
487 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); | 480 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); |
(...skipping 10 matching lines...) Expand all Loading... |
498 // Make sure the width is at least kMinMediaMenuButtonWidth. The | 491 // Make sure the width is at least kMinMediaMenuButtonWidth. The |
499 // maximum width will be clamped by kMaxContentsWidth of the view. | 492 // maximum width will be clamped by kMaxContentsWidth of the view. |
500 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); | 493 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); |
501 | 494 |
502 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); | 495 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); |
503 i != media_menus_.end(); ++i) { | 496 i != media_menus_.end(); ++i) { |
504 i->first->SetMinSize(gfx::Size(menu_width, 0)); | 497 i->first->SetMinSize(gfx::Size(menu_width, 0)); |
505 i->first->SetMaxSize(gfx::Size(menu_width, 0)); | 498 i->first->SetMaxSize(gfx::Size(menu_width, 0)); |
506 } | 499 } |
507 } | 500 } |
OLD | NEW |