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

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

Issue 7648017: Make WebPluginInfo more generic (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months 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) 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 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/chromeos/gview_request_interceptor.h" 8 #include "chrome/browser/chromeos/gview_request_interceptor.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "content/browser/plugin_service.h" 10 #include "content/browser/plugin_service.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 public: 65 public:
66 virtual void SetUp() { 66 virtual void SetUp() {
67 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); 67 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory);
68 job_factory_.AddInterceptor(new GViewRequestInterceptor); 68 job_factory_.AddInterceptor(new GViewRequestInterceptor);
69 request_context_ = new TestURLRequestContext; 69 request_context_ = new TestURLRequestContext;
70 request_context_->set_job_factory(&job_factory_); 70 request_context_->set_job_factory(&job_factory_);
71 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); 71 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_));
72 } 72 }
73 73
74 void RegisterPDFPlugin() { 74 void RegisterPDFPlugin() {
75 webkit::npapi::WebPluginInfo info; 75 webkit::WebPluginInfo info;
76 info.path = pdf_path_; 76 info.path = pdf_path_;
77 info.enabled = webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; 77 info.enabled = webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED;
78 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); 78 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info);
79 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 79 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
80 } 80 }
81 81
82 void UnregisterPDFPlugin() { 82 void UnregisterPDFPlugin() {
83 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_); 83 webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(pdf_path_);
84 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 84 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
85 } 85 }
86 86
87 void SetPDFPluginLoadedState(bool want_loaded, bool* out_is_enabled) { 87 void SetPDFPluginLoadedState(bool want_loaded, bool* out_is_enabled) {
88 webkit::npapi::WebPluginInfo info; 88 webkit::WebPluginInfo info;
89 bool is_loaded = 89 bool is_loaded =
90 webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 90 webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
91 pdf_path_, &info); 91 pdf_path_, &info);
92 if (is_loaded && !want_loaded) { 92 if (is_loaded && !want_loaded) {
93 UnregisterPDFPlugin(); 93 UnregisterPDFPlugin();
94 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 94 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
95 pdf_path_, &info); 95 pdf_path_, &info);
96 } else if (!is_loaded && want_loaded) { 96 } else if (!is_loaded && want_loaded) {
97 // This "loads" the plug-in even if it's not present on the 97 // This "loads" the plug-in even if it's not present on the
98 // system - which is OK since we don't actually use it, just 98 // system - which is OK since we don't actually use it, just
99 // need it to be "enabled" for the test. 99 // need it to be "enabled" for the test.
100 RegisterPDFPlugin(); 100 RegisterPDFPlugin();
101 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 101 is_loaded = webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
102 pdf_path_, &info); 102 pdf_path_, &info);
103 } 103 }
104 EXPECT_EQ(want_loaded, is_loaded); 104 EXPECT_EQ(want_loaded, is_loaded);
105 *out_is_enabled = webkit::npapi::IsPluginEnabled(info); 105 *out_is_enabled = webkit::IsPluginEnabled(info);
106 } 106 }
107 107
108 protected: 108 protected:
109 MessageLoopForIO message_loop_; 109 MessageLoopForIO message_loop_;
110 net::URLRequestJobFactory job_factory_; 110 net::URLRequestJobFactory job_factory_;
111 scoped_refptr<TestURLRequestContext> request_context_; 111 scoped_refptr<TestURLRequestContext> request_context_;
112 TestDelegate test_delegate_; 112 TestDelegate test_delegate_;
113 FilePath pdf_path_; 113 FilePath pdf_path_;
114 }; 114 };
115 115
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 request.Start(); 189 request.Start();
190 MessageLoop::current()->Run(); 190 MessageLoop::current()->Run();
191 EXPECT_EQ(1, test_delegate_.received_redirect_count()); 191 EXPECT_EQ(1, test_delegate_.received_redirect_count());
192 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), 192 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"),
193 request.url()); 193 request.url());
194 } 194 }
195 195
196 } // namespace 196 } // namespace
197 197
198 } // namespace chromeos 198 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gview_request_interceptor.cc ('k') | chrome/browser/extensions/extension_content_settings_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698