| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/third_party/nss/blapi.h" | 13 #include "base/third_party/nss/blapi.h" |
| 14 #include "base/third_party/nss/sha256.h" | 14 #include "base/third_party/nss/sha256.h" |
| 15 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/extensions/extension_error_reporter.h" | 16 #include "chrome/common/extensions/extension_error_reporter.h" |
| 16 #include "chrome/common/extensions/extension_error_utils.h" | 17 #include "chrome/common/extensions/extension_error_utils.h" |
| 17 #include "chrome/common/extensions/user_script.h" | 18 #include "chrome/common/extensions/user_script.h" |
| 18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 19 #include "net/base/base64.h" | 20 #include "net/base/base64.h" |
| 20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 21 | 22 |
| 22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 23 #include "base/registry.h" | 24 #include "base/registry.h" |
| 24 #endif | 25 #endif |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 for (PageActionMap::iterator i = page_actions_.begin(); | 193 for (PageActionMap::iterator i = page_actions_.begin(); |
| 193 i != page_actions_.end(); ++i) | 194 i != page_actions_.end(); ++i) |
| 194 delete i->second; | 195 delete i->second; |
| 195 } | 196 } |
| 196 | 197 |
| 197 const std::string Extension::VersionString() const { | 198 const std::string Extension::VersionString() const { |
| 198 return version_->GetString(); | 199 return version_->GetString(); |
| 199 } | 200 } |
| 200 | 201 |
| 201 // static | 202 // static |
| 203 bool Extension::IsExtension(const FilePath& file_name) { |
| 204 return file_name.MatchesExtension( |
| 205 FilePath::StringType(FILE_PATH_LITERAL(".")) + |
| 206 chrome::kExtensionFileExtension); |
| 207 } |
| 208 |
| 209 // static |
| 202 bool Extension::IdIsValid(const std::string& id) { | 210 bool Extension::IdIsValid(const std::string& id) { |
| 203 // Verify that the id is legal. | 211 // Verify that the id is legal. |
| 204 if (id.size() != (kIdSize * 2)) | 212 if (id.size() != (kIdSize * 2)) |
| 205 return false; | 213 return false; |
| 206 | 214 |
| 207 // We only support lowercase IDs, because IDs can be used as URL components | 215 // We only support lowercase IDs, because IDs can be used as URL components |
| 208 // (where GURL will lowercase it). | 216 // (where GURL will lowercase it). |
| 209 std::string temp = StringToLowerASCII(id); | 217 std::string temp = StringToLowerASCII(id); |
| 210 for (size_t i = 0; i < temp.size(); i++) | 218 for (size_t i = 0; i < temp.size(); i++) |
| 211 if (temp[i] < 'a' || temp[i] > 'p') | 219 if (temp[i] < 'a' || temp[i] > 'p') |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 937 } |
| 930 } | 938 } |
| 931 | 939 |
| 932 for (PageActionMap::const_iterator it = page_actions().begin(); | 940 for (PageActionMap::const_iterator it = page_actions().begin(); |
| 933 it != page_actions().end(); ++it) { | 941 it != page_actions().end(); ++it) { |
| 934 image_paths.insert(it->second->icon_path()); | 942 image_paths.insert(it->second->icon_path()); |
| 935 } | 943 } |
| 936 | 944 |
| 937 return image_paths; | 945 return image_paths; |
| 938 } | 946 } |
| OLD | NEW |