| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_writer.h" | |
| 13 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/values.h" | |
| 15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 16 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
| 20 #include "components/arc/arc_bridge_service.h" | 18 #include "components/arc/arc_bridge_service.h" |
| 21 #include "components/arc/common/intent_helper.mojom.h" | 19 #include "components/arc/common/intent_helper.mojom.h" |
| 22 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 23 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 24 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 25 #include "ui/events/event_constants.h" | |
| 26 | 23 |
| 27 namespace arc { | 24 namespace arc { |
| 28 | 25 |
| 29 namespace { | 26 namespace { |
| 30 | 27 |
| 31 // Default sizes to use. | 28 // Default sizes to use. |
| 32 constexpr int kNexus7Width = 960; | 29 constexpr int kNexus7Width = 960; |
| 33 constexpr int kNexus7Height = 600; | 30 constexpr int kNexus7Height = 600; |
| 34 constexpr int kNexus5Width = 410; | 31 constexpr int kNexus5Width = 410; |
| 35 constexpr int kNexus5Height = 690; | 32 constexpr int kNexus5Height = 690; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 | 43 |
| 47 // Service name strings. | 44 // Service name strings. |
| 48 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; | 45 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; |
| 49 constexpr char kCloseTaskStr[] = "close task"; | 46 constexpr char kCloseTaskStr[] = "close task"; |
| 50 constexpr char kLaunchAppStr[] = "launch app"; | 47 constexpr char kLaunchAppStr[] = "launch app"; |
| 51 constexpr char kRemoveIconStr[] = "remove icon"; | 48 constexpr char kRemoveIconStr[] = "remove icon"; |
| 52 constexpr char kSetActiveTaskStr[] = "set active task"; | 49 constexpr char kSetActiveTaskStr[] = "set active task"; |
| 53 constexpr char kShowPackageInfoStr[] = "show package info"; | 50 constexpr char kShowPackageInfoStr[] = "show package info"; |
| 54 constexpr char kUninstallPackageStr[] = "uninstall package"; | 51 constexpr char kUninstallPackageStr[] = "uninstall package"; |
| 55 | 52 |
| 56 // Intent helper strings. | |
| 57 constexpr char kIntentHelperClassName[] = | |
| 58 "org.chromium.arc.intent_helper.SettingsReceiver"; | |
| 59 constexpr char kIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; | |
| 60 constexpr char kSendBroadcastStr[] = "SendBroadcast"; | |
| 61 constexpr char kSetInTouchModeIntent[] = | |
| 62 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; | |
| 63 constexpr char kShowTalkbackSettingsIntent[] = | |
| 64 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS"; | |
| 65 | |
| 66 // Helper function which returns the AppInstance. Create related logs when error | 53 // Helper function which returns the AppInstance. Create related logs when error |
| 67 // happens. | 54 // happens. |
| 68 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version, | 55 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version, |
| 69 const std::string& service_name) { | 56 const std::string& service_name) { |
| 70 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 57 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 71 if (!bridge_service) { | 58 if (!bridge_service) { |
| 72 VLOG(2) << "Request to " << service_name | 59 VLOG(2) << "Request to " << service_name |
| 73 << " when bridge service is not ready."; | 60 << " when bridge service is not ready."; |
| 74 return nullptr; | 61 return nullptr; |
| 75 } | 62 } |
| 76 | 63 |
| 77 return bridge_service->app()->GetInstanceForMethod(service_name.c_str(), | 64 return bridge_service->app()->GetInstanceForMethod(service_name.c_str(), |
| 78 required_version); | 65 required_version); |
| 79 } | 66 } |
| 80 | 67 |
| 81 // Helper function which returns the IntentHelperInstance. Create related logs | |
| 82 // when error happens. | |
| 83 arc::mojom::IntentHelperInstance* GetIntentHelperInstance( | |
| 84 uint32_t required_version, | |
| 85 const std::string& service_name) { | |
| 86 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
| 87 if (!bridge_service) { | |
| 88 VLOG(2) << "Request to " << service_name | |
| 89 << " when bridge service is not ready."; | |
| 90 return nullptr; | |
| 91 } | |
| 92 | |
| 93 return bridge_service->intent_helper()->GetInstanceForMethod( | |
| 94 service_name.c_str(), required_version); | |
| 95 } | |
| 96 | |
| 97 void PrioritizeArcInstanceCallback(bool success) { | 68 void PrioritizeArcInstanceCallback(bool success) { |
| 98 VLOG(2) << "Finished prioritizing the instance: result=" << success; | 69 VLOG(2) << "Finished prioritizing the instance: result=" << success; |
| 99 if (!success) | 70 if (!success) |
| 100 LOG(ERROR) << "Failed to prioritize ARC"; | 71 LOG(ERROR) << "Failed to prioritize ARC"; |
| 101 } | 72 } |
| 102 | 73 |
| 103 // Find a proper size and position for a given rectangle on the screen. | 74 // Find a proper size and position for a given rectangle on the screen. |
| 104 // TODO(skuhne): This needs more consideration, but it is lacking | 75 // TODO(skuhne): This needs more consideration, but it is lacking |
| 105 // WindowPositioner functionality since we do not have an Aura::Window yet. | 76 // WindowPositioner functionality since we do not have an Aura::Window yet. |
| 106 gfx::Rect GetTargetRect(const gfx::Size& size) { | 77 gfx::Rect GetTargetRect(const gfx::Size& size) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 // WindowPositioner::GetDefaultWindowBounds does for now. | 95 // WindowPositioner::GetDefaultWindowBounds does for now. |
| 125 // Note: Android's positioning will not overlap the shelf - as such we can | 96 // Note: Android's positioning will not overlap the shelf - as such we can |
| 126 // ignore the given workspace inset. | 97 // ignore the given workspace inset. |
| 127 // TODO(skuhne): Replace this with some more useful logic from the | 98 // TODO(skuhne): Replace this with some more useful logic from the |
| 128 // WindowPositioner. | 99 // WindowPositioner. |
| 129 result.set_x((work_area.width() - result.width()) / 2); | 100 result.set_x((work_area.width() - result.width()) / 2); |
| 130 result.set_y((work_area.height() - result.height()) / 2); | 101 result.set_y((work_area.height() - result.height()) / 2); |
| 131 return result; | 102 return result; |
| 132 } | 103 } |
| 133 | 104 |
| 134 // Returns true if |event_flags| came from a mouse or touch event. | |
| 135 bool IsMouseOrTouchEventFromFlags(int event_flags) { | |
| 136 return (event_flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | | |
| 137 ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON | | |
| 138 ui::EF_FORWARD_MOUSE_BUTTON | ui::EF_FROM_TOUCH)) != 0; | |
| 139 } | |
| 140 | |
| 141 // A class which handles the asynchronous ARC runtime callback to figure out if | 105 // A class which handles the asynchronous ARC runtime callback to figure out if |
| 142 // an app can handle a certain resolution or not. | 106 // an app can handle a certain resolution or not. |
| 143 // After LaunchAndRelease() got called, the object will destroy itself once | 107 // After LaunchAndRelease() got called, the object will destroy itself once |
| 144 // done. | 108 // done. |
| 145 class LaunchAppWithoutSize { | 109 class LaunchAppWithoutSize { |
| 146 public: | 110 public: |
| 147 LaunchAppWithoutSize(content::BrowserContext* context, | 111 LaunchAppWithoutSize(content::BrowserContext* context, |
| 148 const std::string& app_id, | 112 const std::string& app_id, |
| 149 bool landscape_mode, | 113 bool landscape_mode) |
| 150 int event_flags) | 114 : context_(context), app_id_(app_id), landscape_mode_(landscape_mode) {} |
| 151 : context_(context), | |
| 152 app_id_(app_id), | |
| 153 landscape_mode_(landscape_mode), | |
| 154 event_flags_(event_flags) {} | |
| 155 | 115 |
| 156 // This will launch the request and after the return the creator does not | 116 // This will launch the request and after the return the creator does not |
| 157 // need to delete the object anymore. | 117 // need to delete the object anymore. |
| 158 bool LaunchAndRelease() { | 118 bool LaunchAndRelease() { |
| 159 landscape_ = landscape_mode_ ? gfx::Rect(0, 0, kNexus7Width, kNexus7Height) | 119 landscape_ = landscape_mode_ ? gfx::Rect(0, 0, kNexus7Width, kNexus7Height) |
| 160 : gfx::Rect(0, 0, kNexus5Width, kNexus5Height); | 120 : gfx::Rect(0, 0, kNexus5Width, kNexus5Height); |
| 161 if (!ash::Shell::HasInstance()) { | 121 if (!ash::Shell::HasInstance()) { |
| 162 // Skip this if there is no Ash shell. | 122 // Skip this if there is no Ash shell. |
| 163 LaunchAppWithRect(context_, app_id_, landscape_, event_flags_); | 123 LaunchAppWithRect(context_, app_id_, landscape_); |
| 164 delete this; | 124 delete this; |
| 165 return true; | 125 return true; |
| 166 } | 126 } |
| 167 | 127 |
| 168 // TODO(skuhne): Change CanHandleResolution into a call which returns | 128 // TODO(skuhne): Change CanHandleResolution into a call which returns |
| 169 // capability flags like [PHONE/TABLET]_[LANDSCAPE/PORTRAIT] and which | 129 // capability flags like [PHONE/TABLET]_[LANDSCAPE/PORTRAIT] and which |
| 170 // might also return the used DP->PIX conversion constant to do better | 130 // might also return the used DP->PIX conversion constant to do better |
| 171 // size calculations. | 131 // size calculations. |
| 172 bool result = CanHandleResolution( | 132 bool result = CanHandleResolution( |
| 173 context_, app_id_, landscape_, | 133 context_, app_id_, landscape_, |
| 174 base::Bind(&LaunchAppWithoutSize::Callback, base::Unretained(this))); | 134 base::Bind(&LaunchAppWithoutSize::Callback, base::Unretained(this))); |
| 175 if (!result) | 135 if (!result) |
| 176 delete this; | 136 delete this; |
| 177 | 137 |
| 178 return result; | 138 return result; |
| 179 } | 139 } |
| 180 | 140 |
| 181 private: | 141 private: |
| 182 content::BrowserContext* context_; | 142 content::BrowserContext* context_; |
| 183 const std::string app_id_; | 143 const std::string app_id_; |
| 184 const bool landscape_mode_; | 144 const bool landscape_mode_; |
| 185 gfx::Rect landscape_; | 145 gfx::Rect landscape_; |
| 186 const int event_flags_; | |
| 187 | 146 |
| 188 // The callback handler which gets called from the CanHandleResolution | 147 // The callback handler which gets called from the CanHandleResolution |
| 189 // function. | 148 // function. |
| 190 void Callback(bool can_handle) { | 149 void Callback(bool can_handle) { |
| 191 gfx::Size target_size = | 150 gfx::Size target_size = |
| 192 can_handle ? landscape_.size() : gfx::Size(kNexus5Width, kNexus5Height); | 151 can_handle ? landscape_.size() : gfx::Size(kNexus5Width, kNexus5Height); |
| 193 LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size), | 152 LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size)); |
| 194 event_flags_); | |
| 195 // Now that we are done, we can delete ourselves. | 153 // Now that we are done, we can delete ourselves. |
| 196 delete this; | 154 delete this; |
| 197 } | 155 } |
| 198 | 156 |
| 199 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); | 157 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); |
| 200 }; | 158 }; |
| 201 | 159 |
| 202 } // namespace | 160 } // namespace |
| 203 | 161 |
| 204 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; | 162 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; |
| 205 const char kPlayStorePackage[] = "com.android.vending"; | 163 const char kPlayStorePackage[] = "com.android.vending"; |
| 206 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; | 164 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; |
| 207 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; | 165 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; |
| 208 | 166 |
| 209 bool ShouldShowInLauncher(const std::string& app_id) { | 167 bool ShouldShowInLauncher(const std::string& app_id) { |
| 210 return (app_id != kSettingsAppId); | 168 return (app_id != kSettingsAppId); |
| 211 } | 169 } |
| 212 | 170 |
| 213 bool LaunchAppWithRect(content::BrowserContext* context, | 171 bool LaunchAppWithRect(content::BrowserContext* context, |
| 214 const std::string& app_id, | 172 const std::string& app_id, |
| 215 const gfx::Rect& target_rect, | 173 const gfx::Rect& target_rect) { |
| 216 int event_flags) { | |
| 217 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 218 CHECK(prefs); | 175 CHECK(prefs); |
| 219 | 176 |
| 220 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 177 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 221 if (!app_info) { | 178 if (!app_info) { |
| 222 VLOG(2) << "Cannot launch unavailable app: " << app_id << "."; | 179 VLOG(2) << "Cannot launch unavailable app: " << app_id << "."; |
| 223 return false; | 180 return false; |
| 224 } | 181 } |
| 225 | 182 |
| 226 if (!app_info->ready) { | 183 if (!app_info->ready) { |
| 227 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; | 184 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; |
| 228 return false; | 185 return false; |
| 229 } | 186 } |
| 230 | 187 |
| 231 if (!app_info->launchable) { | 188 if (!app_info->launchable) { |
| 232 VLOG(2) << "Cannot launch non-launchable app: " << app_id << "."; | 189 VLOG(2) << "Cannot launch non-launchable app: " << app_id << "."; |
| 233 return false; | 190 return false; |
| 234 } | 191 } |
| 235 | 192 |
| 236 arc::mojom::AppInstance* app_instance = | 193 arc::mojom::AppInstance* app_instance = |
| 237 GetAppInstance(kMinVersion, kLaunchAppStr); | 194 GetAppInstance(kMinVersion, kLaunchAppStr); |
| 238 if (!app_instance) | 195 if (!app_instance) |
| 239 return false; | 196 return false; |
| 240 | 197 |
| 241 arc::mojom::IntentHelperInstance* intent_helper_instance = | |
| 242 GetIntentHelperInstance(kSendBroadcastMinVersion, kSendBroadcastStr); | |
| 243 if (intent_helper_instance) { | |
| 244 base::DictionaryValue extras; | |
| 245 extras.SetBoolean("inTouchMode", IsMouseOrTouchEventFromFlags(event_flags)); | |
| 246 std::string extras_string; | |
| 247 base::JSONWriter::Write(extras, &extras_string); | |
| 248 intent_helper_instance->SendBroadcast( | |
| 249 kSetInTouchModeIntent, kIntentHelperPackageName, kIntentHelperClassName, | |
| 250 extras_string); | |
| 251 } | |
| 252 | |
| 253 if (app_info->shortcut) { | 198 if (app_info->shortcut) { |
| 254 app_instance->LaunchIntent(app_info->intent_uri, target_rect); | 199 app_instance->LaunchIntent(app_info->intent_uri, target_rect); |
| 255 } else { | 200 } else { |
| 256 app_instance->LaunchApp(app_info->package_name, app_info->activity, | 201 app_instance->LaunchApp(app_info->package_name, app_info->activity, |
| 257 target_rect); | 202 target_rect); |
| 258 } | 203 } |
| 259 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 204 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 260 | 205 |
| 261 return true; | 206 return true; |
| 262 } | 207 } |
| 263 | 208 |
| 264 bool LaunchAndroidSettingsApp(content::BrowserContext* context, | 209 bool LaunchAndroidSettingsApp(content::BrowserContext* context) { |
| 265 int event_flags) { | |
| 266 constexpr bool kUseLandscapeLayout = true; | 210 constexpr bool kUseLandscapeLayout = true; |
| 267 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout, | 211 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout); |
| 268 event_flags); | 212 } |
| 213 |
| 214 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { |
| 215 return LaunchApp(context, app_id, true); |
| 269 } | 216 } |
| 270 | 217 |
| 271 bool LaunchApp(content::BrowserContext* context, | 218 bool LaunchApp(content::BrowserContext* context, |
| 272 const std::string& app_id, | 219 const std::string& app_id, |
| 273 int event_flags) { | 220 bool landscape_layout) { |
| 274 constexpr bool kUseLandscapeLayout = true; | |
| 275 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags); | |
| 276 } | |
| 277 | |
| 278 bool LaunchApp(content::BrowserContext* context, | |
| 279 const std::string& app_id, | |
| 280 bool landscape_layout, | |
| 281 int event_flags) { | |
| 282 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 221 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 283 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 222 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 284 if (app_info && !app_info->ready) { | 223 if (app_info && !app_info->ready) { |
| 285 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); | 224 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); |
| 286 DCHECK(arc_session_manager); | 225 DCHECK(arc_session_manager); |
| 287 | 226 |
| 288 bool arc_activated = false; | 227 bool arc_activated = false; |
| 289 if (!arc_session_manager->IsArcEnabled()) { | 228 if (!arc_session_manager->IsArcEnabled()) { |
| 290 if (!prefs->IsDefault(app_id)) { | 229 if (!prefs->IsDefault(app_id)) { |
| 291 NOTREACHED(); | 230 NOTREACHED(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 302 | 241 |
| 303 // PlayStore item has special handling for shelf controllers. In order to | 242 // PlayStore item has special handling for shelf controllers. In order to |
| 304 // avoid unwanted initial animation for PlayStore item do not create | 243 // avoid unwanted initial animation for PlayStore item do not create |
| 305 // deferred launch request when PlayStore item enables Arc. | 244 // deferred launch request when PlayStore item enables Arc. |
| 306 if (!arc_activated || app_id != kPlayStoreAppId) { | 245 if (!arc_activated || app_id != kPlayStoreAppId) { |
| 307 ChromeLauncherController* chrome_controller = | 246 ChromeLauncherController* chrome_controller = |
| 308 ChromeLauncherController::instance(); | 247 ChromeLauncherController::instance(); |
| 309 DCHECK(chrome_controller || !ash::Shell::HasInstance()); | 248 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
| 310 if (chrome_controller) { | 249 if (chrome_controller) { |
| 311 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( | 250 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( |
| 312 app_id, event_flags); | 251 app_id); |
| 313 | 252 |
| 314 // On some boards, ARC is booted with a restricted set of resources by | 253 // On some boards, ARC is booted with a restricted set of resources by |
| 315 // default to avoid slowing down Chrome's user session restoration. | 254 // default to avoid slowing down Chrome's user session restoration. |
| 316 // However, the restriction should be lifted once the user explicitly | 255 // However, the restriction should be lifted once the user explicitly |
| 317 // tries to launch an ARC app. | 256 // tries to launch an ARC app. |
| 318 VLOG(2) << "Prioritizing the instance"; | 257 VLOG(2) << "Prioritizing the instance"; |
| 319 chromeos::SessionManagerClient* session_manager_client = | 258 chromeos::SessionManagerClient* session_manager_client = |
| 320 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 259 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 321 session_manager_client->PrioritizeArcInstance( | 260 session_manager_client->PrioritizeArcInstance( |
| 322 base::Bind(PrioritizeArcInstanceCallback)); | 261 base::Bind(PrioritizeArcInstanceCallback)); |
| 323 } | 262 } |
| 324 } | 263 } |
| 325 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 264 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 326 return true; | 265 return true; |
| 327 } | 266 } |
| 328 | 267 |
| 329 return (new LaunchAppWithoutSize(context, app_id, landscape_layout, | 268 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) |
| 330 event_flags)) | |
| 331 ->LaunchAndRelease(); | 269 ->LaunchAndRelease(); |
| 332 } | 270 } |
| 333 | 271 |
| 334 void SetTaskActive(int task_id) { | 272 void SetTaskActive(int task_id) { |
| 335 arc::mojom::AppInstance* app_instance = | 273 arc::mojom::AppInstance* app_instance = |
| 336 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); | 274 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); |
| 337 if (!app_instance) | 275 if (!app_instance) |
| 338 return; | 276 return; |
| 339 app_instance->SetTaskActive(task_id); | 277 app_instance->SetTaskActive(task_id); |
| 340 } | 278 } |
| 341 | 279 |
| 342 void CloseTask(int task_id) { | 280 void CloseTask(int task_id) { |
| 343 arc::mojom::AppInstance* app_instance = | 281 arc::mojom::AppInstance* app_instance = |
| 344 GetAppInstance(kTaskSupportMinVersion, kCloseTaskStr); | 282 GetAppInstance(kTaskSupportMinVersion, kCloseTaskStr); |
| 345 if (!app_instance) | 283 if (!app_instance) |
| 346 return; | 284 return; |
| 347 app_instance->CloseTask(task_id); | 285 app_instance->CloseTask(task_id); |
| 348 } | 286 } |
| 349 | 287 |
| 350 void ShowTalkBackSettings() { | 288 void ShowTalkBackSettings() { |
| 351 arc::mojom::IntentHelperInstance* intent_helper_instance = | 289 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 352 GetIntentHelperInstance(kSendBroadcastMinVersion, kSendBroadcastStr); | 290 if (!bridge_service) { |
| 291 VLOG(2) << "ARC bridge is not ready"; |
| 292 return; |
| 293 } |
| 294 |
| 295 auto* intent_helper_instance = |
| 296 bridge_service->intent_helper()->GetInstanceForMethod( |
| 297 "SendBroadcast", kSendBroadcastMinVersion); |
| 353 if (!intent_helper_instance) | 298 if (!intent_helper_instance) |
| 354 return; | 299 return; |
| 355 | 300 |
| 356 intent_helper_instance->SendBroadcast(kShowTalkbackSettingsIntent, | 301 intent_helper_instance->SendBroadcast( |
| 357 kIntentHelperPackageName, | 302 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS", |
| 358 kIntentHelperClassName, "{}"); | 303 "org.chromium.arc.intent_helper", |
| 304 "org.chromium.arc.intent_helper.SettingsReceiver", |
| 305 "{}"); |
| 359 } | 306 } |
| 360 | 307 |
| 361 bool CanHandleResolution(content::BrowserContext* context, | 308 bool CanHandleResolution(content::BrowserContext* context, |
| 362 const std::string& app_id, | 309 const std::string& app_id, |
| 363 const gfx::Rect& rect, | 310 const gfx::Rect& rect, |
| 364 const CanHandleResolutionCallback& callback) { | 311 const CanHandleResolutionCallback& callback) { |
| 365 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 312 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 366 DCHECK(prefs); | 313 DCHECK(prefs); |
| 367 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 314 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 368 if (!app_info) { | 315 if (!app_info) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (!app_instance) | 373 if (!app_instance) |
| 427 return false; | 374 return false; |
| 428 | 375 |
| 429 app_instance->ShowPackageInfoOnPage( | 376 app_instance->ShowPackageInfoOnPage( |
| 430 package_name, page, | 377 package_name, page, |
| 431 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 378 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
| 432 return true; | 379 return true; |
| 433 } | 380 } |
| 434 | 381 |
| 435 } // namespace arc | 382 } // namespace arc |
| OLD | NEW |