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