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

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

Issue 418133012: Add button to page info to revoke user certificate decisions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 6 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 | Annotate | Revision Log
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/website_settings_bubble_contro ller.h" 5 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro ller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import <AppKit/AppKit.h> 9 #import <AppKit/AppKit.h>
10 10
11 #include "base/mac/bind_objc_block.h" 11 #include "base/mac/bind_objc_block.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #import "chrome/browser/certificate_viewer.h" 14 #import "chrome/browser/certificate_viewer.h"
15 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
16 #import "chrome/browser/ui/browser_dialogs.h" 16 #import "chrome/browser/ui/browser_dialogs.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 18 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
19 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 19 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
20 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 20 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
21 #import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h" 21 #import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
22 #include "chrome/browser/ui/website_settings/permission_menu_model.h" 22 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
23 #include "chrome/browser/ui/website_settings/website_settings_utils.h" 23 #include "chrome/browser/ui/website_settings/website_settings_utils.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/cert_store.h" 25 #include "content/public/browser/cert_store.h"
26 #include "content/public/browser/page_navigator.h" 26 #include "content/public/browser/page_navigator.h"
27 #include "content/public/browser/ssl_host_state.h"
27 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "grit/chromium_strings.h" 30 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
31 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
32 #include "grit/ui_resources.h" 33 #include "grit/ui_resources.h"
33 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 34 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
34 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" 35 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
35 #import "ui/base/cocoa/flipped_view.h" 36 #import "ui/base/cocoa/flipped_view.h"
36 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 base::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); 509 base::UserMetricsAction("WebsiteSettings_CookiesDialogOpened"));
509 chrome::ShowCollectedCookiesDialog(webContents_); 510 chrome::ShowCollectedCookiesDialog(webContents_);
510 } 511 }
511 512
512 // Handler for the link button to show certificate information. 513 // Handler for the link button to show certificate information.
513 - (void)showCertificateInfo:(id)sender { 514 - (void)showCertificateInfo:(id)sender {
514 DCHECK(certificateId_); 515 DCHECK(certificateId_);
515 ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_); 516 ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_);
516 } 517 }
517 518
519 // Handler for the link button to revoke user certificate decisions.
520 - (void)resetCertificateDecisions:(id)sender {
521 DCHECK(resetDecisionsButton_);
522 content::BrowserContext* context = webContents_->GetBrowserContext();
523 content::SSLHostState::GetFor(context)
524 ->RevokeAllowAndDenyPreferences(presenter_->GetSiteURL().host());
Robert Sesek 2014/07/28 15:42:51 Whatever you and pkasting decide about wrapping, a
jww 2014/07/28 19:10:00 Done.
525 }
526
518 // Handler for the link to show help information about the connection tab. 527 // Handler for the link to show help information about the connection tab.
519 - (void)showHelpPage:(id)sender { 528 - (void)showHelpPage:(id)sender {
520 webContents_->OpenURL(content::OpenURLParams( 529 webContents_->OpenURL(content::OpenURLParams(
521 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), 530 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
522 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); 531 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false));
523 } 532 }
524 533
525 // Create the contents of the Connection tab and add it to the given tab view. 534 // Create the contents of the Connection tab and add it to the given tab view.
526 // Returns a weak reference to the tab view item's view. 535 // Returns a weak reference to the tab view item's view.
527 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView { 536 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView {
(...skipping 26 matching lines...) Expand all
554 connectionStatusIcon_ = [self addImageWithSize:imageSize 563 connectionStatusIcon_ = [self addImageWithSize:imageSize
555 toView:contentView 564 toView:contentView
556 atPoint:imagePosition]; 565 atPoint:imagePosition];
557 connectionStatusDescriptionField_ = 566 connectionStatusDescriptionField_ =
558 [self addText:base::string16() 567 [self addText:base::string16()
559 withSize:[NSFont smallSystemFontSize] 568 withSize:[NSFont smallSystemFontSize]
560 bold:NO 569 bold:NO
561 toView:contentView.get() 570 toView:contentView.get()
562 atPoint:textPosition]; 571 atPoint:textPosition];
563 certificateInfoButton_ = nil; // This will be created only if necessary. 572 certificateInfoButton_ = nil; // This will be created only if necessary.
573 resetDecisionsButton_ = nil; // This will be created only if necessary.
564 separatorAfterConnection_ = [self addSeparatorToView:contentView]; 574 separatorAfterConnection_ = [self addSeparatorToView:contentView];
565 [separatorAfterConnection_ setAutoresizingMask:NSViewWidthSizable]; 575 [separatorAfterConnection_ setAutoresizingMask:NSViewWidthSizable];
566 576
567 firstVisitIcon_ = [self addImageWithSize:imageSize 577 firstVisitIcon_ = [self addImageWithSize:imageSize
568 toView:contentView 578 toView:contentView
569 atPoint:imagePosition]; 579 atPoint:imagePosition];
570 firstVisitHeaderField_ = 580 firstVisitHeaderField_ =
571 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE) 581 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE)
572 withSize:[NSFont smallSystemFontSize] 582 withSize:[NSFont smallSystemFontSize]
573 bold:YES 583 bold:YES
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 yPos = std::max(NSMaxY([identityStatusDescriptionField_ frame]), 662 yPos = std::max(NSMaxY([identityStatusDescriptionField_ frame]),
653 NSMaxY([identityStatusIcon_ frame])); 663 NSMaxY([identityStatusIcon_ frame]));
654 if (certificateInfoButton_) { 664 if (certificateInfoButton_) {
655 NSRect certificateButtonFrame = [certificateInfoButton_ frame]; 665 NSRect certificateButtonFrame = [certificateInfoButton_ frame];
656 certificateButtonFrame.origin.x = NSMinX( 666 certificateButtonFrame.origin.x = NSMinX(
657 [identityStatusDescriptionField_ frame]); 667 [identityStatusDescriptionField_ frame]);
658 certificateButtonFrame.origin.y = yPos + kVerticalSpacing; 668 certificateButtonFrame.origin.y = yPos + kVerticalSpacing;
659 [certificateInfoButton_ setFrame:certificateButtonFrame]; 669 [certificateInfoButton_ setFrame:certificateButtonFrame];
660 yPos = NSMaxY(certificateButtonFrame); 670 yPos = NSMaxY(certificateButtonFrame);
661 } 671 }
672 if (resetDecisionsButton_) {
673 NSRect resetDecisionsButtonFrame = [resetDecisionsButton_ frame];
674 resetDecisionsButtonFrame.origin.x =
675 NSMinX([identityStatusDescriptionField_ frame]);
676 resetDecisionsButtonFrame.origin.y = yPos + kVerticalSpacing;
677 [resetDecisionsButton_ setFrame:resetDecisionsButtonFrame];
678 yPos = NSMaxY(resetDecisionsButtonFrame);
679 }
662 yPos = [self setYPositionOfView:separatorAfterIdentity_ 680 yPos = [self setYPositionOfView:separatorAfterIdentity_
663 to:yPos + kVerticalSpacing]; 681 to:yPos + kVerticalSpacing];
664 yPos += kVerticalSpacing; 682 yPos += kVerticalSpacing;
665 683
666 // Lay out the connection status section. 684 // Lay out the connection status section.
667 [self sizeTextFieldHeightToFit:connectionStatusDescriptionField_]; 685 [self sizeTextFieldHeightToFit:connectionStatusDescriptionField_];
668 [self setYPositionOfView:connectionStatusIcon_ to:yPos]; 686 [self setYPositionOfView:connectionStatusIcon_ to:yPos];
669 [self setYPositionOfView:connectionStatusDescriptionField_ to:yPos]; 687 [self setYPositionOfView:connectionStatusDescriptionField_ to:yPos];
670 yPos = std::max(NSMaxY([connectionStatusDescriptionField_ frame]), 688 yPos = std::max(NSMaxY([connectionStatusDescriptionField_ frame]),
671 NSMaxY([connectionStatusIcon_ frame])); 689 NSMaxY([connectionStatusIcon_ frame]));
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 certificateId_ = identityInfo.cert_id; 1008 certificateId_ = identityInfo.cert_id;
991 if (certificateId_) { 1009 if (certificateId_) {
992 if (!certificateInfoButton_) { 1010 if (!certificateInfoButton_) {
993 NSString* text = l10n_util::GetNSString(IDS_PAGEINFO_CERT_INFO_BUTTON); 1011 NSString* text = l10n_util::GetNSString(IDS_PAGEINFO_CERT_INFO_BUTTON);
994 certificateInfoButton_ = [self addLinkButtonWithText:text 1012 certificateInfoButton_ = [self addLinkButtonWithText:text
995 toView:connectionTabContentView_]; 1013 toView:connectionTabContentView_];
996 1014
997 [certificateInfoButton_ setTarget:self]; 1015 [certificateInfoButton_ setTarget:self];
998 [certificateInfoButton_ setAction:@selector(showCertificateInfo:)]; 1016 [certificateInfoButton_ setAction:@selector(showCertificateInfo:)];
999 } 1017 }
1018
1019 // Check if a security decision has been made, and if so, add a button to
1020 // allow the user to retract their decision.
1021 if (identityInfo.certificate_decision_made) {
1022 NSString* text = l10n_util::GetNSString(
1023 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON);
1024 resetDecisionsButton_ =
1025 [self addLinkButtonWithText:text toView:connectionTabContentView_];
1026
1027 [resetDecisionsButton_ setTarget:self];
1028 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)];
1029 }
1000 } else { 1030 } else {
1001 certificateInfoButton_ = nil; 1031 certificateInfoButton_ = nil;
1002 } 1032 }
1003 1033
1004 [identityStatusIcon_ setImage:WebsiteSettingsUI::GetIdentityIcon( 1034 [identityStatusIcon_ setImage:WebsiteSettingsUI::GetIdentityIcon(
1005 identityInfo.identity_status).ToNSImage()]; 1035 identityInfo.identity_status).ToNSImage()];
1006 [identityStatusDescriptionField_ setStringValue: 1036 [identityStatusDescriptionField_ setStringValue:
1007 base::SysUTF8ToNSString(identityInfo.identity_status_description)]; 1037 base::SysUTF8ToNSString(identityInfo.identity_status_description)];
1008 1038
1009 [connectionStatusIcon_ setImage:WebsiteSettingsUI::GetConnectionIcon( 1039 [connectionStatusIcon_ setImage:WebsiteSettingsUI::GetConnectionIcon(
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 [bubble_controller_ setPermissionInfo:permission_info_list]; 1187 [bubble_controller_ setPermissionInfo:permission_info_list];
1158 } 1188 }
1159 1189
1160 void WebsiteSettingsUIBridge::SetFirstVisit(const base::string16& first_visit) { 1190 void WebsiteSettingsUIBridge::SetFirstVisit(const base::string16& first_visit) {
1161 [bubble_controller_ setFirstVisit:first_visit]; 1191 [bubble_controller_ setFirstVisit:first_visit];
1162 } 1192 }
1163 1193
1164 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1194 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1165 [bubble_controller_ setSelectedTab:tab_id]; 1195 [bubble_controller_ setSelectedTab:tab_id];
1166 } 1196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698