components: Replace base::Optional and friends with absl counterparts

This replaces:
- base::Optional -> absl::optional
- include "base/optional.h"
  ->
  include "third_party/abseil-cpp/absl/types/optional.h"
- base::nullopt -> absl::nullopt
- base::make_optional -> absl::make_optional

Bug: 1202909
Change-Id: If697b7bf69b199c1796f873eedca3359cdb48c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897151
Commit-Queue: Anton Bikineev <[email protected]>
Owners-Override: Anton Bikineev <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#883296}
diff --git a/components/autofill_assistant/browser/actions/action_delegate_util_unittest.cc b/components/autofill_assistant/browser/actions/action_delegate_util_unittest.cc
index 682349f..e28afcf 100644
--- a/components/autofill_assistant/browser/actions/action_delegate_util_unittest.cc
+++ b/components/autofill_assistant/browser/actions/action_delegate_util_unittest.cc
@@ -344,7 +344,7 @@
       ->NavigateAndCommit(GURL("https://www.example.com"));
   element->container_frame_host = web_contents_->GetMainFrame();
 
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   EXPECT_CALL(*this, MockValueAction("username", _, _))
@@ -369,7 +369,7 @@
       ->NavigateAndCommit(GURL("https://www.other.com"));
   element->container_frame_host = web_contents_->GetMainFrame();
 
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   EXPECT_CALL(*this, MockValueAction("username", _, _)).Times(0);
diff --git a/components/autofill_assistant/browser/actions/collect_user_data_action.cc b/components/autofill_assistant/browser/actions/collect_user_data_action.cc
index 6cd33ed..ac694f3 100644
--- a/components/autofill_assistant/browser/actions/collect_user_data_action.cc
+++ b/components/autofill_assistant/browser/actions/collect_user_data_action.cc
@@ -152,10 +152,10 @@
 }
 
 bool IsValidDateTimeRange(
-    const base::Optional<autofill_assistant::DateProto>& start_date,
-    const base::Optional<int> start_timeslot,
-    const base::Optional<autofill_assistant::DateProto> end_date,
-    const base::Optional<int> end_timeslot,
+    const absl::optional<autofill_assistant::DateProto>& start_date,
+    const absl::optional<int> start_timeslot,
+    const absl::optional<autofill_assistant::DateProto> end_date,
+    const absl::optional<int> end_timeslot,
     const CollectUserDataOptions& collect_user_data_options) {
   if (!collect_user_data_options.request_date_time_range) {
     return true;
@@ -510,12 +510,12 @@
         login_option.sublabel_accessibility_hint(),
         login_option.preselection_priority(),
         login_option.has_info_popup()
-            ? base::make_optional(login_option.info_popup())
-            : base::nullopt,
+            ? absl::make_optional(login_option.info_popup())
+            : absl::nullopt,
         login_option.has_edit_button_content_description()
-            ? base::make_optional(
+            ? absl::make_optional(
                   login_option.edit_button_content_description())
-            : base::nullopt);
+            : absl::nullopt);
     login_details_map_.emplace(
         identifier, std::make_unique<LoginDetails>(
                         login_option.choose_automatically_if_no_stored_login(),
@@ -810,19 +810,19 @@
             login_option.custom().label(),
             login_option.sublabel(),
             login_option.has_sublabel_accessibility_hint()
-                ? base::make_optional(
+                ? absl::make_optional(
                       login_option.sublabel_accessibility_hint())
-                : base::nullopt,
+                : absl::nullopt,
             login_option.has_preselection_priority()
                 ? login_option.preselection_priority()
                 : -1,
             login_option.has_info_popup()
-                ? base::make_optional(login_option.info_popup())
-                : base::nullopt,
+                ? absl::make_optional(login_option.info_popup())
+                : absl::nullopt,
             login_option.has_edit_button_content_description()
-                ? base::make_optional(
+                ? absl::make_optional(
                       login_option.edit_button_content_description())
-                : base::nullopt};
+                : absl::nullopt};
         collect_user_data_options_->login_choices.emplace_back(
             std::move(choice));
         login_details_map_.emplace(
@@ -1056,10 +1056,10 @@
 // TODO(b/148448649): Move to dedicated helper namespace.
 // static
 bool CollectUserDataAction::SanitizeDateTimeRange(
-    base::Optional<DateProto>* start_date,
-    base::Optional<int>* start_timeslot,
-    base::Optional<DateProto>* end_date,
-    base::Optional<int>* end_timeslot,
+    absl::optional<DateProto>* start_date,
+    absl::optional<int>* start_timeslot,
+    absl::optional<DateProto>* end_date,
+    absl::optional<int>* end_timeslot,
     const CollectUserDataOptions& collect_user_data_options,
     bool change_start) {
   if (!collect_user_data_options.request_date_time_range) {
diff --git a/components/autofill_assistant/browser/actions/collect_user_data_action.h b/components/autofill_assistant/browser/actions/collect_user_data_action.h
index 3707a4b3..efb42492 100644
--- a/components/autofill_assistant/browser/actions/collect_user_data_action.h
+++ b/components/autofill_assistant/browser/actions/collect_user_data_action.h
@@ -11,13 +11,13 @@
 
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "components/autofill/core/browser/personal_data_manager.h"
 #include "components/autofill/core/browser/personal_data_manager_observer.h"
 #include "components/autofill_assistant/browser/actions/action.h"
 #include "components/autofill_assistant/browser/user_data.h"
 #include "components/autofill_assistant/browser/user_model.h"
 #include "components/autofill_assistant/browser/website_login_manager.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 class UserModel;
@@ -44,10 +44,10 @@
   // Ensures that |end| is > |start| by modifying either |start| or |end|,
   // depending on |change_start|. Returns true if changes were performed.
   static bool SanitizeDateTimeRange(
-      base::Optional<DateProto>* start_date,
-      base::Optional<int>* start_timeslot,
-      base::Optional<DateProto>* end_date,
-      base::Optional<int>* end_timeslot,
+      absl::optional<DateProto>* start_date,
+      absl::optional<int>* start_timeslot,
+      absl::optional<DateProto>* end_date,
+      absl::optional<int>* end_timeslot,
       const CollectUserDataOptions& collect_user_data_options,
       bool change_start);
 
@@ -66,7 +66,7 @@
     bool choose_automatically_if_no_stored_login;
     std::string payload;
     // Only for Chrome PWM login details.
-    base::Optional<WebsiteLoginManager::Login> login;
+    absl::optional<WebsiteLoginManager::Login> login;
   };
 
   void InternalProcessAction(ProcessActionCallback callback) override;
diff --git a/components/autofill_assistant/browser/actions/collect_user_data_action_unittest.cc b/components/autofill_assistant/browser/actions/collect_user_data_action_unittest.cc
index 6af97f3..a3e768eb 100644
--- a/components/autofill_assistant/browser/actions/collect_user_data_action_unittest.cc
+++ b/components/autofill_assistant/browser/actions/collect_user_data_action_unittest.cc
@@ -2333,7 +2333,7 @@
             ExpectSelectedProfileMatches("billing", &address_a);
             ExpectSelectedProfileMatches("contact", &address_a);
             ExpectSelectedProfileMatches("shipping", &address_a);
-            EXPECT_EQ(user_data_.selected_login_, base::nullopt);
+            EXPECT_EQ(user_data_.selected_login_, absl::nullopt);
 
             // Do not call the callback. We're only interested in the state.
           }));
diff --git a/components/autofill_assistant/browser/actions/fallback_handler/required_field.h b/components/autofill_assistant/browser/actions/fallback_handler/required_field.h
index 34acdb4..ba568df 100644
--- a/components/autofill_assistant/browser/actions/fallback_handler/required_field.h
+++ b/components/autofill_assistant/browser/actions/fallback_handler/required_field.h
@@ -5,10 +5,10 @@
 #ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_FALLBACK_HANDLER_REQUIRED_FIELD_H_
 #define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_FALLBACK_HANDLER_REQUIRED_FIELD_H_
 
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/action_value.pb.h"
 #include "components/autofill_assistant/browser/selector.h"
 #include "components/autofill_assistant/browser/service.pb.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -62,7 +62,7 @@
   // For JavaScript driven dropdowns. This defines the option to be clicked.
   // The selector must match a generic option, a |inner_text_pattern| will be
   // attached for matching to a unique option.
-  base::Optional<Selector> fallback_click_element = base::nullopt;
+  absl::optional<Selector> fallback_click_element = absl::nullopt;
   // Optional. The click type to be used for clicking JavaScript driven
   // dropdown elements.
   ClickType click_type = ClickType::NOT_SET;
diff --git a/components/autofill_assistant/browser/actions/generate_password_for_form_field_action.cc b/components/autofill_assistant/browser/actions/generate_password_for_form_field_action.cc
index aaecfbb..8d98d8d 100644
--- a/components/autofill_assistant/browser/actions/generate_password_for_form_field_action.cc
+++ b/components/autofill_assistant/browser/actions/generate_password_for_form_field_action.cc
@@ -5,7 +5,7 @@
 #include "components/autofill_assistant/browser/actions/generate_password_for_form_field_action.h"
 
 #include <utility>
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 #include "components/autofill/core/common/form_data.h"
 #include "components/autofill/core/common/form_field_data.h"
diff --git a/components/autofill_assistant/browser/actions/generate_password_for_form_field_action_unittest.cc b/components/autofill_assistant/browser/actions/generate_password_for_form_field_action_unittest.cc
index b3b140a..50374060 100644
--- a/components/autofill_assistant/browser/actions/generate_password_for_form_field_action_unittest.cc
+++ b/components/autofill_assistant/browser/actions/generate_password_for_form_field_action_unittest.cc
@@ -47,7 +47,7 @@
         .WillByDefault(Return(kGeneratedPassword));
 
     user_data_.selected_login_ =
-        base::make_optional<WebsiteLoginManager::Login>(GURL(kFakeUrl),
+        absl::make_optional<WebsiteLoginManager::Login>(GURL(kFakeUrl),
                                                         kFakeUsername);
   }
 
diff --git a/components/autofill_assistant/browser/actions/get_element_status_action_unittest.cc b/components/autofill_assistant/browser/actions/get_element_status_action_unittest.cc
index f7d596c..dc1a5cb6f 100644
--- a/components/autofill_assistant/browser/actions/get_element_status_action_unittest.cc
+++ b/components/autofill_assistant/browser/actions/get_element_status_action_unittest.cc
@@ -638,7 +638,7 @@
 }
 
 TEST_F(GetElementStatusActionTest, SucceedsWithPasswordManagerValue) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   content::WebContentsTester::For(web_contents_.get())
diff --git a/components/autofill_assistant/browser/actions/presave_generated_password_action.cc b/components/autofill_assistant/browser/actions/presave_generated_password_action.cc
index af56e7a..26c66ab 100644
--- a/components/autofill_assistant/browser/actions/presave_generated_password_action.cc
+++ b/components/autofill_assistant/browser/actions/presave_generated_password_action.cc
@@ -5,7 +5,7 @@
 #include "components/autofill_assistant/browser/actions/presave_generated_password_action.h"
 
 #include <utility>
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 #include "components/autofill/core/common/form_data.h"
 #include "components/autofill/core/common/form_field_data.h"
diff --git a/components/autofill_assistant/browser/actions/presave_generated_password_action_unittest.cc b/components/autofill_assistant/browser/actions/presave_generated_password_action_unittest.cc
index e403c9e..5858309f 100644
--- a/components/autofill_assistant/browser/actions/presave_generated_password_action_unittest.cc
+++ b/components/autofill_assistant/browser/actions/presave_generated_password_action_unittest.cc
@@ -50,7 +50,7 @@
 };
 
 TEST_F(PresaveGeneratedPasswordActionTest, PresaveGeneratedPassword) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   user_data_.additional_values_[kMemoryKeyForGeneratedPassword] =
       SimpleValue(std::string(kGeneratedPassword));
@@ -87,7 +87,7 @@
 }
 
 TEST_F(PresaveGeneratedPasswordActionTest, GeneratedPasswordMissing) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   user_data_.password_form_data_ = autofill::FormData();
 
@@ -104,7 +104,7 @@
 }
 
 TEST_F(PresaveGeneratedPasswordActionTest, FormDataMissing) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   user_data_.additional_values_[kMemoryKeyForGeneratedPassword] =
       SimpleValue(std::string(kGeneratedPassword));
diff --git a/components/autofill_assistant/browser/actions/save_generated_password_action.cc b/components/autofill_assistant/browser/actions/save_generated_password_action.cc
index 0d64dabd..020965b 100644
--- a/components/autofill_assistant/browser/actions/save_generated_password_action.cc
+++ b/components/autofill_assistant/browser/actions/save_generated_password_action.cc
@@ -5,7 +5,7 @@
 #include "components/autofill_assistant/browser/actions/save_generated_password_action.h"
 
 #include <utility>
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 #include "components/autofill_assistant/browser/actions/action_delegate.h"
 #include "components/autofill_assistant/browser/client_status.h"
diff --git a/components/autofill_assistant/browser/actions/set_form_field_value_action_unittest.cc b/components/autofill_assistant/browser/actions/set_form_field_value_action_unittest.cc
index 7473361..8b100ea 100644
--- a/components/autofill_assistant/browser/actions/set_form_field_value_action_unittest.cc
+++ b/components/autofill_assistant/browser/actions/set_form_field_value_action_unittest.cc
@@ -136,7 +136,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, RequestedPasswordButPasswordNotAvailable) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -169,7 +169,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, UsernameToFill) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -201,7 +201,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, UsernameFillingFailsForMismatchingOrigin) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("http://www.example.com/"), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -225,7 +225,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, PasswordToFill) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -258,7 +258,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, PasswordFillingFailsForMismatchingOrigin) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("http://www.example.com/"), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -283,7 +283,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, PasswordFillingSucceedsForSubdomain) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("http://www.example.com/"), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -316,7 +316,7 @@
 }
 
 TEST_F(SetFormFieldValueActionTest, PasswordIsClearedFromMemory) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
@@ -597,7 +597,7 @@
 TEST_F(SetFormFieldValueActionTest, FallbackForPassword) {
   InSequence sequence;
 
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL(kFakeUrl), kFakeUsername);
   EXPECT_CALL(mock_action_delegate_, FindElement(fake_selector_, _))
       .WillOnce(testing::WithArgs<1>([this](auto&& callback) {
diff --git a/components/autofill_assistant/browser/actions/show_generic_ui_action.cc b/components/autofill_assistant/browser/actions/show_generic_ui_action.cc
index c6bda899..816677b 100644
--- a/components/autofill_assistant/browser/actions/show_generic_ui_action.cc
+++ b/components/autofill_assistant/browser/actions/show_generic_ui_action.cc
@@ -7,13 +7,13 @@
 #include <utility>
 
 #include "base/containers/flat_map.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/actions/action_delegate.h"
 #include "components/autofill_assistant/browser/client_status.h"
 #include "components/autofill_assistant/browser/user_data_util.h"
 #include "components/autofill_assistant/browser/user_model.h"
 #include "components/autofill_assistant/browser/web/element.h"
 #include "content/public/browser/web_contents.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
diff --git a/components/autofill_assistant/browser/actions/use_address_action.cc b/components/autofill_assistant/browser/actions/use_address_action.cc
index 5dad3b6..95f7af1 100644
--- a/components/autofill_assistant/browser/actions/use_address_action.cc
+++ b/components/autofill_assistant/browser/actions/use_address_action.cc
@@ -9,7 +9,6 @@
 
 #include "base/bind.h"
 #include "base/callback.h"
-#include "base/optional.h"
 #include "base/time/time.h"
 #include "components/autofill/core/browser/autofill_data_util.h"
 #include "components/autofill_assistant/browser/actions/action_delegate.h"
@@ -20,6 +19,7 @@
 #include "components/autofill_assistant/browser/user_data_util.h"
 #include "components/autofill_assistant/browser/user_model.h"
 #include "components/autofill_assistant/browser/value_util.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
diff --git a/components/autofill_assistant/browser/actions/use_credit_card_action.cc b/components/autofill_assistant/browser/actions/use_credit_card_action.cc
index b459fc0..3589f3b 100644
--- a/components/autofill_assistant/browser/actions/use_credit_card_action.cc
+++ b/components/autofill_assistant/browser/actions/use_credit_card_action.cc
@@ -10,7 +10,6 @@
 
 #include "base/bind.h"
 #include "base/callback.h"
-#include "base/optional.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -23,6 +22,7 @@
 #include "components/autofill_assistant/browser/client_status.h"
 #include "components/autofill_assistant/browser/field_formatter.h"
 #include "components/autofill_assistant/browser/user_model.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
diff --git a/components/autofill_assistant/browser/autofill_assistant_onboarding_fetcher.cc b/components/autofill_assistant/browser/autofill_assistant_onboarding_fetcher.cc
index 83025ae..aee9564 100644
--- a/components/autofill_assistant/browser/autofill_assistant_onboarding_fetcher.cc
+++ b/components/autofill_assistant/browser/autofill_assistant_onboarding_fetcher.cc
@@ -129,7 +129,7 @@
   base::JSONReader::ValueWithError data =
       base::JSONReader::ReadAndReturnValueWithError(*response_body);
 
-  if (data.value == base::nullopt) {
+  if (data.value == absl::nullopt) {
     DVLOG(1) << "Parse error: " << data.error_message;
     return ResultStatus::kInvalidJson;
   }
diff --git a/components/autofill_assistant/browser/client.h b/components/autofill_assistant/browser/client.h
index 8a5a4a6..bd16e5a 100644
--- a/components/autofill_assistant/browser/client.h
+++ b/components/autofill_assistant/browser/client.h
@@ -73,7 +73,7 @@
   virtual bool IsAccessibilityEnabled() const = 0;
 
   // Returns the width and height of the window.
-  virtual base::Optional<std::pair<int, int>> GetWindowSize() const = 0;
+  virtual absl::optional<std::pair<int, int>> GetWindowSize() const = 0;
 
   // Returns the orientation of the screen.
   virtual ClientContextProto::ScreenOrientation GetScreenOrientation()
diff --git a/components/autofill_assistant/browser/client_context_unittest.cc b/components/autofill_assistant/browser/client_context_unittest.cc
index 7a5834f..f56d5c8 100644
--- a/components/autofill_assistant/browser/client_context_unittest.cc
+++ b/components/autofill_assistant/browser/client_context_unittest.cc
@@ -128,7 +128,7 @@
   ClientContextImpl client_context(&mock_client_);
 
   // When we update the context, there is no window size anymore.
-  EXPECT_CALL(mock_client_, GetWindowSize()).WillOnce(Return(base::nullopt));
+  EXPECT_CALL(mock_client_, GetWindowSize()).WillOnce(Return(absl::nullopt));
   auto actual_client_context = client_context.AsProto();
   EXPECT_THAT(actual_client_context.window_size().width_pixels(), Eq(1080));
   EXPECT_THAT(actual_client_context.window_size().height_pixels(), Eq(1920));
diff --git a/components/autofill_assistant/browser/client_settings.h b/components/autofill_assistant/browser/client_settings.h
index 3471a1208..40207b6a 100644
--- a/components/autofill_assistant/browser/client_settings.h
+++ b/components/autofill_assistant/browser/client_settings.h
@@ -6,10 +6,10 @@
 #define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_CLIENT_SETTINGS_H_
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "base/time/time.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/strings/grit/components_strings.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -78,17 +78,17 @@
   base::TimeDelta tap_shutdown_delay = base::TimeDelta::FromSeconds(5);
 
   // Optional image drawn on top of overlays.
-  base::Optional<OverlayImageProto> overlay_image;
+  absl::optional<OverlayImageProto> overlay_image;
 
   // Optional settings intended for integration tests.
-  base::Optional<ClientSettingsProto::IntegrationTestSettings>
+  absl::optional<ClientSettingsProto::IntegrationTestSettings>
       integration_test_settings;
 
   float talkback_sheet_size_fraction = 0.5f;
 
   // Optional settings to enable back button error in BottomSheet instead of
   // Snackbar.
-  base::Optional<ClientSettingsProto::BackButtonSettings> back_button_settings;
+  absl::optional<ClientSettingsProto::BackButtonSettings> back_button_settings;
 
   // Whether to show warnings related to a slow connection to the user.
   bool enable_slow_connection_warnings = false;
diff --git a/components/autofill_assistant/browser/controller.cc b/components/autofill_assistant/browser/controller.cc
index 9b8ce1eb..0355b1d0c 100644
--- a/components/autofill_assistant/browser/controller.cc
+++ b/components/autofill_assistant/browser/controller.cc
@@ -254,11 +254,11 @@
   return progress_;
 }
 
-base::Optional<int> Controller::GetProgressActiveStep() const {
+absl::optional<int> Controller::GetProgressActiveStep() const {
   return progress_active_step_;
 }
 
-base::Optional<ShowProgressBarProto::StepProgressBarConfiguration>
+absl::optional<ShowProgressBarProto::StepProgressBarConfiguration>
 Controller::GetStepProgressBarConfiguration() const {
   return step_progress_bar_configuration_;
 }
@@ -1195,7 +1195,7 @@
   if (details->UpdateFromParameters(trigger_context_->GetScriptParameters()))
     SetDetails(std::move(details), base::TimeDelta());
 
-  const base::Optional<std::string> overlay_color =
+  const absl::optional<std::string> overlay_color =
       trigger_context_->GetScriptParameters().GetOverlayColors();
   if (overlay_color) {
     std::unique_ptr<OverlayColors> colors = std::make_unique<OverlayColors>();
@@ -1213,7 +1213,7 @@
 
     SetOverlayColors(std::move(colors));
   }
-  const base::Optional<std::string> password_change_username =
+  const absl::optional<std::string> password_change_username =
       trigger_context_->GetScriptParameters().GetPasswordChangeUsername();
   if (password_change_username) {
     DCHECK(GetDeeplinkURL().is_valid());  // |deeplink_url_| must be set.
@@ -1393,7 +1393,7 @@
 }
 
 void Controller::SetDateTimeRangeStartDate(
-    const base::Optional<DateProto>& date) {
+    const absl::optional<DateProto>& date) {
   if (!user_data_)
     return;
 
@@ -1426,7 +1426,7 @@
 }
 
 void Controller::SetDateTimeRangeStartTimeSlot(
-    const base::Optional<int>& timeslot_index) {
+    const absl::optional<int>& timeslot_index) {
   if (!user_data_)
     return;
 
@@ -1459,7 +1459,7 @@
 }
 
 void Controller::SetDateTimeRangeEndDate(
-    const base::Optional<DateProto>& date) {
+    const absl::optional<DateProto>& date) {
   if (!user_data_)
     return;
 
@@ -1492,7 +1492,7 @@
 }
 
 void Controller::SetDateTimeRangeEndTimeSlot(
-    const base::Optional<int>& timeslot_index) {
+    const absl::optional<int>& timeslot_index) {
   if (!user_data_)
     return;
 
@@ -1748,7 +1748,7 @@
   if (delayed_shutdown_reason_ &&
       script_url_.host() != GetCurrentURL().host()) {
     Metrics::DropOutReason reason = delayed_shutdown_reason_.value();
-    delayed_shutdown_reason_ = base::nullopt;
+    delayed_shutdown_reason_ = absl::nullopt;
     tracking_ = false;
     client_->Shutdown(reason);
   }
diff --git a/components/autofill_assistant/browser/controller.h b/components/autofill_assistant/browser/controller.h
index 92eaa428..0dc25fc4 100644
--- a/components/autofill_assistant/browser/controller.h
+++ b/components/autofill_assistant/browser/controller.h
@@ -12,7 +12,6 @@
 
 #include "base/callback_helpers.h"
 #include "base/macros.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/basic_interactions.h"
 #include "components/autofill_assistant/browser/bottom_sheet_state.h"
 #include "components/autofill_assistant/browser/client.h"
@@ -36,6 +35,7 @@
 #include "components/autofill_assistant/browser/web/web_controller.h"
 #include "content/public/browser/web_contents_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace content {
 class RenderFrameHost;
@@ -198,10 +198,10 @@
   std::vector<Details> GetDetails() const override;
   const InfoBox* GetInfoBox() const override;
   int GetProgress() const override;
-  base::Optional<int> GetProgressActiveStep() const override;
+  absl::optional<int> GetProgressActiveStep() const override;
   bool GetProgressVisible() const override;
   bool GetProgressBarErrorState() const override;
-  base::Optional<ShowProgressBarProto::StepProgressBarConfiguration>
+  absl::optional<ShowProgressBarProto::StepProgressBarConfiguration>
   GetStepProgressBarConfiguration() const override;
   const std::vector<UserAction>& GetUserActions() const override;
   bool PerformUserActionWithContext(
@@ -223,12 +223,12 @@
   void OnTextLinkClicked(int link) override;
   void OnFormActionLinkClicked(int link) override;
   void SetDateTimeRangeStartDate(
-      const base::Optional<DateProto>& date) override;
+      const absl::optional<DateProto>& date) override;
   void SetDateTimeRangeStartTimeSlot(
-      const base::Optional<int>& timeslot_index) override;
-  void SetDateTimeRangeEndDate(const base::Optional<DateProto>& date) override;
+      const absl::optional<int>& timeslot_index) override;
+  void SetDateTimeRangeEndDate(const absl::optional<DateProto>& date) override;
   void SetDateTimeRangeEndTimeSlot(
-      const base::Optional<int>& timeslot_index) override;
+      const absl::optional<int>& timeslot_index) override;
   void SetAdditionalValue(const std::string& client_memory_key,
                           const ValueProto& value) override;
   void GetTouchableArea(std::vector<RectF>* area) const override;
@@ -470,12 +470,12 @@
 
   // Current progress.
   int progress_ = 0;
-  base::Optional<int> progress_active_step_;
+  absl::optional<int> progress_active_step_;
 
   // Current visibility of the progress bar. It is initially visible.
   bool progress_visible_ = true;
   bool progress_bar_error_state_ = false;
-  base::Optional<ShowProgressBarProto::StepProgressBarConfiguration>
+  absl::optional<ShowProgressBarProto::StepProgressBarConfiguration>
       step_progress_bar_configuration_;
 
   // Current set of user actions. May be null, but never empty.
@@ -568,7 +568,7 @@
   // If set, the controller entered the STOPPED state but shutdown was delayed
   // until the browser has left the |script_url_.host()| for which the decision
   // was taken.
-  base::Optional<Metrics::DropOutReason> delayed_shutdown_reason_;
+  absl::optional<Metrics::DropOutReason> delayed_shutdown_reason_;
 
   EventHandler event_handler_;
   UserModel user_model_;
diff --git a/components/autofill_assistant/browser/controller_unittest.cc b/components/autofill_assistant/browser/controller_unittest.cc
index 470c1dd..bc4bf5b5 100644
--- a/components/autofill_assistant/browser/controller_unittest.cc
+++ b/components/autofill_assistant/browser/controller_unittest.cc
@@ -2383,7 +2383,7 @@
             1);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_start_date_->day(), 21);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_end_date_,
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST_F(ControllerTest, SetDateTimeRangeEndDateBeforeStartDate) {
@@ -2423,7 +2423,7 @@
   EXPECT_EQ(controller_->GetUserData()->date_time_range_end_date_->month(), 1);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_end_date_->day(), 19);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_start_date_,
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST_F(ControllerTest, SetDateTimeRangeSameDatesStartTimeAfterEndTime) {
@@ -2460,7 +2460,7 @@
   controller_->SetDateTimeRangeStartTimeSlot(1);
   EXPECT_EQ(*controller_->GetUserData()->date_time_range_start_timeslot_, 1);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_end_timeslot_,
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST_F(ControllerTest, SetDateTimeRangeSameDatesEndTimeBeforeStartTime) {
@@ -2497,7 +2497,7 @@
   controller_->SetDateTimeRangeEndTimeSlot(0);
   EXPECT_EQ(*controller_->GetUserData()->date_time_range_end_timeslot_, 0);
   EXPECT_EQ(controller_->GetUserData()->date_time_range_start_timeslot_,
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST_F(ControllerTest, SetDateTimeRangeSameDateValidTime) {
diff --git a/components/autofill_assistant/browser/details.cc b/components/autofill_assistant/browser/details.cc
index 6a7de34..c632b34 100644
--- a/components/autofill_assistant/browser/details.cc
+++ b/components/autofill_assistant/browser/details.cc
@@ -229,7 +229,7 @@
 }
 
 bool Details::UpdateFromParameters(const ScriptParameters& script_parameters) {
-  base::Optional<bool> show_initial = script_parameters.GetDetailsShowInitial();
+  absl::optional<bool> show_initial = script_parameters.GetDetailsShowInitial();
   if (show_initial.has_value() && !*show_initial) {
     return false;
   }
@@ -239,48 +239,48 @@
   proto_.mutable_placeholders()->set_show_image_placeholder(true);
   bool details_updated = false;
 
-  base::Optional<std::string> title = script_parameters.GetDetailsTitle();
+  absl::optional<std::string> title = script_parameters.GetDetailsTitle();
   if (title) {
     proto_.set_title(title.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> description_line_1 =
+  absl::optional<std::string> description_line_1 =
       script_parameters.GetDetailsDescriptionLine1();
   if (description_line_1) {
     proto_.set_description_line_1(description_line_1.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> description_line_2 =
+  absl::optional<std::string> description_line_2 =
       script_parameters.GetDetailsDescriptionLine2();
   if (description_line_2) {
     proto_.set_description_line_2(description_line_2.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> description_line_3 =
+  absl::optional<std::string> description_line_3 =
       script_parameters.GetDetailsDescriptionLine3();
   if (description_line_3) {
     proto_.set_description_line_3(description_line_3.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> image_url =
+  absl::optional<std::string> image_url =
       script_parameters.GetDetailsImageUrl();
   if (image_url) {
     proto_.set_image_url(image_url.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> image_accessibility_hint =
+  absl::optional<std::string> image_accessibility_hint =
       script_parameters.GetDetailsImageAccessibilityHint();
   if (image_accessibility_hint) {
     proto_.set_image_accessibility_hint(image_accessibility_hint.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> image_clickthrough_url =
+  absl::optional<std::string> image_clickthrough_url =
       script_parameters.GetDetailsImageClickthroughUrl();
   if (image_clickthrough_url) {
     proto_.mutable_image_clickthrough_data()->set_allow_clickthrough(true);
@@ -289,14 +289,14 @@
     details_updated = true;
   }
 
-  base::Optional<std::string> total_price_label =
+  absl::optional<std::string> total_price_label =
       script_parameters.GetDetailsTotalPriceLabel();
   if (total_price_label) {
     proto_.set_total_price_label(total_price_label.value());
     details_updated = true;
   }
 
-  base::Optional<std::string> total_price =
+  absl::optional<std::string> total_price =
       script_parameters.GetDetailsTotalPrice();
   if (total_price) {
     proto_.set_total_price(total_price.value());
@@ -322,11 +322,11 @@
   return proto_.image_url();
 }
 
-const base::Optional<std::string> Details::imageAccessibilityHint() const {
+const absl::optional<std::string> Details::imageAccessibilityHint() const {
   if (proto_.has_image_accessibility_hint()) {
     return proto_.image_accessibility_hint();
   }
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 bool Details::imageAllowClickthrough() const {
diff --git a/components/autofill_assistant/browser/details.h b/components/autofill_assistant/browser/details.h
index 1d9faa9..d5675c2 100644
--- a/components/autofill_assistant/browser/details.h
+++ b/components/autofill_assistant/browser/details.h
@@ -62,7 +62,7 @@
 
   const std::string title() const;
   const std::string imageUrl() const;
-  const base::Optional<std::string> imageAccessibilityHint() const;
+  const absl::optional<std::string> imageAccessibilityHint() const;
   bool imageAllowClickthrough() const;
   const std::string imageDescription() const;
   const std::string imagePositiveText() const;
diff --git a/components/autofill_assistant/browser/devtools/devtools_api/domain_types_h.template b/components/autofill_assistant/browser/devtools/devtools_api/domain_types_h.template
index eb5312a..1ab94684 100644
--- a/components/autofill_assistant/browser/devtools/devtools_api/domain_types_h.template
+++ b/components/autofill_assistant/browser/devtools/devtools_api/domain_types_h.template
@@ -9,7 +9,7 @@
 #ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_DEVTOOLS_DEVTOOLS_DOMAINS_TYPES_{{domain.domain | camelcase_to_hacker_style | upper}}_H_
 #define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_DEVTOOLS_DEVTOOLS_DOMAINS_TYPES_{{domain.domain | camelcase_to_hacker_style | upper}}_H_
 
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "base/values.h"
 {% for domain_name in domain.dependencies %}
 #include "components/autofill_assistant/browser/devtools/devtools/internal/types_forward_declarations_{{domain_name | camelcase_to_hacker_style}}.h"
@@ -102,7 +102,7 @@
 
   {% for property in type.properties %}
     {% if property.optional %}
-  base::Optional<{{resolve_type(property).type}}> {{property.name | camelcase_to_hacker_style}}_;
+  absl::optional<{{resolve_type(property).type}}> {{property.name | camelcase_to_hacker_style}}_;
     {% else %}
   {{resolve_type(property).type}} {{property.name | camelcase_to_hacker_style}}_;
     {% endif %}
diff --git a/components/autofill_assistant/browser/element_precondition.h b/components/autofill_assistant/browser/element_precondition.h
index 6946d89..12c766f 100644
--- a/components/autofill_assistant/browser/element_precondition.h
+++ b/components/autofill_assistant/browser/element_precondition.h
@@ -12,12 +12,12 @@
 #include "base/containers/flat_map.h"
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/client_status.h"
 #include "components/autofill_assistant/browser/selector.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/autofill_assistant/browser/web/element.h"
 #include "components/autofill_assistant/browser/web/element_finder.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 class BatchElementChecker;
@@ -63,7 +63,7 @@
 
     // The identifier given to this result through the script. This identifier
     // can be used to later find the element in the |ElementStore|.
-    base::Optional<std::string> client_id;
+    absl::optional<std::string> client_id;
   };
 
   // Add selectors from |proto| to |results_|, doing a depth-first search.
diff --git a/components/autofill_assistant/browser/event_handler.cc b/components/autofill_assistant/browser/event_handler.cc
index 543d22d1..2ff6ba0 100644
--- a/components/autofill_assistant/browser/event_handler.cc
+++ b/components/autofill_assistant/browser/event_handler.cc
@@ -28,62 +28,62 @@
 }
 
 // static
-base::Optional<EventHandler::EventKey> EventHandler::CreateEventKeyFromProto(
+absl::optional<EventHandler::EventKey> EventHandler::CreateEventKeyFromProto(
     const EventProto& proto) {
   switch (proto.kind_case()) {
     case EventProto::kOnValueChanged:
       if (proto.on_value_changed().model_identifier().empty()) {
         VLOG(1) << "Invalid OnValueChangedEventProto: no model_identifier "
                    "specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(), proto.on_value_changed().model_identifier()});
     case EventProto::kOnViewClicked:
       if (proto.on_view_clicked().view_identifier().empty()) {
         VLOG(1) << "Invalid OnViewClickedEventProto: no view_identifier "
                    "specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(), proto.on_view_clicked().view_identifier()});
     case EventProto::kOnUserActionCalled:
       if (proto.on_user_action_called().user_action_identifier().empty()) {
         VLOG(1) << "Invalid OnUserActionCalled: no user_action_identifier "
                    "specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(),
            proto.on_user_action_called().user_action_identifier()});
     case EventProto::kOnTextLinkClicked:
       if (!proto.on_text_link_clicked().has_text_link()) {
         VLOG(1) << "Invalid OnTextLinkClickedProto: no text_link specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(),
            base::NumberToString(proto.on_text_link_clicked().text_link())});
     case EventProto::kOnPopupDismissed:
       if (proto.on_popup_dismissed().popup_identifier().empty()) {
         VLOG(1)
             << "Invalid OnPopupDismissedProto: no popup_identifier specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(), proto.on_popup_dismissed().popup_identifier()});
     case EventProto::kOnViewContainerCleared:
       if (proto.on_view_container_cleared().view_identifier().empty()) {
         VLOG(1) << "Invalid OnViewContainerClearedProto: no view_identifier "
                    "specified";
-        return base::nullopt;
+        return absl::nullopt;
       }
-      return base::Optional<EventHandler::EventKey>(
+      return absl::optional<EventHandler::EventKey>(
           {proto.kind_case(),
            proto.on_view_container_cleared().view_identifier()});
     case EventProto::KIND_NOT_SET:
       VLOG(1) << "Error creating event: kind not set";
-      return base::nullopt;
+      return absl::nullopt;
   }
 }
 
diff --git a/components/autofill_assistant/browser/event_handler.h b/components/autofill_assistant/browser/event_handler.h
index 92ac4b9..7f6dcad1 100644
--- a/components/autofill_assistant/browser/event_handler.h
+++ b/components/autofill_assistant/browser/event_handler.h
@@ -10,9 +10,9 @@
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/autofill_assistant/browser/user_model.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -38,7 +38,7 @@
 
   void DispatchEvent(const EventKey& key);
 
-  static base::Optional<EventKey> CreateEventKeyFromProto(
+  static absl::optional<EventKey> CreateEventKeyFromProto(
       const EventProto& proto);
 
   void AddObserver(Observer* observer);
diff --git a/components/autofill_assistant/browser/fake_starter_platform_delegate.cc b/components/autofill_assistant/browser/fake_starter_platform_delegate.cc
index 233ee49..ce2c50b 100644
--- a/components/autofill_assistant/browser/fake_starter_platform_delegate.cc
+++ b/components/autofill_assistant/browser/fake_starter_platform_delegate.cc
@@ -22,7 +22,7 @@
 void FakeStarterPlatformDelegate::StartRegularScript(
     GURL url,
     std::unique_ptr<TriggerContext> trigger_context,
-    const base::Optional<TriggerScriptProto>& trigger_script) {
+    const absl::optional<TriggerScriptProto>& trigger_script) {
   if (start_regular_script_callback_) {
     std::move(start_regular_script_callback_)
         .Run(url, std::move(trigger_context), trigger_script);
diff --git a/components/autofill_assistant/browser/fake_starter_platform_delegate.h b/components/autofill_assistant/browser/fake_starter_platform_delegate.h
index 9a1f4c6..b2c9bc7 100644
--- a/components/autofill_assistant/browser/fake_starter_platform_delegate.h
+++ b/components/autofill_assistant/browser/fake_starter_platform_delegate.h
@@ -25,7 +25,7 @@
   void StartRegularScript(
       GURL url,
       std::unique_ptr<TriggerContext> trigger_context,
-      const base::Optional<TriggerScriptProto>& trigger_script) override;
+      const absl::optional<TriggerScriptProto>& trigger_script) override;
   bool IsRegularScriptRunning() const override;
   bool IsRegularScriptVisible() const override;
   WebsiteLoginManager* GetWebsiteLoginManager() const override;
@@ -72,7 +72,7 @@
   base::OnceCallback<void(
       GURL url,
       std::unique_ptr<TriggerContext> trigger_context,
-      const base::Optional<TriggerScriptProto>& trigger_script)>
+      const absl::optional<TriggerScriptProto>& trigger_script)>
       start_regular_script_callback_;
   bool is_regular_script_running_ = false;
   bool is_regular_script_visible_ = false;
diff --git a/components/autofill_assistant/browser/field_formatter.cc b/components/autofill_assistant/browser/field_formatter.cc
index edae232..007c402 100644
--- a/components/autofill_assistant/browser/field_formatter.cc
+++ b/components/autofill_assistant/browser/field_formatter.cc
@@ -23,12 +23,12 @@
 // the prefix before the key, the second for the key itself.
 const char kPlaceholderExtractor[] = R"re((.*?)\$\{([^{}]+)\})re";
 
-base::Optional<std::string> GetFieldValue(
+absl::optional<std::string> GetFieldValue(
     const std::map<std::string, std::string>& mappings,
     const std::string& key) {
   auto it = mappings.find(key);
   if (it == mappings.end()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   return it->second;
 }
@@ -52,7 +52,7 @@
 namespace autofill_assistant {
 namespace field_formatter {
 
-base::Optional<std::string> FormatString(
+absl::optional<std::string> FormatString(
     const std::string& pattern,
     const std::map<std::string, std::string>& mappings,
     bool strict) {
@@ -70,7 +70,7 @@
     if (!rewrite_value.has_value()) {
       if (strict) {
         VLOG(2) << "No value for " << key << " in " << pattern;
-        return base::nullopt;
+        return absl::nullopt;
       }
       // Leave placeholder unchanged.
       rewrite_value = "${" + key + "}";
diff --git a/components/autofill_assistant/browser/field_formatter.h b/components/autofill_assistant/browser/field_formatter.h
index 9d7c0fc..4f14be9 100644
--- a/components/autofill_assistant/browser/field_formatter.h
+++ b/components/autofill_assistant/browser/field_formatter.h
@@ -7,11 +7,11 @@
 
 #include <map>
 #include <string>
-#include "base/optional.h"
 #include "components/autofill/core/browser/data_model/autofill_profile.h"
 #include "components/autofill/core/browser/data_model/credit_card.h"
 #include "components/autofill_assistant/browser/action_value.pb.h"
 #include "components/autofill_assistant/browser/client_status.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 namespace field_formatter {
@@ -21,7 +21,7 @@
 // does not contain curly braces. If |strict| is true, this will fail if any of
 // the found placeholders is not in |mappings|. Otherwise, placeholders other
 // than those from |mappings| will be left unchanged.
-base::Optional<std::string> FormatString(
+absl::optional<std::string> FormatString(
     const std::string& input,
     const std::map<std::string, std::string>& mappings,
     bool strict = true);
diff --git a/components/autofill_assistant/browser/field_formatter_unittest.cc b/components/autofill_assistant/browser/field_formatter_unittest.cc
index ee0c8942..d6d84fb 100644
--- a/components/autofill_assistant/browser/field_formatter_unittest.cc
+++ b/components/autofill_assistant/browser/field_formatter_unittest.cc
@@ -38,8 +38,8 @@
   EXPECT_EQ(*FormatString("Price: $${keyA}", mappings), "Price: $valueA");
   EXPECT_EQ(*FormatString("Price: ${keyD}", mappings), "Price: $30.5");
   EXPECT_EQ(*FormatString("Price: ${keyE}", mappings), "Price: 30.5$");
-  EXPECT_EQ(FormatString("${keyF}", mappings), base::nullopt);
-  EXPECT_EQ(FormatString("${keyA}${keyF}", mappings), base::nullopt);
+  EXPECT_EQ(FormatString("${keyF}", mappings), absl::nullopt);
+  EXPECT_EQ(FormatString("${keyA}${keyF}", mappings), absl::nullopt);
 
   EXPECT_EQ(*FormatString("${keyF}", mappings, /*strict = */ false), "${keyF}");
   EXPECT_EQ(*FormatString("${keyA}${keyF}", mappings, /*strict = */ false),
@@ -136,14 +136,14 @@
                                  "", "", "", "", "XY", "", "US", "");
   EXPECT_EQ(FormatString("${34}", CreateAutofillMappings(unknown_state_profile,
                                                          "en-US")),
-            base::nullopt);
+            absl::nullopt);
   EXPECT_EQ(FormatString("${-6}", CreateAutofillMappings(unknown_state_profile,
                                                          "en-US")),
             "XY");
 
   // UNKNOWN_TYPE
   EXPECT_EQ(FormatString("${1}", CreateAutofillMappings(profile, "en-US")),
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST(FieldFormatterTest, CreditCard) {
@@ -193,12 +193,12 @@
   EXPECT_EQ(*FormatString("${3}", CreateAutofillMappings(profile, "en-US")),
             "John");
   EXPECT_EQ(FormatString("${-1}", CreateAutofillMappings(profile, "en-US")),
-            base::nullopt);
+            absl::nullopt);
   EXPECT_EQ(
       FormatString(
           "${" + base::NumberToString(autofill::MAX_VALID_FIELD_TYPE) + "}",
           CreateAutofillMappings(profile, "en-US")),
-      base::nullopt);
+      absl::nullopt);
 
   // Second {} is not prefixed with $.
   EXPECT_EQ(
diff --git a/components/autofill_assistant/browser/mock_client.h b/components/autofill_assistant/browser/mock_client.h
index 43cd272..1c2d268 100644
--- a/components/autofill_assistant/browser/mock_client.h
+++ b/components/autofill_assistant/browser/mock_client.h
@@ -26,7 +26,7 @@
   MOCK_CONST_METHOD0(GetLocale, std::string());
   MOCK_CONST_METHOD0(GetCountryCode, std::string());
   MOCK_CONST_METHOD0(GetDeviceContext, DeviceContext());
-  MOCK_CONST_METHOD0(GetWindowSize, base::Optional<std::pair<int, int>>());
+  MOCK_CONST_METHOD0(GetWindowSize, absl::optional<std::pair<int, int>>());
   MOCK_CONST_METHOD0(GetScreenOrientation,
                      ClientContextProto::ScreenOrientation());
   MOCK_CONST_METHOD0(IsAccessibilityEnabled, bool());
diff --git a/components/autofill_assistant/browser/protocol_utils.cc b/components/autofill_assistant/browser/protocol_utils.cc
index 9317c16..7147e47f 100644
--- a/components/autofill_assistant/browser/protocol_utils.cc
+++ b/components/autofill_assistant/browser/protocol_utils.cc
@@ -116,7 +116,7 @@
     const std::string& script_payload,
     const ClientContextProto& client_context,
     const ScriptParameters& script_parameters,
-    const base::Optional<ScriptStoreConfig>& script_store_config) {
+    const absl::optional<ScriptStoreConfig>& script_store_config) {
   ScriptActionRequestProto request_proto;
   InitialScriptActionsRequestProto* initial_request_proto =
       request_proto.mutable_initial_request();
@@ -432,7 +432,7 @@
     std::vector<std::unique_ptr<TriggerScript>>* trigger_scripts,
     std::vector<std::string>* additional_allowed_domains,
     int* trigger_condition_check_interval_ms,
-    base::Optional<int>* timeout_ms) {
+    absl::optional<int>* timeout_ms) {
   DCHECK(trigger_scripts);
   DCHECK(additional_allowed_domains);
   DCHECK(trigger_condition_check_interval_ms);
diff --git a/components/autofill_assistant/browser/protocol_utils.h b/components/autofill_assistant/browser/protocol_utils.h
index 8c6198b7..cdfed6e 100644
--- a/components/autofill_assistant/browser/protocol_utils.h
+++ b/components/autofill_assistant/browser/protocol_utils.h
@@ -11,12 +11,12 @@
 #include <string>
 #include <vector>
 
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/actions/action.h"
 #include "components/autofill_assistant/browser/script.h"
 #include "components/autofill_assistant/browser/script_parameters.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/autofill_assistant/browser/trigger_scripts/trigger_script.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 class GURL;
 
@@ -47,7 +47,7 @@
       const std::string& script_payload,
       const ClientContextProto& client_context,
       const ScriptParameters& script_parameters,
-      const base::Optional<ScriptStoreConfig>& script_store_config);
+      const absl::optional<ScriptStoreConfig>& script_store_config);
 
   // Create request to get next sequence of actions for a script.
   static std::string CreateNextScriptActionsRequest(
@@ -92,7 +92,7 @@
       std::vector<std::unique_ptr<TriggerScript>>* trigger_scripts,
       std::vector<std::string>* additional_allowed_domains,
       int* trigger_condition_check_interval_ms,
-      base::Optional<int>* timeout_ms);
+      absl::optional<int>* timeout_ms);
 
  private:
   // Checks that the |trigger_condition| is well-formed (e.g. does not contain
diff --git a/components/autofill_assistant/browser/protocol_utils_unittest.cc b/components/autofill_assistant/browser/protocol_utils_unittest.cc
index 7c55364..fe466bc 100644
--- a/components/autofill_assistant/browser/protocol_utils_unittest.cc
+++ b/components/autofill_assistant/browser/protocol_utils_unittest.cc
@@ -5,11 +5,11 @@
 #include "components/autofill_assistant/browser/protocol_utils.h"
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/selector.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/autofill_assistant/browser/test_util.h"
 #include "testing/gmock/include/gmock/gmock.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "url/gurl.h"
 
 namespace autofill_assistant {
@@ -121,7 +121,7 @@
       request.ParseFromString(ProtocolUtils::CreateInitialScriptActionsRequest(
           "script_path", GURL("http://example.com/"), "global_payload",
           "script_payload", client_context_proto_, parameters,
-          base::Optional<ScriptStoreConfig>(config))));
+          absl::optional<ScriptStoreConfig>(config))));
 
   const InitialScriptActionsRequestProto& initial = request.initial_request();
   EXPECT_THAT(initial.query().script_path(), ElementsAre("script_path"));
@@ -324,7 +324,7 @@
   std::vector<std::unique_ptr<TriggerScript>> trigger_scripts;
   std::vector<std::string> additional_allowed_domains;
   int interval_ms;
-  base::Optional<int> timeout_ms;
+  absl::optional<int> timeout_ms;
   EXPECT_FALSE(ProtocolUtils::ParseTriggerScripts("invalid", &trigger_scripts,
                                                   &additional_allowed_domains,
                                                   &interval_ms, &timeout_ms));
@@ -370,7 +370,7 @@
   std::vector<std::unique_ptr<TriggerScript>> trigger_scripts;
   std::vector<std::string> additional_allowed_domains;
   int interval_ms;
-  base::Optional<int> timeout_ms;
+  absl::optional<int> timeout_ms;
   EXPECT_TRUE(ProtocolUtils::ParseTriggerScripts(proto_str, &trigger_scripts,
                                                  &additional_allowed_domains,
                                                  &interval_ms, &timeout_ms));
@@ -401,7 +401,7 @@
   std::vector<std::unique_ptr<TriggerScript>> trigger_scripts;
   std::vector<std::string> additional_allowed_domains;
   int interval_ms;
-  base::Optional<int> timeout_ms;
+  absl::optional<int> timeout_ms;
 
   EXPECT_TRUE(ProtocolUtils::ParseTriggerScripts(proto_str, &trigger_scripts,
                                                  &additional_allowed_domains,
@@ -434,7 +434,7 @@
   std::vector<std::unique_ptr<TriggerScript>> trigger_scripts;
   std::vector<std::string> additional_allowed_domains;
   int interval_ms;
-  base::Optional<int> timeout_ms;
+  absl::optional<int> timeout_ms;
 
   EXPECT_FALSE(ProtocolUtils::ParseTriggerScripts(proto_str, &trigger_scripts,
                                                   &additional_allowed_domains,
diff --git a/components/autofill_assistant/browser/script_executor.h b/components/autofill_assistant/browser/script_executor.h
index 67ae0e7..6ff27c2e 100644
--- a/components/autofill_assistant/browser/script_executor.h
+++ b/components/autofill_assistant/browser/script_executor.h
@@ -518,7 +518,7 @@
     base::OnceCallback<void()> end_prompt_on_navigation_callback;
   };
   CurrentActionData current_action_data_;
-  base::Optional<size_t> current_action_index_;
+  absl::optional<size_t> current_action_index_;
 
   const UserData* user_data_ = nullptr;
 
diff --git a/components/autofill_assistant/browser/script_parameters.cc b/components/autofill_assistant/browser/script_parameters.cc
index 7ba36771..1b348ca 100644
--- a/components/autofill_assistant/browser/script_parameters.cc
+++ b/components/autofill_assistant/browser/script_parameters.cc
@@ -13,12 +13,12 @@
 // Converts a value to a target type. Returns nullopt for invalid or
 // non-existent values. Expects bool parameters as 'false' and 'true'.
 template <typename T>
-base::Optional<T> GetTypedParameter(
+absl::optional<T> GetTypedParameter(
     const std::map<std::string, std::string> parameters,
     const std::string& key) {
   auto iter = parameters.find(key);
   if (iter == parameters.end())
-    return base::nullopt;
+    return absl::nullopt;
 
   std::stringstream ss;
   ss << iter->second;
@@ -26,7 +26,7 @@
   if (!(ss >> std::boolalpha >> out)) {
     LOG(ERROR) << "Error trying to convert parameter '" << key
                << "' with value '" << iter->second << "' to target type";
-    return base::nullopt;
+    return absl::nullopt;
   }
   return out;
 }
@@ -156,102 +156,102 @@
   return out;
 }
 
-base::Optional<std::string> ScriptParameters::GetParameter(
+absl::optional<std::string> ScriptParameters::GetParameter(
     const std::string& name) const {
   auto iter = parameters_.find(name);
   if (iter == parameters_.end())
-    return base::nullopt;
+    return absl::nullopt;
 
   return iter->second;
 }
 
-base::Optional<std::string> ScriptParameters::GetOverlayColors() const {
+absl::optional<std::string> ScriptParameters::GetOverlayColors() const {
   return GetParameter(kOverlayColorParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetPasswordChangeUsername()
+absl::optional<std::string> ScriptParameters::GetPasswordChangeUsername()
     const {
   return GetParameter(kPasswordChangeUsernameParameterName);
 }
 
-base::Optional<std::string>
+absl::optional<std::string>
 ScriptParameters::GetBase64TriggerScriptsResponseProto() const {
   return GetParameter(kBase64TriggerScriptsResponseProtoParameterName);
 }
 
-base::Optional<bool> ScriptParameters::GetRequestsTriggerScript() const {
+absl::optional<bool> ScriptParameters::GetRequestsTriggerScript() const {
   return GetTypedParameter<bool>(parameters_,
                                  kRequestTriggerScriptParameterName);
 }
 
-base::Optional<bool> ScriptParameters::GetStartImmediately() const {
+absl::optional<bool> ScriptParameters::GetStartImmediately() const {
   return GetTypedParameter<bool>(parameters_, kStartImmediatelyParameterName);
 }
 
-base::Optional<bool> ScriptParameters::GetEnabled() const {
+absl::optional<bool> ScriptParameters::GetEnabled() const {
   return GetTypedParameter<bool>(parameters_, kEnabledParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetOriginalDeeplink() const {
+absl::optional<std::string> ScriptParameters::GetOriginalDeeplink() const {
   return GetParameter(kOriginalDeeplinkParameterName);
 }
 
-base::Optional<bool> ScriptParameters::GetTriggerScriptExperiment() const {
+absl::optional<bool> ScriptParameters::GetTriggerScriptExperiment() const {
   return GetTypedParameter<bool>(parameters_,
                                  kTriggerScriptExperimentParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetIntent() const {
+absl::optional<std::string> ScriptParameters::GetIntent() const {
   return GetParameter(kIntent);
 }
 
-base::Optional<std::string> ScriptParameters::GetCallerEmail() const {
+absl::optional<std::string> ScriptParameters::GetCallerEmail() const {
   return GetParameter(kCallerEmailParameterName);
 }
 
-base::Optional<bool> ScriptParameters::GetDetailsShowInitial() const {
+absl::optional<bool> ScriptParameters::GetDetailsShowInitial() const {
   return GetTypedParameter<bool>(parameters_, kDetailsShowInitialParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsTitle() const {
+absl::optional<std::string> ScriptParameters::GetDetailsTitle() const {
   return GetParameter(kDetailsTitleParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsDescriptionLine1()
+absl::optional<std::string> ScriptParameters::GetDetailsDescriptionLine1()
     const {
   return GetParameter(kDetailsDescriptionLine1ParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsDescriptionLine2()
+absl::optional<std::string> ScriptParameters::GetDetailsDescriptionLine2()
     const {
   return GetParameter(kDetailsDescriptionLine2ParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsDescriptionLine3()
+absl::optional<std::string> ScriptParameters::GetDetailsDescriptionLine3()
     const {
   return GetParameter(kDetailsDescriptionLine3ParameterName);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsImageUrl() const {
+absl::optional<std::string> ScriptParameters::GetDetailsImageUrl() const {
   return GetParameter(kDetailsImageUrl);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsImageAccessibilityHint()
+absl::optional<std::string> ScriptParameters::GetDetailsImageAccessibilityHint()
     const {
   return GetParameter(kDetailsImageAccessibilityHint);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsImageClickthroughUrl()
+absl::optional<std::string> ScriptParameters::GetDetailsImageClickthroughUrl()
     const {
   return GetParameter(kDetailsImageClickthroughUrl);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsTotalPriceLabel()
+absl::optional<std::string> ScriptParameters::GetDetailsTotalPriceLabel()
     const {
   return GetParameter(kDetailsTotalPriceLabel);
 }
 
-base::Optional<std::string> ScriptParameters::GetDetailsTotalPrice() const {
+absl::optional<std::string> ScriptParameters::GetDetailsTotalPrice() const {
   return GetParameter(kDetailsTotalPrice);
 }
 
diff --git a/components/autofill_assistant/browser/script_parameters.h b/components/autofill_assistant/browser/script_parameters.h
index dbf1d725..6cb4f5fb 100644
--- a/components/autofill_assistant/browser/script_parameters.h
+++ b/components/autofill_assistant/browser/script_parameters.h
@@ -8,8 +8,8 @@
 #include <map>
 #include <string>
 
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/service.pb.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -37,31 +37,31 @@
       bool only_trigger_script_allowlisted = false) const;
 
   // Getters for specific parameters.
-  base::Optional<std::string> GetOverlayColors() const;
-  base::Optional<std::string> GetPasswordChangeUsername() const;
-  base::Optional<std::string> GetBase64TriggerScriptsResponseProto() const;
-  base::Optional<bool> GetRequestsTriggerScript() const;
-  base::Optional<bool> GetStartImmediately() const;
-  base::Optional<bool> GetEnabled() const;
-  base::Optional<std::string> GetOriginalDeeplink() const;
-  base::Optional<bool> GetTriggerScriptExperiment() const;
-  base::Optional<std::string> GetIntent() const;
-  base::Optional<std::string> GetCallerEmail() const;
+  absl::optional<std::string> GetOverlayColors() const;
+  absl::optional<std::string> GetPasswordChangeUsername() const;
+  absl::optional<std::string> GetBase64TriggerScriptsResponseProto() const;
+  absl::optional<bool> GetRequestsTriggerScript() const;
+  absl::optional<bool> GetStartImmediately() const;
+  absl::optional<bool> GetEnabled() const;
+  absl::optional<std::string> GetOriginalDeeplink() const;
+  absl::optional<bool> GetTriggerScriptExperiment() const;
+  absl::optional<std::string> GetIntent() const;
+  absl::optional<std::string> GetCallerEmail() const;
 
   // Details parameters.
-  base::Optional<bool> GetDetailsShowInitial() const;
-  base::Optional<std::string> GetDetailsTitle() const;
-  base::Optional<std::string> GetDetailsDescriptionLine1() const;
-  base::Optional<std::string> GetDetailsDescriptionLine2() const;
-  base::Optional<std::string> GetDetailsDescriptionLine3() const;
-  base::Optional<std::string> GetDetailsImageUrl() const;
-  base::Optional<std::string> GetDetailsImageAccessibilityHint() const;
-  base::Optional<std::string> GetDetailsImageClickthroughUrl() const;
-  base::Optional<std::string> GetDetailsTotalPriceLabel() const;
-  base::Optional<std::string> GetDetailsTotalPrice() const;
+  absl::optional<bool> GetDetailsShowInitial() const;
+  absl::optional<std::string> GetDetailsTitle() const;
+  absl::optional<std::string> GetDetailsDescriptionLine1() const;
+  absl::optional<std::string> GetDetailsDescriptionLine2() const;
+  absl::optional<std::string> GetDetailsDescriptionLine3() const;
+  absl::optional<std::string> GetDetailsImageUrl() const;
+  absl::optional<std::string> GetDetailsImageAccessibilityHint() const;
+  absl::optional<std::string> GetDetailsImageClickthroughUrl() const;
+  absl::optional<std::string> GetDetailsTotalPriceLabel() const;
+  absl::optional<std::string> GetDetailsTotalPrice() const;
 
  private:
-  base::Optional<std::string> GetParameter(const std::string& name) const;
+  absl::optional<std::string> GetParameter(const std::string& name) const;
 
   std::map<std::string, std::string> parameters_;
 };
diff --git a/components/autofill_assistant/browser/selector.h b/components/autofill_assistant/browser/selector.h
index 6560037..9ad3ded 100644
--- a/components/autofill_assistant/browser/selector.h
+++ b/components/autofill_assistant/browser/selector.h
@@ -10,9 +10,9 @@
 #include <vector>
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/client_status.h"
 #include "components/autofill_assistant/browser/service.pb.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
diff --git a/components/autofill_assistant/browser/service/mock_url_loader.h b/components/autofill_assistant/browser/service/mock_url_loader.h
index c8fcfd2..50e54b8 100644
--- a/components/autofill_assistant/browser/service/mock_url_loader.h
+++ b/components/autofill_assistant/browser/service/mock_url_loader.h
@@ -73,7 +73,7 @@
   MOCK_CONST_METHOD0(NetError, int());
   MOCK_CONST_METHOD0(ResponseInfo, const ::network::mojom::URLResponseHead*());
   MOCK_CONST_METHOD0(CompletionStatus,
-                     base::Optional<::network::URLLoaderCompletionStatus>&());
+                     absl::optional<::network::URLLoaderCompletionStatus>&());
   MOCK_CONST_METHOD0(GetFinalURL, const GURL&());
   MOCK_CONST_METHOD0(LoadedFromCache, bool());
   MOCK_CONST_METHOD0(GetContentSize, int64_t());
diff --git a/components/autofill_assistant/browser/service/service_impl.h b/components/autofill_assistant/browser/service/service_impl.h
index d23d799..44ce356 100644
--- a/components/autofill_assistant/browser/service/service_impl.h
+++ b/components/autofill_assistant/browser/service/service_impl.h
@@ -95,7 +95,7 @@
 
   // The script store config used for GetActions request. This is set by the
   // controller, obtained from the GetScriptsForUrl's response.
-  base::Optional<ScriptStoreConfig> script_store_config_;
+  absl::optional<ScriptStoreConfig> script_store_config_;
 
   base::WeakPtrFactory<ServiceImpl> weak_ptr_factory_{this};
 };
diff --git a/components/autofill_assistant/browser/starter.cc b/components/autofill_assistant/browser/starter.cc
index da6d0dc..1d7f56b5 100644
--- a/components/autofill_assistant/browser/starter.cc
+++ b/components/autofill_assistant/browser/starter.cc
@@ -231,7 +231,7 @@
           navigation_handle->IsErrorPage()
               ? Metrics::TriggerScriptStarted::NAVIGATION_ERROR
               : Metrics::TriggerScriptStarted::NAVIGATED_AWAY);
-      CancelPendingStartup(base::nullopt);
+      CancelPendingStartup(absl::nullopt);
     } else {
       // Regular startup was interrupted (most likely during the onboarding).
       Metrics::RecordDropOut(waiting_for_onboarding_
@@ -241,7 +241,7 @@
                                  ->GetScriptParameters()
                                  .GetIntent()
                                  .value_or(std::string()));
-      CancelPendingStartup(base::nullopt);
+      CancelPendingStartup(absl::nullopt);
     }
     // Note: do not early-return here. While the previous startup has failed, we
     // may have navigated to a new supported domain and may need to start
@@ -276,7 +276,7 @@
 }
 
 void Starter::OnHeuristicMatch(const GURL& url,
-                               base::Optional<std::string> intent) {
+                               absl::optional<std::string> intent) {
   if (!intent || IsStartupPending() || !fetch_trigger_scripts_on_navigation_) {
     return;
   }
@@ -440,7 +440,7 @@
 }
 
 void Starter::CancelPendingStartup(
-    base::Optional<Metrics::TriggerScriptFinishedState> state) {
+    absl::optional<Metrics::TriggerScriptFinishedState> state) {
   if (!IsStartupPending()) {
     return;
   }
@@ -523,7 +523,7 @@
             Metrics::TriggerScriptFinishedState::BASE64_DECODING_ERROR);
         OnTriggerScriptFinished(
             Metrics::TriggerScriptFinishedState::BASE64_DECODING_ERROR,
-            std::move(pending_trigger_context_), base::nullopt);
+            std::move(pending_trigger_context_), absl::nullopt);
         return;
       }
     } else if (script_parameters.GetRequestsTriggerScript().value_or(false)) {
@@ -563,7 +563,7 @@
 void Starter::OnTriggerScriptFinished(
     Metrics::TriggerScriptFinishedState state,
     std::unique_ptr<TriggerContext> trigger_context,
-    base::Optional<TriggerScriptProto> trigger_script) {
+    absl::optional<TriggerScriptProto> trigger_script) {
   // Update caches on error or user-cancel.
   if (trigger_script_coordinator_) {
     std::string domain = url_utils::GetOrganizationIdentifyingDomain(
@@ -619,7 +619,7 @@
 }
 
 void Starter::MaybeShowOnboarding(
-    base::Optional<TriggerScriptProto> trigger_script) {
+    absl::optional<TriggerScriptProto> trigger_script) {
   if (platform_delegate_->GetOnboardingAccepted()) {
     OnOnboardingFinished(trigger_script, /* shown = */ false,
                          OnboardingResult::ACCEPTED);
@@ -638,7 +638,7 @@
 }
 
 void Starter::OnOnboardingFinished(
-    base::Optional<TriggerScriptProto> trigger_script,
+    absl::optional<TriggerScriptProto> trigger_script,
     bool shown,
     OnboardingResult result) {
   waiting_for_onboarding_ = false;
@@ -680,7 +680,7 @@
 }
 
 void Starter::OnStartDone(bool start_regular_script,
-                          base::Optional<TriggerScriptProto> trigger_script) {
+                          absl::optional<TriggerScriptProto> trigger_script) {
   if (!start_regular_script) {
     // Catch-all to ensure that after a failed startup attempt we reset the
     // UI state.
diff --git a/components/autofill_assistant/browser/starter.h b/components/autofill_assistant/browser/starter.h
index 2ce17c62..0a165a1 100644
--- a/components/autofill_assistant/browser/starter.h
+++ b/components/autofill_assistant/browser/starter.h
@@ -10,7 +10,6 @@
 #include "base/containers/mru_cache.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "base/time/tick_clock.h"
 #include "base/time/time.h"
 #include "components/autofill_assistant/browser/controller.h"
@@ -23,6 +22,7 @@
 #include "components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "services/metrics/public/cpp/ukm_recorder.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -79,7 +79,7 @@
   // This will also hide any currently shown UI (such as a trigger script or the
   // onboarding).
   void CancelPendingStartup(
-      base::Optional<Metrics::TriggerScriptFinishedState> state);
+      absl::optional<Metrics::TriggerScriptFinishedState> state);
 
   // Installs the feature module if necessary, otherwise directly invokes
   // |OnFeatureModuleInstalled|.
@@ -99,26 +99,26 @@
   void OnTriggerScriptFinished(
       Metrics::TriggerScriptFinishedState state,
       std::unique_ptr<TriggerContext> trigger_context,
-      base::Optional<TriggerScriptProto> trigger_script);
+      absl::optional<TriggerScriptProto> trigger_script);
 
   // Shows the onboarding if necessary, otherwise directly invokes
   // |OnOnboardingFinished|.
   void MaybeShowOnboarding(
-      base::Optional<TriggerScriptProto> trigger_script = base::nullopt);
+      absl::optional<TriggerScriptProto> trigger_script = absl::nullopt);
 
   // Starts the regular script if onboarding was accepted. Stops the startup
   // process if onboarding was rejected.
-  void OnOnboardingFinished(base::Optional<TriggerScriptProto> trigger_script,
+  void OnOnboardingFinished(absl::optional<TriggerScriptProto> trigger_script,
                             bool shown,
                             OnboardingResult result);
 
   // Called at the end of each |Start| invocation.
   void OnStartDone(
       bool start_regular_script,
-      base::Optional<TriggerScriptProto> trigger_script = base::nullopt);
+      absl::optional<TriggerScriptProto> trigger_script = absl::nullopt);
 
   // Called when the heuristic result for |url| is available.
-  void OnHeuristicMatch(const GURL& url, base::Optional<std::string> intent);
+  void OnHeuristicMatch(const GURL& url, absl::optional<std::string> intent);
 
   // Returns whether there is a currently pending call to |Start| or not.
   bool IsStartupPending() const;
diff --git a/components/autofill_assistant/browser/starter_heuristic.cc b/components/autofill_assistant/browser/starter_heuristic.cc
index 4745512f..639c298 100644
--- a/components/autofill_assistant/browser/starter_heuristic.cc
+++ b/components/autofill_assistant/browser/starter_heuristic.cc
@@ -48,7 +48,7 @@
   if (parameters.empty()) {
     return;
   }
-  base::Optional<base::Value> dict = base::JSONReader::Read(parameters);
+  absl::optional<base::Value> dict = base::JSONReader::Read(parameters);
   if (!dict || !dict->is_dict()) {
     VLOG(1) << "Failed to parse field trial params as JSON object: "
             << parameters;
@@ -111,34 +111,34 @@
   matcher_id_to_intent_map_ = std::move(mapping);
 }
 
-base::Optional<std::string> StarterHeuristic::IsHeuristicMatch(
+absl::optional<std::string> StarterHeuristic::IsHeuristicMatch(
     const GURL& url) const {
   if (matcher_id_to_intent_map_.empty() || !url.is_valid()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   if (denylisted_domains_.count(
           url_utils::GetOrganizationIdentifyingDomain(url)) > 0) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   std::set<url_matcher::URLMatcherConditionSet::ID> matches =
       url_matcher_.MatchURL(url);
   if (matches.empty()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   // Return the first matching intent.
   auto first_matching_it = matcher_id_to_intent_map_.find(*matches.begin());
   if (first_matching_it == matcher_id_to_intent_map_.end()) {
     DCHECK(false);
-    return base::nullopt;
+    return absl::nullopt;
   }
   return first_matching_it->second;
 }
 
 void StarterHeuristic::RunHeuristicAsync(
     const GURL& url,
-    base::OnceCallback<void(base::Optional<std::string> intent)> callback)
+    base::OnceCallback<void(absl::optional<std::string> intent)> callback)
     const {
   base::ThreadPool::PostTaskAndReplyWithResult(
       FROM_HERE, {base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
diff --git a/components/autofill_assistant/browser/starter_heuristic.h b/components/autofill_assistant/browser/starter_heuristic.h
index 6af264c9..a05259ed 100644
--- a/components/autofill_assistant/browser/starter_heuristic.h
+++ b/components/autofill_assistant/browser/starter_heuristic.h
@@ -10,9 +10,9 @@
 #include "base/containers/flat_map.h"
 #include "base/containers/flat_set.h"
 #include "base/memory/ref_counted.h"
-#include "base/optional.h"
 #include "components/url_matcher/url_matcher.h"
 #include "components/url_matcher/url_matcher_factory.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "url/gurl.h"
 
 namespace autofill_assistant {
@@ -28,7 +28,7 @@
   StarterHeuristic& operator=(const StarterHeuristic&) = delete;
 
   // Runs the heuristic against |url| and invokes the callback with the matching
-  // intent or base::nullopt if there is none. Since we currently do not
+  // intent or absl::nullopt if there is none. Since we currently do not
   // support intent disambiguation in cases where more than one intent is
   // matching for a given URL, this will return the intent of the first matching
   // condition-set specified in the config.
@@ -37,7 +37,7 @@
   // The callback will be invoked on the caller's sequence.
   void RunHeuristicAsync(
       const GURL& url,
-      base::OnceCallback<void(base::Optional<std::string> intent)> callback)
+      base::OnceCallback<void(absl::optional<std::string> intent)> callback)
       const;
 
  private:
@@ -47,14 +47,14 @@
 
   // Initializes the heuristic from the heuristic trial parameters. If there is
   // no trial or parsing fails, the heuristic will be empty and as such always
-  // report base::nullopt. However, if you want to disable implicit startup,
+  // report absl::nullopt. However, if you want to disable implicit startup,
   // you should disable the dedicated in-CCT and/or in-Tab triggering trials
   // instead to prevent the heuristic from being called in the first place.
   void InitFromTrialParams();
 
   // Runs the heuristic against |url|. Returns the matching intent or
-  // base::nullopt if there is none.
-  base::Optional<std::string> IsHeuristicMatch(const GURL& url) const;
+  // absl::nullopt if there is none.
+  absl::optional<std::string> IsHeuristicMatch(const GURL& url) const;
 
   // The set of denylisted domains that will always return false before
   // considering any of the intent heuristics.
diff --git a/components/autofill_assistant/browser/starter_heuristic_unittest.cc b/components/autofill_assistant/browser/starter_heuristic_unittest.cc
index 477f5bb..179247f 100644
--- a/components/autofill_assistant/browser/starter_heuristic_unittest.cc
+++ b/components/autofill_assistant/browser/starter_heuristic_unittest.cc
@@ -24,7 +24,7 @@
   ~StarterHeuristicTest() override = default;
 
   // Synchronous evaluation of the heuristic for easier testing.
-  base::Optional<std::string> IsHeuristicMatchForTest(
+  absl::optional<std::string> IsHeuristicMatchForTest(
       const StarterHeuristic& starter_heuristic,
       const GURL& url) {
     return starter_heuristic.IsHeuristicMatch(url);
@@ -53,9 +53,9 @@
               Eq("FAKE_INTENT_CART"));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic, GURL("invalid/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
 }
 
 TEST_F(StarterHeuristicTest, RunHeuristicAsync) {
@@ -76,7 +76,7 @@
         )"}});
 
   base::test::TaskEnvironment task_environment;
-  base::MockCallback<base::OnceCallback<void(base::Optional<std::string>)>>
+  base::MockCallback<base::OnceCallback<void(absl::optional<std::string>)>>
       callback;
   EXPECT_CALL(callback, Run(Optional(std::string("FAKE_INTENT_CART"))));
   auto starter_heuristic = base::MakeRefCounted<StarterHeuristic>();
@@ -117,7 +117,7 @@
               Eq("FAKE_INTENT_OTHER"));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
   // If both match, FAKE_INTENT_CART has precedence because it was specified
   // first.
   EXPECT_THAT(
@@ -149,21 +149,21 @@
   auto starter_heuristic = base::MakeRefCounted<StarterHeuristic>();
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://example.com/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
   EXPECT_THAT(
       IsHeuristicMatchForTest(*starter_heuristic,
                               GURL("https://subdomain.example.com/cart")),
-      Eq(base::nullopt));
+      Eq(absl::nullopt));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
   EXPECT_THAT(
       IsHeuristicMatchForTest(*starter_heuristic,
                               GURL("https://www.other-example.com/cart")),
-      Eq(base::nullopt));
+      Eq(absl::nullopt));
 
   // URLs on non-denylisted domains still work.
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
@@ -203,7 +203,7 @@
               Eq("FAKE_INTENT_CART"));
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
 }
 
 TEST_F(StarterHeuristicTest, FieldTrialNotSet) {
@@ -211,7 +211,7 @@
   auto starter_heuristic = base::MakeRefCounted<StarterHeuristic>();
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
 }
 
 TEST_F(StarterHeuristicTest, FieldTrialInvalid) {
@@ -223,7 +223,7 @@
   auto starter_heuristic = base::MakeRefCounted<StarterHeuristic>();
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
 }
 
 TEST_F(StarterHeuristicTest, PartiallyInvalidFieldTrialsAreCompletelyIgnored) {
@@ -248,7 +248,7 @@
   auto starter_heuristic = base::MakeRefCounted<StarterHeuristic>();
   EXPECT_THAT(IsHeuristicMatchForTest(*starter_heuristic,
                                       GURL("https://www.example.com/cart")),
-              Eq(base::nullopt));
+              Eq(absl::nullopt));
 }
 
 }  // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/starter_platform_delegate.h b/components/autofill_assistant/browser/starter_platform_delegate.h
index 842839f..5ff9342 100644
--- a/components/autofill_assistant/browser/starter_platform_delegate.h
+++ b/components/autofill_assistant/browser/starter_platform_delegate.h
@@ -35,7 +35,7 @@
   virtual void StartRegularScript(
       GURL url,
       std::unique_ptr<TriggerContext> trigger_context,
-      const base::Optional<TriggerScriptProto>& trigger_script) = 0;
+      const absl::optional<TriggerScriptProto>& trigger_script) = 0;
   // Returns whether a regular script is currently running.
   virtual bool IsRegularScriptRunning() const;
   // Returns whether a regular script is currently showing UI to the user.
diff --git a/components/autofill_assistant/browser/starter_unittest.cc b/components/autofill_assistant/browser/starter_unittest.cc
index 1a828093..67d65362 100644
--- a/components/autofill_assistant/browser/starter_unittest.cc
+++ b/components/autofill_assistant/browser/starter_unittest.cc
@@ -278,7 +278,7 @@
   base::MockCallback<base::OnceCallback<void(
       GURL url,
       std::unique_ptr<TriggerContext> trigger_context,
-      const base::Optional<TriggerScriptProto>& trigger_script)>>
+      const absl::optional<TriggerScriptProto>& trigger_script)>>
       mock_start_regular_script_callback_;
   std::unique_ptr<base::test::ScopedFeatureList> enable_fake_heuristic_;
 };
@@ -750,7 +750,7 @@
   EXPECT_CALL(mock_start_regular_script_callback_,
               Run(GURL(kExampleDeeplink),
                   Pointee(Property(&TriggerContext::GetOnboardingShown, true)),
-                  testing::Ne(base::nullopt)));
+                  testing::Ne(absl::nullopt)));
 
   starter_->Start(std::make_unique<TriggerContext>(
       std::make_unique<ScriptParameters>(script_parameters), options));
@@ -994,7 +994,7 @@
   EXPECT_CALL(mock_start_regular_script_callback_,
               Run(GURL("https://www.some-website.com/cart"),
                   Pointee(Property(&TriggerContext::GetOnboardingShown, false)),
-                  testing::Ne(base::nullopt)));
+                  testing::Ne(absl::nullopt)));
 
   // Implicit startup by navigating to an autofill-assistant-enabled site.
   content::WebContentsTester::For(web_contents())
diff --git a/components/autofill_assistant/browser/startup_util.cc b/components/autofill_assistant/browser/startup_util.cc
index 42479c2..fde7b63 100644
--- a/components/autofill_assistant/browser/startup_util.cc
+++ b/components/autofill_assistant/browser/startup_util.cc
@@ -100,7 +100,7 @@
   return StartupMode::START_RPC_TRIGGER_SCRIPT;
 }
 
-base::Optional<GURL> StartupUtil::ChooseStartupUrlForIntent(
+absl::optional<GURL> StartupUtil::ChooseStartupUrlForIntent(
     const TriggerContext& trigger_context) const {
   GURL url =
       GURL(trigger_context.GetScriptParameters().GetOriginalDeeplink().value_or(
@@ -114,7 +114,7 @@
     return url;
   }
 
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 }  // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/startup_util.h b/components/autofill_assistant/browser/startup_util.h
index 1d4c2ecc..6cdbf6e 100644
--- a/components/autofill_assistant/browser/startup_util.h
+++ b/components/autofill_assistant/browser/startup_util.h
@@ -5,8 +5,8 @@
 #ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_STARTUP_UTIL_H_
 #define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_STARTUP_UTIL_H_
 
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/trigger_context.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "url/gurl.h"
 
 namespace autofill_assistant {
@@ -57,8 +57,8 @@
 
   // Determines the startup URL. Preferably, the caller has passed this in
   // via ORIGINAL_DEEPLINK. If they have not, we try to guess the url from the
-  // initial url. If this fails, this will return base::nullopt.
-  base::Optional<GURL> ChooseStartupUrlForIntent(
+  // initial url. If this fails, this will return absl::nullopt.
+  absl::optional<GURL> ChooseStartupUrlForIntent(
       const TriggerContext& trigger_context) const;
 };
 
diff --git a/components/autofill_assistant/browser/startup_util_unittest.cc b/components/autofill_assistant/browser/startup_util_unittest.cc
index 2ed301f1..859b1fc 100644
--- a/components/autofill_assistant/browser/startup_util_unittest.cc
+++ b/components/autofill_assistant/browser/startup_util_unittest.cc
@@ -458,7 +458,7 @@
   EXPECT_THAT(
       StartupUtil().ChooseStartupUrlForIntent(
           {std::make_unique<ScriptParameters>(), TriggerContext::Options{}}),
-      Eq(base::nullopt));
+      Eq(absl::nullopt));
 }
 
 }  // namespace
diff --git a/components/autofill_assistant/browser/trigger_context.h b/components/autofill_assistant/browser/trigger_context.h
index 9c3e397..69eaed1 100644
--- a/components/autofill_assistant/browser/trigger_context.h
+++ b/components/autofill_assistant/browser/trigger_context.h
@@ -10,9 +10,9 @@
 #include <vector>
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/script_parameters.h"
 #include "components/autofill_assistant/browser/service.pb.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
diff --git a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.cc b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.cc
index 0f78eb54..5b90f51 100644
--- a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.cc
+++ b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.cc
@@ -61,11 +61,11 @@
   selectors_.clear();
 }
 
-base::Optional<bool> DynamicTriggerConditions::GetSelectorMatches(
+absl::optional<bool> DynamicTriggerConditions::GetSelectorMatches(
     const Selector& selector) const {
   auto it = selector_matches_.find(selector);
   if (it == selector_matches_.end()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   return it->second;
 }
diff --git a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.h b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.h
index b9ffd64..df0b727 100644
--- a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.h
+++ b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions.h
@@ -10,9 +10,9 @@
 
 #include "base/callback_forward.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/selector.h"
 #include "components/autofill_assistant/browser/web/web_controller.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -34,7 +34,7 @@
   // Returns whether |selector| currently matches the DOM tree. |Update| must
   // be called prior to this method. Only selectors that have previously been
   // added via |AddSelectorsFromTriggerScript| can be queried.
-  virtual base::Optional<bool> GetSelectorMatches(
+  virtual absl::optional<bool> GetSelectorMatches(
       const Selector& selector) const;
 
   // Sets whether the keyboard is currently visible.
diff --git a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions_unittest.cc b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions_unittest.cc
index b21f2de..c5100477 100644
--- a/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions_unittest.cc
+++ b/components/autofill_assistant/browser/trigger_scripts/dynamic_trigger_conditions_unittest.cc
@@ -48,7 +48,7 @@
 TEST_F(DynamicTriggerConditionsTest, LookupInvalidSelectorsFails) {
   EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                 Selector(ToSelectorProto("not_evaluated"))),
-            base::nullopt);
+            absl::nullopt);
 }
 
 TEST_F(DynamicTriggerConditionsTest, AddSelectorsFromTriggerScript) {
@@ -106,13 +106,13 @@
 
   EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                 Selector(ToSelectorProto("a"))),
-            base::make_optional(true));
+            absl::make_optional(true));
   EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                 Selector(ToSelectorProto("b"))),
-            base::make_optional(false));
+            absl::make_optional(false));
   EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                 Selector(ToSelectorProto("c"))),
-            base::make_optional(true));
+            absl::make_optional(true));
 }
 
 TEST_F(DynamicTriggerConditionsTest, ClearSelectors) {
@@ -148,7 +148,7 @@
             // previous results.
             EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                           Selector(ToSelectorProto("a"))),
-                      base::make_optional(true));
+                      absl::make_optional(true));
             std::move(callback).Run(ClientStatus(ELEMENT_RESOLUTION_FAILED),
                                     nullptr);
           });
@@ -158,7 +158,7 @@
   // After the update, the new result is returned.
   EXPECT_EQ(dynamic_trigger_conditions_.GetSelectorMatches(
                 Selector(ToSelectorProto("a"))),
-            base::make_optional(false));
+            absl::make_optional(false));
 }
 
 TEST_F(DynamicTriggerConditionsTest, GetPathPatternMatches) {
diff --git a/components/autofill_assistant/browser/trigger_scripts/mock_dynamic_trigger_conditions.h b/components/autofill_assistant/browser/trigger_scripts/mock_dynamic_trigger_conditions.h
index 48fb3f6c..9b62f4b8 100644
--- a/components/autofill_assistant/browser/trigger_scripts/mock_dynamic_trigger_conditions.h
+++ b/components/autofill_assistant/browser/trigger_scripts/mock_dynamic_trigger_conditions.h
@@ -16,7 +16,7 @@
   ~MockDynamicTriggerConditions() override;
 
   MOCK_CONST_METHOD1(GetSelectorMatches,
-                     base::Optional<bool>(const Selector& selector));
+                     absl::optional<bool>(const Selector& selector));
 
   MOCK_METHOD1(SetURL, void(const GURL& url));
 
diff --git a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.cc b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.cc
index 0a595842..b7c3fb3 100644
--- a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.cc
+++ b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.cc
@@ -59,7 +59,7 @@
     std::unique_ptr<TriggerContext> trigger_context,
     base::OnceCallback<void(Metrics::TriggerScriptFinishedState,
                             std::unique_ptr<TriggerContext>,
-                            base::Optional<TriggerScriptProto>)> callback) {
+                            absl::optional<TriggerScriptProto>)> callback) {
   DCHECK(!callback_);
   callback_ = std::move(callback);
   deeplink_url_ = deeplink_url;
@@ -90,7 +90,7 @@
 
   trigger_scripts_.clear();
   additional_allowed_domains_.clear();
-  base::Optional<int> timeout_ms;
+  absl::optional<int> timeout_ms;
   int check_interval_ms;
   if (!ProtocolUtils::ParseTriggerScripts(response, &trigger_scripts_,
                                           &additional_allowed_domains_,
@@ -275,7 +275,7 @@
   }
   waiting_for_onboarding_ = false;
 
-  RunCallback(trigger_ui_type, state, /* trigger_script = */ base::nullopt);
+  RunCallback(trigger_ui_type, state, /* trigger_script = */ absl::nullopt);
 }
 
 void TriggerScriptCoordinator::DidFinishNavigation(
@@ -533,7 +533,7 @@
 void TriggerScriptCoordinator::RunCallback(
     TriggerUIType trigger_ui_type,
     Metrics::TriggerScriptFinishedState state,
-    const base::Optional<TriggerScriptProto>& trigger_script) {
+    const absl::optional<TriggerScriptProto>& trigger_script) {
   if (!finished_state_recorded_) {
     finished_state_recorded_ = true;
     Metrics::RecordTriggerScriptFinished(ukm_recorder_, ukm_source_id_,
diff --git a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.h b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.h
index ff3bfca..a53f496a 100644
--- a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.h
+++ b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator.h
@@ -13,7 +13,6 @@
 #include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
 #include "base/observer_list_types.h"
-#include "base/optional.h"
 #include "base/time/time.h"
 #include "components/autofill_assistant/browser/client.h"
 #include "components/autofill_assistant/browser/metrics.h"
@@ -29,6 +28,7 @@
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "services/metrics/public/cpp/ukm_recorder.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "url/gurl.h"
 
 namespace autofill_assistant {
@@ -82,7 +82,7 @@
              base::OnceCallback<void(
                  Metrics::TriggerScriptFinishedState result,
                  std::unique_ptr<TriggerContext> trigger_context,
-                 base::Optional<TriggerScriptProto> trigger_script)> callback);
+                 absl::optional<TriggerScriptProto> trigger_script)> callback);
 
   // Stops the currently running trigger script. Hides any currently shown UI
   // (both trigger script UI and onboarding, if applicable) and returns |state|
@@ -147,7 +147,7 @@
 
   void RunCallback(TriggerUIType trigger_ui_type,
                    Metrics::TriggerScriptFinishedState state,
-                   const base::Optional<TriggerScriptProto>& trigger_script);
+                   const absl::optional<TriggerScriptProto>& trigger_script);
 
   // Value of trigger_ui_type for the currently visible script, if there is one.
   //
@@ -164,7 +164,7 @@
   // The callback to run once the current trigger script flow has finished.
   base::OnceCallback<void(Metrics::TriggerScriptFinishedState,
                           std::unique_ptr<TriggerContext> trigger_context,
-                          base::Optional<TriggerScriptProto>)>
+                          absl::optional<TriggerScriptProto>)>
       callback_;
 
   // The original deeplink to request trigger scripts for.
diff --git a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc
index 3dfd46b4..2b18d30 100644
--- a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc
+++ b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc
@@ -177,7 +177,7 @@
   base::MockCallback<base::OnceCallback<void(
       Metrics::TriggerScriptFinishedState result,
       std::unique_ptr<TriggerContext> trigger_context,
-      base::Optional<TriggerScriptProto> trigger_script)>>
+      absl::optional<TriggerScriptProto> trigger_script)>>
       mock_callback_;
   FakeStarterPlatformDelegate fake_platform_delegate_;
   NiceMock<MockTriggerScriptUiDelegate>* mock_ui_delegate_;
diff --git a/components/autofill_assistant/browser/ui_delegate.h b/components/autofill_assistant/browser/ui_delegate.h
index 2a79cb9..466f50f 100644
--- a/components/autofill_assistant/browser/ui_delegate.h
+++ b/components/autofill_assistant/browser/ui_delegate.h
@@ -9,7 +9,6 @@
 #include <string>
 #include <vector>
 
-#include "base/optional.h"
 #include "bottom_sheet_state.h"
 #include "components/autofill_assistant/browser/client_settings.h"
 #include "components/autofill_assistant/browser/event_handler.h"
@@ -19,6 +18,7 @@
 #include "components/autofill_assistant/browser/user_action.h"
 #include "components/autofill_assistant/browser/user_data.h"
 #include "components/autofill_assistant/browser/viewport_mode.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 class ControllerObserver;
@@ -67,13 +67,13 @@
   virtual int GetProgress() const = 0;
 
   // Returns the currently active progress step.
-  virtual base::Optional<int> GetProgressActiveStep() const = 0;
+  virtual absl::optional<int> GetProgressActiveStep() const = 0;
 
   // Returns whether the progress bar is visible.
   virtual bool GetProgressVisible() const = 0;
 
   // Returns the current configuration of the step progress bar.
-  virtual base::Optional<ShowProgressBarProto::StepProgressBarConfiguration>
+  virtual absl::optional<ShowProgressBarProto::StepProgressBarConfiguration>
   GetStepProgressBarConfiguration() const = 0;
 
   // Returns whether the progress bar should show an error state.
@@ -143,19 +143,19 @@
 
   // Sets the start date of the date/time range.
   virtual void SetDateTimeRangeStartDate(
-      const base::Optional<DateProto>& date) = 0;
+      const absl::optional<DateProto>& date) = 0;
 
   // Sets the start timeslot of the date/time range.
   virtual void SetDateTimeRangeStartTimeSlot(
-      const base::Optional<int>& timeslot_index) = 0;
+      const absl::optional<int>& timeslot_index) = 0;
 
   // Sets the end date of the date/time range.
   virtual void SetDateTimeRangeEndDate(
-      const base::Optional<DateProto>& date) = 0;
+      const absl::optional<DateProto>& date) = 0;
 
   // Sets the end timeslot of the date/time range.
   virtual void SetDateTimeRangeEndTimeSlot(
-      const base::Optional<int>& timeslot_index) = 0;
+      const absl::optional<int>& timeslot_index) = 0;
 
   // Sets an additional value.
   virtual void SetAdditionalValue(const std::string& client_memory_key,
diff --git a/components/autofill_assistant/browser/user_data.cc b/components/autofill_assistant/browser/user_data.cc
index cd279af..9c85a296 100644
--- a/components/autofill_assistant/browser/user_data.cc
+++ b/components/autofill_assistant/browser/user_data.cc
@@ -13,10 +13,10 @@
     const std::string& _identifier,
     const std::string& _label,
     const std::string& _sublabel,
-    const base::Optional<std::string>& _sublabel_accessibility_hint,
+    const absl::optional<std::string>& _sublabel_accessibility_hint,
     int _preselect_priority,
-    const base::Optional<InfoPopupProto>& _info_popup,
-    const base::Optional<std::string>& _edit_button_content_description)
+    const absl::optional<InfoPopupProto>& _info_popup,
+    const absl::optional<std::string>& _edit_button_content_description)
     : identifier(_identifier),
       label(_label),
       sublabel(_sublabel),
diff --git a/components/autofill_assistant/browser/user_data.h b/components/autofill_assistant/browser/user_data.h
index 905df13..931139d 100644
--- a/components/autofill_assistant/browser/user_data.h
+++ b/components/autofill_assistant/browser/user_data.h
@@ -11,12 +11,12 @@
 #include <vector>
 
 #include "base/callback.h"
-#include "base/optional.h"
 #include "components/autofill/core/browser/data_model/autofill_profile.h"
 #include "components/autofill/core/browser/data_model/credit_card.h"
 #include "components/autofill_assistant/browser/service.pb.h"
 #include "components/autofill_assistant/browser/user_action.h"
 #include "components/autofill_assistant/browser/website_login_manager.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill {
 class AutofillProfile;
@@ -56,10 +56,10 @@
       const std::string& id,
       const std::string& label,
       const std::string& sublabel,
-      const base::Optional<std::string>& sublabel_accessibility_hint,
+      const absl::optional<std::string>& sublabel_accessibility_hint,
       int priority,
-      const base::Optional<InfoPopupProto>& info_popup,
-      const base::Optional<std::string>& edit_button_content_description);
+      const absl::optional<InfoPopupProto>& info_popup,
+      const absl::optional<std::string>& edit_button_content_description);
   LoginChoice(const LoginChoice& another);
   ~LoginChoice();
 
@@ -70,13 +70,13 @@
   // The sublabel to display to the user.
   std::string sublabel;
   // The a11y hint for |sublabel|.
-  base::Optional<std::string> sublabel_accessibility_hint;
+  absl::optional<std::string> sublabel_accessibility_hint;
   // The priority to pre-select this choice (-1 == not set/automatic).
   int preselect_priority = -1;
   // The popup to show to provide more information about this login choice.
-  base::Optional<InfoPopupProto> info_popup;
+  absl::optional<InfoPopupProto> info_popup;
   // The a11y hint for the edit button.
-  base::Optional<std::string> edit_button_content_description;
+  absl::optional<std::string> edit_button_content_description;
 };
 
 // Tuple for holding credit card and billing address;
@@ -114,10 +114,10 @@
 
   std::string login_choice_identifier_;
   TermsAndConditionsState terms_and_conditions_ = NOT_SELECTED;
-  base::Optional<DateProto> date_time_range_start_date_;
-  base::Optional<DateProto> date_time_range_end_date_;
-  base::Optional<int> date_time_range_start_timeslot_;
-  base::Optional<int> date_time_range_end_timeslot_;
+  absl::optional<DateProto> date_time_range_start_date_;
+  absl::optional<DateProto> date_time_range_end_date_;
+  absl::optional<int> date_time_range_start_timeslot_;
+  absl::optional<int> date_time_range_end_timeslot_;
 
   // A set of additional key/value pairs to be stored in client_memory.
   std::map<std::string, ValueProto> additional_values_;
@@ -126,7 +126,7 @@
   std::vector<std::unique_ptr<PaymentInstrument>>
       available_payment_instruments_;
 
-  base::Optional<WebsiteLoginManager::Login> selected_login_;
+  absl::optional<WebsiteLoginManager::Login> selected_login_;
 
   // Return true if address has been selected, otherwise return false.
   // Note that selected_address() might return nullptr when
@@ -151,7 +151,7 @@
   // password generation (GeneratePasswordForFormFieldProto) to allow a
   // subsequent PresaveGeneratedPasswordProto to presave the password prior to
   // submission.
-  base::Optional<autofill::FormData> password_form_data_;
+  absl::optional<autofill::FormData> password_form_data_;
 
   std::string GetAllAddressKeyNames() const;
 
@@ -212,9 +212,9 @@
   DateTimeRangeProto date_time_range;
   std::vector<UserFormSectionProto> additional_prepended_sections;
   std::vector<UserFormSectionProto> additional_appended_sections;
-  base::Optional<GenericUserInterfaceProto> generic_user_interface_prepended;
-  base::Optional<GenericUserInterfaceProto> generic_user_interface_appended;
-  base::Optional<std::string> additional_model_identifier_to_check;
+  absl::optional<GenericUserInterfaceProto> generic_user_interface_prepended;
+  absl::optional<GenericUserInterfaceProto> generic_user_interface_appended;
+  absl::optional<std::string> additional_model_identifier_to_check;
 
   base::OnceCallback<void(UserData*, const UserModel*)> confirm_callback;
   base::OnceCallback<void(int, UserData*, const UserModel*)>
diff --git a/components/autofill_assistant/browser/user_data_util_unittest.cc b/components/autofill_assistant/browser/user_data_util_unittest.cc
index a7dfe63..fc0593f 100644
--- a/components/autofill_assistant/browser/user_data_util_unittest.cc
+++ b/components/autofill_assistant/browser/user_data_util_unittest.cc
@@ -811,7 +811,7 @@
 }
 
 TEST_F(UserDataUtilTextValueTest, GetCredentialsFromDifferentDomainFails) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   ElementFinder::Result element;
@@ -842,7 +842,7 @@
 }
 
 TEST_F(UserDataUtilTextValueTest, GetUsernameFromSameDomain) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   ElementFinder::Result element;
@@ -862,7 +862,7 @@
 }
 
 TEST_F(UserDataUtilTextValueTest, GetStoredPasswordFromSameDomain) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   ElementFinder::Result element;
@@ -884,7 +884,7 @@
 }
 
 TEST_F(UserDataUtilTextValueTest, GetStoredPasswordFails) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   ElementFinder::Result element;
@@ -970,7 +970,7 @@
 }
 
 TEST_F(UserDataUtilTextValueTest, TextValuePasswordManagerValue) {
-  user_data_.selected_login_ = base::make_optional<WebsiteLoginManager::Login>(
+  user_data_.selected_login_ = absl::make_optional<WebsiteLoginManager::Login>(
       GURL("https://www.example.com"), "username");
 
   ElementFinder::Result element;
diff --git a/components/autofill_assistant/browser/user_model.cc b/components/autofill_assistant/browser/user_model.cc
index 7c4de44..cd24996 100644
--- a/components/autofill_assistant/browser/user_model.cc
+++ b/components/autofill_assistant/browser/user_model.cc
@@ -19,10 +19,10 @@
 
 // Simple wrapper around value_util::GetNthValue to unwrap the base::optional
 // |value|.
-base::Optional<ValueProto> GetNthValue(const base::Optional<ValueProto>& value,
+absl::optional<ValueProto> GetNthValue(const absl::optional<ValueProto>& value,
                                        int index) {
   if (!value.has_value()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   return GetNthValue(*value, index);
@@ -30,15 +30,15 @@
 
 // Same as above, but expects |index_value| to point to a single integer value
 // specifying the index to retrieve.
-base::Optional<ValueProto> GetNthValue(
-    const base::Optional<ValueProto>& value,
-    const base::Optional<ValueProto>& index_value) {
+absl::optional<ValueProto> GetNthValue(
+    const absl::optional<ValueProto>& value,
+    const absl::optional<ValueProto>& index_value) {
   if (!value.has_value() || !index_value.has_value()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   if (!AreAllValuesOfSize({*index_value}, 1) ||
       !AreAllValuesOfType({*index_value}, ValueProto::kInts)) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   return GetNthValue(*value, index_value->ints().values().at(0));
@@ -73,7 +73,7 @@
   }
 }
 
-base::Optional<ValueProto> UserModel::GetValue(
+absl::optional<ValueProto> UserModel::GetValue(
     const std::string& identifier) const {
   auto it = values_.find(identifier);
   if (it != values_.end()) {
@@ -94,10 +94,10 @@
       }
     }
   }
-  return base::nullopt;
+  return absl::nullopt;
 }
 
-base::Optional<ValueProto> UserModel::GetValue(
+absl::optional<ValueProto> UserModel::GetValue(
     const ValueReferenceProto& reference) const {
   switch (reference.kind_case()) {
     case ValueReferenceProto::kValue:
@@ -105,7 +105,7 @@
     case ValueReferenceProto::kModelIdentifier:
       return GetValue(reference.model_identifier());
     case ValueReferenceProto::KIND_NOT_SET:
-      return base::nullopt;
+      return absl::nullopt;
   }
 }
 
diff --git a/components/autofill_assistant/browser/user_model.h b/components/autofill_assistant/browser/user_model.h
index 8800b734..6b90767 100644
--- a/components/autofill_assistant/browser/user_model.h
+++ b/components/autofill_assistant/browser/user_model.h
@@ -12,12 +12,12 @@
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
-#include "base/optional.h"
 #include "components/autofill/core/browser/data_model/autofill_profile.h"
 #include "components/autofill/core/browser/data_model/credit_card.h"
 #include "components/autofill_assistant/browser/model.pb.h"
 #include "components/autofill_assistant/browser/user_data.h"
 #include "components/autofill_assistant/browser/value_util.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "url/gurl.h"
 
 namespace autofill_assistant {
@@ -55,22 +55,22 @@
   // replaced (see |AddIdentifierPlaceholders|).
   // - Also supports the array operator to retrieve
   // a specific element of a list, e.g., "identifier[0]" to get the first item.
-  base::Optional<ValueProto> GetValue(const std::string& identifier) const;
+  absl::optional<ValueProto> GetValue(const std::string& identifier) const;
 
   // Returns the value for |reference| or nullopt if there is no such value.
-  base::Optional<ValueProto> GetValue(
+  absl::optional<ValueProto> GetValue(
       const ValueReferenceProto& reference) const;
 
   // Returns all specified values in a new std::vector. Returns nullopt if any
   // of the requested values was not found.
   template <class T>
-  base::Optional<std::vector<ValueProto>> GetValues(
+  absl::optional<std::vector<ValueProto>> GetValues(
       const T& value_references) const {
     std::vector<ValueProto> values;
     for (const auto& reference : value_references) {
       auto value = GetValue(reference);
       if (!value.has_value()) {
-        return base::nullopt;
+        return absl::nullopt;
       }
       values.emplace_back(*value);
     }
diff --git a/components/autofill_assistant/browser/user_model_unittest.cc b/components/autofill_assistant/browser/user_model_unittest.cc
index 988f63a3..4657cc2 100644
--- a/components/autofill_assistant/browser/user_model_unittest.cc
+++ b/components/autofill_assistant/browser/user_model_unittest.cc
@@ -236,8 +236,8 @@
   EXPECT_EQ(model_.GetValue("value[2]"), SimpleValue(std::string("c")));
   EXPECT_EQ(model_.GetValue("value[001]"), SimpleValue(std::string("b")));
 
-  EXPECT_EQ(model_.GetValue("value[3]"), base::nullopt);
-  EXPECT_EQ(model_.GetValue("value[-1]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("value[3]"), absl::nullopt);
+  EXPECT_EQ(model_.GetValue("value[-1]"), absl::nullopt);
 
   model_.SetValue("index", SimpleValue(0));
   EXPECT_EQ(model_.GetValue("value[index]"), SimpleValue(std::string("a")));
@@ -246,14 +246,14 @@
   model_.SetValue("index", SimpleValue(2));
   EXPECT_EQ(model_.GetValue("value[index]"), SimpleValue(std::string("c")));
   model_.SetValue("index", SimpleValue(3));
-  EXPECT_EQ(model_.GetValue("value[index]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("value[index]"), absl::nullopt);
   model_.SetValue("index", SimpleValue(-1));
-  EXPECT_EQ(model_.GetValue("value[index]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("value[index]"), absl::nullopt);
 
   model_.SetValue("index", SimpleValue(0));
   EXPECT_EQ(model_.GetValue("value[index[0]]"), SimpleValue(std::string("a")));
   model_.SetValue("index", SimpleValue(std::string("not an index")));
-  EXPECT_EQ(model_.GetValue("value[index]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("value[index]"), absl::nullopt);
 
   ValueProto indices;
   indices.mutable_ints()->add_values(2);
@@ -299,14 +299,14 @@
   // irregular characters (i.e., outside of \w+).
   EXPECT_EQ(model_.GetValue("normal_identifier[1]"),
             SimpleValue(std::string("b")));
-  EXPECT_EQ(model_.GetValue("ends_in_bracket][1]"), base::nullopt);
-  EXPECT_EQ(model_.GetValue("contains_[brackets][1]"), base::nullopt);
-  EXPECT_EQ(model_.GetValue("[][0]"), base::nullopt);
-  EXPECT_EQ(model_.GetValue("empty_brackets[1]"), base::nullopt);
-  EXPECT_EQ(model_.GetValue("empty_brackets[][1]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("ends_in_bracket][1]"), absl::nullopt);
+  EXPECT_EQ(model_.GetValue("contains_[brackets][1]"), absl::nullopt);
+  EXPECT_EQ(model_.GetValue("[][0]"), absl::nullopt);
+  EXPECT_EQ(model_.GetValue("empty_brackets[1]"), absl::nullopt);
+  EXPECT_EQ(model_.GetValue("empty_brackets[][1]"), absl::nullopt);
 
   // Subscript access into UTF-8 identifiers is not supported.
-  EXPECT_EQ(model_.GetValue("utf_8_ü万𠜎[1]"), base::nullopt);
+  EXPECT_EQ(model_.GetValue("utf_8_ü万𠜎[1]"), absl::nullopt);
 }
 
 TEST_F(UserModelTest, SetCreditCards) {
diff --git a/components/autofill_assistant/browser/value_util.cc b/components/autofill_assistant/browser/value_util.cc
index 453d6da..0c9d59d 100644
--- a/components/autofill_assistant/browser/value_util.cc
+++ b/components/autofill_assistant/browser/value_util.cc
@@ -409,12 +409,12 @@
   }
 }
 
-base::Optional<ValueProto> GetNthValue(const ValueProto& value, int index) {
+absl::optional<ValueProto> GetNthValue(const ValueProto& value, int index) {
   if (value == ValueProto()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   if (index < 0 || index >= GetValueSize(value)) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   ValueProto nth_value;
   if (value.is_client_side_only())
@@ -458,7 +458,7 @@
       DCHECK(index == 0);
       return value;
     case ValueProto::KIND_NOT_SET:
-      return base::nullopt;
+      return absl::nullopt;
   }
 }
 
diff --git a/components/autofill_assistant/browser/value_util.h b/components/autofill_assistant/browser/value_util.h
index dae11fc..34cb0669 100644
--- a/components/autofill_assistant/browser/value_util.h
+++ b/components/autofill_assistant/browser/value_util.h
@@ -8,8 +8,8 @@
 #include <ostream>
 #include <string>
 #include <vector>
-#include "base/optional.h"
 #include "components/autofill_assistant/browser/model.pb.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace autofill_assistant {
 
@@ -94,7 +94,7 @@
 
 // Returns the |index|'th item of |value| or nullopt if |index| is
 // out-of-bounds.
-base::Optional<ValueProto> GetNthValue(const ValueProto& value, int index);
+absl::optional<ValueProto> GetNthValue(const ValueProto& value, int index);
 
 }  //  namespace autofill_assistant
 
diff --git a/components/autofill_assistant/browser/value_util_unittest.cc b/components/autofill_assistant/browser/value_util_unittest.cc
index 996b256..09caa4a 100644
--- a/components/autofill_assistant/browser/value_util_unittest.cc
+++ b/components/autofill_assistant/browser/value_util_unittest.cc
@@ -378,8 +378,8 @@
   EXPECT_EQ(GetNthValue(value, 1), SimpleValue(std::string("b")));
   EXPECT_EQ(GetNthValue(value, 2), SimpleValue(std::string("c")));
 
-  EXPECT_EQ(GetNthValue(value, -1), base::nullopt);
-  EXPECT_EQ(GetNthValue(value, 3), base::nullopt);
+  EXPECT_EQ(GetNthValue(value, -1), absl::nullopt);
+  EXPECT_EQ(GetNthValue(value, 3), absl::nullopt);
 
   value.set_is_client_side_only(true);
   EXPECT_EQ(GetNthValue(value, 0),
diff --git a/components/autofill_assistant/browser/web/send_keyboard_input_worker.cc b/components/autofill_assistant/browser/web/send_keyboard_input_worker.cc
index d336f603c..c58f0b65 100644
--- a/components/autofill_assistant/browser/web/send_keyboard_input_worker.cc
+++ b/components/autofill_assistant/browser/web/send_keyboard_input_worker.cc
@@ -14,17 +14,17 @@
 namespace autofill_assistant {
 namespace {
 
-base::Optional<std::vector<std::string>> GetCommandForDomKey(
+absl::optional<std::vector<std::string>> GetCommandForDomKey(
     ui::DomKey dom_key) {
   if (dom_key == ui::DomKey::BACKSPACE) {
     return std::vector<std::string>({"DeleteBackward"});
   }
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 std::unique_ptr<input::DispatchKeyEventParams> CreateKeyEventParamsForKeyEvent(
     input::DispatchKeyEventType type,
-    base::Optional<base::Time> timestamp,
+    absl::optional<base::Time> timestamp,
     const KeyEvent& key_event) {
   auto params = input::DispatchKeyEventParams::Builder().SetType(type).Build();
   if (timestamp) {
@@ -155,7 +155,7 @@
   DCHECK_LT(index, key_events_.size());
   devtools_client_->GetInput()->DispatchKeyEvent(
       CreateKeyEventParamsForKeyEvent(input::DispatchKeyEventType::KEY_DOWN,
-                                      base::nullopt, key_events_[index]),
+                                      absl::nullopt, key_events_[index]),
       frame_id_,
       base::BindOnce(&SendKeyboardInputWorker::DispatchKeyboardTextUpEvent,
                      weak_ptr_factory_.GetWeakPtr(), index));
@@ -178,7 +178,7 @@
   DCHECK_LT(index, key_events_.size());
   devtools_client_->GetInput()->DispatchKeyEvent(
       CreateKeyEventParamsForKeyEvent(input::DispatchKeyEventType::KEY_UP,
-                                      base::nullopt, key_events_[index]),
+                                      absl::nullopt, key_events_[index]),
       frame_id_,
       base::BindOnce(&SendKeyboardInputWorker::WaitBeforeNextKey,
                      weak_ptr_factory_.GetWeakPtr(), index + 1));