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

Side by Side Diff: chrome/common/extensions/permissions/permission_set_unittest.cc

Issue 14358004: Almost all actions in Declarative Web Request require all_urls host permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: All URLs -> all hosts; also rebased Created 7 years, 8 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 12 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_test_util.h"
14 #include "chrome/common/extensions/extension_unittest.h" 15 #include "chrome/common/extensions/extension_unittest.h"
15 #include "chrome/common/extensions/features/feature.h" 16 #include "chrome/common/extensions/features/feature.h"
16 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 17 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
17 #include "chrome/common/extensions/permissions/permission_set.h" 18 #include "chrome/common/extensions/permissions/permission_set.h"
18 #include "chrome/common/extensions/permissions/permissions_info.h" 19 #include "chrome/common/extensions/permissions/permissions_info.h"
19 #include "chrome/common/extensions/permissions/socket_permission.h" 20 #include "chrome/common/extensions/permissions/socket_permission.h"
20 #include "extensions/common/error_utils.h" 21 #include "extensions/common/error_utils.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
24 using extension_test_util::LoadManifest;
25
23 namespace extensions { 26 namespace extensions {
24 27
25 namespace { 28 namespace {
26 29
27 scoped_refptr<Extension> LoadManifest(const std::string& dir,
28 const std::string& test_file,
29 int extra_flags) {
30 base::FilePath path;
31 PathService::Get(chrome::DIR_TEST_DATA, &path);
32 path = path.AppendASCII("extensions")
33 .AppendASCII(dir)
34 .AppendASCII(test_file);
35
36 JSONFileValueSerializer serializer(path);
37 std::string error;
38 scoped_ptr<Value> result(serializer.Deserialize(NULL, &error));
39 if (!result.get()) {
40 EXPECT_EQ("", error);
41 return NULL;
42 }
43
44 scoped_refptr<Extension> extension = Extension::Create(
45 path.DirName(), Manifest::INVALID_LOCATION,
46 *static_cast<DictionaryValue*>(result.get()), extra_flags, &error);
47 EXPECT_TRUE(extension) << error;
48 return extension;
49 }
50
51 scoped_refptr<Extension> LoadManifest(const std::string& dir,
52 const std::string& test_file) {
53 return LoadManifest(dir, test_file, Extension::NO_FLAGS);
54 }
55
56 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { 30 static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
57 int schemes = URLPattern::SCHEME_ALL; 31 int schemes = URLPattern::SCHEME_ALL;
58 extent->AddPattern(URLPattern(schemes, pattern)); 32 extent->AddPattern(URLPattern(schemes, pattern));
59 } 33 }
60 34
61 size_t IndexOf(const std::vector<string16>& warnings, 35 size_t IndexOf(const std::vector<string16>& warnings,
62 const std::string& warning) { 36 const std::string& warning) {
63 for (size_t i = 0; i < warnings.size(); ++i) { 37 for (size_t i = 0; i < warnings.size(); ++i) {
64 if (warnings[i] == ASCIIToUTF16(warning)) 38 if (warnings[i] == ASCIIToUTF16(warning))
65 return i; 39 return i;
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 APIPermissionSet apis; 1351 APIPermissionSet apis;
1378 apis.insert(APIPermission::kSyncFileSystem); 1352 apis.insert(APIPermission::kSyncFileSystem);
1379 EXPECT_TRUE(extension->is_platform_app()); 1353 EXPECT_TRUE(extension->is_platform_app());
1380 EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSyncFileSystem)); 1354 EXPECT_TRUE(extension->HasAPIPermission(APIPermission::kSyncFileSystem));
1381 std::vector<string16> warnings = extension->GetPermissionMessageStrings(); 1355 std::vector<string16> warnings = extension->GetPermissionMessageStrings();
1382 EXPECT_TRUE(Contains(warnings, "Store data in your Google Drive account")); 1356 EXPECT_TRUE(Contains(warnings, "Store data in your Google Drive account"));
1383 ASSERT_EQ(1u, warnings.size()); 1357 ASSERT_EQ(1u, warnings.size());
1384 } 1358 }
1385 1359
1386 } // namespace extensions 1360 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_unittest.cc ('k') | chrome/test/data/extensions/api_test/declarative/api/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698