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") {
"cocoa/autofill/autofill_tooltip_controller.mm",
"cocoa/autofill/credit_card_autofill_touch_bar_controller.h",
"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.mm",
"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 <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 @@
#ifndef 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"
namespace gfx {
......@@ -44,12 +43,6 @@ class PasswordGenerationPopupView {
// when Hide() is called.
static PasswordGenerationPopupView* Create(
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 kExplanatoryTextBackgroundColor;
......
......@@ -5,7 +5,6 @@
#include "chrome/browser/ui/passwords/password_generation_popup_view.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/passwords/password_generation_popup_controller_impl.h"
......@@ -57,8 +56,6 @@ class PasswordGenerationPopupViewTest : public InProcessBrowserTest {
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
// editing dialog doesn't crash.
IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest,
......@@ -84,7 +81,6 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, InvalidContainerView) {
GetWebContents(), NULL);
controller_->Show(true /* display password */);
}
#endif
// Verify that destroying web contents with visible popup does not crash.
IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest,
......
......@@ -6,12 +6,10 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/autofill/popup_constants.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_mode_controller.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
......@@ -262,19 +260,13 @@ bool PasswordGenerationPopupViewViews::IsPointInPasswordBounds(
PasswordGenerationPopupView* PasswordGenerationPopupView::Create(
PasswordGenerationPopupController* controller) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return CreateCocoa(controller);
#endif
if (!controller->container_view())
return nullptr;
views::Widget* observing_widget =
views::Widget::GetTopLevelWidgetForNativeView(
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);
}
......
......@@ -4010,7 +4010,6 @@ test("unit_tests") {
"../browser/ui/cocoa/autofill/autofill_bubble_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/password_generation_popup_view_cocoa_unittest.mm",
"../browser/ui/cocoa/background_gradient_view_unittest.mm",
"../browser/ui/cocoa/base_bubble_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