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

Unified 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: Address pkasting comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
index 450e2f8267254ccb434154240d7ab692ead4a44a..8fb5f4a3d295dfc68462781b4a31719798236e30 100644
--- a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
@@ -24,6 +24,7 @@
#include "chrome/common/url_constants.h"
#include "content/public/browser/cert_store.h"
#include "content/public/browser/page_navigator.h"
+#include "content/public/browser/ssl_host_state.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "grit/chromium_strings.h"
@@ -33,6 +34,7 @@
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#import "ui/base/cocoa/controls/hyperlink_button_cell.h"
#import "ui/base/cocoa/flipped_view.h"
+#import "ui/base/cocoa/hover_button.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
@@ -515,6 +517,14 @@ NSColor* IdentityVerifiedTextColor() {
ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_);
}
+// Handler for the link button to revoke user certificate decisions.
+- (void)resetCertificateDecisions:(id)sender {
+ DCHECK(resetDecisionsButton_);
+ content::SSLHostState(webContents_->GetBrowserContext()).
+ RevokeAllowAndDenyPreferencesHard(presenter_->site_url().host());
+ [self close];
+}
+
// Handler for the link to show help information about the connection tab.
- (void)showHelpPage:(id)sender {
webContents_->OpenURL(content::OpenURLParams(
@@ -561,6 +571,7 @@ NSColor* IdentityVerifiedTextColor() {
toView:contentView.get()
atPoint:textPosition];
certificateInfoButton_ = nil; // This will be created only if necessary.
+ resetDecisionsButton_ = nil; // This will be created only if necessary.
separatorAfterConnection_ = [self addSeparatorToView:contentView];
[separatorAfterConnection_ setAutoresizingMask:NSViewWidthSizable];
@@ -659,6 +670,14 @@ NSColor* IdentityVerifiedTextColor() {
[certificateInfoButton_ setFrame:certificateButtonFrame];
yPos = NSMaxY(certificateButtonFrame);
}
+ if (resetDecisionsButton_) {
+ NSRect resetDecisionsButtonFrame = [resetDecisionsButton_ frame];
+ resetDecisionsButtonFrame.origin.x =
+ NSMinX([identityStatusDescriptionField_ frame]);
+ resetDecisionsButtonFrame.origin.y = yPos + kVerticalSpacing;
+ [resetDecisionsButton_ setFrame:resetDecisionsButtonFrame];
+ yPos = NSMaxY(resetDecisionsButtonFrame);
+ }
yPos = [self setYPositionOfView:separatorAfterIdentity_
to:yPos + kVerticalSpacing];
yPos += kVerticalSpacing;
@@ -832,6 +851,22 @@ NSColor* IdentityVerifiedTextColor() {
return button.get();
}
+// Add a hover button with the given text to |view|.
+- (NSButton*)addHoverButtonWithText:(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<HoverButton> button(
+ [[HoverButton alloc] initWithFrame:frame]);
+ [button setTitle:text];
+
+ [button setButtonType:NSMomentaryPushInButton];
+ [button setBezelStyle:NSRegularSquareBezelStyle];
+ [view addSubview:button.get()];
+
+ [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()];
+ return button.get();
+}
+
// Add a pop-up button for |permissionInfo| to the given view.
- (NSPopUpButton*)addPopUpButtonForPermission:
(const WebsiteSettingsUI::PermissionInfo&)permissionInfo
@@ -997,6 +1032,17 @@ NSColor* IdentityVerifiedTextColor() {
[certificateInfoButton_ setTarget:self];
[certificateInfoButton_ setAction:@selector(showCertificateInfo:)];
}
+
+ // Check if a security decision has been made, and if so, add a button to
+ // allow the user to retract their decision.
+ if (identityInfo.certificate_decision_made) {
+ NSString* text = l10n_util::GetNSString(
+ IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON);
+ resetDecisionsButton_ =
+ [self addHoverButtonWithText:text toView:connectionTabContentView_];
+ [resetDecisionsButton_ setTarget:self];
+ [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)];
+ }
} else {
certificateInfoButton_ = nil;
}

Powered by Google App Engine
This is Rietveld 408576698