[iOS] Update page attachment state through Gemini Chrome settings
When the page content sharing setting is toggled from the settings menu,
the floaty's page attachment state is updated through a provider call.
To be landed after https://crrev.com/i/8476969.
(cherry picked from commit ad63a1f9165d23eaf534c68833c687df8aec59a7)
Bug: 436844461, 436839273
Fixed: 436231809
Change-Id: I5c11d77505cff97bad4920dbb930189e002b2d63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6818999
Reviewed-by: Joemer Ramos <joemerramos@google.com>
Commit-Queue: Adam Arcaro <adamta@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1497670}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6830351
Auto-Submit: Adam Arcaro <adamta@google.com>
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Owners-Override: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/7339@{#222}
Cr-Branched-From: 27be8b77710f4405fdfeb4ee946fcabb0f6c92b2-refs/heads/main@{#1496484}
diff --git a/ios/chrome/browser/providers/bwg/chromium_bwg.mm b/ios/chrome/browser/providers/bwg/chromium_bwg.mm
index b157a81..176c58c 100644
--- a/ios/chrome/browser/providers/bwg/chromium_bwg.mm
+++ b/ios/chrome/browser/providers/bwg/chromium_bwg.mm
@@ -34,6 +34,9 @@
void ResetGemini() {}
+void UpdatePageAttachmentState(
+ BWGPageContextAttachmentState bwg_attachment_state) {}
+
bool IsProtectedUrl(std::string url) {
return false;
}
diff --git a/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/BUILD.gn b/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/BUILD.gn
index fb767cf..202e41eb 100644
--- a/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/BUILD.gn
+++ b/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/BUILD.gn
@@ -16,6 +16,7 @@
"//ios/chrome/browser/shared/model/profile",
"//ios/chrome/browser/shared/public/commands",
"//ios/chrome/browser/shared/ui/table_view:utils",
+ "//ios/public/provider/chrome/browser/bwg:bwg_api",
"//url",
]
}
diff --git a/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/bwg_settings_mediator.mm b/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/bwg_settings_mediator.mm
index f86c34c..1f88cf4 100644
--- a/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/bwg_settings_mediator.mm
+++ b/ios/chrome/browser/settings/ui_bundled/bwg/coordinator/bwg_settings_mediator.mm
@@ -11,6 +11,7 @@
#import "ios/chrome/browser/shared/public/commands/application_commands.h"
#import "ios/chrome/browser/shared/public/commands/open_new_tab_command.h"
#import "ios/chrome/grit/ios_strings.h"
+#import "ios/public/provider/chrome/browser/bwg/bwg_api.h"
#import "ui/base/l10n/l10n_util_mac.h"
#import "url/gurl.h"
@@ -77,6 +78,10 @@
- (void)setPageContentSharingPref:(BOOL)value {
_prefService->SetBoolean(prefs::kIOSBWGPageContentSetting, value);
+ ios::provider::BWGPageContextAttachmentState attachmentState =
+ value ? ios::provider::BWGPageContextAttachmentState::kAttached
+ : ios::provider::BWGPageContextAttachmentState::kUserDisabled;
+ ios::provider::UpdatePageAttachmentState(attachmentState);
}
#pragma mark - BooleanObserver
diff --git a/ios/chrome/test/providers/bwg/test_bwg.mm b/ios/chrome/test/providers/bwg/test_bwg.mm
index ca33af2..1391bb7 100644
--- a/ios/chrome/test/providers/bwg/test_bwg.mm
+++ b/ios/chrome/test/providers/bwg/test_bwg.mm
@@ -36,6 +36,9 @@
void ResetGemini() {}
+void UpdatePageAttachmentState(
+ BWGPageContextAttachmentState bwg_attachment_state) {}
+
bool IsProtectedUrl(std::string url) {
return false;
}
diff --git a/ios/public/provider/chrome/browser/bwg/bwg_api.h b/ios/public/provider/chrome/browser/bwg/bwg_api.h
index b391501..335cc4b 100644
--- a/ios/public/provider/chrome/browser/bwg/bwg_api.h
+++ b/ios/public/provider/chrome/browser/bwg/bwg_api.h
@@ -122,6 +122,10 @@
// Resets the Gemini instance by clearing its state.
void ResetGemini();
+// Updates the page attachment state of the floaty if it's invoked.
+void UpdatePageAttachmentState(
+ BWGPageContextAttachmentState bwg_attachment_state);
+
// Returns true if a URL is protected.
bool IsProtectedUrl(std::string url);