Commit 960a5df5 authored by Irmak Kavasoğlu's avatar Irmak Kavasoğlu Committed by Commit Bot

Added the edit button to pending password bubble for mac platform.

Created the edit button and added it to the pending password bubble for mac platform. Clicking the button does not do anything. Screenshot is added to the bug as comment #19.

Bug: 734965
Change-Id: Iaf424fc8a9964543995a6ef321b9a33af596a594
Reviewed-on: https://chromium-review.googlesource.com/570440
Commit-Queue: Irmak Kavasoğlu <irmakk@google.com>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488619}
parent 11c9d1dc
...@@ -53,12 +53,12 @@ ...@@ -53,12 +53,12 @@
- (void)loadView { - (void)loadView {
base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]); base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]);
// ----------------------------------- // -----------------------------------------
// | Title x | // | Title x |
// | username password | // | username password |
// | Smart Lock welcome (optional) | // | Smart Lock welcome (optional) |
// | [Button1] [Button2] | // | ([Button3]) [Button1] [Button2] |
// ----------------------------------- // -----------------------------------------
// The title text depends on whether the user is signed in and therefore syncs // The title text depends on whether the user is signed in and therefore syncs
// their password // their password
...@@ -69,6 +69,9 @@ ...@@ -69,6 +69,9 @@
// password row, and the buttons row on one line each, but not smaller than // password row, and the buttons row on one line each, but not smaller than
// kDesiredBubbleWidth. // kDesiredBubbleWidth.
// The button 3 is optional and only rendered when child class returns 3
// buttons.
// Create the elements and add them to the view. // Create the elements and add them to the view.
// Close button. // Close button.
...@@ -118,6 +121,14 @@ ...@@ -118,6 +121,14 @@
[button setFrameOrigin:NSMakePoint(curX, curY)]; [button setFrameOrigin:NSMakePoint(curX, curY)];
} }
// Add the third button to the left if it was sent.
if ([buttons count] == 3) {
curX = kFramePadding - (NSWidth([buttons[2] frame]) -
([buttons[2] intrinsicContentSize]).width) /
2;
[buttons[2] setFrameOrigin:NSMakePoint(curX, curY)];
}
curX = kFramePadding; curX = kFramePadding;
curY = NSMaxY([buttons.firstObject frame]) + kUnrelatedControlVerticalPadding; curY = NSMaxY([buttons.firstObject frame]) + kUnrelatedControlVerticalPadding;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
@private @private
base::scoped_nsobject<NSButton> saveButton_; base::scoped_nsobject<NSButton> saveButton_;
base::scoped_nsobject<NSButton> neverButton_; base::scoped_nsobject<NSButton> neverButton_;
base::scoped_nsobject<NSButton> editButton_;
base::scoped_nsobject<PasswordsListViewController> passwordItem_; base::scoped_nsobject<PasswordsListViewController> passwordItem_;
} }
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
@interface SavePendingPasswordViewController (Testing) @interface SavePendingPasswordViewController (Testing)
@property(readonly) NSButton* saveButton; @property(readonly) NSButton* saveButton;
@property(readonly) NSButton* neverButton; @property(readonly) NSButton* neverButton;
@property(readonly) NSButton* editButton;
@end @end
#endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_SAVE_PENDING_PASSWORD_VIEW_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_SAVE_PENDING_PASSWORD_VIEW_CONTROLLER_H_
...@@ -4,14 +4,17 @@ ...@@ -4,14 +4,17 @@
#import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller.h" #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller.h"
#import "chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h"
#import "chrome/browser/ui/cocoa/passwords/passwords_list_view_controller.h" #import "chrome/browser/ui/cocoa/passwords/passwords_list_view_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
@interface SavePendingPasswordViewController () @interface SavePendingPasswordViewController ()
- (void)onSaveClicked:(id)sender; - (void)onSaveClicked:(id)sender;
- (void)onNeverForThisSiteClicked:(id)sender; - (void)onNeverForThisSiteClicked:(id)sender;
- (void)onEditClicked:(id)sender;
@end @end
@implementation SavePendingPasswordViewController @implementation SavePendingPasswordViewController
...@@ -39,8 +42,14 @@ ...@@ -39,8 +42,14 @@
[self.delegate viewShouldDismiss]; [self.delegate viewShouldDismiss];
} }
- (void)onEditClicked:(id)sender {
// TODO(crbug.com/734965)
}
- (NSView*)createPasswordView { - (NSView*)createPasswordView {
if (self.model->pending_password().username_value.empty()) if (!base::FeatureList::IsEnabled(
password_manager::features::kEnableUsernameCorrection) &&
self.model->pending_password().username_value.empty())
return nil; return nil;
passwordItem_.reset([[PasswordsListViewController alloc] passwordItem_.reset([[PasswordsListViewController alloc]
initWithModelAndForm:self.model initWithModelAndForm:self.model
...@@ -64,6 +73,16 @@ ...@@ -64,6 +73,16 @@
toView:view toView:view
target:self target:self
action:@selector(onNeverForThisSiteClicked:)] retain]); action:@selector(onNeverForThisSiteClicked:)] retain]);
if (base::FeatureList::IsEnabled(
password_manager::features::kEnableUsernameCorrection)) {
// Edit button.
editButton_.reset([[self
addButton:l10n_util::GetNSString(IDS_PASSWORD_MANAGER_EDIT_BUTTON)
toView:view
target:self
action:@selector(onEditClicked:)] retain]);
return @[ saveButton_, neverButton_, editButton_ ];
}
return @[ saveButton_, neverButton_ ]; return @[ saveButton_, neverButton_ ];
} }
...@@ -71,6 +90,10 @@ ...@@ -71,6 +90,10 @@
@implementation SavePendingPasswordViewController (Testing) @implementation SavePendingPasswordViewController (Testing)
- (NSButton*)editButton {
return editButton_.get();
}
- (NSButton*)saveButton { - (NSButton*)saveButton {
return saveButton_.get(); return saveButton_.get();
} }
......
...@@ -7,17 +7,18 @@ ...@@ -7,17 +7,18 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#import "chrome/browser/ui/cocoa/bubble_combobox.h" #import "chrome/browser/ui/cocoa/bubble_combobox.h"
#include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h" #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h"
#import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller.h" #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller.h"
#include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h" #include "testing/gtest_mac.h"
// Gmock matcher // Gmock matcher
using testing::_; using testing::_;
...@@ -56,6 +57,23 @@ TEST_F(SavePendingPasswordViewControllerTest, ...@@ -56,6 +57,23 @@ TEST_F(SavePendingPasswordViewControllerTest,
EXPECT_TRUE([delegate() dismissed]); EXPECT_TRUE([delegate() dismissed]);
} }
TEST_F(SavePendingPasswordViewControllerTest,
EditButtonExistsWhenUsernameCorrectionEnabled) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
password_manager::features::kEnableUsernameCorrection);
SetUpSavePendingState(false);
EXPECT_TRUE(controller().editButton);
[controller().editButton performClick:nil];
EXPECT_FALSE([delegate() dismissed]);
}
TEST_F(SavePendingPasswordViewControllerTest,
EditButtonShouldNotExistByDefault) {
SetUpSavePendingState(false);
EXPECT_FALSE(controller().editButton);
}
TEST_F(SavePendingPasswordViewControllerTest, TEST_F(SavePendingPasswordViewControllerTest,
ShouldNeverAndDismissWhenNeverClicked) { ShouldNeverAndDismissWhenNeverClicked) {
SetUpSavePendingState(false); SetUpSavePendingState(false);
......
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