OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NPAPI::PluginVersionInfo info; | 69 NPAPI::PluginVersionInfo info; |
70 info.path = pdf_path_; | 70 info.path = pdf_path_; |
| 71 info.product_name = UTF8ToWide("PDF Internal Plugin"); |
71 memset(&info.entry_points, 0, sizeof(info.entry_points)); | 72 memset(&info.entry_points, 0, sizeof(info.entry_points)); |
72 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); | 73 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); |
73 NPAPI::PluginList::Singleton()->RefreshPlugins(); | 74 NPAPI::PluginList::Singleton()->RefreshPlugins(); |
74 } | 75 } |
75 | 76 |
76 void UnregisterPDFPlugin() { | 77 void UnregisterPDFPlugin() { |
77 NPAPI::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); | 78 NPAPI::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); |
78 NPAPI::PluginList::Singleton()->RefreshPlugins(); | 79 NPAPI::PluginList::Singleton()->RefreshPlugins(); |
79 } | 80 } |
80 | 81 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_EQ(0, test_delegate_.received_redirect_count()); | 122 EXPECT_EQ(0, test_delegate_.received_redirect_count()); |
122 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); | 123 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); |
123 } | 124 } |
124 | 125 |
125 TEST_F(GViewRequestInterceptorTest, DoNotInterceptPdfWhenEnabled) { | 126 TEST_F(GViewRequestInterceptorTest, DoNotInterceptPdfWhenEnabled) { |
126 bool enabled; | 127 bool enabled; |
127 SetPDFPluginLoadedState(true, &enabled); | 128 SetPDFPluginLoadedState(true, &enabled); |
128 | 129 |
129 if (!enabled) { | 130 if (!enabled) { |
130 bool pdf_plugin_enabled = | 131 bool pdf_plugin_enabled = |
131 NPAPI::PluginList::Singleton()->EnablePlugin(pdf_path_); | 132 NPAPI::PluginList::Singleton()->EnablePlugin(pdf_path_, string16()); |
132 EXPECT_TRUE(pdf_plugin_enabled); | 133 EXPECT_TRUE(pdf_plugin_enabled); |
133 } | 134 } |
134 | 135 |
135 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); | 136 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); |
136 request.Start(); | 137 request.Start(); |
137 MessageLoop::current()->Run(); | 138 MessageLoop::current()->Run(); |
138 EXPECT_EQ(0, test_delegate_.received_redirect_count()); | 139 EXPECT_EQ(0, test_delegate_.received_redirect_count()); |
139 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); | 140 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); |
140 } | 141 } |
141 | 142 |
142 TEST_F(GViewRequestInterceptorTest, InterceptPdfWhenDisabled) { | 143 TEST_F(GViewRequestInterceptorTest, InterceptPdfWhenDisabled) { |
143 bool enabled; | 144 bool enabled; |
144 SetPDFPluginLoadedState(true, &enabled); | 145 SetPDFPluginLoadedState(true, &enabled); |
145 | 146 |
146 if (enabled) { | 147 if (enabled) { |
147 bool pdf_plugin_disabled = | 148 bool pdf_plugin_disabled = |
148 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path_); | 149 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path_, string16()); |
149 EXPECT_TRUE(pdf_plugin_disabled); | 150 EXPECT_TRUE(pdf_plugin_disabled); |
150 } | 151 } |
151 | 152 |
152 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); | 153 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); |
153 request.Start(); | 154 request.Start(); |
154 MessageLoop::current()->Run(); | 155 MessageLoop::current()->Run(); |
155 EXPECT_EQ(1, test_delegate_.received_redirect_count()); | 156 EXPECT_EQ(1, test_delegate_.received_redirect_count()); |
156 EXPECT_EQ( | 157 EXPECT_EQ( |
157 GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.pdf"), | 158 GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.pdf"), |
158 request.url()); | 159 request.url()); |
(...skipping 14 matching lines...) Expand all Loading... |
173 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { | 174 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { |
174 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); | 175 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); |
175 request.Start(); | 176 request.Start(); |
176 MessageLoop::current()->Run(); | 177 MessageLoop::current()->Run(); |
177 EXPECT_EQ(1, test_delegate_.received_redirect_count()); | 178 EXPECT_EQ(1, test_delegate_.received_redirect_count()); |
178 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), | 179 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), |
179 request.url()); | 180 request.url()); |
180 } | 181 } |
181 | 182 |
182 } // namespace chromeos | 183 } // namespace chromeos |
OLD | NEW |