| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Now that we are done, we can delete ourselves. | 155 // Now that we are done, we can delete ourselves. |
| 156 delete this; | 156 delete this; |
| 157 } | 157 } |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); | 159 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 } // namespace | 162 } // namespace |
| 163 | 163 |
| 164 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; | 164 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; |
| 165 const char kPlayStorePackage[] = "com.android.vending"; |
| 166 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; |
| 165 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; | 167 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; |
| 166 | 168 |
| 167 bool ShouldShowInLauncher(const std::string& app_id) { | 169 bool ShouldShowInLauncher(const std::string& app_id) { |
| 168 return (app_id != kSettingsAppId); | 170 return (app_id != kSettingsAppId); |
| 169 } | 171 } |
| 170 | 172 |
| 171 bool LaunchAppWithRect(content::BrowserContext* context, | 173 bool LaunchAppWithRect(content::BrowserContext* context, |
| 172 const std::string& app_id, | 174 const std::string& app_id, |
| 173 const gfx::Rect& target_rect) { | 175 const gfx::Rect& target_rect) { |
| 174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 176 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout); | 213 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout); |
| 212 } | 214 } |
| 213 | 215 |
| 214 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { | 216 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { |
| 215 return LaunchApp(context, app_id, true); | 217 return LaunchApp(context, app_id, true); |
| 216 } | 218 } |
| 217 | 219 |
| 218 bool LaunchApp(content::BrowserContext* context, | 220 bool LaunchApp(content::BrowserContext* context, |
| 219 const std::string& app_id, | 221 const std::string& app_id, |
| 220 bool landscape_layout) { | 222 bool landscape_layout) { |
| 221 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 223 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 222 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 224 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 223 if (app_info && !app_info->ready) { | 225 if (app_info && !app_info->ready) { |
| 224 if (!ash::Shell::HasInstance()) | |
| 225 return false; | |
| 226 | |
| 227 ArcAuthService* auth_service = ArcAuthService::Get(); | 226 ArcAuthService* auth_service = ArcAuthService::Get(); |
| 228 DCHECK(auth_service); | 227 DCHECK(auth_service); |
| 229 | 228 |
| 229 bool arc_activated = false; |
| 230 if (!auth_service->IsArcEnabled()) { | 230 if (!auth_service->IsArcEnabled()) { |
| 231 if (!prefs->IsDefault(app_id)) { | 231 if (!prefs->IsDefault(app_id)) { |
| 232 NOTREACHED(); | 232 NOTREACHED(); |
| 233 return false; | 233 return false; |
| 234 } | 234 } |
| 235 | 235 |
| 236 auth_service->EnableArc(); | 236 auth_service->EnableArc(); |
| 237 if (!auth_service->IsArcEnabled()) { | 237 if (!auth_service->IsArcEnabled()) { |
| 238 NOTREACHED(); | 238 NOTREACHED(); |
| 239 return false; | 239 return false; |
| 240 } | 240 } |
| 241 arc_activated = true; |
| 241 } | 242 } |
| 242 | 243 |
| 243 ChromeLauncherController* chrome_controller = | 244 // PlayStore item has special handling for shelf controllers. In order to |
| 244 ChromeLauncherController::instance(); | 245 // avoid unwanted initial animation for PlayStore item do not create |
| 245 DCHECK(chrome_controller); | 246 // deferred launch request when PlayStore item enables Arc. |
| 246 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(app_id); | 247 if (!arc_activated || app_id != kPlayStoreAppId) { |
| 248 ChromeLauncherController* chrome_controller = |
| 249 ChromeLauncherController::instance(); |
| 250 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
| 251 if (chrome_controller) { |
| 252 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( |
| 253 app_id); |
| 254 } |
| 255 } |
| 256 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 247 return true; | 257 return true; |
| 248 } | 258 } |
| 249 | 259 |
| 250 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) | 260 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) |
| 251 ->LaunchAndRelease(); | 261 ->LaunchAndRelease(); |
| 252 } | 262 } |
| 253 | 263 |
| 254 void SetTaskActive(int task_id) { | 264 void SetTaskActive(int task_id) { |
| 255 arc::mojom::AppInstance* app_instance = | 265 arc::mojom::AppInstance* app_instance = |
| 256 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); | 266 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (!app_instance) | 345 if (!app_instance) |
| 336 return false; | 346 return false; |
| 337 | 347 |
| 338 app_instance->ShowPackageInfoOnPage( | 348 app_instance->ShowPackageInfoOnPage( |
| 339 package_name, page, | 349 package_name, page, |
| 340 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 350 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
| 341 return true; | 351 return true; |
| 342 } | 352 } |
| 343 | 353 |
| 344 } // namespace arc | 354 } // namespace arc |
| OLD | NEW |