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 "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 7 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
8 #include "chrome/browser/plugin_service.h" | 8 #include "chrome/browser/plugin_service.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 net::URLRequest::RegisterProtocolFactory("http", NULL); | 59 net::URLRequest::RegisterProtocolFactory("http", NULL); |
60 message_loop_.RunAllPending(); | 60 message_loop_.RunAllPending(); |
61 } | 61 } |
62 | 62 |
63 static net::URLRequestJob* Factory(net::URLRequest* request, | 63 static net::URLRequestJob* Factory(net::URLRequest* request, |
64 const std::string& scheme) { | 64 const std::string& scheme) { |
65 return new GViewURLRequestTestJob(request); | 65 return new GViewURLRequestTestJob(request); |
66 } | 66 } |
67 | 67 |
68 void RegisterPDFPlugin() { | 68 void RegisterPDFPlugin() { |
69 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(pdf_path_); | 69 webkit::npapi::PluginVersionInfo pdf_plugin; |
70 memset(&pdf_plugin.entry_points, 0, sizeof(pdf_plugin.entry_points)); | |
71 pdf_plugin.path = pdf_path_; | |
72 pdf_plugin.product_name = ASCIIToWide("PDF Plugin"); | |
jam
2011/01/19 20:22:09
is this code still needed, i.e. adding a descripti
pastarmovj
2011/01/19 23:39:17
Actually yes. This plugin has description in it's
jam
2011/01/20 00:24:25
oops, I didn't notice that this is a test file, in
| |
73 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(pdf_plugin); | |
70 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 74 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
71 } | 75 } |
72 | 76 |
73 void UnregisterPDFPlugin() { | 77 void UnregisterPDFPlugin() { |
74 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); | 78 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); |
75 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 79 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
76 } | 80 } |
77 | 81 |
78 void SetPDFPluginLoadedState(bool want_loaded, bool* out_is_enabled) { | 82 void SetPDFPluginLoadedState(bool want_loaded, bool* out_is_enabled) { |
79 webkit::npapi::WebPluginInfo info; | 83 webkit::npapi::WebPluginInfo info; |
80 bool is_loaded = | 84 bool is_loaded = |
81 webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 85 webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
82 pdf_path_, &info); | 86 pdf_path_, &info); |
83 if (is_loaded && !want_loaded) { | 87 if (is_loaded && !want_loaded) { |
84 UnregisterPDFPlugin(); | 88 UnregisterPDFPlugin(); |
85 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 89 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
86 pdf_path_, &info); | 90 pdf_path_, &info); |
87 } else if (!is_loaded && want_loaded) { | 91 } else if (!is_loaded && want_loaded) { |
88 // This "loads" the plug-in even if it's not present on the | 92 // This "loads" the plug-in even if it's not present on the |
89 // system - which is OK since we don't actually use it, just | 93 // system - which is OK since we don't actually use it, just |
90 // need it to be "enabled" for the test. | 94 // need it to be "enabled" for the test. |
91 RegisterPDFPlugin(); | 95 RegisterPDFPlugin(); |
92 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 96 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
93 pdf_path_, &info); | 97 pdf_path_, &info); |
94 } | 98 } |
95 EXPECT_EQ(want_loaded, is_loaded); | 99 EXPECT_EQ(want_loaded, is_loaded); |
96 *out_is_enabled = info.enabled; | 100 *out_is_enabled = webkit::npapi::IsPluginEnabled(info); |
97 } | 101 } |
98 | 102 |
99 protected: | 103 protected: |
100 MessageLoopForIO message_loop_; | 104 MessageLoopForIO message_loop_; |
101 TestDelegate test_delegate_; | 105 TestDelegate test_delegate_; |
102 net::URLRequest::Interceptor* interceptor_; | 106 net::URLRequest::Interceptor* interceptor_; |
103 FilePath pdf_path_; | 107 FilePath pdf_path_; |
104 }; | 108 }; |
105 | 109 |
106 TEST_F(GViewRequestInterceptorTest, DoNotInterceptHtml) { | 110 TEST_F(GViewRequestInterceptorTest, DoNotInterceptHtml) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { | 175 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { |
172 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); | 176 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); |
173 request.Start(); | 177 request.Start(); |
174 MessageLoop::current()->Run(); | 178 MessageLoop::current()->Run(); |
175 EXPECT_EQ(1, test_delegate_.received_redirect_count()); | 179 EXPECT_EQ(1, test_delegate_.received_redirect_count()); |
176 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), | 180 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), |
177 request.url()); | 181 request.url()); |
178 } | 182 } |
179 | 183 |
180 } // namespace chromeos | 184 } // namespace chromeos |
OLD | NEW |