Commit dd63892e authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Delete password generation prompt on Cocoa.

The automatic password generation is still not launched. I checked that the Views prompt works all right on Mac. We are gonna invest time only into the Views UI. Let's make it simpler.

Bug: 832676
Change-Id: Ic8bff3d267579df976072cfde762f73054747190
Reviewed-on: https://chromium-review.googlesource.com/1088607Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565669}
parent 2d21d004
...@@ -75,10 +75,6 @@ split_static_library("ui") { ...@@ -75,10 +75,6 @@ split_static_library("ui") {
"cocoa/autofill/autofill_tooltip_controller.mm", "cocoa/autofill/autofill_tooltip_controller.mm",
"cocoa/autofill/credit_card_autofill_touch_bar_controller.h", "cocoa/autofill/credit_card_autofill_touch_bar_controller.h",
"cocoa/autofill/credit_card_autofill_touch_bar_controller.mm", "cocoa/autofill/credit_card_autofill_touch_bar_controller.mm",
"cocoa/autofill/password_generation_popup_view_bridge.h",
"cocoa/autofill/password_generation_popup_view_bridge.mm",
"cocoa/autofill/password_generation_popup_view_cocoa.h",
"cocoa/autofill/password_generation_popup_view_cocoa.mm",
"cocoa/autofill/save_card_bubble_view_views.h", "cocoa/autofill/save_card_bubble_view_views.h",
"cocoa/autofill/save_card_bubble_view_views.mm", "cocoa/autofill/save_card_bubble_view_views.mm",
"cocoa/background_gradient_view.h", "cocoa/background_gradient_view.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_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_BRIDGE_H_
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_BRIDGE_H_
#include <vector>
#include "base/compiler_specific.h"
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "chrome/browser/ui/passwords/password_generation_popup_view.h"
@class PasswordGenerationPopupViewCocoa;
namespace autofill {
// Mac implementation for PasswordGenerationPopupView interface.
// Serves as a bridge to an instance of the Objective-C class which actually
// implements the view.
class PasswordGenerationPopupViewBridge : public PasswordGenerationPopupView {
public:
explicit PasswordGenerationPopupViewBridge(
PasswordGenerationPopupController* controller);
private:
virtual ~PasswordGenerationPopupViewBridge();
// PasswordGenerationPopupView implementation.
void Hide() override;
void Show() override;
gfx::Size GetPreferredSizeOfPasswordView() override;
void UpdateBoundsAndRedrawPopup() override;
void PasswordSelectionUpdated() override;
bool IsPointInPasswordBounds(const gfx::Point& point) override;
// The native Cocoa view.
base::scoped_nsobject<PasswordGenerationPopupViewCocoa> view_;
DISALLOW_COPY_AND_ASSIGN(PasswordGenerationPopupViewBridge);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_BRIDGE_H_
// Copyright (c) 2012 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 <Cocoa/Cocoa.h>
#include "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_bridge.h"
#include "base/logging.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#import "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_cocoa.h"
#include "ui/base/ui_features.h"
#include "ui/gfx/geometry/size.h"
namespace autofill {
PasswordGenerationPopupViewBridge::PasswordGenerationPopupViewBridge(
PasswordGenerationPopupController* controller) {
view_.reset(
[[PasswordGenerationPopupViewCocoa alloc]
initWithController:controller
frame:NSZeroRect]);
}
PasswordGenerationPopupViewBridge::~PasswordGenerationPopupViewBridge() {
[view_ controllerDestroyed];
[view_ hidePopup];
}
void PasswordGenerationPopupViewBridge::Hide() {
delete this;
}
void PasswordGenerationPopupViewBridge::Show() {
[view_ showPopup];
}
gfx::Size PasswordGenerationPopupViewBridge::GetPreferredSizeOfPasswordView() {
return gfx::Size(NSSizeToCGSize([view_ preferredSize]));
}
void PasswordGenerationPopupViewBridge::UpdateBoundsAndRedrawPopup() {
[view_ updateBoundsAndRedrawPopup];
}
void PasswordGenerationPopupViewBridge::PasswordSelectionUpdated() {
[view_ setNeedsDisplay:YES];
}
bool PasswordGenerationPopupViewBridge::IsPointInPasswordBounds(
const gfx::Point& point) {
return [view_ isPointInPasswordBounds:NSPointFromCGPoint(point.ToCGPoint())];
}
PasswordGenerationPopupView* PasswordGenerationPopupView::CreateCocoa(
PasswordGenerationPopupController* controller) {
return new PasswordGenerationPopupViewBridge(controller);
}
#if !BUILDFLAG(MAC_VIEWS_BROWSER)
PasswordGenerationPopupView* PasswordGenerationPopupView::Create(
PasswordGenerationPopupController* controller) {
return CreateCocoa(controller);
}
#endif
} // namespace autofill
// 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_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_COCOA_H_
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.h"
#include "chrome/browser/ui/passwords/password_generation_popup_controller.h"
#import "ui/base/cocoa/tracking_area.h"
@class HyperlinkTextView;
// Draws the native password generation popup view on Mac.
@interface PasswordGenerationPopupViewCocoa
: AutofillPopupBaseViewCocoa <NSTextViewDelegate> {
@private
// The cross-platform controller for this view.
autofill::PasswordGenerationPopupController* controller_; // weak
base::scoped_nsobject<NSView> passwordSection_;
base::scoped_nsobject<NSTextField> passwordField_;
base::scoped_nsobject<NSTextField> passwordTitleField_;
base::scoped_nsobject<NSImageView> keyIcon_;
base::scoped_nsobject<NSBox> divider_;
base::scoped_nsobject<HyperlinkTextView> helpTextView_;
ui::ScopedCrTrackingArea helpTextTrackingArea_;
}
// Designated initializer.
- (id)initWithController:
(autofill::PasswordGenerationPopupController*)controller
frame:(NSRect)frame;
// Determines whether |point| falls inside the password section of the popup.
// |point| needs to be in the popup's coordinate system.
- (BOOL)isPointInPasswordBounds:(NSPoint)point;
// Informs the view that its controller has been (or will imminently be)
// destroyed.
- (void)controllerDestroyed;
// The preferred size for the popup.
- (NSSize)preferredSize;
@end
#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_PASSWORD_GENERATION_POPUP_VIEW_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.
#import "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_cocoa.h"
#include <cmath>
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_popup_view.h"
#include "chrome/browser/ui/autofill/popup_constants.h"
#include "chrome/browser/ui/cocoa/autofill/password_generation_popup_view_bridge.h"
#include "chrome/browser/ui/cocoa/chrome_style.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/controls/hyperlink_text_view.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_util_mac.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/range/range.h"
#include "ui/gfx/text_constants.h"
using autofill::AutofillPopupView;
using autofill::PasswordGenerationPopupController;
using autofill::PasswordGenerationPopupView;
using base::scoped_nsobject;
namespace {
// The height of the divider between the password and help sections, in pixels.
const CGFloat kDividerHeight = 1;
// The amount of whitespace, in pixels, between lines of text in the password
// section.
const CGFloat kPasswordSectionVerticalSeparation = 5;
NSColor* DividerColor() {
return skia::SkColorToCalibratedNSColor(
PasswordGenerationPopupView::kDividerColor);
}
NSColor* HelpTextBackgroundColor() {
return skia::SkColorToCalibratedNSColor(
PasswordGenerationPopupView::kExplanatoryTextBackgroundColor);
}
NSColor* HelpTextColor() {
return skia::SkColorToCalibratedNSColor(
PasswordGenerationPopupView::kExplanatoryTextColor);
}
NSColor* HelpLinkColor() {
return skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
}
} // namespace
@implementation PasswordGenerationPopupViewCocoa
#pragma mark Initialisers
- (id)initWithFrame:(NSRect)frame {
NOTREACHED();
return nil;
}
- (id)initWithController:
(autofill::PasswordGenerationPopupController*)controller
frame:(NSRect)frame {
if (self = [super initWithDelegate:controller frame:frame]) {
controller_ = controller;
passwordSection_.reset([[NSView alloc] initWithFrame:NSZeroRect]);
[self addSubview:passwordSection_];
passwordField_.reset(
[[self textFieldWithText:controller_->password()
attributes:[self passwordAttributes]] retain]);
[passwordSection_ addSubview:passwordField_];
passwordTitleField_.reset(
[[self textFieldWithText:controller_->SuggestedText()
attributes:[self passwordTitleAttributes]] retain]);
[passwordSection_ addSubview:passwordTitleField_];
keyIcon_.reset([[NSImageView alloc] initWithFrame:NSZeroRect]);
NSImage* keyImage = NSImageFromImageSkia(
gfx::CreateVectorIcon(kKeyIcon, 16, gfx::kChromeIconGrey));
[keyIcon_ setImage:keyImage];
[passwordSection_ addSubview:keyIcon_];
divider_.reset([[NSBox alloc] initWithFrame:NSZeroRect]);
[divider_ setBoxType:NSBoxCustom];
[divider_ setBorderType:NSLineBorder];
[divider_ setBorderColor:DividerColor()];
[self addSubview:divider_];
helpTextView_.reset([[HyperlinkTextView alloc] initWithFrame:NSZeroRect]);
[helpTextView_ setMessage:base::SysUTF16ToNSString(controller_->HelpText())
withFont:[self textFont]
messageColor:HelpTextColor()];
[helpTextView_ addLinkRange:controller_->HelpTextLinkRange().ToNSRange()
withURL:nil
linkColor:HelpLinkColor()];
[helpTextView_ setDelegate:self];
[helpTextView_ setDrawsBackground:YES];
[helpTextView_ setBackgroundColor:HelpTextBackgroundColor()];
[helpTextView_
setTextContainerInset:NSMakeSize(controller_->kHorizontalPadding,
controller_->kHelpVerticalPadding)];
// Remove the underlining.
NSTextStorage* text = [helpTextView_ textStorage];
[text addAttribute:NSUnderlineStyleAttributeName
value:@(NSUnderlineStyleNone)
range:controller_->HelpTextLinkRange().ToNSRange()];
[self addSubview:helpTextView_];
}
return self;
}
- (void)updateTrackingAreas {
[super updateTrackingAreas];
if (helpTextTrackingArea_.get())
[self removeTrackingArea:helpTextTrackingArea_.get()];
// Set up tracking for the help text so the cursor, etc. is properly handled.
// Must set tracking to "always" because the autofill window is never key.
NSTrackingAreaOptions options = NSTrackingActiveAlways |
NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved |
NSTrackingCursorUpdate;
helpTextTrackingArea_.reset(
[[CrTrackingArea alloc] initWithRect:[self bounds]
options:options
owner:helpTextView_.get()
userInfo:nil]);
[self addTrackingArea:helpTextTrackingArea_.get()];
}
#pragma mark NSView implementation:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// If the view is in the process of being destroyed, don't bother drawing.
if (!controller_)
return;
[self drawBackgroundAndBorder];
if (controller_->password_selected()) {
// Draw a highlight under the suggested password.
NSRect highlightBounds = [passwordSection_ frame];
[[self highlightColor] set];
[NSBezierPath fillRect:highlightBounds];
}
}
#pragma mark Public API:
- (NSSize)preferredSize {
const NSSize passwordTitleSize =
[base::SysUTF16ToNSString(controller_->SuggestedText())
sizeWithAttributes:@{ NSFontAttributeName : [self boldFont] }];
const NSSize passwordSize = [base::SysUTF16ToNSString(controller_->password())
sizeWithAttributes:@{ NSFontAttributeName : [self textFont] }];
CGFloat width =
autofill::kPopupBorderThickness +
controller_->kHorizontalPadding +
[[keyIcon_ image] size].width +
controller_->kHorizontalPadding +
std::max(passwordSize.width, passwordTitleSize.width) +
controller_->kHorizontalPadding +
autofill::kPopupBorderThickness;
width = std::max(width, (CGFloat)controller_->GetMinimumWidth());
CGFloat contentWidth = width - (2 * controller_->kHorizontalPadding);
CGFloat height =
autofill::kPopupBorderThickness +
controller_->kHelpVerticalPadding +
[self helpSizeForPopupWidth:contentWidth].height +
controller_->kHelpVerticalPadding +
autofill::kPopupBorderThickness;
if (controller_->display_password())
height += controller_->kPopupPasswordSectionHeight;
return NSMakeSize(width, height);
}
- (void)updateBoundsAndRedrawPopup {
const CGFloat popupWidth = controller_->popup_bounds().width();
const CGFloat contentWidth =
popupWidth - (2 * autofill::kPopupBorderThickness);
const CGFloat contentHeight = controller_->popup_bounds().height() -
(2 * autofill::kPopupBorderThickness);
if (controller_->display_password()) {
// The password can change while the bubble is shown: If the user has
// accepted the password and then selects the form again and starts deleting
// the password, the field will be initially invisible and then become
// visible.
[self updatePassword];
// Lay out the password section, which includes the key icon, the title, and
// the suggested password.
[passwordSection_
setFrame:NSMakeRect(autofill::kPopupBorderThickness,
autofill::kPopupBorderThickness,
contentWidth,
controller_->kPopupPasswordSectionHeight)];
// The key icon falls to the left of the title and password.
const NSSize imageSize = [[keyIcon_ image] size];
const CGFloat keyX = controller_->kHorizontalPadding;
const CGFloat keyY =
std::ceil((controller_->kPopupPasswordSectionHeight / 2.0) -
(imageSize.height / 2.0));
[keyIcon_ setFrame:{ NSMakePoint(keyX, keyY), imageSize }];
// The title and password fall to the right of the key icon and are centered
// vertically as a group with some padding in between.
[passwordTitleField_ sizeToFit];
[passwordField_ sizeToFit];
const CGFloat groupHeight = NSHeight([passwordField_ frame]) +
kPasswordSectionVerticalSeparation +
NSHeight([passwordTitleField_ frame]);
const CGFloat groupX =
NSMaxX([keyIcon_ frame]) + controller_->kHorizontalPadding;
const CGFloat groupY =
std::ceil((controller_->kPopupPasswordSectionHeight / 2.0) -
(groupHeight / 2.0));
[passwordField_ setFrameOrigin:NSMakePoint(groupX, groupY)];
const CGFloat titleY = groupY +
NSHeight([passwordField_ frame]) +
kPasswordSectionVerticalSeparation;
[passwordTitleField_ setFrameOrigin:NSMakePoint(groupX, titleY)];
// Layout the divider, which falls immediately below the password section.
const CGFloat dividerX = autofill::kPopupBorderThickness;
const CGFloat dividerY = NSMaxY([passwordSection_ frame]);
NSRect dividerFrame =
NSMakeRect(dividerX, dividerY, contentWidth, kDividerHeight);
[divider_ setFrame:dividerFrame];
}
// Layout the help section beneath the divider (if applicable, otherwise
// beneath the border).
const CGFloat helpX = autofill::kPopupBorderThickness;
const CGFloat helpY = controller_->display_password()
? NSMaxY([divider_ frame])
: autofill::kPopupBorderThickness;
const CGFloat helpHeight = contentHeight -
NSHeight([passwordSection_ frame]) -
NSHeight([divider_ frame]);
[helpTextView_ setFrame:NSMakeRect(helpX, helpY, contentWidth, helpHeight)];
[super updateBoundsAndRedrawPopup];
}
- (BOOL)isPointInPasswordBounds:(NSPoint)point {
return NSPointInRect(point, [passwordSection_ frame]);
}
- (void)controllerDestroyed {
controller_ = NULL;
[super delegateDestroyed];
}
#pragma mark NSTextViewDelegate implementation:
- (BOOL)textView:(NSTextView*)textView
clickedOnLink:(id)link
atIndex:(NSUInteger)charIndex {
controller_->OnSavedPasswordsLinkClicked();
return YES;
}
#pragma mark Private helpers:
- (void)updatePassword {
base::scoped_nsobject<NSMutableAttributedString> updatedPassword(
[[NSMutableAttributedString alloc]
initWithString:base::SysUTF16ToNSString(controller_->password())
attributes:[self passwordAttributes]]);
[passwordField_ setAttributedStringValue:updatedPassword];
}
- (NSDictionary*)passwordTitleAttributes {
scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
[[NSMutableParagraphStyle alloc] init]);
[paragraphStyle setAlignment:NSLeftTextAlignment];
return @{
NSFontAttributeName : [self boldFont],
NSForegroundColorAttributeName : [self nameColor],
NSParagraphStyleAttributeName : paragraphStyle.autorelease()
};
}
- (NSDictionary*)passwordAttributes {
scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
[[NSMutableParagraphStyle alloc] init]);
[paragraphStyle setAlignment:NSLeftTextAlignment];
return @{
NSFontAttributeName : [self textFont],
NSForegroundColorAttributeName : [self nameColor],
NSParagraphStyleAttributeName : paragraphStyle.autorelease()
};
}
- (NSTextField*)textFieldWithText:(const base::string16&)text
attributes:(NSDictionary*)attributes {
NSTextField* textField =
[[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease];
scoped_nsobject<NSAttributedString> attributedString(
[[NSAttributedString alloc]
initWithString:base::SysUTF16ToNSString(text)
attributes:attributes]);
[textField setAttributedStringValue:attributedString.autorelease()];
[textField setEditable:NO];
[textField setSelectable:NO];
[textField setDrawsBackground:NO];
[textField setBezeled:NO];
return textField;
}
- (NSSize)helpSizeForPopupWidth:(CGFloat)width {
const CGFloat helpWidth = width -
2 * controller_->kHorizontalPadding -
2 * autofill::kPopupBorderThickness;
const NSSize size = NSMakeSize(helpWidth, MAXFLOAT);
NSRect textFrame = [base::SysUTF16ToNSString(controller_->HelpText())
boundingRectWithSize:size
options:NSLineBreakByWordWrapping |
NSStringDrawingUsesLineFragmentOrigin
attributes:@{ NSFontAttributeName : [self textFont] }];
return textFrame.size;
}
- (NSFont*)boldFont {
return [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
}
- (NSFont*)textFont {
return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
}
@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/autofill/password_generation_popup_view_cocoa.h"
#include <stddef.h>
#include <memory>
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "components/autofill/core/browser/suggestion.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/range/range.h"
using testing::AtLeast;
using testing::Return;
namespace {
class MockPasswordGenerationPopupController
: public autofill::PasswordGenerationPopupController {
public:
MockPasswordGenerationPopupController()
: help_text_(base::ASCIIToUTF16("Help me if you can I'm feeling dooown")),
popup_bounds_(gfx::Rect(0, 0, 200, 100)) {}
MOCK_METHOD0(PasswordAccepted, void());
void OnSavedPasswordsLinkClicked() override {}
int GetMinimumWidth() override { return 200; }
bool display_password() const override { return true; }
bool password_selected() const override { return false; }
MOCK_CONST_METHOD0(password, base::string16());
base::string16 SuggestedText() override {
return base::ASCIIToUTF16("Suggested by Chrome");
}
const base::string16& HelpText() override { return help_text_; }
const gfx::Range& HelpTextLinkRange() override { return link_range_; }
// AutofillPopupViewDelegate implementation.
void Hide() override {}
MOCK_METHOD0(ViewDestroyed, void());
void SetSelectionAtPoint(const gfx::Point&) override {}
bool AcceptSelectedLine() override { return true; }
void SelectionCleared() override {}
bool HasSelection() const override { return password_selected(); }
gfx::Rect popup_bounds() const override { return popup_bounds_; }
MOCK_METHOD0(container_view, gfx::NativeView());
MOCK_CONST_METHOD0(element_bounds, gfx::RectF&());
MOCK_CONST_METHOD0(IsRTL, bool());
MOCK_METHOD0(GetSuggestions, const std::vector<autofill::Suggestion>());
void SetTypesetter(gfx::Typesetter Typesetter) override {}
MOCK_METHOD1(GetElidedValueWidthForRow, int(int));
MOCK_METHOD1(GetElidedLabelWidthForRow, int(int));
private:
base::string16 help_text_;
gfx::Range link_range_;
const gfx::Rect popup_bounds_;
DISALLOW_COPY_AND_ASSIGN(MockPasswordGenerationPopupController);
};
class PasswordGenerationPopupViewCocoaTest : public CocoaTest {
protected:
PasswordGenerationPopupViewCocoaTest()
: password_(base::ASCIIToUTF16("wow! such password"))
{}
void SetUp() override {
mock_controller_.reset(new MockPasswordGenerationPopupController);
EXPECT_CALL(*mock_controller_, password())
.WillRepeatedly(Return(password_));
view_.reset([[PasswordGenerationPopupViewCocoa alloc]
initWithController:mock_controller_.get()
frame:NSZeroRect]);
NSView* contentView = [test_window() contentView];
[contentView addSubview:view_];
EXPECT_CALL(*mock_controller_, container_view())
.WillRepeatedly(Return(contentView));
}
base::string16 password_;
std::unique_ptr<MockPasswordGenerationPopupController> mock_controller_;
base::scoped_nsobject<PasswordGenerationPopupViewCocoa> view_;
};
TEST_VIEW(PasswordGenerationPopupViewCocoaTest, view_);
TEST_F(PasswordGenerationPopupViewCocoaTest, ShowAndHide) {
// Verify that the view fetches a password from the controller.
EXPECT_CALL(*mock_controller_, password()).Times(AtLeast(1))
.WillRepeatedly(Return(password_));
view_.reset([[PasswordGenerationPopupViewCocoa alloc]
initWithController:mock_controller_.get()
frame:NSZeroRect]);
[view_ showPopup];
[view_ display];
[view_ hidePopup];
}
// Verifies that it doesn't crash when the controller is destroyed before the
// popup is hidden.
TEST_F(PasswordGenerationPopupViewCocoaTest, ControllerDestroyed) {
[view_ showPopup];
mock_controller_.reset();
[view_ controllerDestroyed];
[view_ display];
[view_ hidePopup];
}
} // namespace
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_UI_PASSWORDS_PASSWORD_GENERATION_POPUP_VIEW_H_ #ifndef CHROME_BROWSER_UI_PASSWORDS_PASSWORD_GENERATION_POPUP_VIEW_H_
#define CHROME_BROWSER_UI_PASSWORDS_PASSWORD_GENERATION_POPUP_VIEW_H_ #define CHROME_BROWSER_UI_PASSWORDS_PASSWORD_GENERATION_POPUP_VIEW_H_
#include "build/build_config.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
namespace gfx { namespace gfx {
...@@ -44,12 +43,6 @@ class PasswordGenerationPopupView { ...@@ -44,12 +43,6 @@ class PasswordGenerationPopupView {
// when Hide() is called. // when Hide() is called.
static PasswordGenerationPopupView* Create( static PasswordGenerationPopupView* Create(
PasswordGenerationPopupController* controller); PasswordGenerationPopupController* controller);
#if defined(OS_MACOSX)
// Temporary shim for Polychrome. See bottom of first comment in
// https://crbug.com/804950 for details
static PasswordGenerationPopupView* CreateCocoa(
PasswordGenerationPopupController* controller);
#endif
static const SkColor kPasswordTextColor; static const SkColor kPasswordTextColor;
static const SkColor kExplanatoryTextBackgroundColor; static const SkColor kExplanatoryTextBackgroundColor;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/ui/passwords/password_generation_popup_view.h" #include "chrome/browser/ui/passwords/password_generation_popup_view.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/passwords/password_generation_popup_controller_impl.h" #include "chrome/browser/ui/passwords/password_generation_popup_controller_impl.h"
...@@ -57,8 +56,6 @@ class PasswordGenerationPopupViewTest : public InProcessBrowserTest { ...@@ -57,8 +56,6 @@ class PasswordGenerationPopupViewTest : public InProcessBrowserTest {
TestPasswordGenerationPopupController* controller_; TestPasswordGenerationPopupController* controller_;
}; };
// TODO(gcasto): Enable on Mac when UI is updated. (crbug.com/394303)
#if !defined(OS_MACOSX)
// Regression test for crbug.com/400543. Verifying that moving the mouse in the // Regression test for crbug.com/400543. Verifying that moving the mouse in the
// editing dialog doesn't crash. // editing dialog doesn't crash.
IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest,
...@@ -84,7 +81,6 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, InvalidContainerView) { ...@@ -84,7 +81,6 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, InvalidContainerView) {
GetWebContents(), NULL); GetWebContents(), NULL);
controller_->Show(true /* display password */); controller_->Show(true /* display password */);
} }
#endif
// Verify that destroying web contents with visible popup does not crash. // Verify that destroying web contents with visible popup does not crash.
IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest,
......
...@@ -6,12 +6,10 @@ ...@@ -6,12 +6,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/autofill/popup_constants.h" #include "chrome/browser/ui/autofill/popup_constants.h"
#include "chrome/browser/ui/passwords/password_generation_popup_controller.h" #include "chrome/browser/ui/passwords/password_generation_popup_controller.h"
#include "chrome/browser/ui/views/harmony/chrome_typography.h" #include "chrome/browser/ui/views/harmony/chrome_typography.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
...@@ -262,19 +260,13 @@ bool PasswordGenerationPopupViewViews::IsPointInPasswordBounds( ...@@ -262,19 +260,13 @@ bool PasswordGenerationPopupViewViews::IsPointInPasswordBounds(
PasswordGenerationPopupView* PasswordGenerationPopupView::Create( PasswordGenerationPopupView* PasswordGenerationPopupView::Create(
PasswordGenerationPopupController* controller) { PasswordGenerationPopupController* controller) {
#if defined(OS_MACOSX) if (!controller->container_view())
if (views_mode_controller::IsViewsBrowserCocoa()) return nullptr;
return CreateCocoa(controller);
#endif
views::Widget* observing_widget = views::Widget* observing_widget =
views::Widget::GetTopLevelWidgetForNativeView( views::Widget::GetTopLevelWidgetForNativeView(
controller->container_view()); controller->container_view());
// If the top level widget can't be found, cancel the popup since we can't
// fully set it up.
if (!observing_widget)
return NULL;
return new PasswordGenerationPopupViewViews(controller, observing_widget); return new PasswordGenerationPopupViewViews(controller, observing_widget);
} }
......
...@@ -4010,7 +4010,6 @@ test("unit_tests") { ...@@ -4010,7 +4010,6 @@ test("unit_tests") {
"../browser/ui/cocoa/autofill/autofill_bubble_controller_unittest.mm", "../browser/ui/cocoa/autofill/autofill_bubble_controller_unittest.mm",
"../browser/ui/cocoa/autofill/autofill_tooltip_controller_unittest.mm", "../browser/ui/cocoa/autofill/autofill_tooltip_controller_unittest.mm",
"../browser/ui/cocoa/autofill/credit_card_autofill_touch_bar_controller_unittest.mm", "../browser/ui/cocoa/autofill/credit_card_autofill_touch_bar_controller_unittest.mm",
"../browser/ui/cocoa/autofill/password_generation_popup_view_cocoa_unittest.mm",
"../browser/ui/cocoa/background_gradient_view_unittest.mm", "../browser/ui/cocoa/background_gradient_view_unittest.mm",
"../browser/ui/cocoa/base_bubble_controller_unittest.mm", "../browser/ui/cocoa/base_bubble_controller_unittest.mm",
"../browser/ui/cocoa/bookmarks/bookmark_all_tabs_controller_unittest.mm", "../browser/ui/cocoa/bookmarks/bookmark_all_tabs_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