OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 std::vector<std::string> old_hosts = GetDistinctHosts(old_list, false); | 342 std::vector<std::string> old_hosts = GetDistinctHosts(old_list, false); |
343 | 343 |
344 std::set<std::string> old_hosts_set(old_hosts.begin(), old_hosts.end()); | 344 std::set<std::string> old_hosts_set(old_hosts.begin(), old_hosts.end()); |
345 std::set<std::string> new_hosts_set(new_hosts.begin(), new_hosts.end()); | 345 std::set<std::string> new_hosts_set(new_hosts.begin(), new_hosts.end()); |
346 std::set<std::string> new_hosts_only; | 346 std::set<std::string> new_hosts_only; |
347 | 347 |
348 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 348 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
349 old_hosts_set.begin(), old_hosts_set.end(), | 349 old_hosts_set.begin(), old_hosts_set.end(), |
350 std::inserter(new_hosts_only, new_hosts_only.begin())); | 350 std::inserter(new_hosts_only, new_hosts_only.begin())); |
351 | 351 |
352 return new_hosts_only.size() > 0; | 352 return !new_hosts_only.empty(); |
353 } | 353 } |
354 | 354 |
355 // static | 355 // static |
356 std::vector<std::string> Extension::GetDistinctHosts( | 356 std::vector<std::string> Extension::GetDistinctHosts( |
357 const URLPatternList& host_patterns, bool include_rcd) { | 357 const URLPatternList& host_patterns, bool include_rcd) { |
358 // Vector because we later want to access these by index. | 358 // Vector because we later want to access these by index. |
359 std::vector<std::string> distinct_hosts; | 359 std::vector<std::string> distinct_hosts; |
360 | 360 |
361 std::set<std::string> rcd_set; | 361 std::set<std::string> rcd_set; |
362 for (size_t i = 0; i < host_patterns.size(); ++i) { | 362 for (size_t i = 0; i < host_patterns.size(); ++i) { |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 for (size_t i = 0; i < arraysize(kIconSizes); ++i) { | 1427 for (size_t i = 0; i < arraysize(kIconSizes); ++i) { |
1428 std::string key = base::IntToString(kIconSizes[i]); | 1428 std::string key = base::IntToString(kIconSizes[i]); |
1429 if (icons_value->HasKey(key)) { | 1429 if (icons_value->HasKey(key)) { |
1430 std::string icon_path; | 1430 std::string icon_path; |
1431 if (!icons_value->GetString(key, &icon_path)) { | 1431 if (!icons_value->GetString(key, &icon_path)) { |
1432 *error = ExtensionErrorUtils::FormatErrorMessage( | 1432 *error = ExtensionErrorUtils::FormatErrorMessage( |
1433 errors::kInvalidIconPath, key); | 1433 errors::kInvalidIconPath, key); |
1434 return false; | 1434 return false; |
1435 } | 1435 } |
1436 | 1436 |
1437 if (icon_path.size() > 0 && icon_path[0] == '/') | 1437 if (!icon_path.empty() && icon_path[0] == '/') |
1438 icon_path = icon_path.substr(1); | 1438 icon_path = icon_path.substr(1); |
1439 | 1439 |
1440 if (icon_path.empty()) { | 1440 if (icon_path.empty()) { |
1441 *error = ExtensionErrorUtils::FormatErrorMessage( | 1441 *error = ExtensionErrorUtils::FormatErrorMessage( |
1442 errors::kInvalidIconPath, key); | 1442 errors::kInvalidIconPath, key); |
1443 return false; | 1443 return false; |
1444 } | 1444 } |
1445 | 1445 |
1446 icons_.Add(kIconSizes[i], icon_path); | 1446 icons_.Add(kIconSizes[i], icon_path); |
1447 } | 1447 } |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 | 2311 |
2312 return false; | 2312 return false; |
2313 } | 2313 } |
2314 | 2314 |
2315 bool Extension::HasEffectiveAccessToAllHosts() const { | 2315 bool Extension::HasEffectiveAccessToAllHosts() const { |
2316 return HasEffectiveAccessToAllHosts(GetEffectiveHostPermissions(), | 2316 return HasEffectiveAccessToAllHosts(GetEffectiveHostPermissions(), |
2317 api_permissions()); | 2317 api_permissions()); |
2318 } | 2318 } |
2319 | 2319 |
2320 bool Extension::HasFullPermissions() const { | 2320 bool Extension::HasFullPermissions() const { |
2321 return plugins().size() > 0; | 2321 return !plugins().empty(); |
2322 } | 2322 } |
2323 | 2323 |
2324 bool Extension::ShowConfigureContextMenus() const { | 2324 bool Extension::ShowConfigureContextMenus() const { |
2325 // Don't show context menu for component extensions. We might want to show | 2325 // Don't show context menu for component extensions. We might want to show |
2326 // options for component extension button but now there is no component | 2326 // options for component extension button but now there is no component |
2327 // extension with options. All other menu items like uninstall have | 2327 // extension with options. All other menu items like uninstall have |
2328 // no sense for component extensions. | 2328 // no sense for component extensions. |
2329 return location() != Extension::COMPONENT; | 2329 return location() != Extension::COMPONENT; |
2330 } | 2330 } |
2331 | 2331 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2414 | 2414 |
2415 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2415 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
2416 | 2416 |
2417 | 2417 |
2418 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2418 UnloadedExtensionInfo::UnloadedExtensionInfo( |
2419 const Extension* extension, | 2419 const Extension* extension, |
2420 Reason reason) | 2420 Reason reason) |
2421 : reason(reason), | 2421 : reason(reason), |
2422 already_disabled(false), | 2422 already_disabled(false), |
2423 extension(extension) {} | 2423 extension(extension) {} |
OLD | NEW |