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