| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 15 #include "chrome/browser/extensions/test_extension_dir.h" | 16 #include "chrome/browser/extensions/test_extension_dir.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "components/crx_file/id_util.h" | 21 #include "components/crx_file/id_util.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 " \"permissions\": %s\n" | 61 " \"permissions\": %s\n" |
| 61 "}\n", | 62 "}\n", |
| 62 matches.c_str(), permissions.c_str(), extension_permissions.c_str()); | 63 matches.c_str(), permissions.c_str(), extension_permissions.c_str()); |
| 63 test_extension_dir_.WriteManifest(manifest); | 64 test_extension_dir_.WriteManifest(manifest); |
| 64 return LoadExtension(test_extension_dir_.UnpackedPath()); | 65 return LoadExtension(test_extension_dir_.UnpackedPath()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 std::string MakeJSONList(const std::string& s0 = "", | 68 std::string MakeJSONList(const std::string& s0 = "", |
| 68 const std::string& s1 = "", | 69 const std::string& s1 = "", |
| 69 const std::string& s2 = "") { | 70 const std::string& s2 = "") { |
| 70 std::vector<std::string> v; | 71 std::vector<base::StringPiece> v; |
| 71 if (!s0.empty()) | 72 if (!s0.empty()) |
| 72 v.push_back(s0); | 73 v.push_back(s0); |
| 73 if (!s1.empty()) | 74 if (!s1.empty()) |
| 74 v.push_back(s1); | 75 v.push_back(s1); |
| 75 if (!s2.empty()) | 76 if (!s2.empty()) |
| 76 v.push_back(s2); | 77 v.push_back(s2); |
| 77 std::string list = base::JoinString(v, "\",\""); | 78 std::string list = base::JoinString(v, "\",\""); |
| 78 if (!list.empty()) | 79 if (!list.empty()) |
| 79 list = "\"" + list + "\""; | 80 list = "\"" + list + "\""; |
| 80 return "[" + list + "]"; | 81 return "[" + list + "]"; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // This extension has unlimitedStorage but doesn't grant it to foo.example.com | 257 // This extension has unlimitedStorage but doesn't grant it to foo.example.com |
| 257 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( | 258 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( |
| 258 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"), | 259 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"), |
| 259 MakeJSONList("unlimitedStorage")); | 260 MakeJSONList("unlimitedStorage")); |
| 260 | 261 |
| 261 EXPECT_TRUE( | 262 EXPECT_TRUE( |
| 262 HasUnlimitedStorage(extension.get(), extension->GetResourceURL(""))); | 263 HasUnlimitedStorage(extension.get(), extension->GetResourceURL(""))); |
| 263 EXPECT_FALSE( | 264 EXPECT_FALSE( |
| 264 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); | 265 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); |
| 265 } | 266 } |
| OLD | NEW |