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