OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/policy/app_pack_updater.h" | 5 #include "chrome/browser/policy/app_pack_updater.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const char AppPackUpdater::kExtensionId[] = "extension-id"; | 45 const char AppPackUpdater::kExtensionId[] = "extension-id"; |
46 const char AppPackUpdater::kUpdateUrl[] = "update-url"; | 46 const char AppPackUpdater::kUpdateUrl[] = "update-url"; |
47 | 47 |
48 // A custom ExternalExtensionLoader that the AppPackUpdater creates and uses to | 48 // A custom ExternalExtensionLoader that the AppPackUpdater creates and uses to |
49 // publish AppPack updates to the extensions system. | 49 // publish AppPack updates to the extensions system. |
50 class AppPackExternalExtensionLoader | 50 class AppPackExternalExtensionLoader |
51 : public ExternalExtensionLoader, | 51 : public ExternalExtensionLoader, |
52 public base::SupportsWeakPtr<AppPackExternalExtensionLoader> { | 52 public base::SupportsWeakPtr<AppPackExternalExtensionLoader> { |
53 public: | 53 public: |
54 AppPackExternalExtensionLoader() {} | 54 AppPackExternalExtensionLoader() {} |
55 virtual ~AppPackExternalExtensionLoader() {} | |
56 | 55 |
57 // Used by the AppPackUpdater to update the current list of extensions. | 56 // Used by the AppPackUpdater to update the current list of extensions. |
58 // The format of |prefs| is detailed in the ExternalExtensionLoader/Provider | 57 // The format of |prefs| is detailed in the ExternalExtensionLoader/Provider |
59 // headers. | 58 // headers. |
60 void SetCurrentAppPackExtensions(scoped_ptr<base::DictionaryValue> prefs) { | 59 void SetCurrentAppPackExtensions(scoped_ptr<base::DictionaryValue> prefs) { |
61 app_pack_prefs_.Swap(prefs.get()); | 60 app_pack_prefs_.Swap(prefs.get()); |
62 StartLoading(); | 61 StartLoading(); |
63 } | 62 } |
64 | 63 |
65 // Implementation of ExternalExtensionLoader: | 64 // Implementation of ExternalExtensionLoader: |
66 virtual void StartLoading() OVERRIDE { | 65 virtual void StartLoading() OVERRIDE { |
67 prefs_.reset(app_pack_prefs_.DeepCopy()); | 66 prefs_.reset(app_pack_prefs_.DeepCopy()); |
68 VLOG(1) << "AppPack extension loader publishing " | 67 VLOG(1) << "AppPack extension loader publishing " |
69 << app_pack_prefs_.size() << " crx files."; | 68 << app_pack_prefs_.size() << " crx files."; |
70 LoadFinished(); | 69 LoadFinished(); |
71 } | 70 } |
72 | 71 |
| 72 protected: |
| 73 virtual ~AppPackExternalExtensionLoader() {} |
| 74 |
73 private: | 75 private: |
74 base::DictionaryValue app_pack_prefs_; | 76 base::DictionaryValue app_pack_prefs_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(AppPackExternalExtensionLoader); | 78 DISALLOW_COPY_AND_ASSIGN(AppPackExternalExtensionLoader); |
77 }; | 79 }; |
78 | 80 |
79 AppPackUpdater::AppPackUpdater(net::URLRequestContextGetter* request_context, | 81 AppPackUpdater::AppPackUpdater(net::URLRequestContextGetter* request_context, |
80 BrowserPolicyConnector* connector) | 82 BrowserPolicyConnector* connector) |
81 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | 83 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
82 created_extension_loader_(false), | 84 created_extension_loader_(false), |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 585 } |
584 } | 586 } |
585 | 587 |
586 void AppPackUpdater::SetUpdateChecked(const std::string& id) { | 588 void AppPackUpdater::SetUpdateChecked(const std::string& id) { |
587 PolicyEntryMap::iterator entry = app_pack_extensions_.find(id); | 589 PolicyEntryMap::iterator entry = app_pack_extensions_.find(id); |
588 if (entry != app_pack_extensions_.end()) | 590 if (entry != app_pack_extensions_.end()) |
589 entry->second.update_checked = true; | 591 entry->second.update_checked = true; |
590 } | 592 } |
591 | 593 |
592 } // namespace policy | 594 } // namespace policy |
OLD | NEW |