1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_
6 #define CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_
7 
8 #include "base/macros.h"
9 #include "base/memory/scoped_refptr.h"
10 #include "chrome/browser/extensions/external_provider_impl.h"
11 #include "extensions/common/manifest.h"
12 
13 class Profile;
14 
15 namespace base {
16 class DictionaryValue;
17 }
18 
19 namespace user_prefs {
20 class PrefRegistrySyncable;
21 }
22 
23 // Functions and types related to installing default apps.
24 namespace default_apps {
25 
26 // These enum values are persisted in the user preferences, so they should not
27 // be changed.
28 enum InstallState {
29   kUnknown,
30   // Now unused, left for backward compatibility.
31   kProvideLegacyDefaultApps,
32   kNeverInstallDefaultApps,
33   kAlreadyInstalledDefaultApps
34 };
35 
36 // Register preference properties used by default apps to maintain
37 // install state.
38 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
39 
40 // A specialization of the ExternalProviderImpl that conditionally installs apps
41 // from the chrome::DIR_DEFAULT_APPS location based on a preference in the
42 // profile.
43 class Provider : public extensions::ExternalProviderImpl {
44  public:
45   Provider(Profile* profile,
46            VisitorInterface* service,
47            scoped_refptr<extensions::ExternalLoader> loader,
48            extensions::Manifest::Location crx_location,
49            extensions::Manifest::Location download_location,
50            int creation_flags);
51 
52   bool ShouldInstallInProfile();
53 
54   // ExternalProviderImpl overrides:
55   void VisitRegisteredExtension() override;
56   void SetPrefs(std::unique_ptr<base::DictionaryValue> prefs) override;
57 
58  private:
59   Profile* profile_;
60   bool is_migration_;
61 
62   DISALLOW_COPY_AND_ASSIGN(Provider);
63 };
64 
65 }  // namespace default_apps
66 
67 #endif  // CHROME_BROWSER_EXTENSIONS_DEFAULT_APPS_H_
68