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

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

Issue 2504453003: Page Info (native Mac): Change "Details" link (sec. panel) to "Learn more" (help center). (Closed)
Patch Set: Page Info (native Mac): Change "Details" link (sec. panel) to "Learn more" (help center). Created 4 years 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/website_settings_bubble_contro ller.h" 5 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro ller.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/mac/bind_objc_block.h" 12 #include "base/mac/bind_objc_block.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #import "chrome/browser/certificate_viewer.h" 15 #import "chrome/browser/certificate_viewer.h"
16 #include "chrome/browser/devtools/devtools_toggle_action.h"
17 #include "chrome/browser/devtools/devtools_window.h"
18 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
19 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser_dialogs.h" 18 #include "chrome/browser/ui/browser_dialogs.h"
21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 20 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 21 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 22 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
25 #import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h" 23 #import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
26 #import "chrome/browser/ui/tab_dialogs.h" 24 #import "chrome/browser/ui/tab_dialogs.h"
27 #include "chrome/browser/ui/website_settings/permission_menu_model.h" 25 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
28 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
30 #include "chrome/grit/chromium_strings.h" 27 #include "chrome/grit/chromium_strings.h"
31 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
32 #include "chrome/grit/theme_resources.h" 29 #include "chrome/grit/theme_resources.h"
33 #include "components/prefs/pref_service.h"
34 #include "components/strings/grit/components_chromium_strings.h" 30 #include "components/strings/grit/components_chromium_strings.h"
35 #include "components/strings/grit/components_strings.h" 31 #include "components/strings/grit/components_strings.h"
36 #include "content/public/browser/page_navigator.h" 32 #include "content/public/browser/page_navigator.h"
37 #include "content/public/browser/ssl_host_state_delegate.h" 33 #include "content/public/browser/ssl_host_state_delegate.h"
38 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
39 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
40 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
41 #include "extensions/common/constants.h" 37 #include "extensions/common/constants.h"
42 #include "skia/ext/skia_utils_mac.h" 38 #include "skia/ext/skia_utils_mac.h"
43 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 39 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool IsInternalURL(const GURL& url) { 185 bool IsInternalURL(const GURL& url) {
190 return url.SchemeIs(content::kChromeUIScheme) || 186 return url.SchemeIs(content::kChromeUIScheme) ||
191 url.SchemeIs(content::kChromeDevToolsScheme) || 187 url.SchemeIs(content::kChromeDevToolsScheme) ||
192 url.SchemeIs(extensions::kExtensionScheme) || 188 url.SchemeIs(extensions::kExtensionScheme) ||
193 url.SchemeIs(content::kViewSourceScheme); 189 url.SchemeIs(content::kViewSourceScheme);
194 } 190 }
195 191
196 - (id)initWithParentWindow:(NSWindow*)parentWindow 192 - (id)initWithParentWindow:(NSWindow*)parentWindow
197 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge 193 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge
198 webContents:(content::WebContents*)webContents 194 webContents:(content::WebContents*)webContents
199 url:(const GURL&)url 195 url:(const GURL&)url {
200 isDevToolsDisabled:(BOOL)isDevToolsDisabled {
201 DCHECK(parentWindow); 196 DCHECK(parentWindow);
202 197
203 webContents_ = webContents; 198 webContents_ = webContents;
204 permissionsPresent_ = NO; 199 permissionsPresent_ = NO;
205 isDevToolsDisabled_ = isDevToolsDisabled;
206 url_ = url; 200 url_ = url;
207 201
208 // Use an arbitrary height; it will be changed in performLayout. 202 // Use an arbitrary height; it will be changed in performLayout.
209 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1); 203 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1);
210 // Create an empty window into which content is placed. 204 // Create an empty window into which content is placed.
211 base::scoped_nsobject<InfoBubbleWindow> window( 205 base::scoped_nsobject<InfoBubbleWindow> window(
212 [[InfoBubbleWindow alloc] initWithContentRect:contentRect 206 [[InfoBubbleWindow alloc] initWithContentRect:contentRect
213 styleMask:NSBorderlessWindowMask 207 styleMask:NSBorderlessWindowMask
214 backing:NSBackingStoreBuffered 208 backing:NSBackingStoreBuffered
215 defer:NO]); 209 defer:NO]);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 securityDetailsField_ = [self addText:base::string16() 331 securityDetailsField_ = [self addText:base::string16()
338 withSize:[NSFont smallSystemFontSize] 332 withSize:[NSFont smallSystemFontSize]
339 bold:NO 333 bold:NO
340 toView:securitySectionView 334 toView:securitySectionView
341 atPoint:controlOrigin]; 335 atPoint:controlOrigin];
342 336
343 // These will be created only if necessary. 337 // These will be created only if necessary.
344 resetDecisionsField_ = nil; 338 resetDecisionsField_ = nil;
345 resetDecisionsButton_ = nil; 339 resetDecisionsButton_ = nil;
346 340
347 NSString* securityDetailsButtonText = 341 NSString* connectionHelpButtonText =
348 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK); 342 l10n_util::GetNSString(IDS_LEARN_MORE);
349 // Note: The security details button may be removed from the superview in 343 connectionHelpButton_ = [self addLinkButtonWithText:connectionHelpButtonText
350 // -performLayout in order to hide it (depending on the connection).
351 securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText
352 toView:securitySectionView]; 344 toView:securitySectionView];
353 [securityDetailsButton_ setTarget:self]; 345 [connectionHelpButton_ setTarget:self];
354 [securityDetailsButton_ setAction:@selector(showSecurityDetails:)]; 346 [connectionHelpButton_ setAction:@selector(openConnectionHelp:)];
355 347
356 return securitySectionView.get(); 348 return securitySectionView.get();
357 } 349 }
358 350
359 // Create and return a subview for the site settings and add it to the given 351 // Create and return a subview for the site settings and add it to the given
360 // |superview|. |superview| retains the new view. 352 // |superview|. |superview| retains the new view.
361 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { 353 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview {
362 base::scoped_nsobject<NSView> siteSettingsSectionView( 354 base::scoped_nsobject<NSView> siteSettingsSectionView(
363 [[FlippedView alloc] initWithFrame:[superview frame]]); 355 [[FlippedView alloc] initWithFrame:[superview frame]]);
364 [superview addSubview:siteSettingsSectionView]; 356 [superview addSubview:siteSettingsSectionView];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DCHECK(webContents_); 394 DCHECK(webContents_);
403 DCHECK(presenter_); 395 DCHECK(presenter_);
404 presenter_->RecordWebsiteSettingsAction( 396 presenter_->RecordWebsiteSettingsAction(
405 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); 397 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED);
406 webContents_->OpenURL(content::OpenURLParams( 398 webContents_->OpenURL(content::OpenURLParams(
407 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), 399 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
408 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, 400 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
409 false)); 401 false));
410 } 402 }
411 403
412 // Handler for the site settings button below the list of permissions.
413 // TODO(lgarron): Move some of this to the presenter for separation of concerns 404 // TODO(lgarron): Move some of this to the presenter for separation of concerns
414 // and platform unification. (https://crbug.com/571533) 405 // and platform unification. (https://crbug.com/571533)
415 - (void)showSecurityDetails:(id)sender { 406 - (void)openConnectionHelp:(id)sender {
416 DCHECK(webContents_); 407 DCHECK(webContents_);
417 DCHECK(presenter_); 408 DCHECK(presenter_);
418 presenter_->RecordWebsiteSettingsAction( 409 presenter_->RecordWebsiteSettingsAction(
419 WebsiteSettings::WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED); 410 WebsiteSettings::WEBSITE_SETTINGS_CONNECTION_HELP_OPENED);
420 411 webContents_->OpenURL(content::OpenURLParams(
421 if (isDevToolsDisabled_) { 412 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
422 [self showCertificateInfo:sender]; 413 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
423 } else { 414 false));
424 DevToolsWindow::OpenDevToolsWindow(
425 webContents_, DevToolsToggleAction::ShowSecurityPanel());
426 }
427 } 415 }
428 416
429 // Handler for the link button to show certificate information. 417 // Handler for the link button to show certificate information.
430 - (void)showCertificateInfo:(id)sender { 418 - (void)showCertificateInfo:(id)sender {
431 DCHECK(certificate_.get()); 419 DCHECK(certificate_.get());
432 DCHECK(presenter_); 420 DCHECK(presenter_);
433 presenter_->RecordWebsiteSettingsAction( 421 presenter_->RecordWebsiteSettingsAction(
434 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED); 422 WebsiteSettings::WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED);
435 ShowCertificateViewer(webContents_, [self parentWindow], certificate_.get()); 423 ShowCertificateViewer(webContents_, [self parentWindow], certificate_.get());
436 } 424 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 CGFloat yPos = 0; 492 CGFloat yPos = 0;
505 493
506 [self sizeTextFieldHeightToFit:securitySummaryField_]; 494 [self sizeTextFieldHeightToFit:securitySummaryField_];
507 yPos = [self setYPositionOfView:securitySummaryField_ 495 yPos = [self setYPositionOfView:securitySummaryField_
508 to:yPos + kSectionVerticalPadding]; 496 to:yPos + kSectionVerticalPadding];
509 497
510 [self sizeTextFieldHeightToFit:securityDetailsField_]; 498 [self sizeTextFieldHeightToFit:securityDetailsField_];
511 yPos = [self setYPositionOfView:securityDetailsField_ 499 yPos = [self setYPositionOfView:securityDetailsField_
512 to:yPos + kSecurityParagraphSpacing]; 500 to:yPos + kSecurityParagraphSpacing];
513 501
514 if (isDevToolsDisabled_ && !certificate_) { 502 [connectionHelpButton_
515 // -removeFromSuperview is idempotent. 503 setFrameOrigin:NSMakePoint(
516 [securityDetailsButton_ removeFromSuperview]; 504 kSectionHorizontalPadding - kLinkButtonXAdjustment,
517 } else { 505 yPos)];
518 // -addSubview is idempotent. 506 yPos = NSMaxY([connectionHelpButton_ frame]);
519 [securitySectionView_ addSubview:securityDetailsButton_];
520 [securityDetailsButton_
521 setFrameOrigin:NSMakePoint(
522 kSectionHorizontalPadding - kLinkButtonXAdjustment,
523 yPos)];
524 yPos = NSMaxY([securityDetailsButton_ frame]);
525 }
526 507
527 if (resetDecisionsButton_) { 508 if (resetDecisionsButton_) {
528 DCHECK(resetDecisionsField_); 509 DCHECK(resetDecisionsField_);
529 yPos = [self setYPositionOfView:resetDecisionsField_ 510 yPos = [self setYPositionOfView:resetDecisionsField_
530 to:yPos + kSecurityParagraphSpacing]; 511 to:yPos + kSecurityParagraphSpacing];
531 [resetDecisionsButton_ 512 [resetDecisionsButton_
532 setFrameOrigin:NSMakePoint(NSMinX([resetDecisionsButton_ frame]) - 513 setFrameOrigin:NSMakePoint(NSMinX([resetDecisionsButton_ frame]) -
533 kLinkButtonXAdjustment, 514 kLinkButtonXAdjustment,
534 yPos)]; 515 yPos)];
535 yPos = NSMaxY([resetDecisionsButton_ frame]); 516 yPos = NSMaxY([resetDecisionsButton_ frame]);
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1165
1185 // Don't show the popup if it's already being shown. Since this method is 1166 // Don't show the popup if it's already being shown. Since this method is
1186 // called each time the location icon is clicked, each click toggles the popup 1167 // called each time the location icon is clicked, each click toggles the popup
1187 // in and out. 1168 // in and out.
1188 if (g_is_popup_showing) 1169 if (g_is_popup_showing)
1189 return; 1170 return;
1190 1171
1191 // Create the bridge. This will be owned by the bubble controller. 1172 // Create the bridge. This will be owned by the bubble controller.
1192 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents); 1173 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents);
1193 1174
1194 bool is_devtools_disabled =
1195 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
1196
1197 // Create the bubble controller. It will dealloc itself when it closes, 1175 // Create the bubble controller. It will dealloc itself when it closes,
1198 // resetting |g_is_popup_showing|. 1176 // resetting |g_is_popup_showing|.
1199 WebsiteSettingsBubbleController* bubble_controller = 1177 WebsiteSettingsBubbleController* bubble_controller =
1200 [[WebsiteSettingsBubbleController alloc] 1178 [[WebsiteSettingsBubbleController alloc]
1201 initWithParentWindow:parent 1179 initWithParentWindow:parent
1202 websiteSettingsUIBridge:bridge 1180 websiteSettingsUIBridge:bridge
1203 webContents:web_contents 1181 webContents:web_contents
1204 url:virtual_url 1182 url:virtual_url];
1205 isDevToolsDisabled:is_devtools_disabled];
1206 1183
1207 if (!IsInternalURL(virtual_url)) { 1184 if (!IsInternalURL(virtual_url)) {
1208 // Initialize the presenter, which holds the model and controls the UI. 1185 // Initialize the presenter, which holds the model and controls the UI.
1209 // This is also owned by the bubble controller. 1186 // This is also owned by the bubble controller.
1210 WebsiteSettings* presenter = new WebsiteSettings( 1187 WebsiteSettings* presenter = new WebsiteSettings(
1211 bridge, profile, 1188 bridge, profile,
1212 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, 1189 TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
1213 virtual_url, security_info); 1190 virtual_url, security_info);
1214 [bubble_controller setPresenter:presenter]; 1191 [bubble_controller setPresenter:presenter];
1215 } 1192 }
(...skipping 21 matching lines...) Expand all
1237 void WebsiteSettingsUIBridge::SetPermissionInfo( 1214 void WebsiteSettingsUIBridge::SetPermissionInfo(
1238 const PermissionInfoList& permission_info_list, 1215 const PermissionInfoList& permission_info_list,
1239 ChosenObjectInfoList chosen_object_info_list) { 1216 ChosenObjectInfoList chosen_object_info_list) {
1240 [bubble_controller_ setPermissionInfo:permission_info_list 1217 [bubble_controller_ setPermissionInfo:permission_info_list
1241 andChosenObjects:std::move(chosen_object_info_list)]; 1218 andChosenObjects:std::move(chosen_object_info_list)];
1242 } 1219 }
1243 1220
1244 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1221 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1245 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) 1222 // TODO(lgarron): Remove this from the interface. (crbug.com/571533)
1246 } 1223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698