Commit 4d27ae2e authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Autofill] Introduce SaveAddressProfileView/BubbleController

This CL introduces the skeletons for the SaveAddressProfileView
and SaveAddressProfileBubbleController.

Bug: 1135178
Change-Id: I66e1f931c7e87c03710602b8dd452ac56e5449e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2449982
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814236}
parent d92b6c97
...@@ -3287,6 +3287,8 @@ static_library("ui") { ...@@ -3287,6 +3287,8 @@ static_library("ui") {
if (toolkit_views) { if (toolkit_views) {
sources += [ sources += [
"autofill/address_profiles/save_address_profile_bubble_controller.cc",
"autofill/address_profiles/save_address_profile_bubble_controller.h",
"autofill/payments/local_card_migration_bubble.h", "autofill/payments/local_card_migration_bubble.h",
"autofill/payments/local_card_migration_bubble_controller_impl.cc", "autofill/payments/local_card_migration_bubble_controller_impl.cc",
"autofill/payments/local_card_migration_bubble_controller_impl.h", "autofill/payments/local_card_migration_bubble_controller_impl.h",
...@@ -3356,6 +3358,8 @@ static_library("ui") { ...@@ -3356,6 +3358,8 @@ static_library("ui") {
"views/apps/app_info_dialog/app_info_summary_panel.h", "views/apps/app_info_dialog/app_info_summary_panel.h",
"views/apps/chrome_native_app_window_views.cc", "views/apps/chrome_native_app_window_views.cc",
"views/apps/chrome_native_app_window_views.h", "views/apps/chrome_native_app_window_views.h",
"views/autofill/address_profiles/save_address_profile_view.cc",
"views/autofill/address_profiles/save_address_profile_view.h",
"views/autofill/autofill_bubble_handler_impl.cc", "views/autofill/autofill_bubble_handler_impl.cc",
"views/autofill/autofill_bubble_handler_impl.h", "views/autofill/autofill_bubble_handler_impl.h",
"views/autofill/autofill_popup_base_view.cc", "views/autofill/autofill_popup_base_view.cc",
......
// Copyright 2020 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/autofill/address_profiles/save_address_profile_bubble_controller.h"
#include "components/autofill/core/common/autofill_features.h"
namespace autofill {
SaveAddressProfileBubbleController::SaveAddressProfileBubbleController() {
DCHECK(base::FeatureList::IsEnabled(
features::kAutofillAddressProfileSavePrompt));
}
SaveAddressProfileBubbleController::~SaveAddressProfileBubbleController() =
default;
base::string16 SaveAddressProfileBubbleController::GetWindowTitle() const {
return base::string16();
}
} // namespace autofill
// Copyright 2020 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_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_BUBBLE_CONTROLLER_H_
#include "base/strings/string16.h"
namespace autofill {
// The controller functionality for SaveAddressProfileView.
class SaveAddressProfileBubbleController {
public:
SaveAddressProfileBubbleController();
SaveAddressProfileBubbleController(
const SaveAddressProfileBubbleController&) = delete;
SaveAddressProfileBubbleController& operator=(
const SaveAddressProfileBubbleController&) = delete;
virtual ~SaveAddressProfileBubbleController();
base::string16 GetWindowTitle() const;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_BUBBLE_CONTROLLER_H_
// Copyright 2020 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/autofill/address_profiles/save_address_profile_bubble_controller.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/common/autofill_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
TEST(SaveAddressProfileBubbleControllerTest, NoCrash) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
features::kAutofillAddressProfileSavePrompt);
SaveAddressProfileBubbleController controller;
}
} // namespace autofill
// Copyright 2020 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/views/autofill/address_profiles/save_address_profile_view.h"
#include "components/autofill/core/common/autofill_features.h"
namespace autofill {
SaveAddressProfileView::SaveAddressProfileView(
views::View* anchor_view,
content::WebContents* web_contents)
: LocationBarBubbleDelegateView(anchor_view, web_contents) {
DCHECK(base::FeatureList::IsEnabled(
features::kAutofillAddressProfileSavePrompt));
}
bool SaveAddressProfileView::ShouldShowCloseButton() const {
return true;
}
base::string16 SaveAddressProfileView::GetWindowTitle() const {
return base::string16();
}
} // namespace autofill
// Copyright 2020 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_VIEWS_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_VIEW_H_
#include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h"
namespace content {
class WebContents;
}
namespace views {
class View;
}
namespace autofill {
// This is the bubble views that is part of the flow for when the user submits a
// form with an address profile that Autofill has not previously saved.
class SaveAddressProfileView : public LocationBarBubbleDelegateView {
public:
SaveAddressProfileView(views::View* anchor_view,
content::WebContents* web_contents);
// views::WidgetDelegate:
bool ShouldShowCloseButton() const override;
base::string16 GetWindowTitle() const override;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_ADDRESS_PROFILES_SAVE_ADDRESS_PROFILE_VIEW_H_
// Copyright 2020 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/views/autofill/address_profiles/save_address_profile_view.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "components/autofill/core/common/autofill_features.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
namespace autofill {
class SaveAddressProfileViewTest : public ChromeViewsTestBase {
public:
SaveAddressProfileViewTest();
~SaveAddressProfileViewTest() override = default;
void CreateViewAndShow();
void TearDown() override {
view_->GetWidget()->CloseWithReason(
views::Widget::ClosedReason::kCloseButtonClicked);
anchor_widget_.reset();
ChromeViewsTestBase::TearDown();
}
SaveAddressProfileView* view() { return view_; }
private:
base::test::ScopedFeatureList feature_list_;
TestingProfile profile_;
// This enables uses of TestWebContents.
content::RenderViewHostTestEnabler test_render_host_factories_;
std::unique_ptr<content::WebContents> test_web_contents_;
std::unique_ptr<views::Widget> anchor_widget_;
SaveAddressProfileView* view_;
};
SaveAddressProfileViewTest::SaveAddressProfileViewTest() {
feature_list_.InitAndEnableFeature(
features::kAutofillAddressProfileSavePrompt);
test_web_contents_ =
content::WebContentsTester::CreateTestWebContents(&profile_, nullptr);
}
void SaveAddressProfileViewTest::CreateViewAndShow() {
// The bubble needs the parent as an anchor.
views::Widget::InitParams params =
CreateParams(views::Widget::InitParams::TYPE_WINDOW);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
anchor_widget_ = std::make_unique<views::Widget>();
anchor_widget_->Init(std::move(params));
anchor_widget_->Show();
view_ = new SaveAddressProfileView(anchor_widget_->GetContentsView(),
test_web_contents_.get());
views::BubbleDialogDelegateView::CreateBubble(view_)->Show();
}
TEST_F(SaveAddressProfileViewTest, HasCloseButton) {
CreateViewAndShow();
EXPECT_TRUE(view()->ShouldShowCloseButton());
}
} // namespace autofill
...@@ -4662,6 +4662,7 @@ test("unit_tests") { ...@@ -4662,6 +4662,7 @@ test("unit_tests") {
"../browser/sharing/sms/sms_fetch_request_handler_unittest.cc", "../browser/sharing/sms/sms_fetch_request_handler_unittest.cc",
"../browser/sharing/sms/sms_remote_fetcher_unittest.cc", "../browser/sharing/sms/sms_remote_fetcher_unittest.cc",
"../browser/sharing/webrtc/ice_config_fetcher_unittest.cc", "../browser/sharing/webrtc/ice_config_fetcher_unittest.cc",
"../browser/ui/autofill/address_profiles/save_address_profile_bubble_controller_unittest.cc",
"../browser/ui/autofill/payments/local_card_migration_bubble_controller_impl_unittest.cc", "../browser/ui/autofill/payments/local_card_migration_bubble_controller_impl_unittest.cc",
"../browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc", "../browser/ui/autofill/payments/save_card_bubble_controller_impl_unittest.cc",
"../browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc", "../browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc",
...@@ -4678,6 +4679,7 @@ test("unit_tests") { ...@@ -4678,6 +4679,7 @@ test("unit_tests") {
"../browser/ui/toolbar/media_router_contextual_menu_unittest.cc", "../browser/ui/toolbar/media_router_contextual_menu_unittest.cc",
"../browser/ui/toolbar/mock_media_router_action_controller.cc", "../browser/ui/toolbar/mock_media_router_action_controller.cc",
"../browser/ui/toolbar/mock_media_router_action_controller.h", "../browser/ui/toolbar/mock_media_router_action_controller.h",
"../browser/ui/views/autofill/address_profiles/save_address_profile_view_unittest.cc",
"../browser/ui/views/passwords/move_to_account_store_bubble_view_unittest.cc", "../browser/ui/views/passwords/move_to_account_store_bubble_view_unittest.cc",
"../browser/ui/views/passwords/password_bubble_view_test_base.cc", "../browser/ui/views/passwords/password_bubble_view_test_base.cc",
"../browser/ui/views/passwords/password_bubble_view_test_base.h", "../browser/ui/views/passwords/password_bubble_view_test_base.h",
......
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