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

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

Issue 2182883002: Permissions: Rename PermissionBubbleView to PermissionPromptInterface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: thestig@ review Created 4 years, 4 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 11 matching lines...) Expand all
22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 22 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 23 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
25 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 25 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
26 #include "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h" 26 #include "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
27 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h" 27 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h"
28 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa. h" 28 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa. h"
29 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" 29 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
30 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" 30 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
31 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 31 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
32 #include "chrome/browser/ui/website_settings/permission_bubble_view.h"
33 #include "chrome/browser/ui/website_settings/permission_menu_model.h" 32 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
33 #include "chrome/browser/ui/website_settings/permission_prompt.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/grit/generated_resources.h" 35 #include "chrome/grit/generated_resources.h"
36 #include "components/prefs/pref_service.h" 36 #include "components/prefs/pref_service.h"
37 #include "components/url_formatter/elide_url.h" 37 #include "components/url_formatter/elide_url.h"
38 #include "content/public/browser/native_web_keyboard_event.h" 38 #include "content/public/browser/native_web_keyboard_event.h"
39 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
40 #include "grit/components_strings.h" 40 #include "grit/components_strings.h"
41 #include "skia/ext/skia_utils_mac.h" 41 #include "skia/ext/skia_utils_mac.h"
42 #include "ui/base/cocoa/cocoa_base_utils.h" 42 #include "ui/base/cocoa/cocoa_base_utils.h"
43 #import "ui/base/cocoa/controls/hyperlink_text_view.h" 43 #import "ui/base/cocoa/controls/hyperlink_text_view.h"
(...skipping 28 matching lines...) Expand all
72 // multiple permissions in the bubble. 72 // multiple permissions in the bubble.
73 @interface AllowBlockMenuButton : NSPopUpButton { 73 @interface AllowBlockMenuButton : NSPopUpButton {
74 @private 74 @private
75 std::unique_ptr<PermissionMenuModel> menuModel_; 75 std::unique_ptr<PermissionMenuModel> menuModel_;
76 base::scoped_nsobject<MenuController> menuController_; 76 base::scoped_nsobject<MenuController> menuController_;
77 } 77 }
78 78
79 - (id)initForURL:(const GURL&)url 79 - (id)initForURL:(const GURL&)url
80 allowed:(BOOL)allow 80 allowed:(BOOL)allow
81 index:(int)index 81 index:(int)index
82 delegate:(PermissionBubbleView::Delegate*)delegate; 82 delegate:(PermissionPrompt::Delegate*)delegate;
83 83
84 // Returns the maximum width of its possible titles. 84 // Returns the maximum width of its possible titles.
85 - (CGFloat)maximumTitleWidth; 85 - (CGFloat)maximumTitleWidth;
86 @end 86 @end
87 87
88 @implementation AllowBlockMenuButton 88 @implementation AllowBlockMenuButton
89 89
90 - (id)initForURL:(const GURL&)url 90 - (id)initForURL:(const GURL&)url
91 allowed:(BOOL)allow 91 allowed:(BOOL)allow
92 index:(int)index 92 index:(int)index
93 delegate:(PermissionBubbleView::Delegate*)delegate { 93 delegate:(PermissionPrompt::Delegate*)delegate {
94 if (self = [super initWithFrame:NSZeroRect pullsDown:NO]) { 94 if (self = [super initWithFrame:NSZeroRect pullsDown:NO]) {
95 ContentSetting setting = 95 ContentSetting setting =
96 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 96 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
97 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 97 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
98 [self setBordered:NO]; 98 [self setBordered:NO];
99 99
100 __block PermissionBubbleView::Delegate* blockDelegate = delegate; 100 __block PermissionPrompt::Delegate* blockDelegate = delegate;
101 __block AllowBlockMenuButton* blockSelf = self; 101 __block AllowBlockMenuButton* blockSelf = self;
102 PermissionMenuModel::ChangeCallback changeCallback = 102 PermissionMenuModel::ChangeCallback changeCallback =
103 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { 103 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) {
104 blockDelegate->ToggleAccept( 104 blockDelegate->ToggleAccept(
105 index, permission.setting == CONTENT_SETTING_ALLOW); 105 index, permission.setting == CONTENT_SETTING_ALLOW);
106 [blockSelf setFrameSize: 106 [blockSelf setFrameSize:
107 SizeForWebsiteSettingsButtonTitle(blockSelf, 107 SizeForWebsiteSettingsButtonTitle(blockSelf,
108 [blockSelf title])]; 108 [blockSelf title])];
109 }); 109 });
110 110
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 - (void)parentWindowDidResize:(NSNotification*)notification { 302 - (void)parentWindowDidResize:(NSNotification*)notification {
303 DCHECK(bridge_); 303 DCHECK(bridge_);
304 [self updateAnchorPosition]; 304 [self updateAnchorPosition];
305 } 305 }
306 306
307 - (void)parentWindowDidMove:(NSNotification*)notification { 307 - (void)parentWindowDidMove:(NSNotification*)notification {
308 DCHECK(bridge_); 308 DCHECK(bridge_);
309 [self setAnchorPoint:[self getExpectedAnchorPoint]]; 309 [self setAnchorPoint:[self getExpectedAnchorPoint]];
310 } 310 }
311 311
312 - (void)showWithDelegate:(PermissionBubbleView::Delegate*)delegate 312 - (void)showWithDelegate:(PermissionPrompt::Delegate*)delegate
313 forRequests:(const std::vector<PermissionRequest*>&)requests 313 forRequests:(const std::vector<PermissionRequest*>&)requests
314 acceptStates:(const std::vector<bool>&)acceptStates { 314 acceptStates:(const std::vector<bool>&)acceptStates {
315 DCHECK(!requests.empty()); 315 DCHECK(!requests.empty());
316 DCHECK(delegate); 316 DCHECK(delegate);
317 delegate_ = delegate; 317 delegate_ = delegate;
318 318
319 NSView* contentView = [[self window] contentView]; 319 NSView* contentView = [[self window] contentView];
320 [contentView setSubviews:@[]]; 320 [contentView setSubviews:@[]];
321 321
322 BOOL singlePermission = requests.size() == 1; 322 BOOL singlePermission = requests.size() == 1;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 638
639 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { 639 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB {
640 NSRect frameA = [viewA frame]; 640 NSRect frameA = [viewA frame];
641 NSRect frameB = [viewB frame]; 641 NSRect frameB = [viewB frame];
642 frameA.origin.y = 642 frameA.origin.y =
643 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); 643 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2);
644 [viewA setFrameOrigin:frameA.origin]; 644 [viewA setFrameOrigin:frameA.origin];
645 } 645 }
646 646
647 @end // implementation PermissionBubbleController 647 @end // implementation PermissionBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698