OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ |
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ | 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // the manifest. Sets |error| and returns an empty scoped_ptr on failure. | 55 // the manifest. Sets |error| and returns an empty scoped_ptr on failure. |
56 static scoped_ptr<ExternallyConnectableInfo> FromValue( | 56 static scoped_ptr<ExternallyConnectableInfo> FromValue( |
57 const base::Value& value, | 57 const base::Value& value, |
58 string16* error); | 58 string16* error); |
59 | 59 |
60 virtual ~ExternallyConnectableInfo(); | 60 virtual ~ExternallyConnectableInfo(); |
61 | 61 |
62 // The URL patterns that are allowed to connect/sendMessage. | 62 // The URL patterns that are allowed to connect/sendMessage. |
63 const URLPatternSet matches; | 63 const URLPatternSet matches; |
64 | 64 |
65 // The extension IDs that are allowed to connect/sendMessage. | 65 // The extension IDs that are allowed to connect/sendMessage. Sorted. |
66 const std::vector<std::string> ids; | 66 const std::vector<std::string> ids; |
67 | 67 |
68 // True if any extension is allowed to connect. This would have corresponded | 68 // True if any extension is allowed to connect. This would have corresponded |
69 // to an ID of "*" in |ids|. | 69 // to an ID of "*" in |ids|. |
70 const bool matches_all_ids; | 70 const bool all_ids; |
| 71 |
| 72 // Returns true if |ids| contains |id| or if |all_ids| is true. |
| 73 // |
| 74 // More convenient for callers than checking each individually, and it makes |
| 75 // use of the sortedness of |ids|. |
| 76 bool IdCanConnect(const std::string& id); |
| 77 |
| 78 // Public only for testing. Use FromValue in production. |
| 79 ExternallyConnectableInfo(const URLPatternSet& matches, |
| 80 const std::vector<std::string>& ids, |
| 81 bool all_ids); |
71 | 82 |
72 private: | 83 private: |
73 ExternallyConnectableInfo(const URLPatternSet& matches, | |
74 const std::vector<std::string>& ids, | |
75 bool matches_all_ids); | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(ExternallyConnectableInfo); | 84 DISALLOW_COPY_AND_ASSIGN(ExternallyConnectableInfo); |
78 }; | 85 }; |
79 | 86 |
80 } // namespace extensions | 87 } // namespace extensions |
81 | 88 |
82 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ | 89 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_ |
OLD | NEW |