1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.h"
#include <cmath>
#import <AppKit/AppKit.h>
#include "base/i18n/rtl.h"
#include "base/mac/bind_objc_block.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/certificate_viewer.h"
#include "chrome/browser/devtools/devtools_toggle_action.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_dialogs.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
#import "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/website_settings/permission_menu_model.h"
#include "chrome/browser/ui/website_settings/website_settings_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/cert_store.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "grit/components_chromium_strings.h"
#include "grit/components_google_chrome_strings.h"
#include "grit/components_strings.h"
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/base/cocoa/controls/hyperlink_button_cell.h"
#import "ui/base/cocoa/flipped_view.h"
#import "ui/base/cocoa/hover_image_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#import "ui/gfx/mac/coordinate_conversion.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#include "ui/resources/grit/ui_resources.h"
using ChosenObjectInfoPtr = scoped_ptr<WebsiteSettingsUI::ChosenObjectInfo>;
using ChosenObjectDeleteCallback =
base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>;
namespace {
// The default width of the window, in view coordinates. It may be larger to
// fit the content.
const CGFloat kDefaultWindowWidth = 310;
// Padding between the window frame and content.
const CGFloat kFramePadding = 20;
// Padding between the window frame and content.
const CGFloat kVerticalSectionMargin = 16;
// Padding between the window frame and content for the internal page bubble.
const CGFloat kInternalPageFramePadding = 10;
// Spacing between the identity field and the security summary.
const CGFloat kSpacingBeforeSecuritySummary = 2;
// Spacing between the security summary and the reset decisions button.
const CGFloat kSpacingBeforeResetDecisionsButton = 8;
// Spacing between parts of the site settings section.
const CGFloat kSiteSettingsSectionSpacing = 2;
// Spacing between the image and text for internal pages.
const CGFloat kInternalPageImageSpacing = 10;
// Square size of the permission images.
const CGFloat kPermissionImageSize = 19;
// Square size of the permission delete button image.
const CGFloat kPermissionDeleteImageSize = 16;
// Vertical adjustment for the permission images. They have an extra pixel of
// padding on the bottom edge.
const CGFloat kPermissionImageYAdjust = 1;
// Spacing between a permission image and the text.
const CGFloat kPermissionImageSpacing = 3;
// The spacing between individual items in the Permissions tab.
const CGFloat kPermissionsTabSpacing = 12;
// Extra spacing after a headline on the Permissions tab.
const CGFloat kPermissionsHeadlineSpacing = 2;
// The amount of horizontal space between a permission label and the popup.
const CGFloat kPermissionPopUpXSpacing = 3;
// The amount of padding to *remove* when placing
// |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other.
const CGFloat kTextLabelXPadding = 5;
// Takes in the parent window, which should be a BrowserWindow, and gets the
// proper anchor point for the bubble. The returned point is in screen
// coordinates.
NSPoint AnchorPointForWindow(NSWindow* parent) {
BrowserWindowController* controller = [parent windowController];
NSPoint origin = NSZeroPoint;
if ([controller isKindOfClass:[BrowserWindowController class]]) {
LocationBarViewMac* location_bar = [controller locationBarBridge];
if (location_bar) {
NSPoint bubble_point = location_bar->GetPageInfoBubblePoint();
origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point);
}
}
return origin;
}
} // namespace
@interface ChosenObjectDeleteButton : HoverImageButton {
@private
ChosenObjectInfoPtr objectInfo_;
ChosenObjectDeleteCallback callback_;
}
// Designated initializer. Takes ownership of |objectInfo|.
- (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo
atPoint:(NSPoint)point
withCallback:(ChosenObjectDeleteCallback)callback;
// Action when the button is clicked.
- (void)deleteClicked:(id)sender;
@end
@implementation ChosenObjectDeleteButton
- (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo
atPoint:(NSPoint)point
withCallback:(ChosenObjectDeleteCallback)callback {
NSRect frame = NSMakeRect(point.x, point.y, kPermissionDeleteImageSize,
kPermissionDeleteImageSize);
if (self = [super initWithFrame:frame]) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
[self setDefaultImage:rb.GetNativeImageNamed(IDR_CLOSE_2).ToNSImage()];
[self setHoverImage:rb.GetNativeImageNamed(IDR_CLOSE_2_H).ToNSImage()];
[self setPressedImage:rb.GetNativeImageNamed(IDR_CLOSE_2_P).ToNSImage()];
[self setBordered:NO];
[self setToolTip:l10n_util::GetNSString(
objectInfo->ui_info.delete_tooltip_string_id)];
[self setTarget:self];
[self setAction:@selector(deleteClicked:)];
objectInfo_ = std::move(objectInfo);
callback_ = callback;
}
return self;
}
- (void)deleteClicked:(id)sender {
callback_.Run(*objectInfo_);
}
@end
@implementation WebsiteSettingsBubbleController
- (CGFloat)defaultWindowWidth {
return kDefaultWindowWidth;
}
- (id)initWithParentWindow:(NSWindow*)parentWindow
websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge
webContents:(content::WebContents*)webContents
isInternalPage:(BOOL)isInternalPage
isDevToolsDisabled:(BOOL)isDevToolsDisabled {
DCHECK(parentWindow);
webContents_ = webContents;
permissionsPresent_ = NO;
isDevToolsDisabled_ = isDevToolsDisabled;
// Use an arbitrary height; it will be changed in performLayout.
NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1);
// Create an empty window into which content is placed.
base::scoped_nsobject<InfoBubbleWindow> window(
[[InfoBubbleWindow alloc] initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
if ((self = [super initWithWindow:window.get()
parentWindow:parentWindow
anchoredAt:NSZeroPoint])) {
[[self bubble] setArrowLocation:info_bubble::kTopLeft];
// Create the container view that uses flipped coordinates.
NSRect contentFrame = NSMakeRect(0, 0, [self defaultWindowWidth], 300);
contentView_.reset(
[[FlippedView alloc] initWithFrame:contentFrame]);
// Replace the window's content.
[[[self window] contentView] setSubviews:
[NSArray arrayWithObject:contentView_.get()]];
if (isInternalPage)
[self initializeContentsForInternalPage];
else
[self initializeContents];
bridge_.reset(bridge);
bridge_->set_bubble_controller(self);
}
return self;
}
- (void)windowWillClose:(NSNotification*)notification {
if (presenter_.get())
presenter_->OnUIClosing();
presenter_.reset();
[super windowWillClose:notification];
}
- (void)setPresenter:(WebsiteSettings*)presenter {
presenter_.reset(presenter);
}
// Create the subviews for the bubble for internal Chrome pages.
- (void)initializeContentsForInternalPage {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
NSPoint controlOrigin = NSMakePoint(
kInternalPageFramePadding,
kInternalPageFramePadding + info_bubble::kBubbleArrowHeight);
NSImage* productLogoImage =
rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToNSImage();
NSImageView* imageView = [self addImageWithSize:[productLogoImage size]
toView:contentView_
atPoint:controlOrigin];
[imageView setImage:productLogoImage];
NSRect imageFrame = [imageView frame];
controlOrigin.x += NSWidth(imageFrame) + kInternalPageImageSpacing;
base::string16 text = l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
NSTextField* textField = [self addText:text
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:contentView_
atPoint:controlOrigin];
// Center the image vertically with the text. Previously this code centered
// the text vertically while holding the image in place. That produced correct
// results when the image, at 26x26, was taller than (or just slightly
// shorter) than the text, but produced incorrect results once the icon
// shrank to 16x16. The icon should now always be shorter than the text.
// See crbug.com/572044 .
NSRect textFrame = [textField frame];
imageFrame.origin.y += (NSHeight(textFrame) - NSHeight(imageFrame)) / 2;
[imageView setFrame:imageFrame];
// Adjust the contentView to fit everything.
CGFloat maxY = std::max(NSMaxY(imageFrame), NSMaxY(textFrame));
[contentView_ setFrame:NSMakeRect(
0, 0, [self defaultWindowWidth], maxY + kInternalPageFramePadding)];
[self sizeAndPositionWindow];
}
// Create the subviews for the website settings bubble.
- (void)initializeContents {
securitySectionView_ = [self addSecuritySectionToView:contentView_];
separatorAfterSecuritySection_ = [self addSeparatorToView:contentView_];
siteSettingsSectionView_ = [self addSiteSettingsSectionToView:contentView_];
[self performLayout];
}
// Create and return a subview for the security section and add it to the given
// |superview|. |superview| retains the new view.
- (NSView*)addSecuritySectionToView:(NSView*)superview {
base::scoped_nsobject<NSView> securitySectionView(
[[FlippedView alloc] initWithFrame:[superview frame]]);
[superview addSubview:securitySectionView];
// Create a controlOrigin to place the text fields. The y value doesn't
// matter, because the correct value is calculated in -performLayout.
NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
// Create a text field (empty for now) to show the site identity.
identityField_ = [self addText:base::string16()
withSize:[NSFont systemFontSize]
bold:YES
toView:securitySectionView
atPoint:controlOrigin];
// Create a text field for the security summary (private/not private/etc.).
securitySummaryField_ = [self addText:base::string16()
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:securitySectionView
atPoint:controlOrigin];
resetDecisionsButton_ = nil; // This will be created only if necessary.
NSString* securityDetailsButtonText =
l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK);
// Note: The security details button may be removed from the superview in
// -performLayout in order to hide it (depending on the connection).
securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText
toView:securitySectionView];
[securityDetailsButton_ setTarget:self];
[securityDetailsButton_ setAction:@selector(showSecurityDetails:)];
return securitySectionView.get();
}
// Create and return a subview for the site settings and add it to the given
// |superview|. |superview| retains the new view.
- (NSView*)addSiteSettingsSectionToView:(NSView*)superview {
base::scoped_nsobject<NSView> siteSettingsSectionView(
[[FlippedView alloc] initWithFrame:[superview frame]]);
[superview addSubview:siteSettingsSectionView];
// Initialize the two containers that hold the controls. The initial frames
// are arbitrary, and will be adjusted after the controls are laid out.
cookiesView_ =
[[[FlippedView alloc] initWithFrame:[superview frame]] autorelease];
[cookiesView_ setAutoresizingMask:NSViewWidthSizable];
[siteSettingsSectionView addSubview:cookiesView_];
permissionsView_ =
[[[FlippedView alloc] initWithFrame:[superview frame]] autorelease];
[siteSettingsSectionView addSubview:permissionsView_];
// Create the link button to view site settings. Its position will be set in
// performLayout.
NSString* siteSettingsButtonText =
l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK);
siteSettingsButton_ = [self addLinkButtonWithText:siteSettingsButtonText
toView:siteSettingsSectionView];
[siteSettingsButton_ setTarget:self];
[siteSettingsButton_ setAction:@selector(showSiteSettingsData:)];
return siteSettingsSectionView.get();
}
// Handler for the link button below the list of cookies.
- (void)showCookiesAndSiteData:(id)sender {
DCHECK(webContents_);
DCHECK(presenter_);
presenter_->RecordWebsiteSettingsAction(
WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED);
TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies();
}
// Handler for the site settings button below the list of permissions.
- (void)showSiteSettingsData:(id)sender {
DCHECK(webContents_);
DCHECK(presenter_);
presenter_->RecordWebsiteSettingsAction(
WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED);
webContents_->OpenURL(content::OpenURLParams(
GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false));
}
// Handler for the site settings button below the list of permissions.
// TODO(lgarron): Move some of this to the presenter for separation of concerns
// and platform unification. (https://crbug.com/571533)
- (void)showSecurityDetails:(id)sender {
DCHECK(webContents_);
DCHECK(presenter_);
presenter_->RecordWebsiteSettingsAction(
WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED);
if (isDevToolsDisabled_) {
[self showCertificateInfo:sender];
} else {
DevToolsWindow::OpenDevToolsWindow(
webContents_, DevToolsToggleAction::ShowSecurityPanel());
}
}
// Handler for the link button to show certificate information.
- (void)showCertificateInfo:(id)sender {
DCHECK(certificateId_);
DCHECK(presenter_);
presenter_->RecordWebsiteSettingsAction(
WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_);
}
// Handler for the link button to revoke user certificate decisions.
- (void)resetCertificateDecisions:(id)sender {
DCHECK(resetDecisionsButton_);
presenter_->OnRevokeSSLErrorBypassButtonPressed();
[self close];
}
// Set the Y position of |view| to the given position, and return the position
// of its bottom edge.
- (CGFloat)setYPositionOfView:(NSView*)view to:(CGFloat)position {
NSRect frame = [view frame];
frame.origin.y = position;
[view setFrame:frame];
return position + NSHeight(frame);
}
- (void)setWidthOfView:(NSView*)view to:(CGFloat)width {
[view setFrameSize:NSMakeSize(width, NSHeight([view frame]))];
}
- (void)setHeightOfView:(NSView*)view to:(CGFloat)height {
[view setFrameSize:NSMakeSize(NSWidth([view frame]), height)];
}
// Layout all of the controls in the window. This should be called whenever
// the content has changed.
- (void)performLayout {
// Make the content at least as wide as the permissions view.
CGFloat contentWidth = std::max([self defaultWindowWidth],
NSWidth([permissionsView_ frame]));
// Set the width of the content view now, so that all the text fields will
// be sized to fit before their heights and vertical positions are adjusted.
[self setWidthOfView:contentView_ to:contentWidth];
[self setWidthOfView:securitySectionView_ to:contentWidth];
[self setWidthOfView:siteSettingsSectionView_ to:contentWidth];
CGFloat yPos = info_bubble::kBubbleArrowHeight;
[self layoutSecuritySection];
yPos = [self setYPositionOfView:securitySectionView_ to:yPos + kFramePadding];
yPos = [self setYPositionOfView:separatorAfterSecuritySection_
to:yPos + kVerticalSectionMargin];
[self layoutSiteSettingsSection];
yPos = [self setYPositionOfView:siteSettingsSectionView_
to:yPos + kVerticalSectionMargin];
[contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]),
yPos + kFramePadding)];
[self sizeAndPositionWindow];
}
- (void)layoutSecuritySection {
// Start the layout with the first element. Margins are handled by the caller.
CGFloat yPos = 0;
[self sizeTextFieldHeightToFit:identityField_];
yPos = [self setYPositionOfView:identityField_ to:yPos];
[self sizeTextFieldHeightToFit:securitySummaryField_];
yPos = [self setYPositionOfView:securitySummaryField_
to:yPos + kSpacingBeforeSecuritySummary];
if (isDevToolsDisabled_ && certificateId_ == 0) {
// -removeFromSuperview is idempotent.
[securityDetailsButton_ removeFromSuperview];
} else {
// -addSubview is idempotent.
[securitySectionView_ addSubview:securityDetailsButton_];
yPos = [self setYPositionOfView:securityDetailsButton_ to:yPos];
}
if (resetDecisionsButton_) {
yPos = [self setYPositionOfView:resetDecisionsButton_
to:yPos + kSpacingBeforeResetDecisionsButton];
}
// Resize the height based on contents.
[self setHeightOfView:securitySectionView_ to:yPos];
}
- (void)layoutSiteSettingsSection {
// Start the layout with the first element. Margins are handled by the caller.
CGFloat yPos = 0;
yPos = [self setYPositionOfView:cookiesView_ to:yPos];
if (permissionsPresent_) {
// Put the permission info just below the link button.
yPos = [self setYPositionOfView:permissionsView_
to:yPos + kSiteSettingsSectionSpacing];
}
// Put the link button for site settings just below the permissions.
// TODO(lgarron): set the position of this based on RTL/LTR.
// http://code.google.com/p/chromium/issues/detail?id=525304
yPos += kSiteSettingsSectionSpacing;
[siteSettingsButton_ setFrameOrigin:NSMakePoint(kFramePadding, yPos)];
yPos = NSMaxY([siteSettingsButton_ frame]);
// Resize the height based on contents.
[self setHeightOfView:siteSettingsSectionView_ to:yPos];
}
// Adjust the size of the window to match the size of the content, and position
// the bubble anchor appropriately.
- (void)sizeAndPositionWindow {
NSRect windowFrame = [contentView_ frame];
windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size
toView:nil];
// Adjust the origin by the difference in height.
windowFrame.origin = [[self window] frame].origin;
windowFrame.origin.y -= NSHeight(windowFrame) -
NSHeight([[self window] frame]);
// Resize the window. Only animate if the window is visible, otherwise it
// could be "growing" while it's opening, looking awkward.
[[self window] setFrame:windowFrame
display:YES
animate:[[self window] isVisible]];
// Adjust the anchor for the bubble.
[self setAnchorPoint:AnchorPointForWindow([self parentWindow])];
}
// Sets properties on the given |field| to act as the title or description
// labels in the bubble.
- (void)configureTextFieldAsLabel:(NSTextField*)textField {
[textField setEditable:NO];
[textField setSelectable:YES];
[textField setDrawsBackground:NO];
[textField setBezeled:NO];
}
// Adjust the height of the given text field to match its text.
- (void)sizeTextFieldHeightToFit:(NSTextField*)textField {
NSRect frame = [textField frame];
frame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
textField];
[textField setFrame:frame];
}
// Create a new text field and add it to the given array of subviews.
// The array will retain a reference to the object.
- (NSTextField*)addText:(const base::string16&)text
withSize:(CGFloat)fontSize
bold:(BOOL)bold
toView:(NSView*)view
atPoint:(NSPoint)point {
// Size the text to take up the full available width, with some padding.
// The height is arbitrary as it will be adjusted later.
CGFloat width = NSWidth([view frame]) - point.x - kFramePadding;
NSRect frame = NSMakeRect(point.x, point.y, width, 100);
base::scoped_nsobject<NSTextField> textField(
[[NSTextField alloc] initWithFrame:frame]);
[self configureTextFieldAsLabel:textField.get()];
[textField setStringValue:base::SysUTF16ToNSString(text)];
NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize]
: [NSFont systemFontOfSize:fontSize];
[textField setFont:font];
[self sizeTextFieldHeightToFit:textField];
[textField setAutoresizingMask:NSViewWidthSizable];
[view addSubview:textField.get()];
return textField.get();
}
// Add an image as a subview of the given view, placed at a pre-determined x
// position and the given y position. Return the new NSImageView.
- (NSImageView*)addImageWithSize:(NSSize)size
toView:(NSView*)view
atPoint:(NSPoint)point {
NSRect frame = NSMakeRect(point.x, point.y, size.width, size.height);
base::scoped_nsobject<NSImageView> imageView(
[[NSImageView alloc] initWithFrame:frame]);
[imageView setImageFrameStyle:NSImageFrameNone];
[view addSubview:imageView.get()];
return imageView.get();
}
// Add a separator as a subview of the given view. Return the new view.
- (NSView*)addSeparatorToView:(NSView*)view {
// Use an arbitrary position; it will be adjusted in performLayout.
NSBox* spacer = [self
horizontalSeparatorWithFrame:NSMakeRect(0, 0, NSWidth([view frame]), 0)];
[view addSubview:spacer];
return spacer;
}
// Add a link button with the given text to |view|.
- (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view {
// Frame size is arbitrary; it will be adjusted by the layout tweaker.
NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
base::scoped_nsobject<NSButton> button(
[[NSButton alloc] initWithFrame:frame]);
base::scoped_nsobject<HyperlinkButtonCell> cell(
[[HyperlinkButtonCell alloc] initTextCell:text]);
[cell setControlSize:NSSmallControlSize];
[button setCell:cell.get()];
[button setButtonType:NSMomentaryPushInButton];
[button setBezelStyle:NSRegularSquareBezelStyle];
[view addSubview:button.get()];
[GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()];
return button.get();
}
// Create and return a button with the specified text and add it to the given
// |view|. |view| retains the new button.
- (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view {
NSRect containerFrame = [view frame];
// Frame size is arbitrary; it will be adjusted by the layout tweaker.
NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
base::scoped_nsobject<NSButton> button(
[[NSButton alloc] initWithFrame:frame]);
// Determine the largest possible size for this button. The size is the width
// of the connection section minus the padding on both sides minus the
// connection image size and spacing.
// TODO(lgarron): handle this sizing in -performLayout.
CGFloat maxTitleWidth = containerFrame.size.width - kFramePadding * 2;
base::scoped_nsobject<NSButtonCell> cell(
[[NSButtonCell alloc] initTextCell:text]);
[button setCell:cell.get()];
[GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()];
// Ensure the containing view is large enough to contain the button with its
// widest possible title.
NSRect buttonFrame = [button frame];
buttonFrame.size.width = maxTitleWidth;
[button setFrame:buttonFrame];
[button setButtonType:NSMomentaryPushInButton];
[button setBezelStyle:NSRegularSquareBezelStyle];
[view addSubview:button.get()];
return button.get();
}
// Set the content of the identity and identity status fields.
- (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo {
[identityField_
setStringValue:base::SysUTF8ToNSString(identityInfo.site_identity)];
[securitySummaryField_ setStringValue:base::SysUTF16ToNSString(
identityInfo.GetSecuritySummary())];
certificateId_ = identityInfo.cert_id;
if (certificateId_ && identityInfo.show_ssl_decision_revoke_button) {
NSString* text = l10n_util::GetNSString(
IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON);
resetDecisionsButton_ =
[self addButtonWithText:text toView:securitySectionView_];
[resetDecisionsButton_ setTarget:self];
[resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)];
}
[self performLayout];
}
// Add a pop-up button for |permissionInfo| to the given view.
- (NSPopUpButton*)addPopUpButtonForPermission:
(const WebsiteSettingsUI::PermissionInfo&)permissionInfo
toView:(NSView*)view
atPoint:(NSPoint)point {
GURL url = webContents_ ? webContents_->GetURL() : GURL();
__block WebsiteSettingsBubbleController* weakSelf = self;
PermissionMenuModel::ChangeCallback callback =
base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) {
[weakSelf onPermissionChanged:permission.type to:permission.setting];
});
base::scoped_nsobject<PermissionSelectorButton> button(
[[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo
forURL:url
withCallback:callback]);
// Determine the largest possible size for this button.
CGFloat maxTitleWidth = [button
maxTitleWidthForContentSettingsType:permissionInfo.type
withDefaultSetting:permissionInfo.default_setting];
// Ensure the containing view is large enough to contain the button with its
// widest possible title.
NSRect containerFrame = [view frame];
containerFrame.size.width = std::max(
NSWidth(containerFrame), point.x + maxTitleWidth + kFramePadding);
[view setFrame:containerFrame];
[view addSubview:button.get()];
return button.get();
}
// Add a delete button for |objectInfo| to the given view.
- (NSButton*)addDeleteButtonForChosenObject:(ChosenObjectInfoPtr)objectInfo
toView:(NSView*)view
atPoint:(NSPoint)point {
__block WebsiteSettingsBubbleController* weakSelf = self;
auto callback =
base::BindBlock(^(const WebsiteSettingsUI::ChosenObjectInfo& objectInfo) {
[weakSelf onChosenObjectDeleted:objectInfo];
});
base::scoped_nsobject<ChosenObjectDeleteButton> button(
[[ChosenObjectDeleteButton alloc]
initWithChosenObject:std::move(objectInfo)
atPoint:point
withCallback:callback]);
// Ensure the containing view is large enough to contain the button.
NSRect containerFrame = [view frame];
containerFrame.size.width =
std::max(NSWidth(containerFrame),
point.x + kPermissionDeleteImageSize + kFramePadding);
[view setFrame:containerFrame];
[view addSubview:button.get()];
return button.get();
}
// Called when the user changes the setting of a permission.
- (void)onPermissionChanged:(ContentSettingsType)permissionType
to:(ContentSetting)newSetting {
if (presenter_)
presenter_->OnSitePermissionChanged(permissionType, newSetting);
}
// Called when the user revokes permission for a previously chosen object.
- (void)onChosenObjectDeleted:(const WebsiteSettingsUI::ChosenObjectInfo&)info {
if (presenter_)
presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object);
}
// Adds a new row to the UI listing the permissions. Returns the NSPoint of the
// last UI element added (either the permission button, in LTR, or the text
// label, in RTL).
- (NSPoint)addPermission:
(const WebsiteSettingsUI::PermissionInfo&)permissionInfo
toView:(NSView*)view
atPoint:(NSPoint)point {
base::string16 labelText =
WebsiteSettingsUI::PermissionTypeToUIString(permissionInfo.type) +
base::ASCIIToUTF16(":");
bool isRTL =
base::i18n::RIGHT_TO_LEFT == base::i18n::GetStringDirection(labelText);
base::scoped_nsobject<NSImage> image(
[WebsiteSettingsUI::GetPermissionIcon(permissionInfo).ToNSImage()
retain]);
NSPoint position;
NSImageView* imageView;
NSPopUpButton* button;
NSTextField* label;
CGFloat viewWidth = NSWidth([view frame]);
if (isRTL) {
point.x = NSWidth([view frame]) - kPermissionImageSize -
kPermissionImageSpacing - kFramePadding;
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x -= kPermissionImageSpacing;
label = [self addText:labelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:view
atPoint:point];
[label sizeToFit];
point.x -= NSWidth([label frame]);
[label setFrameOrigin:point];
position = NSMakePoint(point.x, point.y);
button = [self addPopUpButtonForPermission:permissionInfo
toView:view
atPoint:position];
position.x -= NSWidth([button frame]);
[button setFrameOrigin:position];
} else {
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x += kPermissionImageSize + kPermissionImageSpacing;
label = [self addText:labelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:view
atPoint:point];
[label sizeToFit];
position = NSMakePoint(NSMaxX([label frame]), point.y);
button = [self addPopUpButtonForPermission:permissionInfo
toView:view
atPoint:position];
}
[view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))];
// Adjust the vertical position of the button so that its title text is
// aligned with the label. Assumes that the text is the same size in both.
// Also adjust the horizontal position to remove excess space due to the
// invisible bezel.
NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]];
if (isRTL) {
position.x += kPermissionPopUpXSpacing;
} else {
position.x -= titleRect.origin.x - kPermissionPopUpXSpacing;
}
position.y -= titleRect.origin.y;
[button setFrameOrigin:position];
// Align the icon with the text.
[self alignPermissionIcon:imageView withTextField:label];
// Permissions specified by policy or an extension cannot be changed.
if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION ||
permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) {
[button setEnabled:NO];
}
NSRect buttonFrame = [button frame];
return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame));
}
// Adds a new row to the UI listing the permissions. Returns the NSPoint of the
// last UI element added (either the permission button, in LTR, or the text
// label, in RTL).
- (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo
toView:(NSView*)view
atPoint:(NSPoint)point {
base::string16 labelText = l10n_util::GetStringFUTF16(
objectInfo->ui_info.label_string_id,
WebsiteSettingsUI::ChosenObjectToUIString(*objectInfo));
bool isRTL =
base::i18n::RIGHT_TO_LEFT == base::i18n::GetStringDirection(labelText);
base::scoped_nsobject<NSImage> image(
[WebsiteSettingsUI::GetChosenObjectIcon(*objectInfo, false)
.ToNSImage() retain]);
NSPoint position;
NSImageView* imageView;
NSButton* button;
NSTextField* label;
CGFloat viewWidth = NSWidth([view frame]);
if (isRTL) {
point.x = NSWidth([view frame]) - kPermissionImageSize -
kPermissionImageSpacing - kFramePadding;
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x -= kPermissionImageSpacing;
label = [self addText:labelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:view
atPoint:point];
[label sizeToFit];
point.x -= NSWidth([label frame]);
[label setFrameOrigin:point];
position = NSMakePoint(point.x, point.y);
button = [self addDeleteButtonForChosenObject:std::move(objectInfo)
toView:view
atPoint:position];
position.x -= NSWidth([button frame]);
[button setFrameOrigin:position];
} else {
imageView = [self addImageWithSize:[image size] toView:view atPoint:point];
[imageView setImage:image];
point.x += kPermissionImageSize + kPermissionImageSpacing;
label = [self addText:labelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:view
atPoint:point];
[label sizeToFit];
position = NSMakePoint(NSMaxX([label frame]), point.y);
button = [self addDeleteButtonForChosenObject:std::move(objectInfo)
toView:view
atPoint:position];
}
[view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))];
// Adjust the vertical position of the button so that its title text is
// aligned with the label. Assumes that the text is the same size in both.
// Also adjust the horizontal position to remove excess space due to the
// invisible bezel.
NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]];
if (isRTL) {
position.x += kPermissionPopUpXSpacing;
} else {
position.x -= titleRect.origin.x - kPermissionPopUpXSpacing;
}
position.y -= titleRect.origin.y;
[button setFrameOrigin:position];
// Align the icon with the text.
[self alignPermissionIcon:imageView withTextField:label];
NSRect buttonFrame = [button frame];
return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame));
}
// Align an image with a text field by vertically centering the image on
// the cap height of the first line of text.
- (void)alignPermissionIcon:(NSImageView*)imageView
withTextField:(NSTextField*)textField {
NSFont* font = [textField font];
// Calculate the offset from the top of the text field.
CGFloat capHeight = [font capHeight];
CGFloat offset = (kPermissionImageSize - capHeight) / 2 -
([font ascender] - capHeight) - kPermissionImageYAdjust;
NSRect frame = [imageView frame];
frame.origin.y -= offset;
[imageView setFrame:frame];
}
- (void)setCookieInfo:(const CookieInfoList&)cookieInfoList {
// A result of re-ordering of the permissions (crbug.com/444244) is
// that sometimes permissions may not be displayed at all, so it's
// incorrect to check they are set before the cookie info.
// |cookieInfoList| should only ever have 2 items: first- and third-party
// cookies.
DCHECK_EQ(cookieInfoList.size(), 2u);
base::string16 firstPartyLabelText;
base::string16 thirdPartyLabelText;
for (const auto& i : cookieInfoList) {
if (i.is_first_party) {
firstPartyLabelText =
l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA,
base::IntToString16(i.allowed));
} else {
thirdPartyLabelText =
l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA,
base::IntToString16(i.allowed));
}
}
base::string16 sectionTitle =
l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA);
bool isRTL = base::i18n::RIGHT_TO_LEFT ==
base::i18n::GetStringDirection(firstPartyLabelText);
[cookiesView_ setSubviews:[NSArray array]];
NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
NSTextField* label;
CGFloat viewWidth = NSWidth([cookiesView_ frame]);
NSTextField* header = [self addText:sectionTitle
withSize:[NSFont smallSystemFontSize]
bold:YES
toView:cookiesView_
atPoint:controlOrigin];
[header sizeToFit];
if (isRTL) {
controlOrigin.x = viewWidth - kFramePadding - NSWidth([header frame]);
[header setFrameOrigin:controlOrigin];
}
controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
controlOrigin.y += kPermissionsTabSpacing;
// Reset X for the cookie image.
if (isRTL) {
controlOrigin.x = viewWidth - kPermissionImageSize -
kPermissionImageSpacing - kFramePadding;
}
WebsiteSettingsUI::PermissionInfo info;
info.type = CONTENT_SETTINGS_TYPE_COOKIES;
info.setting = CONTENT_SETTING_ALLOW;
// info.default_setting, info.source, and info.is_incognito have not been set,
// but GetPermissionIcon doesn't use any of those.
NSImage* image = WebsiteSettingsUI::GetPermissionIcon(info).ToNSImage();
NSImageView* imageView = [self addImageWithSize:[image size]
toView:cookiesView_
atPoint:controlOrigin];
[imageView setImage:image];
base::string16 comma = base::ASCIIToUTF16(", ");
NSString* cookieButtonText = base::SysUTF16ToNSString(firstPartyLabelText);
if (isRTL) {
NSButton* cookiesButton =
[self addLinkButtonWithText:cookieButtonText toView:cookiesView_];
[cookiesButton setTarget:self];
[cookiesButton setAction:@selector(showCookiesAndSiteData:)];
controlOrigin.x -= NSWidth([cookiesButton frame]);
[cookiesButton setFrameOrigin:controlOrigin];
label = [self addText:comma + thirdPartyLabelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:cookiesView_
atPoint:controlOrigin];
[label sizeToFit];
controlOrigin.x -= NSWidth([label frame]) - kTextLabelXPadding;
[label setFrameOrigin:controlOrigin];
} else {
controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing;
NSButton* cookiesButton =
[self addLinkButtonWithText:cookieButtonText toView:cookiesView_];
[cookiesButton setTarget:self];
[cookiesButton setAction:@selector(showCookiesAndSiteData:)];
[cookiesButton setFrameOrigin:controlOrigin];
controlOrigin.x += NSWidth([cookiesButton frame]) - kTextLabelXPadding;
label = [self addText:comma + thirdPartyLabelText
withSize:[NSFont smallSystemFontSize]
bold:NO
toView:cookiesView_
atPoint:controlOrigin];
[label sizeToFit];
}
// Align the icon with the text.
[self alignPermissionIcon:imageView withTextField:label];
controlOrigin.y += NSHeight([label frame]) + kPermissionsTabSpacing;
[cookiesView_ setFrameSize:
NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)];
[self performLayout];
}
- (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList
andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList {
[permissionsView_ setSubviews:[NSArray array]];
NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
permissionsPresent_ = YES;
if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) {
base::string16 sectionTitle = l10n_util::GetStringUTF16(
IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS);
bool isRTL = base::i18n::RIGHT_TO_LEFT ==
base::i18n::GetStringDirection(sectionTitle);
NSTextField* header = [self addText:sectionTitle
withSize:[NSFont smallSystemFontSize]
bold:YES
toView:permissionsView_
atPoint:controlOrigin];
[header sizeToFit];
if (isRTL) {
controlOrigin.x = NSWidth([permissionsView_ frame]) - kFramePadding -
NSWidth([header frame]);
[header setFrameOrigin:controlOrigin];
}
controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
for (const auto& permission : permissionInfoList) {
controlOrigin.y += kPermissionsTabSpacing;
NSPoint rowBottomRight = [self addPermission:permission
toView:permissionsView_
atPoint:controlOrigin];
controlOrigin.y = rowBottomRight.y;
}
for (auto object : chosenObjectInfoList) {
controlOrigin.y += kPermissionsTabSpacing;
NSPoint rowBottomRight = [self addChosenObject:make_scoped_ptr(object)
toView:permissionsView_
atPoint:controlOrigin];
controlOrigin.y = rowBottomRight.y;
}
controlOrigin.y += kFramePadding;
}
[permissionsView_ setFrameSize:
NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)];
[self performLayout];
}
@end
WebsiteSettingsUIBridge::WebsiteSettingsUIBridge(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
web_contents_(web_contents),
bubble_controller_(nil) {}
WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() {
}
void WebsiteSettingsUIBridge::set_bubble_controller(
WebsiteSettingsBubbleController* controller) {
bubble_controller_ = controller;
}
void WebsiteSettingsUIBridge::Show(
gfx::NativeWindow parent,
Profile* profile,
content::WebContents* web_contents,
const GURL& url,
const security_state::SecurityStateModel::SecurityInfo& security_info) {
if (chrome::ToolkitViewsDialogsEnabled()) {
chrome::ShowWebsiteSettingsBubbleViewsAtPoint(
gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile,
web_contents, url, security_info);
return;
}
bool is_internal_page = InternalChromePage(url);
// Create the bridge. This will be owned by the bubble controller.
WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents);
bool is_devtools_disabled =
profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
// Create the bubble controller. It will dealloc itself when it closes.
WebsiteSettingsBubbleController* bubble_controller =
[[WebsiteSettingsBubbleController alloc]
initWithParentWindow:parent
websiteSettingsUIBridge:bridge
webContents:web_contents
isInternalPage:is_internal_page
isDevToolsDisabled:is_devtools_disabled];
if (!is_internal_page) {
// Initialize the presenter, which holds the model and controls the UI.
// This is also owned by the bubble controller.
WebsiteSettings* presenter = new WebsiteSettings(
bridge, profile,
TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
url, security_info, content::CertStore::GetInstance());
[bubble_controller setPresenter:presenter];
}
[bubble_controller showWindow:nil];
}
void WebsiteSettingsUIBridge::SetIdentityInfo(
const WebsiteSettingsUI::IdentityInfo& identity_info) {
[bubble_controller_ setIdentityInfo:identity_info];
}
void WebsiteSettingsUIBridge::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
if (render_frame_host == web_contents_->GetMainFrame()) {
[bubble_controller_ close];
}
}
void WebsiteSettingsUIBridge::SetCookieInfo(
const CookieInfoList& cookie_info_list) {
[bubble_controller_ setCookieInfo:cookie_info_list];
}
void WebsiteSettingsUIBridge::SetPermissionInfo(
const PermissionInfoList& permission_info_list,
const ChosenObjectInfoList& chosen_object_info_list) {
[bubble_controller_ setPermissionInfo:permission_info_list
andChosenObjects:chosen_object_info_list];
}
void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
// TODO(lgarron): Remove this from the interface. (crbug.com/571533)
}
|