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

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: Created 8 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 | 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 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 new extensions::Command( 1491 new extensions::Command(
1492 values::kBrowserActionCommandEvent, string16(), "")); 1492 values::kBrowserActionCommandEvent, string16(), ""));
1493 } 1493 }
1494 1494
1495 return true; 1495 return true;
1496 } 1496 }
1497 1497
1498 bool Extension::LoadPlugins(string16* error) { 1498 bool Extension::LoadPlugins(string16* error) {
1499 if (!manifest_->HasKey(keys::kPlugins)) 1499 if (!manifest_->HasKey(keys::kPlugins))
1500 return true; 1500 return true;
1501
1502 // If the extension has NPAPI plugins then by default assume it needs them.
1503 requirements_.npapi = true;
Aaron Boodman 2012/09/19 21:34:52 Why did you move this from LoadRequirements()? I t
Wez 2012/09/21 00:13:56 The existing code was setting this value based on
Aaron Boodman 2012/09/21 02:33:08 I see. I mean, you could just check manifest->HasK
Wez 2012/09/22 07:21:00 OK, you've convinced me. Moved.
1504
1501 ListValue* list_value = NULL; 1505 ListValue* list_value = NULL;
1502 if (!manifest_->GetList(keys::kPlugins, &list_value)) { 1506 if (!manifest_->GetList(keys::kPlugins, &list_value)) {
1503 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1507 *error = ASCIIToUTF16(errors::kInvalidPlugins);
1504 return false; 1508 return false;
1505 } 1509 }
1506 1510
1507 for (size_t i = 0; i < list_value->GetSize(); ++i) { 1511 for (size_t i = 0; i < list_value->GetSize(); ++i) {
1508 DictionaryValue* plugin_value = NULL; 1512 DictionaryValue* plugin_value = NULL;
1509 if (!list_value->GetDictionary(i, &plugin_value)) { 1513 if (!list_value->GetDictionary(i, &plugin_value)) {
1510 *error = ASCIIToUTF16(errors::kInvalidPlugins); 1514 *error = ASCIIToUTF16(errors::kInvalidPlugins);
(...skipping 10 matching lines...) Expand all
1521 // Get plugins[i].content (optional). 1525 // Get plugins[i].content (optional).
1522 bool is_public = false; 1526 bool is_public = false;
1523 if (plugin_value->HasKey(keys::kPluginsPublic)) { 1527 if (plugin_value->HasKey(keys::kPluginsPublic)) {
1524 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { 1528 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
1525 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 1529 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
1526 errors::kInvalidPluginsPublic, base::IntToString(i)); 1530 errors::kInvalidPluginsPublic, base::IntToString(i));
1527 return false; 1531 return false;
1528 } 1532 }
1529 } 1533 }
1530 1534
1535 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under
1536 // Windows 8 Metro mode, but still parse the entries to display consistent
1537 // error messages. If the extension actually requires the plugins then
1538 // LoadRequirements will prevent it loading.
1531 #if defined(OS_CHROMEOS) 1539 #if defined(OS_CHROMEOS)
1532 // We don't allow extension plugins to run on Chrome OS. We still 1540 continue;
1533 // parse the manifest entry so that error messages are consistently 1541 #elif defined(OS_WIN)
1534 // displayed across platforms.
1535 #else
1536 #if defined(OS_WIN)
1537 // Like Chrome OS, we don't support NPAPI plugins in Windows 8 metro mode
1538 // but in this case we want to fail with an error.
1539 if (base::win::IsMetroProcess()) { 1542 if (base::win::IsMetroProcess()) {
1540 *error = l10n_util::GetStringUTF16( 1543 continue;
1541 IDS_EXTENSION_INSTALL_PLUGIN_NOT_SUPPORTED);
1542 return false;
1543 } 1544 }
1544 #endif // defined(OS_WIN). 1545 #endif // defined(OS_WIN).
1545 plugins_.push_back(PluginInfo()); 1546 plugins_.push_back(PluginInfo());
1546 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str)); 1547 plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str));
1547 plugins_.back().is_public = is_public; 1548 plugins_.back().is_public = is_public;
1548 #endif // defined(OS_CHROMEOS).
1549 } 1549 }
1550 return true; 1550 return true;
1551 } 1551 }
1552 1552
1553 bool Extension::LoadNaClModules(string16* error) { 1553 bool Extension::LoadNaClModules(string16* error) {
1554 if (!manifest_->HasKey(keys::kNaClModules)) 1554 if (!manifest_->HasKey(keys::kNaClModules))
1555 return true; 1555 return true;
1556 ListValue* list_value = NULL; 1556 ListValue* list_value = NULL;
1557 if (!manifest_->GetList(keys::kNaClModules, &list_value)) { 1557 if (!manifest_->GetList(keys::kNaClModules, &list_value)) {
1558 *error = ASCIIToUTF16(errors::kInvalidNaClModules); 1558 *error = ASCIIToUTF16(errors::kInvalidNaClModules);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 sandboxed_pages_content_security_policy_ = 1666 sandboxed_pages_content_security_policy_ =
1667 kDefaultSandboxedPageContentSecurityPolicy; 1667 kDefaultSandboxedPageContentSecurityPolicy;
1668 CHECK(ContentSecurityPolicyIsSandboxed( 1668 CHECK(ContentSecurityPolicyIsSandboxed(
1669 sandboxed_pages_content_security_policy_, GetType())); 1669 sandboxed_pages_content_security_policy_, GetType()));
1670 } 1670 }
1671 1671
1672 return true; 1672 return true;
1673 } 1673 }
1674 1674
1675 bool Extension::LoadRequirements(string16* error) { 1675 bool Extension::LoadRequirements(string16* error) {
1676 // If the extension has plugins, then |requirements_.npapi| defaults to true.
1677 if (plugins_.size() > 0)
1678 requirements_.npapi = true;
1679
1680 if (!manifest_->HasKey(keys::kRequirements)) 1676 if (!manifest_->HasKey(keys::kRequirements))
1681 return true; 1677 return true;
1682 1678
1683 DictionaryValue* requirements_value = NULL; 1679 DictionaryValue* requirements_value = NULL;
1684 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) { 1680 if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) {
1685 *error = ASCIIToUTF16(errors::kInvalidRequirements); 1681 *error = ASCIIToUTF16(errors::kInvalidRequirements);
1686 return false; 1682 return false;
1687 } 1683 }
1688 1684
1689 for (DictionaryValue::key_iterator it = requirements_value->begin_keys(); 1685 for (DictionaryValue::key_iterator it = requirements_value->begin_keys();
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4021 4017
4022 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 4018 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
4023 const Extension* extension, 4019 const Extension* extension,
4024 const PermissionSet* permissions, 4020 const PermissionSet* permissions,
4025 Reason reason) 4021 Reason reason)
4026 : reason(reason), 4022 : reason(reason),
4027 extension(extension), 4023 extension(extension),
4028 permissions(permissions) {} 4024 permissions(permissions) {}
4029 4025
4030 } // namespace extensions 4026 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698