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

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

Issue 10949017: 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: Patch cross-origin-XHR all-URLs test for ChromeOS. 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
1516 ListValue* list_value = NULL; 1517 ListValue* list_value = NULL;
1517 if (!manifest_->GetList(keys::kPlugins, &list_value)) { 1518 if (!manifest_->GetList(keys::kPlugins, &list_value)) {
1518 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1519 *error = ASCIIToUTF16(errors::kInvalidPlugins);
1519 return false; 1520 return false;
1520 } 1521 }
1521 1522
1522 for (size_t i = 0; i < list_value->GetSize(); ++i) { 1523 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1523 DictionaryValue* plugin_value = NULL; 1524 DictionaryValue* plugin_value = NULL;
1524 if (!list_value->GetDictionary(i, &plugin_value)) { 1525 if (!list_value->GetDictionary(i, &plugin_value)) {
1525 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1526 *error = ASCIIToUTF16(errors::kInvalidPlugins);
(...skipping 10 matching lines...) Expand all
1536 // Get plugins[i].content (optional). 1537 // Get plugins[i].content (optional).
1537 bool is_public = false; 1538 bool is_public = false;
1538 if (plugin_value->HasKey(keys::kPluginsPublic)) { 1539 if (plugin_value->HasKey(keys::kPluginsPublic)) {
1539 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { 1540 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
1540 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 1541 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1541 errors::kInvalidPluginsPublic, base::IntToString(i)); 1542 errors::kInvalidPluginsPublic, base::IntToString(i));
1542 return false; 1543 return false;
1543 } 1544 }
1544 } 1545 }
1545 1546
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.
1546 #if defined(OS_CHROMEOS) 1551 #if defined(OS_CHROMEOS)
1547 // We don't allow extension plugins to run on Chrome OS. We still 1552 continue;
1548 // parse the manifest entry so that error messages are consistently 1553 #elif defined(OS_WIN)
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 *error = l10n_util::GetStringUTF16( 1555 continue;
1556 IDS_EXTENSION_INSTALL_PLUGIN_NOT_SUPPORTED);
1557 return false;
1558 } 1556 }
1559 #endif // defined(OS_WIN). 1557 #endif // defined(OS_WIN).
1560 plugins_.push_back(PluginInfo()); 1558 plugins_.push_back(PluginInfo());
1561 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str)); 1559 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str));
1562 plugins_.back().is_public = is_public; 1560 plugins_.back().is_public = is_public;
1563 #endif // defined(OS_CHROMEOS).
1564 } 1561 }
1565 return true; 1562 return true;
1566 } 1563 }
1567 1564
1568 bool Extension::LoadNaClModules(string16* error) { 1565 bool Extension::LoadNaClModules(string16* error) {
1569 if (!manifest_->HasKey(keys::kNaClModules)) 1566 if (!manifest_->HasKey(keys::kNaClModules))
1570 return true; 1567 return true;
1571 ListValue* list_value = NULL; 1568 ListValue* list_value = NULL;
1572 if (!manifest_->GetList(keys::kNaClModules, &list_value)) { 1569 if (!manifest_->GetList(keys::kNaClModules, &list_value)) {
1573 *error = ASCIIToUTF16(errors::kInvalidNaClModules); 1570 *error = ASCIIToUTF16(errors::kInvalidNaClModules);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 sandboxed_pages_content_security_policy_ = 1678 sandboxed_pages_content_security_policy_ =
1682 kDefaultSandboxedPageContentSecurityPolicy; 1679 kDefaultSandboxedPageContentSecurityPolicy;
1683 CHECK(ContentSecurityPolicyIsSandboxed( 1680 CHECK(ContentSecurityPolicyIsSandboxed(
1684 sandboxed_pages_content_security_policy_, GetType())); 1681 sandboxed_pages_content_security_policy_, GetType()));
1685 } 1682 }
1686 1683
1687 return true; 1684 return true;
1688 } 1685 }
1689 1686
1690 bool Extension::LoadRequirements(string16* error) { 1687 bool Extension::LoadRequirements(string16* error) {
1691 // If the extension has plugins, then |requirements_.npapi| defaults to true. 1688 // Before parsing requirements from the manifest, automatically default the
1692 if (plugins_.size() > 0) 1689 // NPAPI plugin requirement based on whether it includes NPAPI plugins.
1693 requirements_.npapi = true; 1690 ListValue* list_value = NULL;
1691 requirements_.npapi =
1692 manifest_->GetList(keys::kPlugins, &list_value) && !list_value->empty();
1694 1693
1695 if (!manifest_->HasKey(keys::kRequirements)) 1694 if (!manifest_->HasKey(keys::kRequirements))
1696 return true; 1695 return true;
1697 1696
1698 DictionaryValue* requirements_value = NULL; 1697 DictionaryValue* requirements_value = NULL;
1699 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { 1698 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) {
1700 *error = ASCIIToUTF16(errors::kInvalidRequirements); 1699 *error = ASCIIToUTF16(errors::kInvalidRequirements);
1701 return false; 1700 return false;
1702 } 1701 }
1703 1702
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after
4026 4025
4027 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4026 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4028 const Extension* extension, 4027 const Extension* extension,
4029 const PermissionSet* permissions, 4028 const PermissionSet* permissions,
4030 Reason reason) 4029 Reason reason)
4031 : reason(reason), 4030 : reason(reason),
4032 extension(extension), 4031 extension(extension),
4033 permissions(permissions) {} 4032 permissions(permissions) {}
4034 4033
4035 } // namespace extensions 4034 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698