[PDP] Introduce WebExtractor for local extraction
This CL introduces a new component named WebExtractor which will handle
local extractions of commerce information from WebWrapper. WebExtractor
is implemented differently on iOS and non-iOS platforms, which allow
us to use different extraction strategies on different platforms later.
This CL is a no-op and doesn't change any of the existing extraction
logic.
Bug: 1491256
Change-Id: I32e84f473282d9f62bc93898fea177a60b13cda5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4927495
Reviewed-by: David Maunder <[email protected]>
Commit-Queue: Yue Zhang <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Reviewed-by: Matthew Jones <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1217741}
diff --git a/components/commerce/ios/browser/web_extractor_impl.mm b/components/commerce/ios/browser/web_extractor_impl.mm
new file mode 100644
index 0000000..98d1934
--- /dev/null
+++ b/components/commerce/ios/browser/web_extractor_impl.mm
@@ -0,0 +1,26 @@
+// Copyright 2023 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "components/commerce/ios/browser/web_extractor_impl.h"
+
+#import "base/strings/utf_string_conversions.h"
+#import "components/grit/components_resources.h"
+#import "ui/base/resource/resource_bundle.h"
+
+namespace commerce {
+
+WebExtractorImpl::WebExtractorImpl() = default;
+WebExtractorImpl::~WebExtractorImpl() = default;
+
+void WebExtractorImpl::ExtractMetaInfo(
+ WebWrapper* web_wrapper,
+ base::OnceCallback<void(const base::Value)> callback) {
+ std::string script =
+ ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
+ IDR_QUERY_SHOPPING_META_JS);
+
+ web_wrapper->RunJavascript(base::UTF8ToUTF16(script), std::move(callback));
+}
+
+} // namespace commerce