diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 19:40:29 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 19:40:29 +0000 |
commit | 3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be (patch) | |
tree | a4e06819ca0c59659ff8d4538c51bdbfd18e0873 /chrome | |
parent | 096d5cdd6c7b6930ca4a59bb965b5e4f6647f8e0 (diff) | |
download | chromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.zip chromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.tar.gz chromium_src-3c8bd9f45bfeb09acc2fbad3407e7b2c14d7c7be.tar.bz2 |
Expose whether we're in private browsing mode to plugins.I chose to implement this for multi-process mode only and not --single-process or --in-process-plugins, since I wanted to send this data from the browser process, not the renderer (in case it's exploited).
BUG=158
Review URL: http://codereview.chromium.org/52037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/plugin_process_host.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.h | 4 | ||||
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 3 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 2 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.h | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 6 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.h | 2 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 4 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 2 | ||||
-rw-r--r-- | chrome/test/data/npapi/private.html | 25 | ||||
-rw-r--r-- | chrome/test/ui/npapi_test_helper.cc | 8 | ||||
-rw-r--r-- | chrome/test/ui/npapi_test_helper.h | 6 | ||||
-rw-r--r-- | chrome/test/ui/npapi_uitest.cpp | 24 |
14 files changed, 87 insertions, 9 deletions
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 7168e36..890a387 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -613,7 +613,8 @@ void PluginProcessHost::RequestPluginChannel( // plugin process (i.e. unblocks a Send() call like a sync message) otherwise // a deadlock can occur if the plugin creation request from the renderer is // a result of a sync message by the plugin process. - PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel(); + PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel( + renderer_message_filter->off_the_record()); msg->set_unblock(true); if (Send(msg)) { sent_requests_.push(ChannelRequest( diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 73f7154..92faa44 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -117,7 +117,8 @@ ResourceMessageFilter::ResourceMessageFilter( media_request_context_(profile->GetRequestContextForMedia()), profile_(profile), render_widget_helper_(render_widget_helper), - audio_renderer_host_(audio_renderer_host) { + audio_renderer_host_(audio_renderer_host), + off_the_record_(profile->IsOffTheRecord()) { DCHECK(request_context_.get()); DCHECK(request_context_->cookie_store()); DCHECK(media_request_context_.get()); diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 8023d43..42650f2 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -94,6 +94,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, return resource_dispatcher_host_; } MessageLoop* ui_loop() { return render_widget_helper_->ui_loop(); } + bool off_the_record() { return off_the_record_; } // NotificationObserver implementation. virtual void Observe(NotificationType type, @@ -269,6 +270,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // Object that should take care of audio related resource requests. scoped_refptr<AudioRendererHost> audio_renderer_host_; + // Whether this process is used for off the record tabs. + bool off_the_record_; + DISALLOW_COPY_AND_ASSIGN(ResourceMessageFilter); }; diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 6aaca34..b9c7a58 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -13,7 +13,8 @@ IPC_BEGIN_MESSAGES(PluginProcess) // Tells the plugin process to create a new channel for communication with a // renderer. The channel name is returned in a // PluginProcessHostMsg_ChannelCreated message. - IPC_MESSAGE_CONTROL0(PluginProcessMsg_CreateChannel) + IPC_MESSAGE_CONTROL1(PluginProcessMsg_CreateChannel, + bool /* off_the_record */) IPC_MESSAGE_CONTROL1(PluginProcessMsg_ShutdownResponse, bool /* ok to shutdown */) diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index 675a46f..125054a 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -27,7 +27,7 @@ PluginChannel* PluginChannel::GetPluginChannel(MessageLoop* ipc_message_loop) { false)); } -PluginChannel::PluginChannel() : in_send_(0) { +PluginChannel::PluginChannel() : in_send_(0), off_the_record_(false) { SendUnblockingOnlyDuringDispatch(); PluginProcess::current()->AddRefProcess(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); diff --git a/chrome/plugin/plugin_channel.h b/chrome/plugin/plugin_channel.h index 22ebbfa..94d18f9 100644 --- a/chrome/plugin/plugin_channel.h +++ b/chrome/plugin/plugin_channel.h @@ -26,6 +26,9 @@ class PluginChannel : public PluginChannelBase { bool in_send() { return in_send_ != 0; } + bool off_the_record() { return off_the_record_; } + void set_off_the_record(bool value) { off_the_record_ = value; } + protected: // IPC::Channel::Listener implementation: virtual void OnChannelConnected(int32 peer_pid); @@ -52,6 +55,7 @@ class PluginChannel : public PluginChannelBase { int in_send_; // Tracks if we're in a Send call. bool log_messages_; // True if we should log sent and received messages. + bool off_the_record_; // True if the renderer is in off the record mode. DISALLOW_EVIL_CONSTRUCTORS(PluginChannel); }; diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 5f26f71..10172e7 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -88,12 +88,14 @@ void PluginThread::CleanUp() { ChildThread::CleanUp(); } -void PluginThread::OnCreateChannel() { +void PluginThread::OnCreateChannel(bool off_the_record) { std::wstring channel_name; scoped_refptr<PluginChannel> channel = PluginChannel::GetPluginChannel(owner_loop()); - if (channel.get()) + if (channel.get()) { channel_name = channel->channel_name(); + channel->set_off_the_record(off_the_record); + } Send(new PluginProcessHostMsg_ChannelCreated(channel_name)); } diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h index bcf926f..1550d5a 100644 --- a/chrome/plugin/plugin_thread.h +++ b/chrome/plugin/plugin_thread.h @@ -29,7 +29,7 @@ class PluginThread : public ChildThread { virtual void Init(); virtual void CleanUp(); - void OnCreateChannel(); + void OnCreateChannel(bool off_the_record); void OnShutdownResponse(bool ok_to_shutdown); void OnPluginMessage(const std::vector<uint8> &data); void OnBrowserShutdown(); diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index dbe9b5a..38310fb 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -439,3 +439,7 @@ void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { Paint(damaged_rect); Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); } + +bool WebPluginProxy::IsOffTheRecord() { + return channel_->off_the_record(); +} diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 78ca43c..cba1ac5 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -94,6 +94,8 @@ class WebPluginProxy : public WebPlugin { bool notify_needed, HANDLE notify_data); + bool IsOffTheRecord(); + base::WaitableEvent* modal_dialog_event() { return modal_dialog_event_.get(); } diff --git a/chrome/test/data/npapi/private.html b/chrome/test/data/npapi/private.html new file mode 100644 index 0000000..46cacde --- /dev/null +++ b/chrome/test/data/npapi/private.html @@ -0,0 +1,25 @@ +<html> + +<head> +<script src="npapi.js"></script> +</head> + + +<body> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +Test running.... +</div> + + +NPAPI Private Mode test<p> +Tests that a plugin can query the private browsing mode.<P> + +<embed type="application/vnd.npapi-test" + src="foo" + name="private" + id="1" + mode="np_embed" +> + +</body> +</html> diff --git a/chrome/test/ui/npapi_test_helper.cc b/chrome/test/ui/npapi_test_helper.cc index c6753d0..859d3df 100644 --- a/chrome/test/ui/npapi_test_helper.cc +++ b/chrome/test/ui/npapi_test_helper.cc @@ -31,6 +31,8 @@ #include "chrome/test/ui/npapi_test_helper.h" +#include "chrome/common/chrome_switches.h" + NPAPITester::NPAPITester() : UITest() { } @@ -59,3 +61,9 @@ void NPAPIVisiblePluginTester::SetUp() { show_window_ = true; NPAPITester::SetUp(); } + +// NPAPIIncognitoTester members. +void NPAPIIncognitoTester::SetUp() { + launch_arguments_.AppendSwitch(switches::kIncognito); + NPAPITester::SetUp(); +} diff --git a/chrome/test/ui/npapi_test_helper.h b/chrome/test/ui/npapi_test_helper.h index 26f4c67..7b79e0e 100644 --- a/chrome/test/ui/npapi_test_helper.h +++ b/chrome/test/ui/npapi_test_helper.h @@ -46,3 +46,9 @@ class NPAPIVisiblePluginTester : public NPAPITester { protected: virtual void SetUp(); }; + +// Helper class for NPAPI plugin UI tests which use incognito mode. +class NPAPIIncognitoTester : public NPAPITester { + protected: + virtual void SetUp(); +}; diff --git a/chrome/test/ui/npapi_uitest.cpp b/chrome/test/ui/npapi_uitest.cpp index 8d808be..7826878 100644 --- a/chrome/test/ui/npapi_uitest.cpp +++ b/chrome/test/ui/npapi_uitest.cpp @@ -76,7 +76,6 @@ TEST_F(NPAPITester, Arguments) { kTestCompleteSuccess, kShortWaitTimeout); } - // Test invoking many plugins within a single page. TEST_F(NPAPITester, ManyPlugins) { std::wstring test_case = L"many_plugins.html"; @@ -134,7 +133,6 @@ TEST_F(NPAPITester, GetJavaScriptURL) { kTestCompleteSuccess, kShortWaitTimeout); } - // Tests that if an NPObject is proxies back to its original process, the // original pointer is returned and not a proxy. If this fails the plugin // will crash. @@ -261,3 +259,25 @@ TEST_F(NPAPIVisiblePluginTester, OpenPopupWindowWithPlugin) { kTestCompleteCookie, kTestCompleteSuccess, action_timeout_ms()); } + +// Test checking the privacy mode is off. +TEST_F(NPAPITester, PrivateDisabled) { + if (UITest::in_process_renderer()) + return; + + GURL url = GetTestUrl(L"npapi", L"private.html"); + NavigateToURL(url); + WaitForFinish("private", "1", url, kTestCompleteCookie, + kTestCompleteSuccess, kShortWaitTimeout); +} + +// Test checking the privacy mode is on. +TEST_F(NPAPIIncognitoTester, PrivateEnabled) { + if (UITest::in_process_renderer()) + return; + + GURL url = GetTestUrl(L"npapi", L"private.html?secure"); + NavigateToURL(url); + WaitForFinish("private", "1", url, kTestCompleteCookie, + kTestCompleteSuccess, kShortWaitTimeout); +} |