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

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

Issue 1514693006: Revert of Use a single views::MenuConfig instance for each platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase revert on https://codereview.chromium.org/1504743003 Created 5 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
OLDNEW
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
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(); 340 UpdateMenuButtonSizes(GetNativeTheme());
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
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
412 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, 418 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
413 const ui::Event& event) { 419 const ui::Event& event) {
414 RadioGroup::const_iterator i( 420 RadioGroup::const_iterator i(
415 std::find(radio_group_.begin(), radio_group_.end(), sender)); 421 std::find(radio_group_.begin(), radio_group_.end(), sender));
416 if (i != radio_group_.end()) { 422 if (i != radio_group_.end()) {
417 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); 423 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
418 return; 424 return;
419 } 425 }
420 DCHECK_EQ(sender, close_button_); 426 DCHECK_EQ(sender, close_button_);
421 content_setting_bubble_model_->OnDoneClicked(); 427 content_setting_bubble_model_->OnDoneClicked();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 gfx::Point screen_location; 465 gfx::Point screen_location;
460 views::View::ConvertPointToScreen(j->first, &screen_location); 466 views::View::ConvertPointToScreen(j->first, &screen_location);
461 ignore_result( 467 ignore_result(
462 menu_runner_->RunMenuAt(source->GetWidget(), 468 menu_runner_->RunMenuAt(source->GetWidget(),
463 j->first, 469 j->first,
464 gfx::Rect(screen_location, j->first->size()), 470 gfx::Rect(screen_location, j->first->size()),
465 views::MENU_ANCHOR_TOPLEFT, 471 views::MENU_ANCHOR_TOPLEFT,
466 ui::MENU_SOURCE_NONE)); 472 ui::MENU_SOURCE_NONE));
467 } 473 }
468 474
469 void ContentSettingBubbleContents::UpdateMenuButtonSizes() { 475 void ContentSettingBubbleContents::UpdateMenuButtonSizes(
470 const views::MenuConfig& config = views::MenuConfig::instance(); 476 const ui::NativeTheme* theme) {
477 const views::MenuConfig config = views::MenuConfig(theme);
471 const int margins = config.item_left_margin + config.check_width + 478 const int margins = config.item_left_margin + config.check_width +
472 config.label_to_arrow_padding + config.arrow_width + 479 config.label_to_arrow_padding + config.arrow_width +
473 config.arrow_to_edge_padding; 480 config.arrow_to_edge_padding;
474 481
475 // The preferred media menu size sort of copies the logic in 482 // The preferred media menu size sort of copies the logic in
476 // MenuItemView::CalculateDimensions(). When this was using TextButton, it 483 // MenuItemView::CalculateDimensions(). When this was using TextButton, it
477 // completely coincidentally matched the logic in MenuItemView. We now need 484 // completely coincidentally matched the logic in MenuItemView. We now need
478 // to redo this manually. 485 // to redo this manually.
479 int menu_width = 0; 486 int menu_width = 0;
480 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); 487 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin();
(...skipping 10 matching lines...) Expand all
491 // Make sure the width is at least kMinMediaMenuButtonWidth. The 498 // Make sure the width is at least kMinMediaMenuButtonWidth. The
492 // maximum width will be clamped by kMaxContentsWidth of the view. 499 // maximum width will be clamped by kMaxContentsWidth of the view.
493 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); 500 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins);
494 501
495 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); 502 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin();
496 i != media_menus_.end(); ++i) { 503 i != media_menus_.end(); ++i) {
497 i->first->SetMinSize(gfx::Size(menu_width, 0)); 504 i->first->SetMinSize(gfx::Size(menu_width, 0));
498 i->first->SetMaxSize(gfx::Size(menu_width, 0)); 505 i->first->SetMaxSize(gfx::Size(menu_width, 0));
499 } 506 }
500 } 507 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/content_setting_bubble_contents.h ('k') | chrome/browser/ui/views/toolbar/app_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698