Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_utils.cc

Issue 2308643002: arc: Make Play Store item persistent in app list. (Closed)
Patch Set: fix unit_tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Now that we are done, we can delete ourselves. 156 // Now that we are done, we can delete ourselves.
157 delete this; 157 delete this;
158 } 158 }
159 159
160 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); 160 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize);
161 }; 161 };
162 162
163 } // namespace 163 } // namespace
164 164
165 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; 165 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa";
166 const char kPlayStorePackage[] = "com.android.vending";
167 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity";
166 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; 168 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj";
167 169
168 bool ShouldShowInLauncher(const std::string& app_id) { 170 bool ShouldShowInLauncher(const std::string& app_id) {
169 return (app_id != kSettingsAppId); 171 return (app_id != kSettingsAppId);
170 } 172 }
171 173
172 bool LaunchAppWithRect(content::BrowserContext* context, 174 bool LaunchAppWithRect(content::BrowserContext* context,
173 const std::string& app_id, 175 const std::string& app_id,
174 const gfx::Rect& target_rect) { 176 const gfx::Rect& target_rect) {
175 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 177 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout); 214 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout);
213 } 215 }
214 216
215 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { 217 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) {
216 return LaunchApp(context, app_id, true); 218 return LaunchApp(context, app_id, true);
217 } 219 }
218 220
219 bool LaunchApp(content::BrowserContext* context, 221 bool LaunchApp(content::BrowserContext* context,
220 const std::string& app_id, 222 const std::string& app_id,
221 bool landscape_layout) { 223 bool landscape_layout) {
222 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 224 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
223 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 225 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
224 if (app_info && !app_info->ready) { 226 if (app_info && !app_info->ready) {
225 if (!ash::Shell::HasInstance())
226 return false;
227
228 ArcAuthService* auth_service = ArcAuthService::Get(); 227 ArcAuthService* auth_service = ArcAuthService::Get();
229 DCHECK(auth_service); 228 DCHECK(auth_service);
230 229
230 bool arc_activated = false;
231 if (!auth_service->IsArcEnabled()) { 231 if (!auth_service->IsArcEnabled()) {
232 if (!prefs->IsDefault(app_id)) { 232 if (!prefs->IsDefault(app_id)) {
233 NOTREACHED(); 233 NOTREACHED();
234 return false; 234 return false;
235 } 235 }
236 236
237 auth_service->EnableArc(); 237 auth_service->EnableArc();
238 if (!auth_service->IsArcEnabled()) { 238 if (!auth_service->IsArcEnabled()) {
239 NOTREACHED(); 239 NOTREACHED();
240 return false; 240 return false;
241 } 241 }
242 arc_activated = true;
242 } 243 }
243 244
244 ChromeLauncherController* chrome_controller = 245 // PlayStore item has special handling for shelf controllers. In order to
245 ChromeLauncherController::instance(); 246 // avoid unwanted initial animation for PlayStore item do not create
246 DCHECK(chrome_controller); 247 // deferred launch request when PlayStore item enables Arc.
247 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(app_id); 248 if (!arc_activated || app_id != kPlayStoreAppId) {
249 ChromeLauncherController* chrome_controller =
250 ChromeLauncherController::instance();
251 DCHECK(chrome_controller || !ash::Shell::HasInstance());
252 if (chrome_controller) {
253 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(
254 app_id);
255 }
256 }
257 prefs->SetLastLaunchTime(app_id, base::Time::Now());
248 return true; 258 return true;
249 } 259 }
250 260
251 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) 261 return (new LaunchAppWithoutSize(context, app_id, landscape_layout))
252 ->LaunchAndRelease(); 262 ->LaunchAndRelease();
253 } 263 }
254 264
255 void SetTaskActive(int task_id) { 265 void SetTaskActive(int task_id) {
256 arc::mojom::AppInstance* app_instance = 266 arc::mojom::AppInstance* app_instance =
257 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); 267 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 if (!app_instance) 371 if (!app_instance)
362 return false; 372 return false;
363 373
364 app_instance->ShowPackageInfoOnPage( 374 app_instance->ShowPackageInfoOnPage(
365 package_name, page, 375 package_name, page,
366 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); 376 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height)));
367 return true; 377 return true;
368 } 378 }
369 379
370 } // namespace arc 380 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_utils.h ('k') | chrome/browser/ui/app_list/arc/arc_default_app_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698