summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/plugin_service.cc11
-rw-r--r--chrome/browser/plugin_service.h5
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc3
-rw-r--r--chrome_frame/test/net/test_automation_provider.cc20
-rw-r--r--chrome_frame/test/net/test_automation_provider.h17
5 files changed, 42 insertions, 14 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 5f66be9..ba5821e 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -42,10 +42,18 @@ static void NotifyPluginsOfActivation() {
#endif
// static
+bool PluginService::enable_chrome_plugins_ = true;
+
+// static
PluginService* PluginService::GetInstance() {
return Singleton<PluginService>::get();
}
+// static
+void PluginService::EnableChromePlugins(bool enable) {
+ enable_chrome_plugins_ = enable;
+}
+
PluginService::PluginService()
: main_message_loop_(MessageLoop::current()),
resource_dispatcher_host_(NULL),
@@ -103,6 +111,9 @@ PluginService::~PluginService() {
void PluginService::LoadChromePlugins(
ResourceDispatcherHost* resource_dispatcher_host) {
+ if (!enable_chrome_plugins_)
+ return;
+
resource_dispatcher_host_ = resource_dispatcher_host;
ChromePluginLib::LoadChromePlugins(GetCPBrowserFuncsForBrowser());
}
diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h
index c9ee5a1..7ab39e2 100644
--- a/chrome/browser/plugin_service.h
+++ b/chrome/browser/plugin_service.h
@@ -91,6 +91,8 @@ class PluginService
return resource_dispatcher_host_;
}
+ static void EnableChromePlugins(bool enable);
+
private:
friend struct DefaultSingletonTraits<PluginService>;
@@ -143,6 +145,9 @@ class PluginService
base::WaitableEventWatcher hklm_watcher_;
#endif
+ // Set to true if chrome plugins are enabled. Defaults to true.
+ static bool enable_chrome_plugins_;
+
DISALLOW_COPY_AND_ASSIGN(PluginService);
};
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index 5168372..5caadd33 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -19,6 +19,7 @@
#include "base/scoped_variant_win.h"
#include "chrome/browser/browser_prefs.h"
+#include "chrome/browser/plugin_service.h"
#include "chrome/browser/process_singleton.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -28,7 +29,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
-
#include "chrome_frame/utils.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test/net/dialog_watchdog.h"
@@ -386,6 +386,7 @@ int main(int argc, char** argv) {
watchdog.AddObserver(&credentials);
testing::InitGoogleTest(&argc, argv);
FilterDisabledTests();
+ PluginService::EnableChromePlugins(false);
CFUrlRequestUnittestRunner test_suite(argc, argv);
test_suite.RunMainUIThread();
return 0;
diff --git a/chrome_frame/test/net/test_automation_provider.cc b/chrome_frame/test/net/test_automation_provider.cc
index f1a3b13..d9cd8db 100644
--- a/chrome_frame/test/net/test_automation_provider.cc
+++ b/chrome_frame/test/net/test_automation_provider.cc
@@ -23,16 +23,22 @@ bool CFTestsDisabled() {
} // end namespace
+TestAutomationProvider* TestAutomationProvider::g_provider_instance_ = NULL;
+
TestAutomationProvider::TestAutomationProvider(
Profile* profile,
TestAutomationProviderDelegate* delegate)
: AutomationProvider(profile), tab_handle_(-1), delegate_(delegate) {
filter_ = new TestAutomationResourceMessageFilter(this);
- URLRequest::RegisterRequestInterceptor(this);
+ URLRequest::RegisterProtocolFactory("http",
+ TestAutomationProvider::Factory);
+ URLRequest::RegisterProtocolFactory("https",
+ TestAutomationProvider::Factory);
+ g_provider_instance_ = this;
}
TestAutomationProvider::~TestAutomationProvider() {
- URLRequest::UnregisterRequestInterceptor(this);
+ g_provider_instance_ = NULL;
}
void TestAutomationProvider::OnMessageReceived(const IPC::Message& msg) {
@@ -56,7 +62,8 @@ bool TestAutomationProvider::Send(IPC::Message* msg) {
return AutomationProvider::Send(msg);
}
-URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) {
+URLRequestJob* TestAutomationProvider::Factory(URLRequest* request,
+ const std::string& scheme) {
if (CFTestsDisabled())
return NULL;
@@ -67,8 +74,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) {
// We could also check if the current thread is our TestUrlRequest thread
// and only intercept requests that belong to that thread.
- if (request->GetUserData(NULL) == NULL) {
- DCHECK(tab_handle_ != -1);
+ if (g_provider_instance_ && request->GetUserData(NULL) == NULL) {
+ DCHECK(g_provider_instance_->tab_handle_ != -1);
// We generate our own request id which is also what
// ResourceDispatcherHost does (well, the id is actually generated by
// ResourceDispatcher). Since these requests are divided into with
@@ -76,7 +83,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) {
// a little easier, we have a significantly higher start value.
static int new_id = 0x00100000;
URLRequestAutomationJob* job = new URLRequestAutomationJob(request,
- tab_handle_, new_id++, filter_);
+ g_provider_instance_->tab_handle_, new_id++,
+ g_provider_instance_->filter_);
return job;
}
}
diff --git a/chrome_frame/test/net/test_automation_provider.h b/chrome_frame/test/net/test_automation_provider.h
index 75830ba..a745537 100644
--- a/chrome_frame/test/net/test_automation_provider.h
+++ b/chrome_frame/test/net/test_automation_provider.h
@@ -19,22 +19,23 @@ class TestAutomationProviderDelegate {
// (see TestAutomationResourceMessageFilter) and know when the initial
// ExternalTab has been loaded.
// In order to intercept UrlRequests and make the URLRequestAutomationJob class
-// handle requests from unit tests, we also implement URLRequest::Interceptor.
+// handle requests from unit tests, we register a protocol factory for
+// http/https.
class TestAutomationProvider
- : public AutomationProvider,
- public URLRequest::Interceptor {
+ : public AutomationProvider {
public:
explicit TestAutomationProvider(Profile* profile,
TestAutomationProviderDelegate* delegate);
virtual ~TestAutomationProvider();
-
+
// AutomationProvider overrides.
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool Send(IPC::Message* msg);
- // URLRequest::Interceptor.
- virtual URLRequestJob* MaybeIntercept(URLRequest* request);
+ // Protocol factory for handling http/https requests over automation.
+ static URLRequestJob* Factory(URLRequest* request,
+ const std::string& scheme);
// Call to instantiate and initialize a new instance of
// TestAutomationProvider.
@@ -47,6 +48,8 @@ class TestAutomationProvider
scoped_refptr<TestAutomationResourceMessageFilter> filter_;
int tab_handle_;
TestAutomationProviderDelegate* delegate_;
+
+ static TestAutomationProvider* g_provider_instance_;
};
-#endif CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_
+#endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_