| 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 "chrome/browser/extensions/api/web_request/web_request_permissions.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/browser/extensions/extension_info_map.h" | 8 #include "chrome/browser/extensions/extension_info_map.h" |
| 9 #include "chrome/common/extensions/extension_constants.h" | 9 #include "chrome/common/extensions/extension_constants.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "content/public/browser/resource_request_info.h" | 11 #include "content/public/browser/resource_request_info.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 12 #include "net/url_request/url_request_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using content::ResourceRequestInfo; | 15 using content::ResourceRequestInfo; |
| 16 | 16 |
| 17 TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) { | 17 TEST(ExtensionWebRequestHelpersTest, TestHideRequestForURL) { |
| 18 MessageLoopForIO message_loop; | 18 base::MessageLoopForIO message_loop; |
| 19 net::TestURLRequestContext context; | 19 net::TestURLRequestContext context; |
| 20 scoped_refptr<ExtensionInfoMap> extension_info_map(new ExtensionInfoMap); | 20 scoped_refptr<ExtensionInfoMap> extension_info_map(new ExtensionInfoMap); |
| 21 const char* sensitive_urls[] = { | 21 const char* sensitive_urls[] = { |
| 22 "http://clients2.google.com", | 22 "http://clients2.google.com", |
| 23 "http://clients22.google.com", | 23 "http://clients22.google.com", |
| 24 "https://clients2.google.com", | 24 "https://clients2.google.com", |
| 25 "http://clients2.google.com/service/update2/crx", | 25 "http://clients2.google.com/service/update2/crx", |
| 26 "https://clients.google.com", | 26 "https://clients.google.com", |
| 27 "https://test.clients.google.com", | 27 "https://test.clients.google.com", |
| 28 "https://clients2.google.com/service/update2/crx", | 28 "https://clients2.google.com/service/update2/crx", |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 int frame_id = 17; | 64 int frame_id = 17; |
| 65 net::TestURLRequest sensitive_request( | 65 net::TestURLRequest sensitive_request( |
| 66 non_sensitive_url, NULL, &context, NULL); | 66 non_sensitive_url, NULL, &context, NULL); |
| 67 ResourceRequestInfo::AllocateForTesting(&sensitive_request, | 67 ResourceRequestInfo::AllocateForTesting(&sensitive_request, |
| 68 ResourceType::SCRIPT, NULL, process_id, frame_id); | 68 ResourceType::SCRIPT, NULL, process_id, frame_id); |
| 69 extension_info_map->RegisterExtensionProcess(extension_misc::kWebStoreAppId, | 69 extension_info_map->RegisterExtensionProcess(extension_misc::kWebStoreAppId, |
| 70 process_id, site_instance_id); | 70 process_id, site_instance_id); |
| 71 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map.get(), | 71 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map.get(), |
| 72 &sensitive_request)); | 72 &sensitive_request)); |
| 73 } | 73 } |
| OLD | NEW |