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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.mm

Issue 2408613002: Replace kPreferHtmlOverPlugins feature checks with PluginUtils::ShouldPreferHtmlOverPlugi… (Closed)
Patch Set: Replace remaining kPreferHtmlOverPlugins feature checks with PluginUtils::ShouldPreferHtmlOverPlugi… Created 4 years, 2 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/bind_objc_block.h" 9 #include "base/mac/bind_objc_block.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // multiple permissions in the bubble. 77 // multiple permissions in the bubble.
78 @interface AllowBlockMenuButton : NSPopUpButton { 78 @interface AllowBlockMenuButton : NSPopUpButton {
79 @private 79 @private
80 std::unique_ptr<PermissionMenuModel> menuModel_; 80 std::unique_ptr<PermissionMenuModel> menuModel_;
81 base::scoped_nsobject<MenuController> menuController_; 81 base::scoped_nsobject<MenuController> menuController_;
82 } 82 }
83 83
84 - (id)initForURL:(const GURL&)url 84 - (id)initForURL:(const GURL&)url
85 allowed:(BOOL)allow 85 allowed:(BOOL)allow
86 index:(int)index 86 index:(int)index
87 delegate:(PermissionPrompt::Delegate*)delegate; 87 delegate:(PermissionPrompt::Delegate*)delegate
88 profile:(Profile*)profile;
88 89
89 // Returns the maximum width of its possible titles. 90 // Returns the maximum width of its possible titles.
90 - (CGFloat)maximumTitleWidth; 91 - (CGFloat)maximumTitleWidth;
91 @end 92 @end
92 93
93 @implementation AllowBlockMenuButton 94 @implementation AllowBlockMenuButton
94 95
95 - (id)initForURL:(const GURL&)url 96 - (id)initForURL:(const GURL&)url
96 allowed:(BOOL)allow 97 allowed:(BOOL)allow
97 index:(int)index 98 index:(int)index
98 delegate:(PermissionPrompt::Delegate*)delegate { 99 delegate:(PermissionPrompt::Delegate*)delegate
100 profile:(Profile*)profile {
99 if (self = [super initWithFrame:NSZeroRect pullsDown:NO]) { 101 if (self = [super initWithFrame:NSZeroRect pullsDown:NO]) {
100 ContentSetting setting = 102 ContentSetting setting =
101 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 103 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
102 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 104 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
103 [self setBordered:NO]; 105 [self setBordered:NO];
104 106
105 __block PermissionPrompt::Delegate* blockDelegate = delegate; 107 __block PermissionPrompt::Delegate* blockDelegate = delegate;
106 __block AllowBlockMenuButton* blockSelf = self; 108 __block AllowBlockMenuButton* blockSelf = self;
107 PermissionMenuModel::ChangeCallback changeCallback = 109 PermissionMenuModel::ChangeCallback changeCallback =
108 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { 110 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) {
109 blockDelegate->ToggleAccept( 111 blockDelegate->ToggleAccept(
110 index, permission.setting == CONTENT_SETTING_ALLOW); 112 index, permission.setting == CONTENT_SETTING_ALLOW);
111 [blockSelf setFrameSize: 113 [blockSelf setFrameSize:
112 SizeForWebsiteSettingsButtonTitle(blockSelf, 114 SizeForWebsiteSettingsButtonTitle(blockSelf,
113 [blockSelf title])]; 115 [blockSelf title])];
114 }); 116 });
115 117
116 menuModel_.reset(new PermissionMenuModel(url, setting, changeCallback)); 118 menuModel_.reset(
119 new PermissionMenuModel(profile, url, setting, changeCallback));
117 menuController_.reset([[MenuController alloc] initWithModel:menuModel_.get() 120 menuController_.reset([[MenuController alloc] initWithModel:menuModel_.get()
118 useWithPopUpButtonCell:NO]); 121 useWithPopUpButtonCell:NO]);
119 [self setMenu:[menuController_ menu]]; 122 [self setMenu:[menuController_ menu]];
120 [self selectItemAtIndex:menuModel_->GetIndexOfCommandId(setting)]; 123 [self selectItemAtIndex:menuModel_->GetIndexOfCommandId(setting)];
121 // Although the frame is reset, below, this sizes the cell properly. 124 // Although the frame is reset, below, this sizes the cell properly.
122 [self sizeToFit]; 125 [self sizeToFit];
123 // Adjust the size to fit the current title. Using only -sizeToFit leaves 126 // Adjust the size to fit the current title. Using only -sizeToFit leaves
124 // an ugly amount of whitespace between the title and the arrows because it 127 // an ugly amount of whitespace between the title and the arrows because it
125 // will fit to the largest element in the menu, not just the selected item. 128 // will fit to the largest element in the menu, not just the selected item.
126 [self setFrameSize:SizeForWebsiteSettingsButtonTitle(self, [self title])]; 129 [self setFrameSize:SizeForWebsiteSettingsButtonTitle(self, [self title])];
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 575
573 - (NSView*)menuForRequest:(PermissionRequest*)request 576 - (NSView*)menuForRequest:(PermissionRequest*)request
574 atIndex:(int)index 577 atIndex:(int)index
575 allow:(BOOL)allow { 578 allow:(BOOL)allow {
576 DCHECK(request); 579 DCHECK(request);
577 DCHECK(delegate_); 580 DCHECK(delegate_);
578 base::scoped_nsobject<AllowBlockMenuButton> button( 581 base::scoped_nsobject<AllowBlockMenuButton> button(
579 [[AllowBlockMenuButton alloc] initForURL:request->GetOrigin() 582 [[AllowBlockMenuButton alloc] initForURL:request->GetOrigin()
580 allowed:allow 583 allowed:allow
581 index:index 584 index:index
582 delegate:delegate_]); 585 delegate:delegate_
586 profile:browser_->profile()]);
583 return button.autorelease(); 587 return button.autorelease();
584 } 588 }
585 589
586 - (NSView*)buttonWithTitle:(NSString*)title 590 - (NSView*)buttonWithTitle:(NSString*)title
587 action:(SEL)action { 591 action:(SEL)action {
588 base::scoped_nsobject<NSButton> button( 592 base::scoped_nsobject<NSButton> button(
589 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); 593 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
590 [button setButtonType:NSMomentaryPushInButton]; 594 [button setButtonType:NSMomentaryPushInButton];
591 [button setTitle:title]; 595 [button setTitle:title];
592 [button setTarget:self]; 596 [button setTarget:self];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 658
655 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { 659 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB {
656 NSRect frameA = [viewA frame]; 660 NSRect frameA = [viewA frame];
657 NSRect frameB = [viewB frame]; 661 NSRect frameB = [viewB frame];
658 frameA.origin.y = 662 frameA.origin.y =
659 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); 663 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2);
660 [viewA setFrameOrigin:frameA.origin]; 664 [viewA setFrameOrigin:frameA.origin];
661 } 665 }
662 666
663 @end // implementation PermissionBubbleController 667 @end // implementation PermissionBubbleController
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugins_field_trial.cc ('k') | chrome/browser/ui/cocoa/website_settings/permission_selector_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698