Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: extensions/common/extension.cc

Issue 516293007: Enable forced extension updates on NaCl arch mismatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Oops - include unit test changes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/extension.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "extensions/common/extension.h" 5 #include "extensions/common/extension.h"
6 6
7 #include <algorithm>
8
7 #include "base/base64.h" 9 #include "base/base64.h"
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_enumerator.h"
10 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h"
11 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
12 #include "base/logging.h" 16 #include "base/logging.h"
13 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
14 #include "base/stl_util.h" 18 #include "base/stl_util.h"
15 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_piece.h" 21 #include "base/strings/string_piece.h"
18 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // We should disallow backslash '\\' as file path separator even on Windows, 62 // We should disallow backslash '\\' as file path separator even on Windows,
59 // because the backslash is not regarded as file path separator on Linux/Mac. 63 // because the backslash is not regarded as file path separator on Linux/Mac.
60 // Extensions are cross-platform. 64 // Extensions are cross-platform.
61 // Since FilePath uses backslash '\\' as file path separator on Windows, so we 65 // Since FilePath uses backslash '\\' as file path separator on Windows, so we
62 // need to check manually. 66 // need to check manually.
63 if (path.value().find('\\') != path.value().npos) 67 if (path.value().find('\\') != path.value().npos)
64 return true; 68 return true;
65 return !net::IsSafePortableRelativePath(path); 69 return !net::IsSafePortableRelativePath(path);
66 } 70 }
67 71
72 void CollectPlatformSpecificResourceArchs(const base::FilePath& extension_path,
73 std::set<std::string>* archs) {
74 archs->clear();
75 base::FilePath platform_specific_path = extension_path.Append(
76 kPlatformSpecificFolder);
77 if (!base::PathExists(platform_specific_path)) {
78 return;
79 }
80
81 base::FileEnumerator all_archs(platform_specific_path,
82 false,
83 base::FileEnumerator::DIRECTORIES);
84 base::FilePath arch;
85 while (!(arch = all_archs.Next()).empty()) {
86 std::string arch_name = arch.BaseName().AsUTF8Unsafe();
87 std::replace(arch_name.begin(), arch_name.end(), '_', '-');
88 archs->insert(arch_name);
89 }
90 }
91
68 } // namespace 92 } // namespace
69 93
70 const int Extension::kInitFromValueFlagBits = 13; 94 const int Extension::kInitFromValueFlagBits = 13;
71 95
72 const char Extension::kMimeType[] = "application/x-chrome-extension"; 96 const char Extension::kMimeType[] = "application/x-chrome-extension";
73 97
74 const int Extension::kValidWebExtentSchemes = 98 const int Extension::kValidWebExtentSchemes =
75 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; 99 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS;
76 100
77 const int Extension::kValidHostPermissionSchemes = URLPattern::SCHEME_CHROMEUI | 101 const int Extension::kValidHostPermissionSchemes = URLPattern::SCHEME_CHROMEUI |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 452 }
429 453
430 void Extension::AddWebExtentPattern(const URLPattern& pattern) { 454 void Extension::AddWebExtentPattern(const URLPattern& pattern) {
431 // Bookmark apps are permissionless. 455 // Bookmark apps are permissionless.
432 if (from_bookmark()) 456 if (from_bookmark())
433 return; 457 return;
434 458
435 extent_.AddPattern(pattern); 459 extent_.AddPattern(pattern);
436 } 460 }
437 461
462 bool Extension::HasPlatformSpecificResources() const {
463 return !platform_specific_resource_archs_.empty();
464 }
465
466 bool Extension::HasResourcesForPlatform(const std::string& arch) const {
467 return platform_specific_resource_archs_.find(arch) !=
468 platform_specific_resource_archs_.end();
469 }
470
438 // static 471 // static
439 bool Extension::InitExtensionID(extensions::Manifest* manifest, 472 bool Extension::InitExtensionID(extensions::Manifest* manifest,
440 const base::FilePath& path, 473 const base::FilePath& path,
441 const std::string& explicit_id, 474 const std::string& explicit_id,
442 int creation_flags, 475 int creation_flags,
443 base::string16* error) { 476 base::string16* error) {
444 if (!explicit_id.empty()) { 477 if (!explicit_id.empty()) {
445 manifest->set_extension_id(explicit_id); 478 manifest->set_extension_id(explicit_id);
446 return true; 479 return true;
447 } 480 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (!LoadSharedFeatures(error)) 562 if (!LoadSharedFeatures(error))
530 return false; 563 return false;
531 564
532 permissions_parser_->Finalize(this); 565 permissions_parser_->Finalize(this);
533 permissions_parser_.reset(); 566 permissions_parser_.reset();
534 567
535 finished_parsing_manifest_ = true; 568 finished_parsing_manifest_ = true;
536 569
537 permissions_data_.reset(new PermissionsData(this)); 570 permissions_data_.reset(new PermissionsData(this));
538 571
572 CollectPlatformSpecificResourceArchs(path_,
573 &platform_specific_resource_archs_);
574
539 return true; 575 return true;
540 } 576 }
541 577
542 bool Extension::LoadRequiredFeatures(base::string16* error) { 578 bool Extension::LoadRequiredFeatures(base::string16* error) {
543 if (!LoadName(error) || 579 if (!LoadName(error) ||
544 !LoadVersion(error)) 580 !LoadVersion(error))
545 return false; 581 return false;
546 return true; 582 return true;
547 } 583 }
548 584
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 799
764 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 800 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
765 const Extension* extension, 801 const Extension* extension,
766 const PermissionSet* permissions, 802 const PermissionSet* permissions,
767 Reason reason) 803 Reason reason)
768 : reason(reason), 804 : reason(reason),
769 extension(extension), 805 extension(extension),
770 permissions(permissions) {} 806 permissions(permissions) {}
771 807
772 } // namespace extensions 808 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698