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

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

Issue 9317013: Add a centralized mechanism for whitelisting access to extension permissions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix a couple tests Created 8 years, 10 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
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 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 i != api_perms.end(); ++i) { 590 i != api_perms.end(); ++i) {
591 if (*i == ExtensionAPIPermission::kExperimental) 591 if (*i == ExtensionAPIPermission::kExperimental)
592 continue; 592 continue;
593 593
594 ExtensionAPIPermission* permission = info->GetByID(*i); 594 ExtensionAPIPermission* permission = info->GetByID(*i);
595 const char* name = permission->name(); 595 const char* name = permission->name();
596 StringValue* p = new StringValue(name); 596 StringValue* p = new StringValue(name);
597 permissions->Clear(); 597 permissions->Clear();
598 permissions->Append(p); 598 permissions->Append(p);
599 599
600 // Some permissions are only available to component hosted apps. 600 if (permission->should_enforce_whitelist()) {
601 if (permission->is_component_only()) {
602 LoadAndExpectError(Manifest(manifest.get(), name), 601 LoadAndExpectError(Manifest(manifest.get(), name),
603 errors::kPermissionNotAllowed, 602 errors::kPermissionNotAllowed,
604 Extension::INTERNAL); 603 Extension::INTERNAL);
604
605 // Some permissions are only available to component hosted apps.
606 } else if (permission->is_component_only()) {
607 LoadAndExpectError(Manifest(manifest.get(), name),
608 errors::kPermissionNotAllowed,
609 Extension::INTERNAL);
605 scoped_refptr<Extension> extension( 610 scoped_refptr<Extension> extension(
606 LoadAndExpectSuccess(Manifest(manifest.get(), name), 611 LoadAndExpectSuccess(Manifest(manifest.get(), name),
607 Extension::COMPONENT)); 612 Extension::COMPONENT));
608 EXPECT_TRUE(extension->GetActivePermissions()->HasAPIPermission( 613 EXPECT_TRUE(extension->GetActivePermissions()->HasAPIPermission(
609 permission->id())); 614 permission->id()));
610 615
611 } else if (permission->type_restrictions() == platform_app) { 616 } else if (permission->type_restrictions() == platform_app) {
612 LoadAndExpectError(Manifest(manifest.get(), name), 617 LoadAndExpectError(Manifest(manifest.get(), name),
613 errors::kPermissionNotAllowed, 618 errors::kPermissionNotAllowed,
614 Extension::INTERNAL, 619 Extension::INTERNAL,
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 EXPECT_EQ("", extension->page_action()->id()); 1063 EXPECT_EQ("", extension->page_action()->id());
1059 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size()); 1064 EXPECT_EQ(0u, extension->page_action()->icon_paths()->size());
1060 EXPECT_EQ("", extension->page_action()->GetTitle( 1065 EXPECT_EQ("", extension->page_action()->GetTitle(
1061 ExtensionAction::kDefaultTabId)); 1066 ExtensionAction::kDefaultTabId));
1062 EXPECT_FALSE(extension->page_action()->HasPopup( 1067 EXPECT_FALSE(extension->page_action()->HasPopup(
1063 ExtensionAction::kDefaultTabId)); 1068 ExtensionAction::kDefaultTabId));
1064 1069
1065 LoadAndExpectError("page_action_manifest_version_2b.json", 1070 LoadAndExpectError("page_action_manifest_version_2b.json",
1066 errors::kInvalidPageActionPopup); 1071 errors::kInvalidPageActionPopup);
1067 } 1072 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698