| Index: chrome/browser/ui/app_list/arc/arc_app_utils.cc
|
| 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 a120f6474a876159f94a80c28195ebb249bf404c..d17f85cb62329ceaea288d969fe7a8e278b1601c 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_utils.cc
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_utils.cc
|
| @@ -9,7 +9,9 @@
|
|
|
| #include "ash/shell.h"
|
| #include "base/bind.h"
|
| +#include "base/json/json_writer.h"
|
| #include "base/synchronization/waitable_event.h"
|
| +#include "base/values.h"
|
| #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
|
| #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
|
| @@ -20,6 +22,7 @@
|
| #include "ui/aura/window.h"
|
| #include "ui/display/display.h"
|
| #include "ui/display/screen.h"
|
| +#include "ui/events/event_utils.h"
|
|
|
| namespace arc {
|
|
|
| @@ -50,6 +53,11 @@ constexpr char kSetActiveTaskStr[] = "set active task";
|
| constexpr char kShowPackageInfoStr[] = "show package info";
|
| constexpr char kUninstallPackageStr[] = "uninstall package";
|
|
|
| +// Intent helper strings.
|
| +constexpr char kIntentHelperPackageName[] = "org.chromium.arc.intent_helper";
|
| +constexpr char kIntentHelperClassName[] =
|
| + "org.chromium.arc.intent_helper.SettingsReceiver";
|
| +
|
| // Helper function which returns the AppInstance. Create related logs when error
|
| // happens.
|
| arc::mojom::AppInstance* GetAppInstance(uint32_t required_version,
|
| @@ -110,8 +118,12 @@ class LaunchAppWithoutSize {
|
| public:
|
| LaunchAppWithoutSize(content::BrowserContext* context,
|
| const std::string& app_id,
|
| - bool landscape_mode)
|
| - : context_(context), app_id_(app_id), landscape_mode_(landscape_mode) {}
|
| + bool landscape_mode,
|
| + int event_flags)
|
| + : context_(context),
|
| + app_id_(app_id),
|
| + landscape_mode_(landscape_mode),
|
| + event_flags_(event_flags) {}
|
|
|
| // This will launch the request and after the return the creator does not
|
| // need to delete the object anymore.
|
| @@ -120,7 +132,7 @@ class LaunchAppWithoutSize {
|
| : gfx::Rect(0, 0, kNexus5Width, kNexus5Height);
|
| if (!ash::Shell::HasInstance()) {
|
| // Skip this if there is no Ash shell.
|
| - LaunchAppWithRect(context_, app_id_, landscape_);
|
| + LaunchAppWithRect(context_, app_id_, landscape_, event_flags_);
|
| delete this;
|
| return true;
|
| }
|
| @@ -143,13 +155,15 @@ class LaunchAppWithoutSize {
|
| const std::string app_id_;
|
| const bool landscape_mode_;
|
| gfx::Rect landscape_;
|
| + const int event_flags_;
|
|
|
| // The callback handler which gets called from the CanHandleResolution
|
| // function.
|
| void Callback(bool can_handle) {
|
| gfx::Size target_size =
|
| can_handle ? landscape_.size() : gfx::Size(kNexus5Width, kNexus5Height);
|
| - LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size));
|
| + LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size),
|
| + event_flags_);
|
| // Now that we are done, we can delete ourselves.
|
| delete this;
|
| }
|
| @@ -170,7 +184,8 @@ bool ShouldShowInLauncher(const std::string& app_id) {
|
|
|
| bool LaunchAppWithRect(content::BrowserContext* context,
|
| const std::string& app_id,
|
| - const gfx::Rect& target_rect) {
|
| + const gfx::Rect& target_rect,
|
| + int event_flags) {
|
| ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
|
| CHECK(prefs);
|
|
|
| @@ -195,6 +210,23 @@ bool LaunchAppWithRect(content::BrowserContext* context,
|
| if (!app_instance)
|
| return false;
|
|
|
| + arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
|
| + DCHECK(bridge_service);
|
| + auto* intent_helper_instance =
|
| + bridge_service->intent_helper()->GetInstanceForMethod(
|
| + "SendBroadcast", kSendBroadcastMinVersion);
|
| + if (intent_helper_instance) {
|
| + base::DictionaryValue extras;
|
| + extras.SetBoolean("inTouchMode",
|
| + ui::IsMouseEventFromFlags(event_flags) ||
|
| + ui::IsTouchEventFromFlags(event_flags));
|
| + std::string extras_string;
|
| + base::JSONWriter::Write(extras, &extras_string);
|
| + intent_helper_instance->SendBroadcast(
|
| + "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE",
|
| + kIntentHelperPackageName, kIntentHelperClassName, extras_string);
|
| + }
|
| +
|
| if (app_info->shortcut) {
|
| app_instance->LaunchIntent(app_info->intent_uri, target_rect);
|
| } else {
|
| @@ -206,18 +238,24 @@ bool LaunchAppWithRect(content::BrowserContext* context,
|
| return true;
|
| }
|
|
|
| -bool LaunchAndroidSettingsApp(content::BrowserContext* context) {
|
| +bool LaunchAndroidSettingsApp(content::BrowserContext* context,
|
| + int event_flags) {
|
| constexpr bool kUseLandscapeLayout = true;
|
| - return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout);
|
| + return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout,
|
| + event_flags);
|
| }
|
|
|
| -bool LaunchApp(content::BrowserContext* context, const std::string& app_id) {
|
| - return LaunchApp(context, app_id, true);
|
| +bool LaunchApp(content::BrowserContext* context,
|
| + const std::string& app_id,
|
| + int event_flags) {
|
| + constexpr bool kUseLandscapeLayout = true;
|
| + return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags);
|
| }
|
|
|
| bool LaunchApp(content::BrowserContext* context,
|
| const std::string& app_id,
|
| - bool landscape_layout) {
|
| + bool landscape_layout,
|
| + int event_flags) {
|
| ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
|
| std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
|
| if (app_info && !app_info->ready) {
|
| @@ -265,7 +303,8 @@ bool LaunchApp(content::BrowserContext* context,
|
| return true;
|
| }
|
|
|
| - return (new LaunchAppWithoutSize(context, app_id, landscape_layout))
|
| + return (new LaunchAppWithoutSize(context, app_id, landscape_layout,
|
| + event_flags))
|
| ->LaunchAndRelease();
|
| }
|
|
|
| @@ -299,10 +338,8 @@ void ShowTalkBackSettings() {
|
| return;
|
|
|
| intent_helper_instance->SendBroadcast(
|
| - "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS",
|
| - "org.chromium.arc.intent_helper",
|
| - "org.chromium.arc.intent_helper.SettingsReceiver",
|
| - "{}");
|
| + "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS",
|
| + kIntentHelperPackageName, kIntentHelperClassName, "{}");
|
| }
|
|
|
| bool CanHandleResolution(content::BrowserContext* context,
|
|
|