Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: chrome/browser/chromeos/gview_request_interceptor_unittest.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up WebPluginInfo and rebased on fixed PluginGroup::InitFrom. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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::PluginVersionInfo info; 69 webkit::npapi::PluginVersionInfo info;
70 info.path = pdf_path_; 70 info.path = pdf_path_;
71 info.product_name = UTF8ToWide("PDF Internal Plugin");
jam 2010/12/21 19:57:42 why is this needed here?
pastarmovj 2010/12/21 20:31:19 I use the existence of a description as a marker f
72 info.file_description = UTF8ToWide("PDF Internal Plugin");
71 memset(&info.entry_points, 0, sizeof(info.entry_points)); 73 memset(&info.entry_points, 0, sizeof(info.entry_points));
72 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); 74 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info);
73 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 75 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
74 } 76 }
75 77
76 void UnregisterPDFPlugin() { 78 void UnregisterPDFPlugin() {
77 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); 79 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_);
78 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 80 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
79 } 81 }
80 82
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_EQ(0, test_delegate_.received_redirect_count()); 124 EXPECT_EQ(0, test_delegate_.received_redirect_count());
123 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); 125 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url());
124 } 126 }
125 127
126 TEST_F(GViewRequestInterceptorTest, DoNotInterceptPdfWhenEnabled) { 128 TEST_F(GViewRequestInterceptorTest, DoNotInterceptPdfWhenEnabled) {
127 bool enabled; 129 bool enabled;
128 SetPDFPluginLoadedState(true, &enabled); 130 SetPDFPluginLoadedState(true, &enabled);
129 131
130 if (!enabled) { 132 if (!enabled) {
131 bool pdf_plugin_enabled = 133 bool pdf_plugin_enabled =
132 webkit::npapi::PluginList::Singleton()->EnablePlugin(pdf_path_); 134 webkit::npapi::PluginList::Singleton()->EnablePlugin(pdf_path_,
135 string16());
133 EXPECT_TRUE(pdf_plugin_enabled); 136 EXPECT_TRUE(pdf_plugin_enabled);
134 } 137 }
135 138
136 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); 139 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_);
137 request.Start(); 140 request.Start();
138 MessageLoop::current()->Run(); 141 MessageLoop::current()->Run();
139 EXPECT_EQ(0, test_delegate_.received_redirect_count()); 142 EXPECT_EQ(0, test_delegate_.received_redirect_count());
140 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url()); 143 EXPECT_EQ(GURL("http://foo.com/file.pdf"), request.url());
141 } 144 }
142 145
143 TEST_F(GViewRequestInterceptorTest, InterceptPdfWhenDisabled) { 146 TEST_F(GViewRequestInterceptorTest, InterceptPdfWhenDisabled) {
144 bool enabled; 147 bool enabled;
145 SetPDFPluginLoadedState(true, &enabled); 148 SetPDFPluginLoadedState(true, &enabled);
146 149
147 if (enabled) { 150 if (enabled) {
148 bool pdf_plugin_disabled = 151 bool pdf_plugin_disabled =
149 webkit::npapi::PluginList::Singleton()->DisablePlugin(pdf_path_); 152 webkit::npapi::PluginList::Singleton()->DisablePlugin(pdf_path_,
153 string16());
150 EXPECT_TRUE(pdf_plugin_disabled); 154 EXPECT_TRUE(pdf_plugin_disabled);
151 } 155 }
152 156
153 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_); 157 net::URLRequest request(GURL("http://foo.com/file.pdf"), &test_delegate_);
154 request.Start(); 158 request.Start();
155 MessageLoop::current()->Run(); 159 MessageLoop::current()->Run();
156 EXPECT_EQ(1, test_delegate_.received_redirect_count()); 160 EXPECT_EQ(1, test_delegate_.received_redirect_count());
157 EXPECT_EQ( 161 EXPECT_EQ(
158 GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.pdf"), 162 GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.pdf"),
159 request.url()); 163 request.url());
(...skipping 14 matching lines...) Expand all
174 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { 178 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) {
175 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); 179 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_);
176 request.Start(); 180 request.Start();
177 MessageLoop::current()->Run(); 181 MessageLoop::current()->Run();
178 EXPECT_EQ(1, test_delegate_.received_redirect_count()); 182 EXPECT_EQ(1, test_delegate_.received_redirect_count());
179 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), 183 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"),
180 request.url()); 184 request.url());
181 } 185 }
182 186
183 } // namespace chromeos 187 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698