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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_list_prefs.h

Issue 2763753003: [Merge To M58]Fix Default icon issue when cached icon file is corrupted. (Closed)
Patch Set: Rebase. Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_
6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ui::ScaleFactor scale_factor) const; 192 ui::ScaleFactor scale_factor) const;
193 // Constructs path to default app icon for specific scale factor. This path 193 // Constructs path to default app icon for specific scale factor. This path
194 // is used to resolve icon if no icon is available at |GetIconPath|. 194 // is used to resolve icon if no icon is available at |GetIconPath|.
195 base::FilePath MaybeGetIconPathForDefaultApp( 195 base::FilePath MaybeGetIconPathForDefaultApp(
196 const std::string& app_id, 196 const std::string& app_id,
197 ui::ScaleFactor scale_factor) const; 197 ui::ScaleFactor scale_factor) const;
198 198
199 // Sets last launched time for the requested app. 199 // Sets last launched time for the requested app.
200 void SetLastLaunchTime(const std::string& app_id, const base::Time& time); 200 void SetLastLaunchTime(const std::string& app_id, const base::Time& time);
201 201
202 // Requests to load an app icon for specific scale factor. If the app or ARC 202 // Calls RequestIcon if no request is recorded.
203 // bridge service is not ready, then defer this request until the app gets 203 void MaybeRequestIcon(const std::string& app_id,
204 // available. Once new icon is installed notifies an observer 204 ui::ScaleFactor scale_factor);
205 // OnAppIconUpdated.
206 void RequestIcon(const std::string& app_id, ui::ScaleFactor scale_factor);
207 205
208 // Sets notification enabled flag for given value. If the app or ARC bridge 206 // Sets notification enabled flag for given value. If the app or ARC bridge
209 // service is not ready, then defer this request until the app gets 207 // service is not ready, then defer this request until the app gets
210 // available. Once new value is set notifies an observer 208 // available. Once new value is set notifies an observer
211 // OnNotificationsEnabledChanged. 209 // OnNotificationsEnabledChanged.
212 void SetNotificationsEnabled(const std::string& app_id, bool enabled); 210 void SetNotificationsEnabled(const std::string& app_id, bool enabled);
213 211
214 // Returns true if app is registered. 212 // Returns true if app is registered.
215 bool IsRegistered(const std::string& app_id) const; 213 bool IsRegistered(const std::string& app_id) const;
216 // Returns true if app is a default app. 214 // Returns true if app is a default app.
(...skipping 25 matching lines...) Expand all
242 } 240 }
243 241
244 std::unordered_set<std::string> GetAppsForPackage( 242 std::unordered_set<std::string> GetAppsForPackage(
245 const std::string& package_name) const; 243 const std::string& package_name) const;
246 244
247 void SetDefaltAppsReadyCallback(base::Closure callback); 245 void SetDefaltAppsReadyCallback(base::Closure callback);
248 void SimulateDefaultAppAvailabilityTimeoutForTesting(); 246 void SimulateDefaultAppAvailabilityTimeoutForTesting();
249 247
250 private: 248 private:
251 friend class ChromeLauncherControllerImplTest; 249 friend class ChromeLauncherControllerImplTest;
250 friend class ArcAppModelBuilderTest;
252 251
253 // See the Create methods. 252 // See the Create methods.
254 ArcAppListPrefs( 253 ArcAppListPrefs(
255 Profile* profile, 254 Profile* profile,
256 arc::InstanceHolder<arc::mojom::AppInstance>* app_instance_holder); 255 arc::InstanceHolder<arc::mojom::AppInstance>* app_instance_holder);
257 256
258 // arc::InstanceHolder<arc::mojom::AppInstance>::Observer: 257 // arc::InstanceHolder<arc::mojom::AppInstance>::Observer:
259 void OnInstanceReady() override; 258 void OnInstanceReady() override;
260 void OnInstanceClosed() override; 259 void OnInstanceClosed() override;
261 260
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 335
337 // Installs an icon to file system in the special folder of the profile 336 // Installs an icon to file system in the special folder of the profile
338 // directory. 337 // directory.
339 void InstallIcon(const std::string& app_id, 338 void InstallIcon(const std::string& app_id,
340 ui::ScaleFactor scale_factor, 339 ui::ScaleFactor scale_factor,
341 const std::vector<uint8_t>& contentPng); 340 const std::vector<uint8_t>& contentPng);
342 void OnIconInstalled(const std::string& app_id, 341 void OnIconInstalled(const std::string& app_id,
343 ui::ScaleFactor scale_factor, 342 ui::ScaleFactor scale_factor,
344 bool install_succeed); 343 bool install_succeed);
345 344
345 // Requests to load an app icon for specific scale factor. If the app or ARC
346 // bridge service is not ready, then defer this request until the app gets
347 // available. Once new icon is installed notifies an observer
348 // OnAppIconUpdated.
349 void RequestIcon(const std::string& app_id, ui::ScaleFactor scale_factor);
350
346 // This checks if app is not registered yet and in this case creates 351 // This checks if app is not registered yet and in this case creates
347 // non-launchable app entry. 352 // non-launchable app entry.
348 void MaybeAddNonLaunchableApp(const base::Optional<std::string>& name, 353 void MaybeAddNonLaunchableApp(const base::Optional<std::string>& name,
349 const std::string& package_name, 354 const std::string& package_name,
350 const std::string& activity); 355 const std::string& activity);
351 356
352 // Reveals first app from provided package in app launcher if package is newly 357 // Reveals first app from provided package in app launcher if package is newly
353 // installed by user. If all apps in package are hidden then app list is not 358 // installed by user. If all apps in package are hidden then app list is not
354 // shown. 359 // shown.
355 void MaybeShowPackageInAppLauncher( 360 void MaybeShowPackageInAppLauncher(
356 const arc::mojom::ArcPackageInfo& package_info); 361 const arc::mojom::ArcPackageInfo& package_info);
357 362
358 // Returns true is specified package is new in the system, was not installed 363 // Returns true is specified package is new in the system, was not installed
359 // and it is not scheduled to install by sync. 364 // and it is not scheduled to install by sync.
360 bool IsUnknownPackage(const std::string& package_name) const; 365 bool IsUnknownPackage(const std::string& package_name) const;
361 366
362 // Detects that default apps either exist or installation session is started. 367 // Detects that default apps either exist or installation session is started.
363 void DetectDefaultAppAvailability(); 368 void DetectDefaultAppAvailability();
364 369
365 // Performs data clean up for removed package. 370 // Performs data clean up for removed package.
366 void HandlePackageRemoved(const std::string& package_name); 371 void HandlePackageRemoved(const std::string& package_name);
367 372
368 // Sets timeout to wait for default app installed or installation started if 373 // Sets timeout to wait for default app installed or installation started if
369 // some default app is not available yet. 374 // some default app is not available yet.
370 void MaybeSetDefaultAppLoadingTimeout(); 375 void MaybeSetDefaultAppLoadingTimeout();
371 376
377 bool IsIconRequestRecorded(const std::string& app_id,
378 ui::ScaleFactor scale_factor) const;
379
380 // Remove the IconRequestRecord associated with app_id.
381 void MaybeRemoveIconRequestRecord(const std::string& app_id);
382
383 void ClearIconRequestRecord();
384
372 Profile* const profile_; 385 Profile* const profile_;
373 386
374 // Owned by the BrowserContext. 387 // Owned by the BrowserContext.
375 PrefService* const prefs_; 388 PrefService* const prefs_;
376 389
377 arc::InstanceHolder<arc::mojom::AppInstance>* const app_instance_holder_; 390 arc::InstanceHolder<arc::mojom::AppInstance>* const app_instance_holder_;
378 391
379 // List of observers. 392 // List of observers.
380 base::ObserverList<Observer> observer_list_; 393 base::ObserverList<Observer> observer_list_;
381 // Keeps root folder where ARC app icons for different scale factor are 394 // Keeps root folder where ARC app icons for different scale factor are
382 // stored. 395 // stored.
383 base::FilePath base_path_; 396 base::FilePath base_path_;
384 // Contains set of ARC apps that are currently ready. 397 // Contains set of ARC apps that are currently ready.
385 std::unordered_set<std::string> ready_apps_; 398 std::unordered_set<std::string> ready_apps_;
386 // Contains set of ARC apps that are currently tracked. 399 // Contains set of ARC apps that are currently tracked.
387 std::unordered_set<std::string> tracked_apps_; 400 std::unordered_set<std::string> tracked_apps_;
388 // Contains number of ARC packages that are currently installing. 401 // Contains number of ARC packages that are currently installing.
389 int installing_packages_count_ = 0; 402 int installing_packages_count_ = 0;
390 // Keeps deferred icon load requests. Each app may contain several requests 403 // Keeps record for icon request. Each app may contain several requests for
391 // for different scale factor. Scale factor is defined by specific bit 404 // different scale factor. Scale factor is defined by specific bit position.
392 // position. 405 // Mainly two usages:
393 std::map<std::string, uint32_t> request_icon_deferred_; 406 // 1. Keeps deferred icon load requests when apps are not ready. Request will
407 // be sent when apps becomes ready.
408 // 2. Keeps record of icon request sent to Android. In each user session, one
409 // request per app per scale_factor is allowed once.
410 // When ARC is disabled or the app is uninstalled, the record will be erased.
411 std::map<std::string, uint32_t> request_icon_recorded_;
394 // True if this preference has been initialized once. 412 // True if this preference has been initialized once.
395 bool is_initialized_ = false; 413 bool is_initialized_ = false;
396 // True if apps were restored. 414 // True if apps were restored.
397 bool apps_restored_ = false; 415 bool apps_restored_ = false;
398 // True is ARC package list has been refreshed once. 416 // True is ARC package list has been refreshed once.
399 bool package_list_initial_refreshed_ = false; 417 bool package_list_initial_refreshed_ = false;
400 // Play Store does not have publicly available observers for default app 418 // Play Store does not have publicly available observers for default app
401 // installations. This timeout is for validating default app availability. 419 // installations. This timeout is for validating default app availability.
402 // Default apps should be either already installed or their installations 420 // Default apps should be either already installed or their installations
403 // should be started soon after initial app list refresh. 421 // should be started soon after initial app list refresh.
(...skipping 10 matching lines...) Expand all
414 base::Closure default_apps_ready_callback_; 432 base::Closure default_apps_ready_callback_;
415 int last_shown_batch_installation_revision_ = -1; 433 int last_shown_batch_installation_revision_ = -1;
416 int current_batch_installation_revision_ = 0; 434 int current_batch_installation_revision_ = 0;
417 435
418 base::WeakPtrFactory<ArcAppListPrefs> weak_ptr_factory_; 436 base::WeakPtrFactory<ArcAppListPrefs> weak_ptr_factory_;
419 437
420 DISALLOW_COPY_AND_ASSIGN(ArcAppListPrefs); 438 DISALLOW_COPY_AND_ASSIGN(ArcAppListPrefs);
421 }; 439 };
422 440
423 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ 441 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_icon.cc ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698