Commit 405b5e35 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: remove Cocoa PageInfo code

This code is dead since SecondaryUiMd has been on by default for several
releases now.

Bug: 832676
Change-Id: I5cfcdf8d1147dd3a788f0e8b57cf96a98d86f39e
Reviewed-on: https://chromium-review.googlesource.com/1148010Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577493}
parent 1a5ca118
......@@ -425,14 +425,6 @@ jumbo_split_static_library("ui") {
"cocoa/one_click_signin_dialog_controller.mm",
"cocoa/one_click_signin_view_controller.h",
"cocoa/one_click_signin_view_controller.mm",
"cocoa/page_info/page_info_bubble_controller.h",
"cocoa/page_info/page_info_bubble_controller.mm",
"cocoa/page_info/page_info_utils_cocoa.h",
"cocoa/page_info/page_info_utils_cocoa.mm",
"cocoa/page_info/permission_selector_button.h",
"cocoa/page_info/permission_selector_button.mm",
"cocoa/page_info/split_block_button.h",
"cocoa/page_info/split_block_button.mm",
"cocoa/password_reuse_warning_dialog_cocoa.h",
"cocoa/password_reuse_warning_dialog_cocoa.mm",
"cocoa/password_reuse_warning_view_controller.h",
......@@ -2622,8 +2614,6 @@ jumbo_split_static_library("ui") {
"cocoa/importer/import_lock_dialog_cocoa.mm",
"cocoa/login_handler_cocoa.h",
"cocoa/login_handler_cocoa.mm",
"cocoa/page_info/page_info_bubble_controller.h",
"cocoa/page_info/page_info_bubble_controller.mm",
"cocoa/password_reuse_warning_dialog_cocoa.h",
"cocoa/password_reuse_warning_dialog_cocoa.mm",
"cocoa/password_reuse_warning_view_controller.h",
......
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#include <memory>
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#import "chrome/browser/ui/cocoa/base_bubble_controller.h"
#include "chrome/browser/ui/page_info/page_info_ui.h"
#include "content/public/browser/web_contents_observer.h"
class LocationBarDecoration;
class PageInfoUIBridge;
@class InspectLinkView;
namespace content {
class WebContents;
}
namespace net {
class X509Certificate;
}
// This NSWindowController subclass manages the InfoBubbleWindow and view that
// are displayed when the user clicks the omnibox security indicator icon.
@interface PageInfoBubbleController : BaseBubbleController {
@private
content::WebContents* webContents_;
base::scoped_nsobject<NSView> contentView_;
// The main content view for the Permissions tab.
NSView* securitySectionView_;
// Displays the short security summary for the page
// (private/not private/etc.).
NSTextField* securitySummaryField_;
// Displays a longer explanation of the page's security state, and how the
// user should treat it.
NSTextField* securityDetailsField_;
// The link button for opening a Chrome Help Center page explaining connection
// security.
NSButton* connectionHelpButton_;
// URL of the page for which the bubble is shown.
GURL url_;
// Displays a paragraph to accompany the reset decisions button, explaining
// that the user has made a decision to trust an invalid security certificate
// for the current site.
// This field only shows when there is an acrive certificate exception.
NSTextField* resetDecisionsField_;
// The link button for revoking certificate decisions.
// This link only shows when there is an active certificate exception.
NSButton* resetDecisionsButton_;
// The server certificate from the identity info. This should always be
// non-null on a cryptographic connection, and null otherwise.
scoped_refptr<net::X509Certificate> certificate_;
// Separator line.
NSView* separatorAfterSecuritySection_;
// Container for the site settings section.
NSView* siteSettingsSectionView_;
// Container for certificate info in the site settings section.
InspectLinkView* certificateView_;
// Container for cookies info in the site settings section.
InspectLinkView* cookiesView_;
// Container for permission info in the site settings section.
NSView* permissionsView_;
// The link button for showing site settings.
NSButton* siteSettingsButton_;
// The UI translates user actions to specific events and forwards them to the
// |presenter_|. The |presenter_| handles these events and updates the UI.
std::unique_ptr<PageInfo> presenter_;
// Bridge which implements the PageInfoUI interface and forwards
// methods on to this class.
std::unique_ptr<PageInfoUIBridge> bridge_;
// The omnibox icon the bubble is anchored to. The icon is set as active
// when the bubble is opened, and inactive when the bubble is closed.
// Usually we would override OmniboxDecorationBubbleController but the page
// info icon has a race condition where it might switch between
// LocationIconDecoration and SecurityStateBubbleDecoration.
LocationBarDecoration* decoration_; // Weak.
// The button for changing password decisions.
// This button only shows when there is an password reuse event.
NSButton* changePasswordButton_;
// The button for whitelisting password reuse decisions.
// This button only shows when there is an password reuse event.
NSButton* whitelistPasswordReuseButton_;
}
// Designated initializer. The controller will release itself when the bubble
// is closed. |parentWindow| cannot be nil. |webContents| may be nil for
// testing purposes.
- (id)initWithParentWindow:(NSWindow*)parentWindow
pageInfoUIBridge:(PageInfoUIBridge*)bridge
webContents:(content::WebContents*)webContents
url:(const GURL&)url;
// Return the default width of the window. It may be wider to fit the content.
// This may be overriden by a subclass for testing purposes.
- (CGFloat)defaultWindowWidth;
@end
// Provides a bridge between the PageInfoUI C++ interface and the Cocoa
// implementation in PageInfoBubbleController.
class PageInfoUIBridge : public content::WebContentsObserver,
public PageInfoUI {
public:
explicit PageInfoUIBridge(content::WebContents* web_contents);
~PageInfoUIBridge() override;
void set_bubble_controller(PageInfoBubbleController* bubble_controller);
// WebContentsObserver implementation.
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
// PageInfoUI implementations.
void SetCookieInfo(const CookieInfoList& cookie_info_list) override;
void SetPermissionInfo(const PermissionInfoList& permission_info_list,
ChosenObjectInfoList chosen_object_info_list) override;
void SetIdentityInfo(const IdentityInfo& identity_info) override;
protected:
// WebContentsObserver implementation.
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
private:
// The WebContents the bubble UI is attached to.
content::WebContents* web_contents_;
// The Cocoa controller for the bubble UI.
PageInfoBubbleController* bubble_controller_;
DISALLOW_COPY_AND_ASSIGN(PageInfoUIBridge);
};
#endif // CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_
......@@ -66,19 +66,13 @@ IN_PROC_BROWSER_TEST_P(PageInfoBubbleViewsMacTest, NoCrashOnFullScreenToggle) {
access_manager->fullscreen_controller();
fullscreen_controller->ToggleBrowserFullscreenMode();
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
views::BubbleDialogDelegateView* page_info =
PageInfoBubbleView::GetPageInfoBubble();
EXPECT_TRUE(page_info);
views::Widget* page_info_bubble = page_info->GetWidget();
EXPECT_TRUE(page_info_bubble);
EXPECT_EQ(GetParam().bubble_type, PageInfoBubbleView::GetShownBubbleType());
EXPECT_TRUE(page_info_bubble->IsVisible());
} else {
EXPECT_TRUE([PageInfoBubbleController getPageInfoBubbleForTest]);
// In Cocoa, the crash occurs when the bubble tries to re-layout.
[[PageInfoBubbleController getPageInfoBubbleForTest] performLayout];
}
views::BubbleDialogDelegateView* page_info =
PageInfoBubbleView::GetPageInfoBubble();
EXPECT_TRUE(page_info);
views::Widget* page_info_bubble = page_info->GetWidget();
EXPECT_TRUE(page_info_bubble);
EXPECT_EQ(GetParam().bubble_type, PageInfoBubbleView::GetShownBubbleType());
EXPECT_TRUE(page_info_bubble->IsVisible());
// There should be no crash here from re-anchoring the Page Info bubble while
// transitioning into full screen.
......
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_UTILS_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_UTILS_COCOA_H_
#import <Cocoa/Cocoa.h>
NSSize SizeForPageInfoButtonTitle(NSPopUpButton* button, NSString* title);
#endif // CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_UTILS_COCOA_H_
// 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.
#include "chrome/browser/ui/cocoa/page_info/page_info_utils_cocoa.h"
namespace {
// The amount of horizontal space between the button's title and its arrow icon.
const CGFloat kButtonTitleRightPadding = 4.0f;
}
// Determine the size of a popup button with the given title.
NSSize SizeForPageInfoButtonTitle(NSPopUpButton* button, NSString* title) {
NSDictionary* textAttributes =
[[button attributedTitle] attributesAtIndex:0 effectiveRange:NULL];
NSSize titleSize = [title sizeWithAttributes:textAttributes];
NSRect frame = [button frame];
NSRect titleRect = [[button cell] titleRectForBounds:frame];
CGFloat width = titleSize.width + NSWidth(frame) - NSWidth(titleRect);
return NSMakeSize(width + kButtonTitleRightPadding, NSHeight(frame));
}
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_PAGE_INFO_PERMISSION_SELECTOR_BUTTON_H_
#define CHROME_BROWSER_UI_COCOA_PAGE_INFO_PERMISSION_SELECTOR_BUTTON_H_
#import <Cocoa/Cocoa.h>
#include <memory>
#include "base/mac/scoped_nsobject.h"
#include "chrome/browser/ui/page_info/permission_menu_model.h"
#include "components/content_settings/core/common/content_settings.h"
@class MenuControllerCocoa;
class Profile;
@interface PermissionSelectorButton : NSPopUpButton {
@private
std::unique_ptr<PermissionMenuModel> menuModel_;
base::scoped_nsobject<MenuControllerCocoa> menuController_;
}
// Designated initializer.
- (id)initWithPermissionInfo:(const PageInfoUI::PermissionInfo&)permissionInfo
forURL:(const GURL&)url
withCallback:(PermissionMenuModel::ChangeCallback)callback
profile:(Profile*)profile;
// Returns the largest possible size given all of the items in the menu.
- (CGFloat)maxTitleWidthForContentSettingsType:(ContentSettingsType)type
withDefaultSetting:(ContentSetting)defaultSetting
profile:(Profile*)profile;
// Updates the title of the NSPopUpButton and resizes it to fit the new text.
- (void)setButtonTitle:(const PageInfoUI::PermissionInfo&)permissionInfo
profile:(Profile*)profile;
@end
#endif // CHROME_BROWSER_UI_COCOA_PAGE_INFO_PERMISSION_SELECTOR_BUTTON_H_
// 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/page_info/permission_selector_button.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/ui/cocoa/page_info/page_info_utils_cocoa.h"
#include "chrome/browser/ui/page_info/page_info_ui.h"
#import "ui/base/cocoa/menu_controller.h"
@implementation PermissionSelectorButton
- (id)initWithPermissionInfo:(const PageInfoUI::PermissionInfo&)permissionInfo
forURL:(const GURL&)url
withCallback:(PermissionMenuModel::ChangeCallback)callback
profile:(Profile*)profile {
if (self = [super initWithFrame:NSMakeRect(0, 0, 1, 1) pullsDown:NO]) {
[self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[self setBordered:NO];
[[self cell] setControlSize:NSSmallControlSize];
menuModel_.reset(
new PermissionMenuModel(profile, url, permissionInfo, callback));
menuController_.reset([[MenuControllerCocoa alloc]
initWithModel:menuModel_.get()
useWithPopUpButtonCell:NO]);
[self setMenu:[menuController_ menu]];
[self selectItemWithTag:permissionInfo.setting];
[self setButtonTitle:permissionInfo profile:profile];
NSString* description = base::SysUTF16ToNSString(
PageInfoUI::PermissionTypeToUIString(permissionInfo.type));
[[self cell]
accessibilitySetOverrideValue:description
forAttribute:NSAccessibilityDescriptionAttribute];
}
return self;
}
- (CGFloat)maxTitleWidthForContentSettingsType:(ContentSettingsType)type
withDefaultSetting:(ContentSetting)defaultSetting
profile:(Profile*)profile {
// Determine the largest possible size for this button.
CGFloat maxTitleWidth = 0;
for (NSMenuItem* item in [self itemArray]) {
NSString* title =
base::SysUTF16ToNSString(PageInfoUI::PermissionActionToUIString(
profile, type, static_cast<ContentSetting>([item tag]),
defaultSetting, content_settings::SETTING_SOURCE_USER));
NSSize size = SizeForPageInfoButtonTitle(self, title);
maxTitleWidth = std::max(maxTitleWidth, size.width);
}
return maxTitleWidth;
}
// Accessor function for testing only.
- (NSMenu*)permissionMenu {
return [menuController_ menu];
}
- (void)setButtonTitle:(const PageInfoUI::PermissionInfo&)permissionInfo
profile:(Profile*)profile {
// Set the button title.
base::scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]);
base::string16 buttonTitle = PageInfoUI::PermissionActionToUIString(
profile, permissionInfo.type, permissionInfo.setting,
permissionInfo.default_setting, permissionInfo.source);
[titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)];
[[self cell] setUsesItemFromMenu:NO];
[[self cell] setMenuItem:titleItem];
// Although the frame is reset, below, this sizes the cell properly.
[self sizeToFit];
// Size the button to just fit the visible title - not all of its items.
[self setFrameSize:SizeForPageInfoButtonTitle(self, [self title])];
}
@end
// 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/page_info/permission_selector_button.h"
#include "base/mac/scoped_nsobject.h"
#include "base/test/scoped_feature_list.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "chrome/browser/ui/page_info/page_info_ui.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "ui/base/ui_base_features.h"
@interface PermissionSelectorButton (Testing)
- (NSMenu*)permissionMenu;
@end
namespace {
const ContentSettingsType kTestPermissionType =
CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
class PermissionSelectorButtonTest : public CocoaTest {
public:
PermissionSelectorButtonTest() {
// This file only tests Cocoa UI and can be deleted when kSecondaryUiMd is
// default.
scoped_feature_list_.InitAndDisableFeature(features::kSecondaryUiMd);
got_callback_ = false;
PageInfoUI::PermissionInfo test_info;
test_info.type = kTestPermissionType;
test_info.setting = CONTENT_SETTING_BLOCK;
test_info.source = content_settings::SETTING_SOURCE_USER;
test_info.is_incognito = false;
GURL test_url("http://www.google.com");
PermissionMenuModel::ChangeCallback callback = base::Bind(
&PermissionSelectorButtonTest::Callback, base::Unretained(this));
view_.reset([[PermissionSelectorButton alloc]
initWithPermissionInfo:test_info
forURL:test_url
withCallback:callback
profile:&profile_]);
[[test_window() contentView] addSubview:view_];
}
void Callback(const PageInfoUI::PermissionInfo& permission) {
EXPECT_TRUE(permission.type == kTestPermissionType);
got_callback_ = true;
}
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
bool got_callback_;
base::scoped_nsobject<PermissionSelectorButton> view_;
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(PermissionSelectorButtonTest);
};
TEST_VIEW(PermissionSelectorButtonTest, view_);
TEST_F(PermissionSelectorButtonTest, Callback) {
NSMenu* menu = [view_ permissionMenu];
NSMenuItem* item = [menu itemAtIndex:0];
[[item target] performSelector:[item action] withObject:item];
EXPECT_TRUE(got_callback_);
}
} // namespace
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_PAGE_INFO_SPLIT_BLOCK_BUTTON_H_
#define CHROME_BROWSER_UI_COCOA_PAGE_INFO_SPLIT_BLOCK_BUTTON_H_
#import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
#include "ui/base/models/simple_menu_model.h"
@class SplitButtonPopUpCell;
@class SplitButtonTitleCell;
// Block ('deny') button for the permissions bubble. Subclassed from
// ConstrainedWindowButton, so that it shares styling, but contains two cells
// instead of just one. The left cell behaves as a normal button, and when
// clicked, calls the button's |action| on its |target|. The right cell behaves
// as a NSPopUpButtonCell, and implements a single-item menu.
@interface SplitBlockButton : ConstrainedWindowButton {
@private
base::scoped_nsobject<SplitButtonTitleCell> leftCell_;
base::scoped_nsobject<SplitButtonPopUpCell> rightCell_;
ui::ScopedCrTrackingArea leftTrackingArea_;
ui::ScopedCrTrackingArea rightTrackingArea_;
}
// Designated initializer.
- (id)initWithMenuDelegate:(ui::SimpleMenuModel::Delegate*)menuDelegate;
@end
#endif // CHROME_BROWSER_UI_COCOA_PAGE_INFO_SPLIT_BLOCK_BUTTON_H_
......@@ -4168,7 +4168,6 @@ test("unit_tests") {
"../browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm",
"../browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm",
"../browser/ui/cocoa/page_info/page_info_bubble_controller_unittest.mm",
"../browser/ui/cocoa/page_info/permission_selector_button_unittest.mm",
"../browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm",
"../browser/ui/cocoa/profiles/avatar_button_unittest.mm",
"../browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment