commit ed166c6aad48473059ca6c0b58be523b7f4b9b3f
Author: Eriko Kurimoto <
elk...@chromium.org>
AuthorDate: Thu Feb 10 10:44:11 2022
Commit: Chromium LUCI CQ <
chromiu...@luci-project-accounts.iam.gserviceaccount.com>
CommitDate: Thu Feb 10 10:44:11 2022
Define kArcIntentHelperPackageName in a single place
This CL moves ArcIntentHelperBridge::kArcIntentHelperPackageName to
//components/arc/common/arc_intent_helper_package.h.
Before this change, kArcIntentHelperPackageName is defined in several
different places and it was not ensured that there are using the same
string "org.chromium.arc.intent_helper".
We used to define it in several places because Lacros needs this param
while cannot access to ArcIntentHelperBridge.
//components/arc/common which is visible from both lacros and ash.
Bug: 1296071
Change-Id: I54b730a16cf44237ee39146a233cefea0d8634a5
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/3435250
Reviewed-by: Scott Violet <
s...@chromium.org>
Reviewed-by: David Jacobo <
dja...@chromium.org>
Reviewed-by: Maggie Cai <
mx...@chromium.org>
Reviewed-by: Hidehiko Abe <
hide...@chromium.org>
Commit-Queue: Eriko Kurimoto <
elk...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#969377}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 61bf100..a8d825c 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4974,6 +4974,7 @@
"//components/app_restore",
"//components/arc",
"//components/arc/common",
+ "//components/arc/common:arc_intent_helper_constants",
"//components/desks_storage",
"//components/metrics/structured:neutrino_logging",
"//components/metrics/structured:neutrino_logging_util",
@@ -5310,6 +5311,7 @@
"//chromeos/dbus/constants",
"//chromeos/ui/wm",
"//components/arc/common",
+ "//components/arc/common:arc_intent_helper_constants",
]
allow_circular_includes_from += [ "//chrome/browser/policy:onc" ]
}
diff --git a/chrome/browser/apps/app_service/publishers/arc_apps.cc b/chrome/browser/apps/app_service/publishers/arc_apps.cc
index ade3412..26ce715 100644
--- a/chrome/browser/apps/app_service/publishers/arc_apps.cc
+++ b/chrome/browser/apps/app_service/publishers/arc_apps.cc
@@ -48,6 +48,7 @@
#include "components/app_restore/app_launch_info.h"
#include "components/app_restore/full_restore_save_handler.h"
#include "components/app_restore/full_restore_utils.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/icon_types.h"
#include "components/services/app_service/public/cpp/intent_filter.h"
@@ -321,8 +322,7 @@
// If |app_info| doesn't exist, we are trying to set preferences for a
// non-ARC app. Set the preferred app as the ARC intent helper package.
const std::string& package_name =
- app_info ? app_info->package_name
- : arc::ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ app_info ? app_info->package_name : arc::kArcIntentHelperPackageName;
instance->AddPreferredApp(
package_name,
@@ -1597,8 +1597,7 @@
auto* intent_helper_bridge =
arc::ArcIntentHelperBridge::GetForBrowserContext(profile_);
if (intent_helper_bridge &&
- app_info.package_name !=
- arc::ArcIntentHelperBridge::kArcIntentHelperPackageName) {
+ app_info.package_name != arc::kArcIntentHelperPackageName) {
app->intent_filters = apps_util::CreateIntentFiltersFromArcBridge(
app_info.package_name, intent_helper_bridge);
}
@@ -1675,8 +1674,7 @@
auto* intent_helper_bridge =
arc::ArcIntentHelperBridge::GetForBrowserContext(profile_);
if (intent_helper_bridge &&
- app_info.package_name !=
- arc::ArcIntentHelperBridge::kArcIntentHelperPackageName) {
+ app_info.package_name != arc::kArcIntentHelperPackageName) {
UpdateAppIntentFilters(app_info.package_name, intent_helper_bridge,
&app->intent_filters);
}
diff --git a/chrome/browser/ash/arc/bluetooth/arc_bluetooth_bridge.cc b/chrome/browser/ash/arc/bluetooth/arc_bluetooth_bridge.cc
index 3890e97..6d0748e 100644
--- a/chrome/browser/ash/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/chrome/browser/ash/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -35,6 +35,7 @@
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/device_event_log/device_event_log.h"
#include "components/prefs/pref_service.h"
@@ -1692,7 +1693,7 @@
intent_instance->SendBroadcast(
ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
"SET_BLUETOOTH_STATE"),
- ArcIntentHelperBridge::kArcIntentHelperPackageName,
+ kArcIntentHelperPackageName,
ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
"SettingsReceiver"),
extras_json);
diff --git a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc
index f3c1cdf2..50a80c5 100644
--- a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc
+++ b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc
@@ -41,6 +41,7 @@
#include "chromeos/network/network_state_handler_observer.h"
#include "chromeos/network/onc/network_onc_utils.h"
#include "chromeos/network/proxy/proxy_config_service_impl.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/language/core/browser/pref_names.h"
#include "components/onc/onc_pref_names.h"
@@ -794,7 +795,7 @@
DCHECK(write_success);
instance->SendBroadcast(
- action, ArcIntentHelperBridge::kArcIntentHelperPackageName,
+ action, kArcIntentHelperPackageName,
ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
"SettingsReceiver"),
extras_json);
diff --git a/chrome/browser/ash/arc/user_session/arc_user_session_service.cc b/chrome/browser/ash/arc/user_session/arc_user_session_service.cc
index 3dd9386b..0f7a8c4b 100644
--- a/chrome/browser/ash/arc/user_session/arc_user_session_service.cc
+++ b/chrome/browser/ash/arc/user_session/arc_user_session_service.cc
@@ -7,6 +7,7 @@
#include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "ash/components/arc/session/arc_bridge_service.h"
#include "base/memory/singleton.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/session_manager/core/session_manager.h"
@@ -73,7 +74,7 @@
instance->SendBroadcast(
ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
"USER_SESSION_ACTIVE"),
- ArcIntentHelperBridge::kArcIntentHelperPackageName,
+ kArcIntentHelperPackageName,
ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
"ArcIntentHelperService"),
"{}");
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn
index 7460b5b..7831065 100644
--- a/chrome/browser/chromeos/BUILD.gn
+++ b/chrome/browser/chromeos/BUILD.gn
@@ -348,6 +348,7 @@
"//components/app_restore",
"//components/arc",
"//components/arc/common",
+ "//components/arc/common:arc_intent_helper_constants",
"//components/autofill/core/browser",
"//components/browser_sync",
"//components/captive_portal/core",
diff --git a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
index 2b718dc..56a4b84 100644
--- a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
+++ b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/intent_picker_tab_helper.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/sync/protocol/sync_enums.pb.h"
#include "components/sync_device_info/device_info.h"
#include "content/public/browser/browser_context.h"
@@ -53,9 +54,6 @@
constexpr char kActivityForOpeningArcImeSettingsPage[] =
"org.chromium.arc.applauncher.InputMethodSettingsActivity";
-// A package name for the intent_helper apk.
-constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
-
// Size of device icons in DIPs.
constexpr int kDeviceIconSize = 16;
diff --git a/chrome/browser/chromeos/arc/arc_external_protocol_dialog_unittest.cc b/chrome/browser/chromeos/arc/arc_external_protocol_dialog_unittest.cc
index 5968554..b7cafe1 100644
--- a/chrome/browser/chromeos/arc/arc_external_protocol_dialog_unittest.cc
+++ b/chrome/browser/chromeos/arc/arc_external_protocol_dialog_unittest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/sharing/sharing_service_factory.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/arc/common/intent_helper/arc_intent_helper_mojo_delegate.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/common/test/fake_arc_icon_cache.h"
#include "components/arc/common/test/fake_arc_intent_helper_mojo.h"
#include "content/public/browser/render_process_host.h"
@@ -81,8 +82,6 @@
std::unique_ptr<ArcIconCacheDelegateProvider> delegate_provider_;
};
-const char* kChromePackageName = "org.chromium.arc.intent_helper";
-
// Creates a dummy GurlAndActivityInfo object.
GurlAndActivityInfo CreateEmptyGurlAndActivityInfo() {
return std::make_pair(GURL(), ArcIntentHelperMojoDelegate::ActivityName(
@@ -306,7 +305,8 @@
const std::string activity_name("chrome_activity_name");
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
- handlers.push_back(Create("Chrome", kChromePackageName, activity_name,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ activity_name,
/*is_preferred=*/true,
/*fallback_url=*/GURL()));
@@ -318,15 +318,16 @@
GetActionForTesting(geo_url, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(geo_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(activity_name, url_and_activity_name.second.activity_name);
// Value will be corrected as in previous scenarios.
EXPECT_TRUE(in_out_safe_to_bypass_ui);
}
// Tests that OPEN_URL_IN_CHROME is returned when a handler with a fallback http
-// URL and kChromePackageName is passed to GetAction, even if the handler is not
-// a preferred one.
+// URL and kArcIntentHelperPackageName is passed to GetAction, even if the
+// handler is not a preferred one.
TEST(ArcExternalProtocolDialogTest, TestGetActionWithOneFallbackUrl) {
const GURL intent_url_with_fallback(
"intent://scan/#Intent;scheme=abc;package=com.google.abc;"
@@ -335,7 +336,8 @@
const std::string activity_name("fake_activity_name");
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
- handlers.push_back(Create("Chrome", kChromePackageName, activity_name,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ activity_name,
/*is_preferred=*/false, fallback_url));
const size_t no_selection = handlers.size();
@@ -348,7 +350,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(activity_name, url_and_activity_name.second.activity_name);
EXPECT_TRUE(in_out_safe_to_bypass_ui);
@@ -358,7 +361,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(activity_name, url_and_activity_name.second.activity_name);
EXPECT_TRUE(in_out_safe_to_bypass_ui);
}
@@ -372,7 +376,8 @@
const std::string activity_name("fake_activity_name");
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
- handlers.push_back(Create("Chrome", kChromePackageName, activity_name,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ activity_name,
/*is_preferred=*/true, fallback_url));
const size_t no_selection = handlers.size();
@@ -386,7 +391,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(activity_name, url_and_activity_name.second.activity_name);
EXPECT_TRUE(in_out_safe_to_bypass_ui);
@@ -397,7 +403,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(activity_name, url_and_activity_name.second.activity_name);
EXPECT_TRUE(in_out_safe_to_bypass_ui);
}
@@ -415,7 +422,7 @@
handlers.push_back(Create("Other browser", "com.other.browser",
/*activity_name=*/std::string(),
/*is_preferred=*/false, fallback_url));
- handlers.push_back(Create("Chrome", kChromePackageName,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, fallback_url));
@@ -443,7 +450,8 @@
handlers.push_back(Create("Other browser", "com.other.browser",
"fake_activity",
/*is_preferred=*/false, fallback_url));
- handlers.push_back(Create("Chrome", kChromePackageName, chrome_activity,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ chrome_activity,
/*is_preferred=*/true, fallback_url));
const size_t no_selection = handlers.size();
@@ -454,7 +462,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(chrome_activity, url_and_activity_name.second.activity_name);
// Remember that this flag gets fixed under the presence of a preferred app.
EXPECT_TRUE(in_out_safe_to_bypass_ui);
@@ -475,7 +484,8 @@
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
handlers.push_back(Create("Other browser", package_name, other_activity_name,
/*is_preferred=*/true, fallback_url));
- handlers.push_back(Create("Chrome", kChromePackageName, chrome_activity_name,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ chrome_activity_name,
/*is_preferred=*/false, fallback_url));
const size_t no_selection = handlers.size();
@@ -504,7 +514,8 @@
handlers.push_back(Create("Other browser", "com.other.browser",
/*activity_name=*/std::string(),
/*is_preferred=*/false, fallback_url));
- handlers.push_back(Create("Chrome", kChromePackageName, chrome_activity_name,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ chrome_activity_name,
/*is_preferred=*/false, fallback_url));
constexpr size_t kSelection = 1; // Chrome
@@ -515,7 +526,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, kSelection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(fallback_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(chrome_activity_name, url_and_activity_name.second.activity_name);
EXPECT_FALSE(in_out_safe_to_bypass_ui);
}
@@ -533,7 +545,8 @@
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
handlers.push_back(Create("Other browser", package_name, other_activity_name,
/*is_preferred=*/false, fallback_url));
- handlers.push_back(Create("Chrome", kChromePackageName, "chrome_activity",
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ "chrome_activity",
/*is_preferred=*/false, fallback_url));
constexpr size_t kSelection = 0; // the other browser
@@ -767,7 +780,8 @@
const std::string chrome_activity("chrome.activity");
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
- handlers.push_back(Create("Chrome", kChromePackageName, chrome_activity,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
+ chrome_activity,
/*is_preferred=*/true, geo_url));
const size_t no_selection = handlers.size();
@@ -780,7 +794,8 @@
GetActionForTesting(intent_url_with_fallback, handlers, no_selection,
&url_and_activity_name, &in_out_safe_to_bypass_ui));
EXPECT_EQ(geo_url, url_and_activity_name.first);
- EXPECT_EQ(kChromePackageName, url_and_activity_name.second.package_name);
+ EXPECT_EQ(kArcIntentHelperPackageName,
+ url_and_activity_name.second.package_name);
EXPECT_EQ(chrome_activity, url_and_activity_name.second.activity_name);
EXPECT_TRUE(in_out_safe_to_bypass_ui);
}
@@ -823,9 +838,9 @@
// contains Chrome, but it's not for http(s).
TEST(ArcExternalProtocolDialogTest, TestGetUrlToNavigateOnDeactivateGeoUrl) {
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers;
- handlers.push_back(
- Create("Chrome", kChromePackageName, /*activity_name=*/std::string(),
- /*is_preferred=*/false, GURL("geo:37.4220,-122.0840")));
+ handlers.push_back(Create(
+ "Chrome", kArcIntentHelperPackageName, /*activity_name=*/std::string(),
+ /*is_preferred=*/false, GURL("geo:37.4220,-122.0840")));
EXPECT_EQ(GURL(), GetUrlToNavigateOnDeactivateForTesting(handlers));
}
@@ -839,7 +854,7 @@
handlers.push_back(Create("A browser app", "browser.app.package",
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
http://www1/")));
- handlers.push_back(Create("Chrome", kChromePackageName,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
http://www2/")));
handlers.push_back(Create("Yet another browser app",
@@ -858,7 +873,7 @@
handlers.push_back(Create("A browser app", "browser.app.package",
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www1/")));
- handlers.push_back(Create("Chrome", kChromePackageName,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www2/")));
handlers.push_back(Create("Yet another browser app",
@@ -895,7 +910,7 @@
handlers.push_back(
Create("fake app 2", "fake.app.package2", /*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www.bar.com")));
- handlers.push_back(Create("Chrome", kChromePackageName,
+ handlers.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www/")));
EXPECT_TRUE(IsChromeAnAppCandidateForTesting(handlers));
@@ -904,7 +919,7 @@
handlers2.push_back(
Create("fake app 1", "fake.app.package", /*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www.fo.com")));
- handlers2.push_back(Create("Chrome", kChromePackageName,
+ handlers2.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www/")));
handlers2.push_back(
@@ -913,7 +928,7 @@
EXPECT_TRUE(IsChromeAnAppCandidateForTesting(handlers2));
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers3;
- handlers3.push_back(Create("Chrome", kChromePackageName,
+ handlers3.push_back(Create("Chrome", kArcIntentHelperPackageName,
/*activity_name=*/std::string(),
/*is_preferred=*/false, GURL("
https://www/")));
handlers3.push_back(
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 09e515fec..f0183de 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -3053,6 +3053,7 @@
"//components/app_constants",
"//components/app_restore",
"//components/arc",
+ "//components/arc/common:arc_intent_helper_constants",
"//components/assist_ranker",
"//components/assist_ranker/proto",
"//components/captive_portal/core",
diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils.cc b/chrome/browser/ui/app_list/arc/arc_app_utils.cc
index 4d8f6dd..e90a276 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_utils.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_utils.cc
@@ -55,7 +55,7 @@
#include "chrome/common/pref_names.h"
#include "components/app_restore/app_restore_utils.h"
#include "components/app_restore/features.h"
-#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
@@ -481,9 +481,9 @@
extras.SetBoolean("inTouchMode", enable);
std::string extras_string;
base::JSONWriter::Write(extras, &extras_string);
- intent_helper_instance->SendBroadcast(
- kSetInTouchModeIntent, ArcIntentHelperBridge::kArcIntentHelperPackageName,
- kIntentHelperClassName, extras_string);
+ intent_helper_instance->SendBroadcast(kSetInTouchModeIntent,
+ kArcIntentHelperPackageName,
+ kIntentHelperClassName, extras_string);
return true;
}
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
index 311815d..3d501cf 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/arc_app_info_links_panel.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
-#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/display/display.h"
@@ -76,9 +76,9 @@
gfx::NativeView native_view = GetWidget()->GetNativeView();
const int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestView(native_view).id();
- if (arc::ShowPackageInfo(
- arc::ArcIntentHelperBridge::kArcIntentHelperPackageName,
- arc::mojom::ShowPackageInfoPage::MANAGE_LINKS, display_id)) {
+ if (arc::ShowPackageInfo(arc::kArcIntentHelperPackageName,
+ arc::mojom::ShowPackageInfoPage::MANAGE_LINKS,
+ display_id)) {
Close();
}
}
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view.cc b/chrome/browser/ui/views/intent_picker_bubble_view.cc
index 87bc4054..f7794c3 100644
--- a/chrome/browser/ui/views/intent_picker_bubble_view.cc
+++ b/chrome/browser/ui/views/intent_picker_bubble_view.cc
@@ -48,7 +48,7 @@
#include "ui/views/layout/grid_layout.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h" // nogncheck
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace {
@@ -343,8 +343,7 @@
size_t to_erase = app_info_.size();
for (const auto& app_info : app_info_) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
- if (arc::ArcIntentHelperBridge::IsIntentHelperPackage(
- app_info.launch_name)) {
+ if (app_info.launch_name == arc::kArcIntentHelperPackageName) {
to_erase = i;
continue;
}
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc b/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc
index c96a111..dddac62 100644
--- a/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc
+++ b/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc
@@ -37,7 +37,7 @@
#include "url/origin.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#endif
using AppInfo = apps::IntentPickerAppInfo;
@@ -52,13 +52,13 @@
// IntentPickerBubbleView on non-ChromeOS platforms, if needs to not filter any
// packages.
#if BUILDFLAG(IS_CHROMEOS_ASH)
-const char* kArcIntentHelperPackageName =
- arc::ArcIntentHelperBridge::kArcIntentHelperPackageName;
-bool (*IsIntentHelperPackage)(const std::string&) =
- arc::ArcIntentHelperBridge::IsIntentHelperPackage;
+const char* kArcIntentHelperPackageName = arc::kArcIntentHelperPackageName;
+bool IsIntentHelperPackage(const base::StringPiece package_name) {
+ return package_name == arc::kArcIntentHelperPackageName;
+}
#else
-static const char kArcIntentHelperPackageName[] = "unused_intent_helper";
-bool IsIntentHelperPackage(const std::string& package_name) {
+constexpr char kArcIntentHelperPackageName[] = "unused_intent_helper";
+bool IsIntentHelperPackage(const base::StringPiece package_name) {
return false;
}
#endif
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index c7b3a45..e4d5b8e 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -6654,6 +6654,7 @@
]
deps += [
"//components/arc/common",
+ "//components/arc/common:arc_intent_helper_constants",
"//components/arc/common:arc_test_support",
]
}
diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn
index 4baddb0..829e593 100644
--- a/components/arc/BUILD.gn
+++ b/components/arc/BUILD.gn
@@ -24,6 +24,7 @@
"//ash/components/arc",
"//ash/public/cpp",
"//components/arc/common",
+ "//components/arc/common:arc_intent_helper_constants",
"//components/exo",
"//components/google/core/common",
@@ -64,6 +65,7 @@
"//ash/components/arc/mojom",
"//ash/components/arc/session",
"//base/test:test_support",
+ "//components/arc/common:arc_intent_helper_constants",
"//testing/gmock",
"//testing/gtest",
"//ui/aura:test_support",
diff --git a/components/arc/common/BUILD.gn b/components/arc/common/BUILD.gn
index f0fa105..f14d54d 100644
--- a/components/arc/common/BUILD.gn
+++ b/components/arc/common/BUILD.gn
@@ -19,6 +19,7 @@
]
deps = [
+ ":arc_intent_helper_constants",
"//base",
"//build:chromeos_buildflags",
"//components/google/core/common",
@@ -45,6 +46,10 @@
}
}
+static_library("arc_intent_helper_constants") {
+ sources = [ "intent_helper/arc_intent_helper_package.h" ]
+}
+
static_library("arc_test_support") {
testonly = true
sources = [
diff --git a/components/arc/common/intent_helper/arc_intent_helper_package.h b/components/arc/common/intent_helper/arc_intent_helper_package.h
new file mode 100644
index 0000000..23488b6
--- /dev/null
+++ b/components/arc/common/intent_helper/arc_intent_helper_package.h
@@ -0,0 +1,18 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ARC_COMMON_INTENT_HELPER_ARC_INTENT_HELPER_PACKAGE_H_
+#define COMPONENTS_ARC_COMMON_INTENT_HELPER_ARC_INTENT_HELPER_PACKAGE_H_
+
+namespace arc {
+
+// The name of intent helper package which is used by ARC to send URLs to
+// Chrome.
+// This package does not count as a candidate to open ARC apps, so it should be
+// removed from candidate list such as context menu.
+constexpr char kArcIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
+
+} // namespace arc
+
+#endif // COMPONENTS_ARC_COMMON_INTENT_HELPER_ARC_INTENT_HELPER_PACKAGE_H_
diff --git a/components/arc/common/intent_helper/link_handler_model.cc b/components/arc/common/intent_helper/link_handler_model.cc
index 9c138375..0b4f03f 100644
--- a/components/arc/common/intent_helper/link_handler_model.cc
+++ b/components/arc/common/intent_helper/link_handler_model.cc
@@ -12,6 +12,7 @@
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/google/core/common/google_util.h"
#include "url/url_util.h"
@@ -110,7 +111,7 @@
void LinkHandlerModel::OnUrlHandlerList(
std::vector<ArcIntentHelperMojoDelegate::IntentHandlerInfo> handlers) {
for (auto& handler : handlers) {
- if (handler.package_name == "org.chromium.arc.intent_helper")
+ if (handler.package_name == kArcIntentHelperPackageName)
continue;
handlers_.push_back(std::move(handler));
}
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc
index aaf0212..8ed38f1 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc
@@ -20,6 +20,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/values.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/intent_helper/control_camera_app_delegate.h"
#include "components/arc/intent_helper/intent_constants.h"
#include "components/arc/intent_helper/open_url_delegate.h"
@@ -113,10 +114,6 @@
} // namespace
// static
-const char ArcIntentHelperBridge::kArcIntentHelperPackageName[] =
- "org.chromium.arc.intent_helper";
-
-// static
ArcIntentHelperBridge* ArcIntentHelperBridge::GetForBrowserContext(
content::BrowserContext* context) {
return ArcIntentHelperBridgeFactory::GetForBrowserContext(context);
@@ -379,7 +376,7 @@
for (auto& package_filters : intent_filters_) {
// The intent helper package is used by ARC to send URLs to Chrome, so it
// does not count as a candidate.
- if (IsIntentHelperPackage(package_filters.first))
+ if (package_filters.first == kArcIntentHelperPackageName)
continue;
for (auto& filter : package_filters.second) {
if (filter.Match(url))
@@ -458,18 +455,12 @@
}
// static
-bool ArcIntentHelperBridge::IsIntentHelperPackage(
- const std::string& package_name) {
- return package_name == kArcIntentHelperPackageName;
-}
-
-// static
std::vector<mojom::IntentHandlerInfoPtr>
ArcIntentHelperBridge::FilterOutIntentHelper(
std::vector<mojom::IntentHandlerInfoPtr> handlers) {
std::vector<mojom::IntentHandlerInfoPtr> handlers_filtered;
for (auto& handler : handlers) {
- if (IsIntentHelperPackage(handler->package_name))
+ if (handler->package_name == kArcIntentHelperPackageName)
continue;
handlers_filtered.push_back(std::move(handler));
}
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.h b/components/arc/intent_helper/arc_intent_helper_bridge.h
index 6bce1c1..4c2c2ce 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge.h
+++ b/components/arc/intent_helper/arc_intent_helper_bridge.h
@@ -139,16 +139,11 @@
void SendNewCaptureBroadcast(bool is_video, std::string file_path);
- // Returns false if |package_name| is for the intent_helper apk.
- static bool IsIntentHelperPackage(const std::string& package_name);
-
// Filters out handlers that belong to the intent_helper apk and returns
// a new array.
static std::vector<mojom::IntentHandlerInfoPtr> FilterOutIntentHelper(
std::vector<mojom::IntentHandlerInfoPtr> handlers);
- static const char kArcIntentHelperPackageName[];
-
const std::vector<IntentFilter>& GetIntentFilterForPackage(
const std::string& package_name);
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc b/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
index c0aa012..73bf61a 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge_unittest.cc
@@ -16,6 +16,7 @@
#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
#include "base/test/metrics/histogram_tester.h"
+#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#include "components/arc/intent_helper/intent_constants.h"
#include "components/arc/intent_helper/open_url_delegate.h"
#include "mojo/public/cpp/bindings/clone_traits.h"
@@ -106,19 +107,6 @@
}
};
-// Tests if IsIntentHelperPackage works as expected. Probably too trivial
-// to test but just in case.
-TEST_F(ArcIntentHelperTest, TestIsIntentHelperPackage) {
- EXPECT_FALSE(ArcIntentHelperBridge::IsIntentHelperPackage(""));
- EXPECT_FALSE(ArcIntentHelperBridge::IsIntentHelperPackage(
- ArcIntentHelperBridge::kArcIntentHelperPackageName + std::string("a")));
- EXPECT_FALSE(ArcIntentHelperBridge::IsIntentHelperPackage(
- ArcIntentHelperBridge::kArcIntentHelperPackageName +
- std::string("/.ArcIntentHelperActivity")));
- EXPECT_TRUE(ArcIntentHelperBridge::IsIntentHelperPackage(
- ArcIntentHelperBridge::kArcIntentHelperPackageName));
-}
-
// Tests if FilterOutIntentHelper removes handlers as expected.
TEST_F(ArcIntentHelperTest, TestFilterOutIntentHelper) {
{
@@ -147,7 +135,7 @@
std::vector<mojom::IntentHandlerInfoPtr> orig;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[0]->name = "0";
- orig[0]->package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ orig[0]->package_name = kArcIntentHelperPackageName;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[1]->name = "1";
orig[1]->package_name = "package_name1";
@@ -164,13 +152,13 @@
std::vector<mojom::IntentHandlerInfoPtr> orig;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[0]->name = "0";
- orig[0]->package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ orig[0]->package_name = kArcIntentHelperPackageName;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[1]->name = "1";
orig[1]->package_name = "package_name1";
orig.push_back(mojom::IntentHandlerInfo::New());
orig[2]->name = "2";
- orig[2]->package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ orig[2]->package_name = kArcIntentHelperPackageName;
// FilterOutIntentHelper should remove two elements.
std::vector<mojom::IntentHandlerInfoPtr> filtered =
@@ -184,10 +172,10 @@
std::vector<mojom::IntentHandlerInfoPtr> orig;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[0]->name = "0";
- orig[0]->package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ orig[0]->package_name = kArcIntentHelperPackageName;
orig.push_back(mojom::IntentHandlerInfo::New());
orig[1]->name = "1";
- orig[1]->package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ orig[1]->package_name = kArcIntentHelperPackageName;
// FilterOutIntentHelper should remove all elements.
std::vector<mojom::IntentHandlerInfoPtr> filtered =
@@ -362,10 +350,10 @@
// suitable app candidates should still match if possible.
TEST_F(ArcIntentHelperTest, TestIntentHelperAppIsNotAValidCandidate) {
std::vector<IntentFilter> array;
- array.emplace_back(GetIntentFilter(
- "
www.google.com", ArcIntentHelperBridge::kArcIntentHelperPackageName));
- array.emplace_back(GetIntentFilter(
- "
www.android.com", ArcIntentHelperBridge::kArcIntentHelperPackageName));
+ array.emplace_back(
+ GetIntentFilter("
www.google.com", kArcIntentHelperPackageName));
+ array.emplace_back(
+ GetIntentFilter("
www.android.com", kArcIntentHelperPackageName));
// Let the package name start with "z" to ensure the intent helper package
// is not always the last package checked in the ShouldChromeHandleUrl
// filter matching logic. This is to ensure this unit test tests the package
@@ -461,7 +449,7 @@
// Tests that AppendStringToIntentHelperPackageName works.
TEST_F(ArcIntentHelperTest, TestAppendStringToIntentHelperPackageName) {
- std::string package_name = ArcIntentHelperBridge::kArcIntentHelperPackageName;
+ std::string package_name = kArcIntentHelperPackageName;
std::string fake_activity = "this_is_a_fake_activity";
EXPECT_EQ(ArcIntentHelperBridge::AppendStringToIntentHelperPackageName(
fake_activity),