Commit fb1763fd authored by Mathias Carlen's avatar Mathias Carlen Committed by Commit Bot

[Autofill Assistant] Remove the CCT dependency.

Before this patch, we used the chrome custom tab activity instead of the
ChromeActivity base activity.

This will prevent us to introduce Autofill Assistant other flavors than
CCT. This patch reverts to ChromeActivity. The one caveat is that CCT's
finish() does a little more cleanup compared to ChromeActivity, but the
behavior for the cases we tested is the same.

Bug: 806868
Change-Id: I77e99419738f41f0dbaaa5cbb3bb0f64f8c9a37c
Reviewed-on: https://chromium-review.googlesource.com/c/1348114
Commit-Queue: Mathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610599}
parent 110e2dc7
......@@ -6,7 +6,7 @@ package org.chromium.chrome.browser.autofill_assistant;
import android.os.Bundle;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver;
......@@ -34,7 +34,7 @@ public class AutofillAssistantFacade {
}
/** Starts Autofill Assistant on the given {@code activity}. */
public static void start(CustomTabActivity activity) {
public static void start(ChromeActivity activity) {
Map<String, String> parameters = extractParameters(activity.getInitialIntent().getExtras());
parameters.remove(PARAMETER_ENABLED);
......@@ -51,9 +51,10 @@ public class AutofillAssistantFacade {
uiDelegate.startOrSkipInitScreen();
}
private static void initTabObservers(
CustomTabActivity activity, UiDelegateHolder delegateHolder) {
private static void initTabObservers(ChromeActivity activity, UiDelegateHolder delegateHolder) {
// Shut down Autofill Assistant when the tab is detached from the activity.
//
// Note: For now this logic assumes that |activity| is a CustomTabActivity.
Tab activityTab = activity.getActivityTab();
activityTab.addObserver(new EmptyTabObserver() {
@Override
......
......@@ -16,8 +16,8 @@ import org.chromium.base.LocaleUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.PaymentOptions;
......@@ -70,10 +70,9 @@ public class AutofillAssistantUiController implements AutofillAssistantUiDelegat
/**
* Construct Autofill Assistant UI controller.
*
* @param activity The CustomTabActivity of the controller associated with.
* @param activity The ChromeActivity of the controller associated with.
*/
public AutofillAssistantUiController(
CustomTabActivity activity, Map<String, String> parameters) {
public AutofillAssistantUiController(ChromeActivity activity, Map<String, String> parameters) {
mWebContents = activity.getActivityTab().getWebContents();
mInitialUrl = activity.getInitialIntent().getDataString();
......@@ -208,8 +207,8 @@ public class AutofillAssistantUiController implements AutofillAssistantUiDelegat
}
@CalledByNative
private void onCloseCustomTab() {
mUiDelegateHolder.closeCustomTab();
private void onClose() {
mUiDelegateHolder.close();
}
@CalledByNative
......
......@@ -39,6 +39,7 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.autofill_assistant.ui.BottomBarAnimations;
......@@ -86,7 +87,7 @@ class AutofillAssistantUiDelegate {
private static final SimpleDateFormat sDetailsDateFormat =
new SimpleDateFormat("EEE, MMM d", Locale.getDefault());
private final CustomTabActivity mActivity;
private final ChromeActivity mActivity;
private final Client mClient;
private final ViewGroup mCoordinatorView;
private final View mFullContainer;
......@@ -252,7 +253,7 @@ class AutofillAssistantUiDelegate {
* @param activity The ChromeActivity
* @param client The client to forward events to
*/
public AutofillAssistantUiDelegate(CustomTabActivity activity, Client client) {
public AutofillAssistantUiDelegate(ChromeActivity activity, Client client) {
mActivity = activity;
mClient = client;
......@@ -473,10 +474,15 @@ class AutofillAssistantUiDelegate {
}
/**
* Closes the Chrome Custom Tab.
* Closes the activity.
*
* Note: The close() logic here assumes that |mActivity| is a CustomTabActivity since in the
* more general case we probably just want to close the active tab instead of the entire Chrome
* activity.
*/
public void closeCustomTab() {
mActivity.finishAndClose(false);
public void close() {
assert mActivity instanceof CustomTabActivity;
mActivity.finish();
}
/** Called to show overlay. */
......
......@@ -132,9 +132,9 @@ class UiDelegateHolder {
/**
* Closes the Chrome Custom Tab.
*/
void closeCustomTab() {
void close() {
shutdown();
mUiDelegate.closeCustomTab();
mUiDelegate.close();
}
/**
......
......@@ -141,8 +141,8 @@ void UiControllerAndroid::ShutdownGracefully() {
AttachCurrentThread(), java_autofill_assistant_ui_controller_);
}
void UiControllerAndroid::CloseCustomTab() {
Java_AutofillAssistantUiController_onCloseCustomTab(
void UiControllerAndroid::Close() {
Java_AutofillAssistantUiController_onClose(
AttachCurrentThread(), java_autofill_assistant_ui_controller_);
}
......
......@@ -43,7 +43,7 @@ class UiControllerAndroid : public UiController,
void HideOverlay() override;
void Shutdown() override;
void ShutdownGracefully() override;
void CloseCustomTab() override;
void Close() override;
void UpdateScripts(const std::vector<ScriptHandle>& scripts) override;
void Choose(const std::vector<UiController::Choice>& choices,
base::OnceCallback<void(const std::string&)> callback) override;
......
......@@ -168,8 +168,8 @@ class ActionDelegate {
// Shut down Autofill Assistant at the end of the current script.
virtual void Shutdown() = 0;
// Shut down Autofill Assistant and close the CCT.
virtual void CloseCustomTab() = 0;
// Shut down Autofill Assistant and closes Chrome.
virtual void Close() = 0;
// Restart Autofill Assistant at the end of the current script with a cleared
// state.
......
......@@ -145,7 +145,7 @@ class MockActionDelegate : public ActionDelegate {
base::OnceCallback<void(bool, const std::string&)> callback));
MOCK_METHOD1(LoadURL, void(const GURL& url));
MOCK_METHOD0(Shutdown, void());
MOCK_METHOD0(CloseCustomTab, void());
MOCK_METHOD0(Close, void());
MOCK_METHOD0(Restart, void());
MOCK_METHOD0(GetClientMemory, ClientMemory*());
MOCK_METHOD0(GetPersonalDataManager, autofill::PersonalDataManager*());
......
......@@ -36,7 +36,7 @@ void ShowDetailsAction::OnShowDetails(ProcessActionCallback callback,
ActionDelegate* delegate,
bool can_continue) {
if (!can_continue) {
delegate->CloseCustomTab();
delegate->Close();
}
UpdateProcessedAction(ACTION_APPLIED);
std::move(callback).Run(std::move(processed_action_proto_));
......
......@@ -293,7 +293,7 @@ void Controller::OnScriptExecuted(const std::string& script_path,
return;
case ScriptExecutor::CLOSE_CUSTOM_TAB:
GetUiController()->CloseCustomTab();
GetUiController()->Close();
return;
case ScriptExecutor::RESTART:
......
......@@ -28,7 +28,7 @@ class MockUiController : public UiController {
MOCK_METHOD0(HideOverlay, void());
MOCK_METHOD0(Shutdown, void());
MOCK_METHOD0(ShutdownGracefully, void());
MOCK_METHOD0(CloseCustomTab, void());
MOCK_METHOD0(Close, void());
MOCK_METHOD1(UpdateScripts, void(const std::vector<ScriptHandle>& scripts));
void Choose(const std::vector<UiController::Choice>& choices,
......
......@@ -252,7 +252,7 @@ void ScriptExecutor::Shutdown() {
}
}
void ScriptExecutor::CloseCustomTab() {
void ScriptExecutor::Close() {
at_end_ = CLOSE_CUSTOM_TAB;
should_stop_script_ = true;
}
......
......@@ -130,7 +130,7 @@ class ScriptExecutor : public ActionDelegate {
base::OnceCallback<void(bool, const std::string&)> callback) override;
void LoadURL(const GURL& url) override;
void Shutdown() override;
void CloseCustomTab() override;
void Close() override;
void Restart() override;
ClientMemory* GetClientMemory() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
......
......@@ -59,8 +59,8 @@ class UiController {
// Warning: this indirectly deletes the caller.
virtual void ShutdownGracefully() = 0;
// Shuts down Autofill Assistant and closes CCT.
virtual void CloseCustomTab() = 0;
// Shuts down Autofill Assistant and closes Chrome.
virtual void Close() = 0;
// Update the list of scripts in the UI.
virtual void UpdateScripts(const std::vector<ScriptHandle>& scripts) = 0;
......
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