| 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 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" | 5 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return out; | 49 return out; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 ExternallyConnectableHandler::ExternallyConnectableHandler() {} | 54 ExternallyConnectableHandler::ExternallyConnectableHandler() {} |
| 55 | 55 |
| 56 ExternallyConnectableHandler::~ExternallyConnectableHandler() {} | 56 ExternallyConnectableHandler::~ExternallyConnectableHandler() {} |
| 57 | 57 |
| 58 bool ExternallyConnectableHandler::Parse(Extension* extension, | 58 bool ExternallyConnectableHandler::Parse(Extension* extension, |
| 59 string16* error) { | 59 base::string16* error) { |
| 60 const base::Value* externally_connectable = NULL; | 60 const base::Value* externally_connectable = NULL; |
| 61 CHECK(extension->manifest()->Get(keys::kExternallyConnectable, | 61 CHECK(extension->manifest()->Get(keys::kExternallyConnectable, |
| 62 &externally_connectable)); | 62 &externally_connectable)); |
| 63 std::vector<InstallWarning> install_warnings; | 63 std::vector<InstallWarning> install_warnings; |
| 64 scoped_ptr<ExternallyConnectableInfo> info = | 64 scoped_ptr<ExternallyConnectableInfo> info = |
| 65 ExternallyConnectableInfo::FromValue(*externally_connectable, | 65 ExternallyConnectableInfo::FromValue(*externally_connectable, |
| 66 &install_warnings, | 66 &install_warnings, |
| 67 error); | 67 error); |
| 68 if (!info) | 68 if (!info) |
| 69 return false; | 69 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 84 ExternallyConnectableInfo* ExternallyConnectableInfo::Get( | 84 ExternallyConnectableInfo* ExternallyConnectableInfo::Get( |
| 85 const Extension* extension) { | 85 const Extension* extension) { |
| 86 return static_cast<ExternallyConnectableInfo*>( | 86 return static_cast<ExternallyConnectableInfo*>( |
| 87 extension->GetManifestData(keys::kExternallyConnectable)); | 87 extension->GetManifestData(keys::kExternallyConnectable)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // static | 90 // static |
| 91 scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue( | 91 scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue( |
| 92 const base::Value& value, | 92 const base::Value& value, |
| 93 std::vector<InstallWarning>* install_warnings, | 93 std::vector<InstallWarning>* install_warnings, |
| 94 string16* error) { | 94 base::string16* error) { |
| 95 scoped_ptr<ExternallyConnectable> externally_connectable = | 95 scoped_ptr<ExternallyConnectable> externally_connectable = |
| 96 ExternallyConnectable::FromValue(value, error); | 96 ExternallyConnectable::FromValue(value, error); |
| 97 if (!externally_connectable) | 97 if (!externally_connectable) |
| 98 return scoped_ptr<ExternallyConnectableInfo>(); | 98 return scoped_ptr<ExternallyConnectableInfo>(); |
| 99 | 99 |
| 100 URLPatternSet matches; | 100 URLPatternSet matches; |
| 101 | 101 |
| 102 if (externally_connectable->matches) { | 102 if (externally_connectable->matches) { |
| 103 for (std::vector<std::string>::iterator it = | 103 for (std::vector<std::string>::iterator it = |
| 104 externally_connectable->matches->begin(); | 104 externally_connectable->matches->begin(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 accepts_tls_channel_id(accepts_tls_channel_id) {} | 204 accepts_tls_channel_id(accepts_tls_channel_id) {} |
| 205 | 205 |
| 206 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { | 206 bool ExternallyConnectableInfo::IdCanConnect(const std::string& id) { |
| 207 if (all_ids) | 207 if (all_ids) |
| 208 return true; | 208 return true; |
| 209 DCHECK(base::STLIsSorted(ids)); | 209 DCHECK(base::STLIsSorted(ids)); |
| 210 return std::binary_search(ids.begin(), ids.end(), id); | 210 return std::binary_search(ids.begin(), ids.end(), id); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace extensions | 213 } // namespace extensions |
| OLD | NEW |