| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 #include "content/public/common/process_type.h" | 116 #include "content/public/common/process_type.h" |
| 117 #include "content/public/common/result_codes.h" | 117 #include "content/public/common/result_codes.h" |
| 118 #include "content/public/common/url_constants.h" | 118 #include "content/public/common/url_constants.h" |
| 119 #include "content/public/common/webplugininfo.h" | 119 #include "content/public/common/webplugininfo.h" |
| 120 #include "content/public/test/browser_test_utils.h" | 120 #include "content/public/test/browser_test_utils.h" |
| 121 #include "content/public/test/download_test_observer.h" | 121 #include "content/public/test/download_test_observer.h" |
| 122 #include "content/public/test/mock_notification_observer.h" | 122 #include "content/public/test/mock_notification_observer.h" |
| 123 #include "content/public/test/test_navigation_observer.h" | 123 #include "content/public/test/test_navigation_observer.h" |
| 124 #include "content/public/test/test_utils.h" | 124 #include "content/public/test/test_utils.h" |
| 125 #include "content/test/net/url_request_failed_job.h" | 125 #include "content/test/net/url_request_failed_job.h" |
| 126 #include "content/test/net/url_request_mock_http_job.h" | |
| 127 #include "extensions/browser/extension_host.h" | 126 #include "extensions/browser/extension_host.h" |
| 128 #include "extensions/browser/extension_system.h" | 127 #include "extensions/browser/extension_system.h" |
| 129 #include "extensions/browser/process_manager.h" | 128 #include "extensions/browser/process_manager.h" |
| 130 #include "extensions/browser/uninstall_reason.h" | 129 #include "extensions/browser/uninstall_reason.h" |
| 131 #include "extensions/common/constants.h" | 130 #include "extensions/common/constants.h" |
| 132 #include "extensions/common/extension.h" | 131 #include "extensions/common/extension.h" |
| 133 #include "extensions/common/extension_set.h" | 132 #include "extensions/common/extension_set.h" |
| 134 #include "net/base/net_errors.h" | 133 #include "net/base/net_errors.h" |
| 135 #include "net/base/net_util.h" | 134 #include "net/base/net_util.h" |
| 136 #include "net/base/url_util.h" | 135 #include "net/base/url_util.h" |
| 137 #include "net/http/http_stream_factory.h" | 136 #include "net/http/http_stream_factory.h" |
| 137 #include "net/test/url_request/url_request_mock_http_job.h" |
| 138 #include "net/url_request/url_request.h" | 138 #include "net/url_request/url_request.h" |
| 139 #include "net/url_request/url_request_filter.h" | 139 #include "net/url_request/url_request_filter.h" |
| 140 #include "policy/policy_constants.h" | 140 #include "policy/policy_constants.h" |
| 141 #include "testing/gmock/include/gmock/gmock.h" | 141 #include "testing/gmock/include/gmock/gmock.h" |
| 142 #include "testing/gtest/include/gtest/gtest.h" | 142 #include "testing/gtest/include/gtest/gtest.h" |
| 143 #include "third_party/WebKit/public/web/WebInputEvent.h" | 143 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 144 #include "ui/base/l10n/l10n_util.h" | 144 #include "ui/base/l10n/l10n_util.h" |
| 145 #include "ui/base/resource/resource_bundle.h" | 145 #include "ui/base/resource/resource_bundle.h" |
| 146 #include "url/gurl.h" | 146 #include "url/gurl.h" |
| 147 | 147 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 #include "base/basictypes.h" | 162 #include "base/basictypes.h" |
| 163 #include "base/compiler_specific.h" | 163 #include "base/compiler_specific.h" |
| 164 #include "chrome/browser/ui/extensions/application_launch.h" | 164 #include "chrome/browser/ui/extensions/application_launch.h" |
| 165 #include "extensions/browser/app_window/app_window.h" | 165 #include "extensions/browser/app_window/app_window.h" |
| 166 #include "extensions/browser/app_window/app_window_registry.h" | 166 #include "extensions/browser/app_window/app_window_registry.h" |
| 167 #include "extensions/browser/app_window/native_app_window.h" | 167 #include "extensions/browser/app_window/native_app_window.h" |
| 168 #include "ui/base/window_open_disposition.h" | 168 #include "ui/base/window_open_disposition.h" |
| 169 #endif | 169 #endif |
| 170 | 170 |
| 171 using content::BrowserThread; | 171 using content::BrowserThread; |
| 172 using content::URLRequestMockHTTPJob; | 172 using net::URLRequestMockHTTPJob; |
| 173 using testing::Mock; | 173 using testing::Mock; |
| 174 using testing::Return; | 174 using testing::Return; |
| 175 using testing::_; | 175 using testing::_; |
| 176 | 176 |
| 177 namespace policy { | 177 namespace policy { |
| 178 | 178 |
| 179 namespace { | 179 namespace { |
| 180 | 180 |
| 181 #if defined(OS_CHROMEOS) | 181 #if defined(OS_CHROMEOS) |
| 182 const int kOneHourInMs = 60 * 60 * 1000; | 182 const int kOneHourInMs = 60 * 60 * 1000; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // dir through URLRequestMockHTTPJobs. | 218 // dir through URLRequestMockHTTPJobs. |
| 219 void RedirectHostsToTestData(const char* const urls[], size_t size) { | 219 void RedirectHostsToTestData(const char* const urls[], size_t size) { |
| 220 // Map the given hosts to the test data dir. | 220 // Map the given hosts to the test data dir. |
| 221 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 221 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 222 base::FilePath base_path; | 222 base::FilePath base_path; |
| 223 PathService::Get(chrome::DIR_TEST_DATA, &base_path); | 223 PathService::Get(chrome::DIR_TEST_DATA, &base_path); |
| 224 for (size_t i = 0; i < size; ++i) { | 224 for (size_t i = 0; i < size; ++i) { |
| 225 const GURL url(urls[i]); | 225 const GURL url(urls[i]); |
| 226 EXPECT_TRUE(url.is_valid()); | 226 EXPECT_TRUE(url.is_valid()); |
| 227 filter->AddUrlInterceptor( | 227 filter->AddUrlInterceptor( |
| 228 url, URLRequestMockHTTPJob::CreateInterceptor(base_path)); | 228 url, URLRequestMockHTTPJob::CreateInterceptor( |
| 229 base_path, |
| 230 content::BrowserThread::GetBlockingPool())); |
| 229 } | 231 } |
| 230 } | 232 } |
| 231 | 233 |
| 232 // Remove filters for requests to the hosts in |urls|. | 234 // Remove filters for requests to the hosts in |urls|. |
| 233 void UndoRedirectHostsToTestData(const char* const urls[], size_t size) { | 235 void UndoRedirectHostsToTestData(const char* const urls[], size_t size) { |
| 234 // Map the given hosts to the test data dir. | 236 // Map the given hosts to the test data dir. |
| 235 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 237 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 236 for (size_t i = 0; i < size; ++i) { | 238 for (size_t i = 0; i < size; ++i) { |
| 237 const GURL url(urls[i]); | 239 const GURL url(urls[i]); |
| 238 EXPECT_TRUE(url.is_valid()); | 240 EXPECT_TRUE(url.is_valid()); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 614 base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 613 } | 615 } |
| 614 | 616 |
| 615 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA | 617 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA |
| 616 // instead of chrome::DIR_TEST_DATA. | 618 // instead of chrome::DIR_TEST_DATA. |
| 617 void ServeContentTestData() { | 619 void ServeContentTestData() { |
| 618 base::FilePath root_http; | 620 base::FilePath root_http; |
| 619 PathService::Get(content::DIR_TEST_DATA, &root_http); | 621 PathService::Get(content::DIR_TEST_DATA, &root_http); |
| 620 BrowserThread::PostTaskAndReply( | 622 BrowserThread::PostTaskAndReply( |
| 621 BrowserThread::IO, FROM_HERE, | 623 BrowserThread::IO, FROM_HERE, |
| 622 base::Bind(URLRequestMockHTTPJob::AddUrlHandler, root_http), | 624 base::Bind( |
| 625 URLRequestMockHTTPJob::AddUrlHandler, |
| 626 root_http, |
| 627 scoped_refptr<base::SequencedWorkerPool> ( |
| 628 BrowserThread::GetBlockingPool())), |
| 623 base::MessageLoop::current()->QuitWhenIdleClosure()); | 629 base::MessageLoop::current()->QuitWhenIdleClosure()); |
| 624 content::RunMessageLoop(); | 630 content::RunMessageLoop(); |
| 625 } | 631 } |
| 626 | 632 |
| 627 void SetScreenshotPolicy(bool enabled) { | 633 void SetScreenshotPolicy(bool enabled) { |
| 628 PolicyMap policies; | 634 PolicyMap policies; |
| 629 policies.Set(key::kDisableScreenshots, | 635 policies.Set(key::kDisableScreenshots, |
| 630 POLICY_LEVEL_MANDATORY, | 636 POLICY_LEVEL_MANDATORY, |
| 631 POLICY_SCOPE_USER, | 637 POLICY_SCOPE_USER, |
| 632 new base::FundamentalValue(!enabled), | 638 new base::FundamentalValue(!enabled), |
| (...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3223 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 3218 browser2->tab_strip_model()->GetActiveWebContents(), | 3224 browser2->tab_strip_model()->GetActiveWebContents(), |
| 3219 "domAutomationController.send(window.showModalDialog !== undefined);", | 3225 "domAutomationController.send(window.showModalDialog !== undefined);", |
| 3220 &result)); | 3226 &result)); |
| 3221 EXPECT_TRUE(result); | 3227 EXPECT_TRUE(result); |
| 3222 } | 3228 } |
| 3223 | 3229 |
| 3224 #endif // !defined(CHROME_OS) | 3230 #endif // !defined(CHROME_OS) |
| 3225 | 3231 |
| 3226 } // namespace policy | 3232 } // namespace policy |
| OLD | NEW |