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

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

Issue 10982037: Revert 158217 - Allow extensions which can run without NPAPI to run under Windows 8 Metro. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <ostream> 7 #include <ostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 new extensions::Command( 1506 new extensions::Command(
1507 values::kBrowserActionCommandEvent, string16(), "")); 1507 values::kBrowserActionCommandEvent, string16(), ""));
1508 } 1508 }
1509 1509
1510 return true; 1510 return true;
1511 } 1511 }
1512 1512
1513 bool Extension::LoadPlugins(string16* error) { 1513 bool Extension::LoadPlugins(string16* error) {
1514 if (!manifest_->HasKey(keys::kPlugins)) 1514 if (!manifest_->HasKey(keys::kPlugins))
1515 return true; 1515 return true;
1516
1517 ListValue* list_value = NULL; 1516 ListValue* list_value = NULL;
1518 if (!manifest_->GetList(keys::kPlugins, &list_value)) { 1517 if (!manifest_->GetList(keys::kPlugins, &list_value)) {
1519 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1518 *error = ASCIIToUTF16(errors::kInvalidPlugins);
1520 return false; 1519 return false;
1521 } 1520 }
1522 1521
1523 for (size_t i = 0; i < list_value->GetSize(); ++i) { 1522 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1524 DictionaryValue* plugin_value = NULL; 1523 DictionaryValue* plugin_value = NULL;
1525 if (!list_value->GetDictionary(i, &plugin_value)) { 1524 if (!list_value->GetDictionary(i, &plugin_value)) {
1526 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1525 *error = ASCIIToUTF16(errors::kInvalidPlugins);
(...skipping 10 matching lines...) Expand all
1537 // Get plugins[i].content (optional). 1536 // Get plugins[i].content (optional).
1538 bool is_public = false; 1537 bool is_public = false;
1539 if (plugin_value->HasKey(keys::kPluginsPublic)) { 1538 if (plugin_value->HasKey(keys::kPluginsPublic)) {
1540 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { 1539 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
1541 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 1540 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1542 errors::kInvalidPluginsPublic, base::IntToString(i)); 1541 errors::kInvalidPluginsPublic, base::IntToString(i));
1543 return false; 1542 return false;
1544 } 1543 }
1545 } 1544 }
1546 1545
1547 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under
1548 // Windows 8 Metro mode, but still parse the entries to display consistent
1549 // error messages. If the extension actually requires the plugins then
1550 // LoadRequirements will prevent it loading.
1551 #if defined(OS_CHROMEOS) 1546 #if defined(OS_CHROMEOS)
1552 continue; 1547 // We don't allow extension plugins to run on Chrome OS. We still
1553 #elif defined(OS_WIN) 1548 // parse the manifest entry so that error messages are consistently
1549 // displayed across platforms.
1550 #else
1551 #if defined(OS_WIN)
1552 // Like Chrome OS, we don't support NPAPI plugins in Windows 8 metro mode
1553 // but in this case we want to fail with an error.
1554 if (base::win::IsMetroProcess()) { 1554 if (base::win::IsMetroProcess()) {
1555 continue; 1555 *error = l10n_util::GetStringUTF16(
1556 IDS_EXTENSION_INSTALL_PLUGIN_NOT_SUPPORTED);
1557 return false;
1556 } 1558 }
1557 #endif // defined(OS_WIN). 1559 #endif // defined(OS_WIN).
1558 plugins_.push_back(PluginInfo()); 1560 plugins_.push_back(PluginInfo());
1559 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str)); 1561 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str));
1560 plugins_.back().is_public = is_public; 1562 plugins_.back().is_public = is_public;
1563 #endif // defined(OS_CHROMEOS).
1561 } 1564 }
1562 return true; 1565 return true;
1563 } 1566 }
1564 1567
1565 bool Extension::LoadNaClModules(string16* error) { 1568 bool Extension::LoadNaClModules(string16* error) {
1566 if (!manifest_->HasKey(keys::kNaClModules)) 1569 if (!manifest_->HasKey(keys::kNaClModules))
1567 return true; 1570 return true;
1568 ListValue* list_value = NULL; 1571 ListValue* list_value = NULL;
1569 if (!manifest_->GetList(keys::kNaClModules, &list_value)) { 1572 if (!manifest_->GetList(keys::kNaClModules, &list_value)) {
1570 *error = ASCIIToUTF16(errors::kInvalidNaClModules); 1573 *error = ASCIIToUTF16(errors::kInvalidNaClModules);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 sandboxed_pages_content_security_policy_ = 1681 sandboxed_pages_content_security_policy_ =
1679 kDefaultSandboxedPageContentSecurityPolicy; 1682 kDefaultSandboxedPageContentSecurityPolicy;
1680 CHECK(ContentSecurityPolicyIsSandboxed( 1683 CHECK(ContentSecurityPolicyIsSandboxed(
1681 sandboxed_pages_content_security_policy_, GetType())); 1684 sandboxed_pages_content_security_policy_, GetType()));
1682 } 1685 }
1683 1686
1684 return true; 1687 return true;
1685 } 1688 }
1686 1689
1687 bool Extension::LoadRequirements(string16* error) { 1690 bool Extension::LoadRequirements(string16* error) {
1688 // Before parsing requirements from the manifest, automatically default the 1691 // If the extension has plugins, then |requirements_.npapi| defaults to true.
1689 // NPAPI plugin requirement based on whether it includes NPAPI plugins. 1692 if (plugins_.size() > 0)
1690 ListValue* list_value = NULL; 1693 requirements_.npapi = true;
1691 requirements_.npapi =
1692 manifest_->GetList(keys::kPlugins, &list_value) && !list_value->empty();
1693 1694
1694 if (!manifest_->HasKey(keys::kRequirements)) 1695 if (!manifest_->HasKey(keys::kRequirements))
1695 return true; 1696 return true;
1696 1697
1697 DictionaryValue* requirements_value = NULL; 1698 DictionaryValue* requirements_value = NULL;
1698 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { 1699 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) {
1699 *error = ASCIIToUTF16(errors::kInvalidRequirements); 1700 *error = ASCIIToUTF16(errors::kInvalidRequirements);
1700 return false; 1701 return false;
1701 } 1702 }
1702 1703
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 4026
4026 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4027 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4027 const Extension* extension, 4028 const Extension* extension,
4028 const PermissionSet* permissions, 4029 const PermissionSet* permissions,
4029 Reason reason) 4030 Reason reason)
4030 : reason(reason), 4031 : reason(reason),
4031 extension(extension), 4032 extension(extension),
4032 permissions(permissions) {} 4033 permissions(permissions) {}
4033 4034
4034 } // namespace extensions 4035 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698