| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 EXTENSIONS_BROWSER_MOCK_EXTERNAL_PROVIDER_H_ |
| 6 #define EXTENSIONS_BROWSER_MOCK_EXTERNAL_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <string> |
| 11 #include <utility> |
| 12 |
| 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" |
| 15 #include "extensions/browser/external_provider_interface.h" |
| 16 #include "extensions/common/extension_id.h" |
| 17 #include "extensions/common/manifest.h" |
| 18 |
| 19 namespace base { |
| 20 class Version; |
| 21 } |
| 22 |
| 23 namespace extensions { |
| 24 |
| 25 class MockExternalProvider : public ExternalProviderInterface { |
| 26 public: |
| 27 MockExternalProvider(VisitorInterface* visitor, Manifest::Location location); |
| 28 ~MockExternalProvider() override; |
| 29 |
| 30 void UpdateOrAddExtension(const ExtensionId& id, |
| 31 const std::string& version, |
| 32 const base::FilePath& path); |
| 33 |
| 34 void RemoveExtension(const ExtensionId& id); |
| 35 |
| 36 // ExternalProviderInterface implementation: |
| 37 void VisitRegisteredExtension() override; |
| 38 bool HasExtension(const std::string& id) const override; |
| 39 bool GetExtensionDetails( |
| 40 const std::string& id, |
| 41 Manifest::Location* location, |
| 42 std::unique_ptr<base::Version>* version) const override; |
| 43 bool IsReady() const override; |
| 44 void ServiceShutdown() override {} |
| 45 |
| 46 int visit_count() const { return visit_count_; } |
| 47 void set_visit_count(int visit_count) { visit_count_ = visit_count; } |
| 48 |
| 49 private: |
| 50 using DataMap = std::map<ExtensionId, std::pair<std::string, base::FilePath>>; |
| 51 DataMap extension_map_; |
| 52 Manifest::Location location_; |
| 53 VisitorInterface* visitor_; |
| 54 |
| 55 // visit_count_ tracks the number of calls to VisitRegisteredExtension(). |
| 56 // Mutable because it must be incremented on each call to |
| 57 // VisitRegisteredExtension(), which must be a const method to inherit |
| 58 // from the class being mocked. |
| 59 mutable int visit_count_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(MockExternalProvider); |
| 62 }; |
| 63 |
| 64 } // namespace extensions |
| 65 |
| 66 #endif // EXTENSIONS_BROWSER_MOCK_EXTERNAL_PROVIDER_H_ |
| OLD | NEW |