| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/chrome_plugin_service_filter.h" | 10 #include "chrome/browser/chrome_plugin_service_filter.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 old_factory_ = request_context->job_factory(); | 100 old_factory_ = request_context->job_factory(); |
| 101 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); | 101 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); |
| 102 job_factory_.AddInterceptor(new GViewRequestInterceptor); | 102 job_factory_.AddInterceptor(new GViewRequestInterceptor); |
| 103 request_context->set_job_factory(&job_factory_); | 103 request_context->set_job_factory(&job_factory_); |
| 104 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(&prefs_); | 104 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(&prefs_); |
| 105 plugin_prefs_ = new PluginPrefs(); | 105 plugin_prefs_ = new PluginPrefs(); |
| 106 plugin_prefs_->SetPrefs(&prefs_); | 106 plugin_prefs_->SetPrefs(&prefs_); |
| 107 ChromePluginServiceFilter* filter = | 107 ChromePluginServiceFilter* filter = |
| 108 ChromePluginServiceFilter::GetInstance(); | 108 ChromePluginServiceFilter::GetInstance(); |
| 109 filter->RegisterResourceContext(plugin_prefs_, resource_context); | 109 filter->RegisterResourceContext(plugin_prefs_, resource_context); |
| 110 PluginService::GetInstance()->set_filter(filter); | 110 PluginService::GetInstance()->SetFilter(filter); |
| 111 | 111 |
| 112 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); | 112 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); |
| 113 | 113 |
| 114 handler_ = new content::DummyResourceHandler(); | 114 handler_ = new content::DummyResourceHandler(); |
| 115 | 115 |
| 116 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_); | 116 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_); |
| 117 PluginService::GetInstance()->Init(); | 117 PluginService::GetInstance()->Init(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 virtual void TearDown() { | 120 virtual void TearDown() { |
| 121 plugin_prefs_->ShutdownOnUIThread(); | 121 plugin_prefs_->ShutdownOnUIThread(); |
| 122 content::ResourceContext* resource_context = | 122 content::ResourceContext* resource_context = |
| 123 content::MockResourceContext::GetInstance(); | 123 content::MockResourceContext::GetInstance(); |
| 124 net::URLRequestContext* request_context = | 124 net::URLRequestContext* request_context = |
| 125 resource_context->request_context(); | 125 resource_context->request_context(); |
| 126 request_context->set_job_factory(old_factory_); | 126 request_context->set_job_factory(old_factory_); |
| 127 ChromePluginServiceFilter* filter = | 127 ChromePluginServiceFilter* filter = |
| 128 ChromePluginServiceFilter::GetInstance(); | 128 ChromePluginServiceFilter::GetInstance(); |
| 129 filter->UnregisterResourceContext(resource_context); | 129 filter->UnregisterResourceContext(resource_context); |
| 130 PluginService::GetInstance()->set_filter(NULL); | 130 PluginService::GetInstance()->SetFilter(NULL); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void RegisterPDFPlugin() { | 133 void RegisterPDFPlugin() { |
| 134 webkit::WebPluginInfo info; | 134 webkit::WebPluginInfo info; |
| 135 info.path = pdf_path_; | 135 info.path = pdf_path_; |
| 136 plugin_list_.AddPluginToLoad(info); | 136 plugin_list_.AddPluginToLoad(info); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void UnregisterPDFPlugin() { | 139 void UnregisterPDFPlugin() { |
| 140 plugin_list_.ClearPluginsToLoad(); | 140 plugin_list_.ClearPluginsToLoad(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 SetupRequest(&request); | 289 SetupRequest(&request); |
| 290 request.Start(); | 290 request.Start(); |
| 291 MessageLoop::current()->Run(); | 291 MessageLoop::current()->Run(); |
| 292 EXPECT_EQ(0, test_delegate_.received_redirect_count()); | 292 EXPECT_EQ(0, test_delegate_.received_redirect_count()); |
| 293 EXPECT_EQ(GURL(kPdfBlob), request.url()); | 293 EXPECT_EQ(GURL(kPdfBlob), request.url()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace | 296 } // namespace |
| 297 | 297 |
| 298 } // namespace chromeos | 298 } // namespace chromeos |
| OLD | NEW |