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..7e84701cc0fc2243a8bf97ecc38827a41281a4de 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_constants.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, |
@@ -102,6 +110,13 @@ gfx::Rect GetTargetRect(const gfx::Size& size) { |
return result; |
} |
+// Returns true if |event_flags| came from a mouse or touch event. |
+bool IsMouseOrTouchEventFromFlags(int event_flags) { |
+ return (event_flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | |
+ ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON | |
+ ui::EF_FORWARD_MOUSE_BUTTON | ui::EF_FROM_TOUCH)) != 0; |
+} |
+ |
// A class which handles the asynchronous ARC runtime callback to figure out if |
// an app can handle a certain resolution or not. |
// After LaunchAndRelease() got called, the object will destroy itself once |
@@ -110,8 +125,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 +139,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 +162,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 +191,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 +217,21 @@ 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) { |
khmel
2016/11/28 22:08:51
Nit: please log error if instance is not available
Luis Héctor Chávez
2016/11/28 22:50:00
GetInstanceForMethod already performs logging. We
|
+ base::DictionaryValue extras; |
+ extras.SetBoolean("inTouchMode", IsMouseOrTouchEventFromFlags(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 +243,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 +308,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 +343,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, |