OLD | NEW |
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 <utility> |
5 #include <vector> | 6 #include <vector> |
6 | 7 |
| 8 #include "base/memory/ptr_util.h" |
7 #include "chrome/browser/extensions/webstore_inline_installer.h" | 9 #include "chrome/browser/extensions/webstore_inline_installer.h" |
8 #include "chrome/common/extensions/webstore_install_result.h" | 10 #include "chrome/common/extensions/webstore_install_result.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
13 | 15 |
14 namespace extensions { | 16 namespace extensions { |
15 | 17 |
16 namespace { | 18 namespace { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 scoped_refptr<TestWebstoreInlineInstaller> installer = | 90 scoped_refptr<TestWebstoreInlineInstaller> installer = |
89 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); | 91 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); |
90 return installer->TestCheckRequestorPermitted(webstore_data); | 92 return installer->TestCheckRequestorPermitted(webstore_data); |
91 } | 93 } |
92 | 94 |
93 // Simulates a test against a list of verified site strings from a Webstore | 95 // Simulates a test against a list of verified site strings from a Webstore |
94 // item's "verified_sites" manifest entry. | 96 // item's "verified_sites" manifest entry. |
95 bool WebstoreInlineInstallerTest::TestMultipleVerifiedSites( | 97 bool WebstoreInlineInstallerTest::TestMultipleVerifiedSites( |
96 const std::string& requestor_url, | 98 const std::string& requestor_url, |
97 const std::vector<std::string>& verified_sites) { | 99 const std::vector<std::string>& verified_sites) { |
98 base::ListValue* sites = new base::ListValue(); | 100 auto sites = base::MakeUnique<base::ListValue>(); |
99 for (std::vector<std::string>::const_iterator it = verified_sites.begin(); | 101 for (std::vector<std::string>::const_iterator it = verified_sites.begin(); |
100 it != verified_sites.end(); ++it) { | 102 it != verified_sites.end(); ++it) { |
101 sites->AppendString(*it); | 103 sites->AppendString(*it); |
102 } | 104 } |
103 base::DictionaryValue webstore_data; | 105 base::DictionaryValue webstore_data; |
104 webstore_data.Set("verified_sites", sites); | 106 webstore_data.Set("verified_sites", std::move(sites)); |
105 | 107 |
106 scoped_refptr<TestWebstoreInlineInstaller> installer = | 108 scoped_refptr<TestWebstoreInlineInstaller> installer = |
107 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); | 109 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); |
108 return installer->TestCheckRequestorPermitted(webstore_data); | 110 return installer->TestCheckRequestorPermitted(webstore_data); |
109 } | 111 } |
110 | 112 |
111 } // namespace | 113 } // namespace |
112 | 114 |
113 TEST_F(WebstoreInlineInstallerTest, DomainVerification) { | 115 TEST_F(WebstoreInlineInstallerTest, DomainVerification) { |
114 // Exact domain match. | 116 // Exact domain match. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 verified_sites)); | 221 verified_sites)); |
220 | 222 |
221 EXPECT_FALSE(TestMultipleVerifiedSites("http://baz.example.com", | 223 EXPECT_FALSE(TestMultipleVerifiedSites("http://baz.example.com", |
222 verified_sites)); | 224 verified_sites)); |
223 | 225 |
224 EXPECT_FALSE(TestMultipleVerifiedSites("http://bar.example.com:456", | 226 EXPECT_FALSE(TestMultipleVerifiedSites("http://bar.example.com:456", |
225 verified_sites)); | 227 verified_sites)); |
226 } | 228 } |
227 | 229 |
228 } // namespace extensions | 230 } // namespace extensions |
OLD | NEW |