Commit ef916278 authored by jam@chromium.org's avatar jam@chromium.org

Add the page url to plugin crashes to aid debugging.

Review URL: http://codereview.chromium.org/155238

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20191 0039d316-1c4b-4281-b951-d872f2087c98
parent 9e6f8526
...@@ -78,10 +78,10 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& dll_path, ...@@ -78,10 +78,10 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& dll_path,
google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32");
google_breakpad::CustomInfoEntry type_entry(L"ptype", type.c_str()); google_breakpad::CustomInfoEntry type_entry(L"ptype", type.c_str());
if (type == L"renderer") { if (type == L"renderer" || type == L"plugin") {
// If we're a renderer create entries for the URL. Currently we only allow // Create entries for the URL. Currently we only allow each chunk to be 64
// each chunk to be 64 characters, which isn't enough for a URL. As a hack // characters, which isn't enough for a URL. As a hack we create 8 entries
// we create 8 entries and split the URL across the entries. // and split the URL across the entries.
google_breakpad::CustomInfoEntry url1(L"url-chunk-1", L""); google_breakpad::CustomInfoEntry url1(L"url-chunk-1", L"");
google_breakpad::CustomInfoEntry url2(L"url-chunk-2", L""); google_breakpad::CustomInfoEntry url2(L"url-chunk-2", L"");
google_breakpad::CustomInfoEntry url3(L"url-chunk-3", L""); google_breakpad::CustomInfoEntry url3(L"url-chunk-3", L"");
...@@ -181,7 +181,7 @@ long WINAPI ChromeExceptionFilter(EXCEPTION_POINTERS* info) { ...@@ -181,7 +181,7 @@ long WINAPI ChromeExceptionFilter(EXCEPTION_POINTERS* info) {
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
extern "C" void __declspec(dllexport) __cdecl SetActiveRendererURL( extern "C" void __declspec(dllexport) __cdecl SetActiveURL(
const wchar_t* url_cstring) { const wchar_t* url_cstring) {
DCHECK(url_cstring); DCHECK(url_cstring);
if (!g_url_chunks) if (!g_url_chunks)
......
...@@ -326,6 +326,10 @@ ...@@ -326,6 +326,10 @@
'common/child_process_host.h', 'common/child_process_host.h',
'common/child_process_info.cc', 'common/child_process_info.cc',
'common/child_process_info.h', 'common/child_process_info.h',
'common/child_process_logging.h',
'common/child_process_logging_linux.cc',
'common/child_process_logging_mac.mm',
'common/child_process_logging_win.cc',
'common/child_thread.cc', 'common/child_thread.cc',
'common/child_thread.h', 'common/child_thread.h',
'common/chrome_constants.cc', 'common/chrome_constants.cc',
...@@ -2325,10 +2329,6 @@ ...@@ -2325,10 +2329,6 @@
'renderer/renderer_glue.cc', 'renderer/renderer_glue.cc',
'renderer/renderer_histogram_snapshots.cc', 'renderer/renderer_histogram_snapshots.cc',
'renderer/renderer_histogram_snapshots.h', 'renderer/renderer_histogram_snapshots.h',
'renderer/renderer_logging.h',
'renderer/renderer_logging_linux.cc',
'renderer/renderer_logging_mac.mm',
'renderer/renderer_logging_win.cc',
'renderer/renderer_main.cc', 'renderer/renderer_main.cc',
'renderer/renderer_main_platform_delegate.h', 'renderer/renderer_main_platform_delegate.h',
'renderer/renderer_main_platform_delegate_linux.cc', 'renderer/renderer_main_platform_delegate_linux.cc',
...@@ -3587,6 +3587,7 @@ ...@@ -3587,6 +3587,7 @@
'browser/webdata/web_database_unittest.cc', 'browser/webdata/web_database_unittest.cc',
'browser/window_sizer_unittest.cc', 'browser/window_sizer_unittest.cc',
'common/bzip2_unittest.cc', 'common/bzip2_unittest.cc',
'common/child_process_logging_mac_unittest.mm',
'common/chrome_plugin_unittest.cc', 'common/chrome_plugin_unittest.cc',
'common/extensions/extension_unittest.cc', 'common/extensions/extension_unittest.cc',
'common/extensions/url_pattern_unittest.cc', 'common/extensions/url_pattern_unittest.cc',
...@@ -3618,7 +3619,6 @@ ...@@ -3618,7 +3619,6 @@
'renderer/render_thread_unittest.cc', 'renderer/render_thread_unittest.cc',
'renderer/render_view_unittest.cc', 'renderer/render_view_unittest.cc',
'renderer/render_widget_unittest.cc', 'renderer/render_widget_unittest.cc',
'renderer/renderer_logging_mac_unittest.mm',
'renderer/renderer_main_unittest.cc', 'renderer/renderer_main_unittest.cc',
'test/browser_with_test_window_test.cc', 'test/browser_with_test_window_test.cc',
'test/browser_with_test_window_test.h', 'test/browser_with_test_window_test.h',
......
...@@ -2,35 +2,35 @@ ...@@ -2,35 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_RENDERER_RENDERER_LOGGING_H_ #ifndef CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
#define CHROME_RENDERER_RENDERER_LOGGING_H_ #define CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
#include "base/basictypes.h" #include "base/basictypes.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
namespace renderer_logging { namespace child_process_logging {
// Sets the URL that is logged if the renderer crashes. Use GURL() to clear // Sets the URL that is logged if the child process crashes. Use GURL() to clear
// the URL. // the URL.
void SetActiveRendererURL(const GURL& url); void SetActiveURL(const GURL& url);
// Simple wrapper class that sets the active rendering URL in it's constructor // Simple wrapper class that sets the active URL in it's constructor and clears
// and clears the active rendering URL in the destructor. // the active URL in the destructor.
class ScopedActiveRenderingURLSetter { class ScopedActiveURLSetter {
public: public:
explicit ScopedActiveRenderingURLSetter(const GURL& url) { explicit ScopedActiveURLSetter(const GURL& url) {
SetActiveRendererURL(url); SetActiveURL(url);
} }
~ScopedActiveRenderingURLSetter() { ~ScopedActiveURLSetter() {
SetActiveRendererURL(GURL()); SetActiveURL(GURL());
} }
private: private:
DISALLOW_COPY_AND_ASSIGN(ScopedActiveRenderingURLSetter); DISALLOW_COPY_AND_ASSIGN(ScopedActiveURLSetter);
}; };
} // namespace renderer_logging } // namespace child_process_logging
#if defined(OS_MACOSX) && __OBJC__ #if defined(OS_MACOSX) && __OBJC__
// Exported for testing purposes. // Exported for testing purposes.
...@@ -40,16 +40,16 @@ class ScopedActiveRenderingURLSetter { ...@@ -40,16 +40,16 @@ class ScopedActiveRenderingURLSetter {
typedef void (*SetCrashKeyValueFuncPtr)(NSString*, NSString*); typedef void (*SetCrashKeyValueFuncPtr)(NSString*, NSString*);
typedef void (*ClearCrashKeyValueFuncPtr)(NSString*); typedef void (*ClearCrashKeyValueFuncPtr)(NSString*);
namespace renderer_logging { namespace child_process_logging {
void SetActiveRendererURLImpl(const GURL& url, void SetActiveURLImpl(const GURL& url,
SetCrashKeyValueFuncPtr set_key_func, SetCrashKeyValueFuncPtr set_key_func,
ClearCrashKeyValueFuncPtr clear_key_func); ClearCrashKeyValueFuncPtr clear_key_func);
extern const int kMaxNumCrashURLChunks; extern const int kMaxNumCrashURLChunks;
extern const int kMaxNumURLChunkValueLength; extern const int kMaxNumURLChunkValueLength;
extern const char *kUrlChunkFormatStr; extern const char *kUrlChunkFormatStr;
} // namespace renderer_logging } // namespace child_process_logging
#endif // defined(OS_MACOSX) && __OBJC__ #endif // defined(OS_MACOSX) && __OBJC__
#endif // CHROME_RENDERER_RENDERER_LOGGING_H_ #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
...@@ -2,23 +2,21 @@ ...@@ -2,23 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/renderer/renderer_logging.h" #include "chrome/common/child_process_logging.h"
#include <string> #include <string>
#include "base/logging.h" #include "base/logging.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
namespace renderer_logging { namespace child_process_logging {
// We use a static string to hold the most recent active url. If we crash, the // We use a static string to hold the most recent active url. If we crash, the
// crash handler code will send the contents of this string to the browser. // crash handler code will send the contents of this string to the browser.
std::string active_url; std::string active_url;
// Sets the URL that is logged if the renderer crashes. Use GURL() to clear void SetActiveURL(const GURL& url) {
// the URL.
void SetActiveRendererURL(const GURL& url) {
active_url = url.possibly_invalid_spec(); active_url = url.possibly_invalid_spec();
} }
} // namespace renderer_logging } // namespace child_process_logging
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/renderer/renderer_logging.h" #include "chrome/common/child_process_logging.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#import "chrome/app/breakpad_mac.h" #import "chrome/app/breakpad_mac.h"
namespace renderer_logging { namespace child_process_logging {
const int kMaxNumCrashURLChunks = 8; const int kMaxNumCrashURLChunks = 8;
const int kMaxNumURLChunkValueLength = 255; const int kMaxNumURLChunkValueLength = 255;
const char *kUrlChunkFormatStr = "url-chunk-%d"; const char *kUrlChunkFormatStr = "url-chunk-%d";
void SetActiveRendererURLImpl(const GURL& url, void SetActiveURLImpl(const GURL& url,
SetCrashKeyValueFuncPtr set_key_func, SetCrashKeyValueFuncPtr set_key_func,
ClearCrashKeyValueFuncPtr clear_key_func) { ClearCrashKeyValueFuncPtr clear_key_func) {
NSString *kUrlChunkFormatStr_utf8 = [NSString NSString *kUrlChunkFormatStr_utf8 = [NSString
stringWithUTF8String:kUrlChunkFormatStr]; stringWithUTF8String:kUrlChunkFormatStr];
...@@ -59,13 +59,13 @@ void SetActiveRendererURLImpl(const GURL& url, ...@@ -59,13 +59,13 @@ void SetActiveRendererURLImpl(const GURL& url,
} }
} }
void SetActiveRendererURL(const GURL& url) { void SetActiveURL(const GURL& url) {
// If Breakpad isn't initialized then bail. // If Breakpad isn't initialized then bail.
if (IsCrashReporterDisabled()) { if (IsCrashReporterDisabled()) {
return; return;
} }
SetActiveRendererURLImpl(url, SetCrashKeyValue, ClearCrashKeyValue); SetActiveURLImpl(url, SetCrashKeyValue, ClearCrashKeyValue);
} }
} // namespace renderer_logging } // namespace child_process_logging
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/renderer/renderer_logging.h" #include "chrome/common/child_process_logging.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
typedef PlatformTest RendererLoggingTest; typedef PlatformTest ChildProcessLoggingTest;
namespace { namespace {
...@@ -48,9 +48,9 @@ class MockBreakpadKeyValueStore { ...@@ -48,9 +48,9 @@ class MockBreakpadKeyValueStore {
} }
bool VerifyDictionaryContents(const std::string &url) { bool VerifyDictionaryContents(const std::string &url) {
using renderer_logging::kMaxNumCrashURLChunks; using child_process_logging::kMaxNumCrashURLChunks;
using renderer_logging::kMaxNumURLChunkValueLength; using child_process_logging::kMaxNumURLChunkValueLength;
using renderer_logging::kUrlChunkFormatStr; using child_process_logging::kUrlChunkFormatStr;
int num_url_chunks = CountDictionaryEntries(); int num_url_chunks = CountDictionaryEntries();
EXPECT_TRUE(num_url_chunks <= kMaxNumCrashURLChunks); EXPECT_TRUE(num_url_chunks <= kMaxNumCrashURLChunks);
...@@ -80,21 +80,21 @@ class MockBreakpadKeyValueStore { ...@@ -80,21 +80,21 @@ class MockBreakpadKeyValueStore {
} // namespace } // namespace
// Call through to SetActiveRendererURLImpl using the functions from // Call through to SetActiveURLImpl using the functions from
// MockBreakpadKeyValueStore. // MockBreakpadKeyValueStore.
void SetActiveRendererURLWithMock(const GURL& url) { void SetActiveURLWithMock(const GURL& url) {
using renderer_logging::SetActiveRendererURLImpl; using child_process_logging::SetActiveURLImpl;
SetCrashKeyValueFuncPtr setFunc = MockBreakpadKeyValueStore::SetKeyValue; SetCrashKeyValueFuncPtr setFunc = MockBreakpadKeyValueStore::SetKeyValue;
ClearCrashKeyValueFuncPtr clearFunc = ClearCrashKeyValueFuncPtr clearFunc =
MockBreakpadKeyValueStore::ClearKeyValue; MockBreakpadKeyValueStore::ClearKeyValue;
SetActiveRendererURLImpl(url, setFunc, clearFunc); SetActiveURLImpl(url, setFunc, clearFunc);
} }
TEST_F(RendererLoggingTest, TestUrlSplitting) { TEST_F(ChildProcessLoggingTest, TestUrlSplitting) {
using renderer_logging::kMaxNumCrashURLChunks; using child_process_logging::kMaxNumCrashURLChunks;
using renderer_logging::kMaxNumURLChunkValueLength; using child_process_logging::kMaxNumURLChunkValueLength;
const std::string short_url("http://abc/"); const std::string short_url("http://abc/");
std::string long_url("http://"); std::string long_url("http://");
...@@ -110,29 +110,29 @@ TEST_F(RendererLoggingTest, TestUrlSplitting) { ...@@ -110,29 +110,29 @@ TEST_F(RendererLoggingTest, TestUrlSplitting) {
// Check that Clearing NULL URL works. // Check that Clearing NULL URL works.
MockBreakpadKeyValueStore mock; MockBreakpadKeyValueStore mock;
SetActiveRendererURLWithMock(GURL()); SetActiveURLWithMock(GURL());
EXPECT_EQ(mock.CountDictionaryEntries(), 0); EXPECT_EQ(mock.CountDictionaryEntries(), 0);
// Check that we can set a URL. // Check that we can set a URL.
SetActiveRendererURLWithMock(GURL(short_url.c_str())); SetActiveURLWithMock(GURL(short_url.c_str()));
EXPECT_TRUE(mock.VerifyDictionaryContents(short_url)); EXPECT_TRUE(mock.VerifyDictionaryContents(short_url));
EXPECT_EQ(mock.CountDictionaryEntries(), 1); EXPECT_EQ(mock.CountDictionaryEntries(), 1);
SetActiveRendererURLWithMock(GURL()); SetActiveURLWithMock(GURL());
EXPECT_EQ(mock.CountDictionaryEntries(), 0); EXPECT_EQ(mock.CountDictionaryEntries(), 0);
// Check that we can replace a long url with a short url. // Check that we can replace a long url with a short url.
SetActiveRendererURLWithMock(GURL(long_url.c_str())); SetActiveURLWithMock(GURL(long_url.c_str()));
EXPECT_TRUE(mock.VerifyDictionaryContents(long_url)); EXPECT_TRUE(mock.VerifyDictionaryContents(long_url));
SetActiveRendererURLWithMock(GURL(short_url.c_str())); SetActiveURLWithMock(GURL(short_url.c_str()));
EXPECT_TRUE(mock.VerifyDictionaryContents(short_url)); EXPECT_TRUE(mock.VerifyDictionaryContents(short_url));
SetActiveRendererURLWithMock(GURL()); SetActiveURLWithMock(GURL());
EXPECT_EQ(mock.CountDictionaryEntries(), 0); EXPECT_EQ(mock.CountDictionaryEntries(), 0);
// Check that overflow works correctly. // Check that overflow works correctly.
SetActiveRendererURLWithMock(GURL(overflow_url.c_str())); SetActiveURLWithMock(GURL(overflow_url.c_str()));
EXPECT_TRUE(mock.VerifyDictionaryContents( EXPECT_TRUE(mock.VerifyDictionaryContents(
overflow_url.substr(0, max_num_chars_stored_in_dump))); overflow_url.substr(0, max_num_chars_stored_in_dump)));
SetActiveRendererURLWithMock(GURL()); SetActiveURLWithMock(GURL());
EXPECT_EQ(mock.CountDictionaryEntries(), 0); EXPECT_EQ(mock.CountDictionaryEntries(), 0);
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/renderer/renderer_logging.h" #include "chrome/common/child_process_logging.h"
#include <windows.h> #include <windows.h>
...@@ -10,24 +10,22 @@ ...@@ -10,24 +10,22 @@
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
namespace renderer_logging { namespace child_process_logging {
typedef void (__cdecl *MainSetActiveRendererURL)(const wchar_t*); typedef void (__cdecl *MainSetActiveURL)(const wchar_t*);
// Sets the URL that is logged if the renderer crashes. Use GURL() to clear void SetActiveURL(const GURL& url) {
// the URL.
void SetActiveRendererURL(const GURL& url) {
HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
if (!exe_module) if (!exe_module)
return; return;
MainSetActiveRendererURL set_active_renderer_url = MainSetActiveURL set_active_url =
reinterpret_cast<MainSetActiveRendererURL>( reinterpret_cast<MainSetActiveURL>(
GetProcAddress(exe_module, "SetActiveRendererURL")); GetProcAddress(exe_module, "SetActiveURL"));
if (!set_active_renderer_url) if (!set_active_url)
return; return;
(set_active_renderer_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str()); (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str());
} }
} // namespace renderer_logging } // namespace child_process_logging
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
struct PluginMsg_Init_Params { struct PluginMsg_Init_Params {
gfx::NativeViewId containing_window; gfx::NativeViewId containing_window;
GURL url; GURL url;
GURL page_url;
std::vector<std::string> arg_names; std::vector<std::string> arg_names;
std::vector<std::string> arg_values; std::vector<std::string> arg_values;
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -109,6 +110,7 @@ struct ParamTraits<PluginMsg_Init_Params> { ...@@ -109,6 +110,7 @@ struct ParamTraits<PluginMsg_Init_Params> {
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, p.containing_window); WriteParam(m, p.containing_window);
WriteParam(m, p.url); WriteParam(m, p.url);
WriteParam(m, p.page_url);
DCHECK(p.arg_names.size() == p.arg_values.size()); DCHECK(p.arg_names.size() == p.arg_values.size());
WriteParam(m, p.arg_names); WriteParam(m, p.arg_names);
WriteParam(m, p.arg_values); WriteParam(m, p.arg_values);
...@@ -120,6 +122,7 @@ struct ParamTraits<PluginMsg_Init_Params> { ...@@ -120,6 +122,7 @@ struct ParamTraits<PluginMsg_Init_Params> {
static bool Read(const Message* m, void** iter, param_type* p) { static bool Read(const Message* m, void** iter, param_type* p) {
return ReadParam(m, iter, &p->containing_window) && return ReadParam(m, iter, &p->containing_window) &&
ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->url) &&
ReadParam(m, iter, &p->page_url) &&
ReadParam(m, iter, &p->arg_names) && ReadParam(m, iter, &p->arg_names) &&
ReadParam(m, iter, &p->arg_values) && ReadParam(m, iter, &p->arg_values) &&
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -133,6 +136,8 @@ struct ParamTraits<PluginMsg_Init_Params> { ...@@ -133,6 +136,8 @@ struct ParamTraits<PluginMsg_Init_Params> {
l->append(L", "); l->append(L", ");
LogParam(p.url, l); LogParam(p.url, l);
l->append(L", "); l->append(L", ");
LogParam(p.page_url, l);
l->append(L", ");
LogParam(p.arg_names, l); LogParam(p.arg_names, l);
l->append(L", "); l->append(L", ");
LogParam(p.arg_values, l); LogParam(p.arg_values, l);
......
...@@ -49,11 +49,13 @@ NPObjectProxy::NPObjectProxy( ...@@ -49,11 +49,13 @@ NPObjectProxy::NPObjectProxy(
PluginChannelBase* channel, PluginChannelBase* channel,
int route_id, int route_id,
intptr_t npobject_ptr, intptr_t npobject_ptr,
base::WaitableEvent* modal_dialog_event) base::WaitableEvent* modal_dialog_event,
const GURL& page_url)
: channel_(channel), : channel_(channel),
route_id_(route_id), route_id_(route_id),
npobject_ptr_(npobject_ptr), npobject_ptr_(npobject_ptr),
modal_dialog_event_(modal_dialog_event) { modal_dialog_event_(modal_dialog_event),
page_url_(page_url) {
channel_->AddRoute(route_id, this, true); channel_->AddRoute(route_id, this, true);
} }
...@@ -68,11 +70,12 @@ NPObjectProxy::~NPObjectProxy() { ...@@ -68,11 +70,12 @@ NPObjectProxy::~NPObjectProxy() {
NPObject* NPObjectProxy::Create(PluginChannelBase* channel, NPObject* NPObjectProxy::Create(PluginChannelBase* channel,
int route_id, int route_id,
intptr_t npobject_ptr, intptr_t npobject_ptr,
base::WaitableEvent* modal_dialog_event) { base::WaitableEvent* modal_dialog_event,
const GURL& page_url) {
NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>( NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>(
NPN_CreateObject(0, &npclass_proxy_)); NPN_CreateObject(0, &npclass_proxy_));
obj->proxy = new NPObjectProxy( obj->proxy = new NPObjectProxy(
channel, route_id, npobject_ptr, modal_dialog_event); channel, route_id, npobject_ptr, modal_dialog_event, page_url);
return reinterpret_cast<NPObject*>(obj); return reinterpret_cast<NPObject*>(obj);
} }
...@@ -166,7 +169,8 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp, ...@@ -166,7 +169,8 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp,
for (unsigned int i = 0; i < arg_count; ++i) { for (unsigned int i = 0; i < arg_count; ++i) {
NPVariant_Param param; NPVariant_Param param;
CreateNPVariantParam( CreateNPVariantParam(
args[i], channel_copy, &param, false, proxy->modal_dialog_event_); args[i], channel_copy, &param, false, proxy->modal_dialog_event_,
proxy->page_url_);
args_param.push_back(param); args_param.push_back(param);
} }
...@@ -184,6 +188,7 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp, ...@@ -184,6 +188,7 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp,
base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
GURL page_url = proxy->page_url_;
proxy->Send(msg); proxy->Send(msg);
// Send may delete proxy. // Send may delete proxy.
...@@ -193,7 +198,8 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp, ...@@ -193,7 +198,8 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp,
return false; return false;
CreateNPVariant( CreateNPVariant(
param_result, channel_copy, np_result, modal_dialog_event_handle); param_result, channel_copy, np_result, modal_dialog_event_handle,
page_url);
return true; return true;
} }
...@@ -243,6 +249,8 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj, ...@@ -243,6 +249,8 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj,
NPVariant_Param param; NPVariant_Param param;
base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
scoped_refptr<PluginChannelBase> channel(proxy->channel_); scoped_refptr<PluginChannelBase> channel(proxy->channel_);
GURL page_url = proxy->page_url_;
proxy->Send(new NPObjectMsg_GetProperty( proxy->Send(new NPObjectMsg_GetProperty(
proxy->route_id(), name_param, &param, &result)); proxy->route_id(), name_param, &param, &result));
// Send may delete proxy. // Send may delete proxy.
...@@ -251,7 +259,7 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj, ...@@ -251,7 +259,7 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj,
return false; return false;
CreateNPVariant( CreateNPVariant(
param, channel.get(), np_result, modal_dialog_event_handle); param, channel.get(), np_result, modal_dialog_event_handle, page_url);
return true; return true;
} }
...@@ -271,7 +279,7 @@ bool NPObjectProxy::NPSetProperty(NPObject *obj, ...@@ -271,7 +279,7 @@ bool NPObjectProxy::NPSetProperty(NPObject *obj,
NPVariant_Param value_param; NPVariant_Param value_param;
CreateNPVariantParam( CreateNPVariantParam(
*value, proxy->channel(), &value_param, false, *value, proxy->channel(), &value_param, false,
proxy->modal_dialog_event_); proxy->modal_dialog_event_, proxy->page_url_);
proxy->Send(new NPObjectMsg_SetProperty( proxy->Send(new NPObjectMsg_SetProperty(
proxy->route_id(), name_param, value_param, &result)); proxy->route_id(), name_param, value_param, &result));
...@@ -358,7 +366,8 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj, ...@@ -358,7 +366,8 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj,
for (unsigned int i = 0; i < arg_count; ++i) { for (unsigned int i = 0; i < arg_count; ++i) {
NPVariant_Param param; NPVariant_Param param;
CreateNPVariantParam( CreateNPVariantParam(
args[i], channel_copy, &param, false, proxy->modal_dialog_event_); args[i], channel_copy, &param, false, proxy->modal_dialog_event_,
proxy->page_url_);
args_param.push_back(param); args_param.push_back(param);
} }
...@@ -371,6 +380,7 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj, ...@@ -371,6 +380,7 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj,
base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
GURL page_url = proxy->page_url_;
proxy->Send(msg); proxy->Send(msg);
// Send may delete proxy. // Send may delete proxy.
...@@ -380,7 +390,8 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj, ...@@ -380,7 +390,8 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj,
return false; return false;
CreateNPVariant( CreateNPVariant(
param_result, channel_copy, np_result, modal_dialog_event_handle); param_result, channel_copy, np_result, modal_dialog_event_handle,
page_url);
return true; return true;
} }
...@@ -418,6 +429,8 @@ bool NPObjectProxy::NPNEvaluate(NPP npp, ...@@ -418,6 +429,8 @@ bool NPObjectProxy::NPNEvaluate(NPP npp,
msg->set_pump_messages_event(proxy->modal_dialog_event_); msg->set_pump_messages_event(proxy->modal_dialog_event_);
scoped_refptr<PluginChannelBase> channel(proxy->channel_); scoped_refptr<PluginChannelBase> channel(proxy->channel_);
base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
GURL page_url = proxy->page_url_;
proxy->Send(msg); proxy->Send(msg);
// Send may delete proxy. // Send may delete proxy.
proxy = NULL; proxy = NULL;
...@@ -425,7 +438,8 @@ bool NPObjectProxy::NPNEvaluate(NPP npp, ...@@ -425,7 +438,8 @@ bool NPObjectProxy::NPNEvaluate(NPP npp,
return false; return false;
CreateNPVariant( CreateNPVariant(
result_param, channel.get(), result_var, modal_dialog_event_handle); result_param, channel.get(), result_var, modal_dialog_event_handle,
page_url);
return true; return true;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "chrome/common/ipc_channel.h" #include "chrome/common/ipc_channel.h"
#include "googleurl/src/gurl.h"
#include "third_party/npapi/bindings/npruntime.h" #include "third_party/npapi/bindings/npruntime.h"
class PluginChannelBase; class PluginChannelBase;
...@@ -36,7 +37,8 @@ class NPObjectProxy : public IPC::Channel::Listener, ...@@ -36,7 +37,8 @@ class NPObjectProxy : public IPC::Channel::Listener,
static NPObject* Create(PluginChannelBase* channel, static NPObject* Create(PluginChannelBase* channel,
int route_id, int route_id,
intptr_t npobject_ptr, intptr_t npobject_ptr,
base::WaitableEvent* modal_dialog_event); base::WaitableEvent* modal_dialog_event,
const GURL& page_url);
// IPC::Message::Sender implementation: // IPC::Message::Sender implementation:
bool Send(IPC::Message* msg); bool Send(IPC::Message* msg);
...@@ -101,7 +103,8 @@ class NPObjectProxy : public IPC::Channel::Listener, ...@@ -101,7 +103,8 @@ class NPObjectProxy : public IPC::Channel::Listener,
NPObjectProxy(PluginChannelBase* channel, NPObjectProxy(PluginChannelBase* channel,
int route_id, int route_id,
intptr_t npobject_ptr, intptr_t npobject_ptr,
base::WaitableEvent* modal_dialog_event); base::WaitableEvent* modal_dialog_event,
const GURL& page_url);
// IPC::Channel::Listener implementation: // IPC::Channel::Listener implementation:
void OnMessageReceived(const IPC::Message& msg); void OnMessageReceived(const IPC::Message& msg);
...@@ -118,6 +121,9 @@ class NPObjectProxy : public IPC::Channel::Listener, ...@@ -118,6 +121,9 @@ class NPObjectProxy : public IPC::Channel::Listener,
int route_id_; int route_id_;
intptr_t npobject_ptr_; intptr_t npobject_ptr_;
base::WaitableEvent* modal_dialog_event_; base::WaitableEvent* modal_dialog_event_;
// The url of the main frame hosting the plugin.
GURL page_url_;
}; };
#endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_ #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/plugin/npobject_stub.h" #include "chrome/plugin/npobject_stub.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/plugin_messages.h" #include "chrome/common/plugin_messages.h"
#include "chrome/plugin/npobject_util.h" #include "chrome/plugin/npobject_util.h"
#include "chrome/plugin/plugin_channel_base.h" #include "chrome/plugin/plugin_channel_base.h"
...@@ -15,13 +16,15 @@ NPObjectStub::NPObjectStub( ...@@ -15,13 +16,15 @@ NPObjectStub::NPObjectStub(
NPObject* npobject, NPObject* npobject,
PluginChannelBase* channel, PluginChannelBase* channel,
int route_id, int route_id,
base::WaitableEvent* modal_dialog_event) base::WaitableEvent* modal_dialog_event,
const GURL& page_url)
: npobject_(npobject), : npobject_(npobject),
channel_(channel), channel_(channel),
route_id_(route_id), route_id_(route_id),
valid_(true), valid_(true),
web_plugin_delegate_proxy_(NULL), web_plugin_delegate_proxy_(NULL),
modal_dialog_event_(modal_dialog_event) { modal_dialog_event_(modal_dialog_event),
page_url_(page_url) {
channel_->AddRoute(route_id, this, true); channel_->AddRoute(route_id, this, true);
// We retain the object just as PluginHost does if everything was in-process. // We retain the object just as PluginHost does if everything was in-process.
...@@ -42,6 +45,8 @@ bool NPObjectStub::Send(IPC::Message* msg) { ...@@ -42,6 +45,8 @@ bool NPObjectStub::Send(IPC::Message* msg) {
} }
void NPObjectStub::OnMessageReceived(const IPC::Message& msg) { void NPObjectStub::OnMessageReceived(const IPC::Message& msg) {
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
if (!valid_) { if (!valid_) {
if (msg.is_sync()) { if (msg.is_sync()) {
// The object could be garbage because the frame has gone away, so // The object could be garbage because the frame has gone away, so
...@@ -117,7 +122,8 @@ void NPObjectStub::OnInvoke(bool is_default, ...@@ -117,7 +122,8 @@ void NPObjectStub::OnInvoke(bool is_default,
NPVariant* args_var = new NPVariant[arg_count]; NPVariant* args_var = new NPVariant[arg_count];
for (int i = 0; i < arg_count; ++i) { for (int i = 0; i < arg_count; ++i) {
CreateNPVariant( CreateNPVariant(
args[i], local_channel, &(args_var[i]), modal_dialog_event_); args[i], local_channel, &(args_var[i]), modal_dialog_event_,
page_url_);
} }
if (is_default) { if (is_default) {
...@@ -153,7 +159,8 @@ void NPObjectStub::OnInvoke(bool is_default, ...@@ -153,7 +159,8 @@ void NPObjectStub::OnInvoke(bool is_default,
delete[] args_var; delete[] args_var;
CreateNPVariantParam( CreateNPVariantParam(
result_var, local_channel, &result_param, true, modal_dialog_event_); result_var, local_channel, &result_param, true, modal_dialog_event_,
page_url_);
NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value); NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value);
local_channel->Send(reply_msg); local_channel->Send(reply_msg);
} }
...@@ -190,7 +197,7 @@ void NPObjectStub::OnGetProperty(const NPIdentifier_Param& name, ...@@ -190,7 +197,7 @@ void NPObjectStub::OnGetProperty(const NPIdentifier_Param& name,
} }
CreateNPVariantParam( CreateNPVariantParam(
result_var, channel_, property, true, modal_dialog_event_); result_var, channel_, property, true, modal_dialog_event_, page_url_);
} }
void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name, void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name,
...@@ -200,7 +207,8 @@ void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name, ...@@ -200,7 +207,8 @@ void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name,
VOID_TO_NPVARIANT(result_var); VOID_TO_NPVARIANT(result_var);
NPIdentifier id = CreateNPIdentifier(name); NPIdentifier id = CreateNPIdentifier(name);
NPVariant property_var; NPVariant property_var;
CreateNPVariant(property, channel_, &property_var, modal_dialog_event_); CreateNPVariant(
property, channel_, &property_var, modal_dialog_event_, page_url_);
if (IsPluginProcess()) { if (IsPluginProcess()) {
if (npobject_->_class->setProperty) { if (npobject_->_class->setProperty) {
...@@ -281,7 +289,7 @@ void NPObjectStub::OnConstruct(const std::vector<NPVariant_Param>& args, ...@@ -281,7 +289,7 @@ void NPObjectStub::OnConstruct(const std::vector<NPVariant_Param>& args,
NPVariant* args_var = new NPVariant[arg_count]; NPVariant* args_var = new NPVariant[arg_count];
for (int i = 0; i < arg_count; ++i) { for (int i = 0; i < arg_count; ++i) {
CreateNPVariant( CreateNPVariant(
args[i], local_channel, &(args_var[i]), modal_dialog_event_); args[i], local_channel, &(args_var[i]), modal_dialog_event_, page_url_);
} }
if (IsPluginProcess()) { if (IsPluginProcess()) {
...@@ -302,7 +310,8 @@ void NPObjectStub::OnConstruct(const std::vector<NPVariant_Param>& args, ...@@ -302,7 +310,8 @@ void NPObjectStub::OnConstruct(const std::vector<NPVariant_Param>& args,
delete[] args_var; delete[] args_var;
CreateNPVariantParam( CreateNPVariantParam(
result_var, local_channel, &result_param, true, modal_dialog_event_); result_var, local_channel, &result_param, true, modal_dialog_event_,
page_url_);
NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value); NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value);
local_channel->Send(reply_msg); local_channel->Send(reply_msg);
} }
...@@ -331,7 +340,8 @@ void NPObjectStub::OnEvaluate(const std::string& script, ...@@ -331,7 +340,8 @@ void NPObjectStub::OnEvaluate(const std::string& script,
NPVariant_Param result_param; NPVariant_Param result_param;
CreateNPVariantParam( CreateNPVariantParam(
result_var, local_channel, &result_param, true, modal_dialog_event_); result_var, local_channel, &result_param, true, modal_dialog_event_,
page_url_);
NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value); NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value);
local_channel->Send(reply_msg); local_channel->Send(reply_msg);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "chrome/common/ipc_channel.h" #include "chrome/common/ipc_channel.h"
#include "googleurl/src/gurl.h"
namespace base { namespace base {
class WaitableEvent; class WaitableEvent;
...@@ -32,7 +33,8 @@ class NPObjectStub : public IPC::Channel::Listener, ...@@ -32,7 +33,8 @@ class NPObjectStub : public IPC::Channel::Listener,
NPObjectStub(NPObject* npobject, NPObjectStub(NPObject* npobject,
PluginChannelBase* channel, PluginChannelBase* channel,
int route_id, int route_id,
base::WaitableEvent* modal_dialog_event); base::WaitableEvent* modal_dialog_event,
const GURL& page_url);
~NPObjectStub(); ~NPObjectStub();
// IPC::Message::Sender implementation: // IPC::Message::Sender implementation:
...@@ -90,6 +92,9 @@ class NPObjectStub : public IPC::Channel::Listener, ...@@ -90,6 +92,9 @@ class NPObjectStub : public IPC::Channel::Listener,
WebPluginDelegateProxy* web_plugin_delegate_proxy_; WebPluginDelegateProxy* web_plugin_delegate_proxy_;
base::WaitableEvent* modal_dialog_event_; base::WaitableEvent* modal_dialog_event_;
// The url of the main frame hosting the plugin.
GURL page_url_;
}; };
#endif // CHROME_PLUGIN_NPOBJECT_STUB_H_ #endif // CHROME_PLUGIN_NPOBJECT_STUB_H_
...@@ -138,7 +138,8 @@ void CreateNPVariantParam(const NPVariant& variant, ...@@ -138,7 +138,8 @@ void CreateNPVariantParam(const NPVariant& variant,
PluginChannelBase* channel, PluginChannelBase* channel,
NPVariant_Param* param, NPVariant_Param* param,
bool release, bool release,
base::WaitableEvent* modal_dialog_event) { base::WaitableEvent* modal_dialog_event,
const GURL& page_url) {
switch (variant.type) { switch (variant.type) {
case NPVariantType_Void: case NPVariantType_Void:
param->type = NPVARIANT_PARAM_VOID; param->type = NPVARIANT_PARAM_VOID;
...@@ -183,7 +184,8 @@ void CreateNPVariantParam(const NPVariant& variant, ...@@ -183,7 +184,8 @@ void CreateNPVariantParam(const NPVariant& variant,
param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID;
int route_id = channel->GenerateRouteID(); int route_id = channel->GenerateRouteID();
new NPObjectStub( new NPObjectStub(
variant.value.objectValue, channel, route_id, modal_dialog_event); variant.value.objectValue, channel, route_id, modal_dialog_event,
page_url);
param->npobject_routing_id = route_id; param->npobject_routing_id = route_id;
param->npobject_pointer = param->npobject_pointer =
reinterpret_cast<intptr_t>(variant.value.objectValue); reinterpret_cast<intptr_t>(variant.value.objectValue);
...@@ -204,7 +206,8 @@ void CreateNPVariantParam(const NPVariant& variant, ...@@ -204,7 +206,8 @@ void CreateNPVariantParam(const NPVariant& variant,
void CreateNPVariant(const NPVariant_Param& param, void CreateNPVariant(const NPVariant_Param& param,
PluginChannelBase* channel, PluginChannelBase* channel,
NPVariant* result, NPVariant* result,
base::WaitableEvent* modal_dialog_event) { base::WaitableEvent* modal_dialog_event,
const GURL& page_url) {
switch (param.type) { switch (param.type) {
case NPVARIANT_PARAM_VOID: case NPVARIANT_PARAM_VOID:
result->type = NPVariantType_Void; result->type = NPVariantType_Void;
...@@ -237,7 +240,8 @@ void CreateNPVariant(const NPVariant_Param& param, ...@@ -237,7 +240,8 @@ void CreateNPVariant(const NPVariant_Param& param,
NPObjectProxy::Create(channel, NPObjectProxy::Create(channel,
param.npobject_routing_id, param.npobject_routing_id,
param.npobject_pointer, param.npobject_pointer,
modal_dialog_event); modal_dialog_event,
page_url);
break; break;
case NPVARIANT_PARAM_OBJECT_POINTER: case NPVARIANT_PARAM_OBJECT_POINTER:
result->type = NPVariantType_Object; result->type = NPVariantType_Object;
......
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
#include "chrome/plugin/npobject_stub.h" #include "chrome/plugin/npobject_stub.h"
struct _NPVariant; class GURL;
typedef _NPVariant NPVariant;
class NPObjectProxy; class NPObjectProxy;
class PluginChannelBase; class PluginChannelBase;
struct _NPVariant;
struct NPIdentifier_Param; struct NPIdentifier_Param;
struct NPVariant_Param; struct NPVariant_Param;
typedef _NPVariant NPVariant;
typedef void *NPIdentifier; typedef void *NPIdentifier;
namespace base { namespace base {
...@@ -50,13 +53,15 @@ void CreateNPVariantParam(const NPVariant& variant, ...@@ -50,13 +53,15 @@ void CreateNPVariantParam(const NPVariant& variant,
PluginChannelBase* channel, PluginChannelBase* channel,
NPVariant_Param* param, NPVariant_Param* param,
bool release, bool release,
base::WaitableEvent* modal_dialog_event); base::WaitableEvent* modal_dialog_event,
const GURL& page_url);
// Creates an NPVariant from the marshalled object. // Creates an NPVariant from the marshalled object.
void CreateNPVariant(const NPVariant_Param& param, void CreateNPVariant(const NPVariant_Param& param,
PluginChannelBase* channel, PluginChannelBase* channel,
NPVariant* result, NPVariant* result,
base::WaitableEvent* modal_dialog_event); base::WaitableEvent* modal_dialog_event,
const GURL& page_url);
#if defined(OS_WIN) #if defined(OS_WIN)
// Given a plugin's HWND, returns an event associated with the TabContents // Given a plugin's HWND, returns an event associated with the TabContents
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/plugin_messages.h" #include "chrome/common/plugin_messages.h"
#include "chrome/plugin/npobject_stub.h" #include "chrome/plugin/npobject_stub.h"
...@@ -49,6 +50,8 @@ WebPluginDelegateStub::WebPluginDelegateStub( ...@@ -49,6 +50,8 @@ WebPluginDelegateStub::WebPluginDelegateStub(
} }
WebPluginDelegateStub::~WebPluginDelegateStub() { WebPluginDelegateStub::~WebPluginDelegateStub() {
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
if (channel_->in_send()) { if (channel_->in_send()) {
// The delegate or an npobject is in the callstack, so don't delete it // The delegate or an npobject is in the callstack, so don't delete it
// right away. // right away.
...@@ -64,6 +67,8 @@ WebPluginDelegateStub::~WebPluginDelegateStub() { ...@@ -64,6 +67,8 @@ WebPluginDelegateStub::~WebPluginDelegateStub() {
} }
void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) {
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
// A plugin can execute a script to delete itself in any of its NPP methods. // A plugin can execute a script to delete itself in any of its NPP methods.
// Hold an extra reference to ourself so that if this does occur and we're // Hold an extra reference to ourself so that if this does occur and we're
// handling a sync message, we don't crash when attempting to send a reply. // handling a sync message, we don't crash when attempting to send a reply.
...@@ -110,6 +115,9 @@ bool WebPluginDelegateStub::Send(IPC::Message* msg) { ...@@ -110,6 +115,9 @@ bool WebPluginDelegateStub::Send(IPC::Message* msg) {
void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
bool* result) { bool* result) {
page_url_ = params.page_url;
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
*result = false; *result = false;
int argc = static_cast<int>(params.arg_names.size()); int argc = static_cast<int>(params.arg_names.size());
if (argc != static_cast<int>(params.arg_values.size())) { if (argc != static_cast<int>(params.arg_values.size())) {
...@@ -139,7 +147,8 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, ...@@ -139,7 +147,8 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
delegate_ = WebPluginDelegate::Create(path, mime_type_, parent); delegate_ = WebPluginDelegate::Create(path, mime_type_, parent);
if (delegate_) { if (delegate_) {
webplugin_ = new WebPluginProxy(channel_, instance_id_, delegate_); webplugin_ = new WebPluginProxy(
channel_, instance_id_, delegate_, page_url_);
#if defined(OS_WIN) #if defined(OS_WIN)
if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event)) if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event))
return; return;
...@@ -278,7 +287,8 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, ...@@ -278,7 +287,8 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id,
// The stub will delete itself when the proxy tells it that it's released, or // The stub will delete itself when the proxy tells it that it's released, or
// otherwise when the channel is closed. // otherwise when the channel is closed.
new NPObjectStub( new NPObjectStub(
object, channel_.get(), *route_id, webplugin_->modal_dialog_event()); object, channel_.get(), *route_id, webplugin_->modal_dialog_event(),
page_url_);
// Release ref added by GetPluginScriptableObject (our stub holds its own). // Release ref added by GetPluginScriptableObject (our stub holds its own).
NPN_ReleaseObject(object); NPN_ReleaseObject(object);
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include "base/task.h" #include "base/task.h"
#include "chrome/common/ipc_channel.h" #include "chrome/common/ipc_channel.h"
#include "chrome/common/transport_dib.h" #include "chrome/common/transport_dib.h"
#include "googleurl/src/gurl.h"
#include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npapi.h"
class GURL;
class PluginChannel; class PluginChannel;
class WebPluginProxy; class WebPluginProxy;
class WebPluginDelegate; class WebPluginDelegate;
...@@ -105,6 +105,9 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, ...@@ -105,6 +105,9 @@ class WebPluginDelegateStub : public IPC::Channel::Listener,
WebPluginDelegate* delegate_; WebPluginDelegate* delegate_;
WebPluginProxy* webplugin_; WebPluginProxy* webplugin_;
// The url of the main frame hosting the plugin.
GURL page_url_;
DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub); DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub);
}; };
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/singleton.h" #include "base/singleton.h"
#include "base/waitable_event.h" #include "base/waitable_event.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/plugin_messages.h" #include "chrome/common/plugin_messages.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/npobject_proxy.h"
...@@ -35,7 +36,8 @@ static ContextMap& GetContextMap() { ...@@ -35,7 +36,8 @@ static ContextMap& GetContextMap() {
WebPluginProxy::WebPluginProxy( WebPluginProxy::WebPluginProxy(
PluginChannel* channel, PluginChannel* channel,
int route_id, int route_id,
WebPluginDelegate* delegate) WebPluginDelegate* delegate,
const GURL& page_url)
: channel_(channel), : channel_(channel),
route_id_(route_id), route_id_(route_id),
cp_browsing_context_(0), cp_browsing_context_(0),
...@@ -43,6 +45,7 @@ WebPluginProxy::WebPluginProxy( ...@@ -43,6 +45,7 @@ WebPluginProxy::WebPluginProxy(
plugin_element_(NULL), plugin_element_(NULL),
delegate_(delegate), delegate_(delegate),
waiting_for_paint_(false), waiting_for_paint_(false),
page_url_(page_url),
ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this))
{ {
} }
...@@ -159,10 +162,9 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() { ...@@ -159,10 +162,9 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() {
if (!success) if (!success)
return NULL; return NULL;
window_npobject_ = NPObjectProxy::Create(channel_, window_npobject_ = NPObjectProxy::Create(
npobject_route_id, channel_, npobject_route_id, npobject_ptr, modal_dialog_event_.get(),
npobject_ptr, page_url_);
modal_dialog_event_.get());
return window_npobject_; return window_npobject_;
} }
...@@ -179,10 +181,9 @@ NPObject* WebPluginProxy::GetPluginElement() { ...@@ -179,10 +181,9 @@ NPObject* WebPluginProxy::GetPluginElement() {
if (!success) if (!success)
return NULL; return NULL;
plugin_element_ = NPObjectProxy::Create(channel_, plugin_element_ = NPObjectProxy::Create(
npobject_route_id, channel_, npobject_route_id, npobject_ptr, modal_dialog_event_.get(),
npobject_ptr, page_url_);
modal_dialog_event_.get());
return plugin_element_; return plugin_element_;
} }
...@@ -518,6 +519,8 @@ void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, ...@@ -518,6 +519,8 @@ void WebPluginProxy::InitiateHTTPRangeRequest(const char* url,
} }
void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) {
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
Paint(damaged_rect); Paint(damaged_rect);
Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect));
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message.h"
#include "chrome/common/chrome_plugin_api.h" #include "chrome/common/chrome_plugin_api.h"
#include "chrome/common/transport_dib.h" #include "chrome/common/transport_dib.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/webplugin.h" #include "webkit/glue/webplugin.h"
namespace base { namespace base {
...@@ -33,7 +34,8 @@ class WebPluginProxy : public WebPlugin { ...@@ -33,7 +34,8 @@ class WebPluginProxy : public WebPlugin {
// marshalled WebPlugin calls. // marshalled WebPlugin calls.
WebPluginProxy(PluginChannel* channel, WebPluginProxy(PluginChannel* channel,
int route_id, int route_id,
WebPluginDelegate* delegate); WebPluginDelegate* delegate,
const GURL& page_url);
~WebPluginProxy(); ~WebPluginProxy();
// WebPlugin overrides // WebPlugin overrides
...@@ -156,6 +158,8 @@ class WebPluginProxy : public WebPlugin { ...@@ -156,6 +158,8 @@ class WebPluginProxy : public WebPlugin {
gfx::Rect damaged_rect_; gfx::Rect damaged_rect_;
bool waiting_for_paint_; bool waiting_for_paint_;
scoped_ptr<base::WaitableEvent> modal_dialog_event_; scoped_ptr<base::WaitableEvent> modal_dialog_event_;
// The url of the main frame hosting the plugin.
GURL page_url_;
#if defined(OS_WIN) #if defined(OS_WIN)
// Variables used for desynchronized windowless plugin painting. See note in // Variables used for desynchronized windowless plugin painting. See note in
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "base/string_util.h" #include "base/string_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/bindings_policy.h" #include "chrome/common/bindings_policy.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/jstemplate_builder.h" #include "chrome/common/jstemplate_builder.h"
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
#include "chrome/renderer/navigation_state.h" #include "chrome/renderer/navigation_state.h"
#include "chrome/renderer/print_web_view_helper.h" #include "chrome/renderer/print_web_view_helper.h"
#include "chrome/renderer/render_process.h" #include "chrome/renderer/render_process.h"
#include "chrome/renderer/renderer_logging.h"
#include "chrome/renderer/user_script_slave.h" #include "chrome/renderer/user_script_slave.h"
#include "chrome/renderer/visitedlink_slave.h" #include "chrome/renderer/visitedlink_slave.h"
#include "chrome/renderer/webplugin_delegate_proxy.h" #include "chrome/renderer/webplugin_delegate_proxy.h"
...@@ -325,7 +325,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd, ...@@ -325,7 +325,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
void RenderView::OnMessageReceived(const IPC::Message& message) { void RenderView::OnMessageReceived(const IPC::Message& message) {
WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL;
renderer_logging::ScopedActiveRenderingURLSetter url_setter( child_process_logging::ScopedActiveURLSetter url_setter(
main_frame ? main_frame->GetURL() : GURL()); main_frame ? main_frame->GetURL() : GURL());
// If this is developer tools renderer intercept tools messages first. // If this is developer tools renderer intercept tools messages first.
...@@ -626,7 +626,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { ...@@ -626,7 +626,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) {
if (!webview()) if (!webview())
return; return;
renderer_logging::ScopedActiveRenderingURLSetter url_setter(params.url); child_process_logging::ScopedActiveURLSetter url_setter(params.url);
AboutHandler::MaybeHandle(params.url); AboutHandler::MaybeHandle(params.url);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/gfx/size.h" #include "base/gfx/size.h"
#include "base/gfx/native_widget_types.h" #include "base/gfx/native_widget_types.h"
#include "chrome/app/chrome_dll_resource.h" #include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/plugin_messages.h" #include "chrome/common/plugin_messages.h"
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
#include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/npobject_proxy.h"
...@@ -26,7 +27,6 @@ ...@@ -26,7 +27,6 @@
#include "chrome/plugin/npobject_util.h" #include "chrome/plugin/npobject_util.h"
#include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h" #include "chrome/renderer/render_view.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "printing/native_metafile.h" #include "printing/native_metafile.h"
...@@ -170,7 +170,8 @@ WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, ...@@ -170,7 +170,8 @@ WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type,
window_script_object_(NULL), window_script_object_(NULL),
sad_plugin_(NULL), sad_plugin_(NULL),
invalidate_pending_(false), invalidate_pending_(false),
transparent_(false) { transparent_(false),
page_url_(render_view_->webview()->GetMainFrame()->GetURL()) {
} }
WebPluginDelegateProxy::~WebPluginDelegateProxy() { WebPluginDelegateProxy::~WebPluginDelegateProxy() {
...@@ -245,6 +246,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, ...@@ -245,6 +246,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn,
PluginMsg_Init_Params params; PluginMsg_Init_Params params;
params.containing_window = render_view_->host_window(); params.containing_window = render_view_->host_window();
params.url = url; params.url = url;
params.page_url = page_url_;
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
params.arg_names.push_back(argn[i]); params.arg_names.push_back(argn[i]);
params.arg_values.push_back(argv[i]); params.arg_values.push_back(argv[i]);
...@@ -329,6 +331,8 @@ void WebPluginDelegateProxy::InstallMissingPlugin() { ...@@ -329,6 +331,8 @@ void WebPluginDelegateProxy::InstallMissingPlugin() {
} }
void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) {
child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg)
IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow)
#if defined(OS_LINUX) #if defined(OS_LINUX)
...@@ -608,7 +612,7 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { ...@@ -608,7 +612,7 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() {
npobject_ = NPObjectProxy::Create( npobject_ = NPObjectProxy::Create(
channel_host_.get(), route_id, npobject_ptr, channel_host_.get(), route_id, npobject_ptr,
render_view_->modal_dialog_event()); render_view_->modal_dialog_event(), page_url_);
return NPN_RetainObject(npobject_); return NPN_RetainObject(npobject_);
} }
...@@ -698,7 +702,7 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject( ...@@ -698,7 +702,7 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject(
// otherwise when the channel is closed. // otherwise when the channel is closed.
NPObjectStub* stub = new NPObjectStub( NPObjectStub* stub = new NPObjectStub(
npobject, channel_host_.get(), route_id, npobject, channel_host_.get(), route_id,
render_view_->modal_dialog_event()); render_view_->modal_dialog_event(), page_url_);
window_script_object_ = stub; window_script_object_ = stub;
window_script_object_->set_proxy(this); window_script_object_->set_proxy(this);
*success = true; *success = true;
...@@ -718,7 +722,7 @@ void WebPluginDelegateProxy::OnGetPluginElement( ...@@ -718,7 +722,7 @@ void WebPluginDelegateProxy::OnGetPluginElement(
// otherwise when the channel is closed. // otherwise when the channel is closed.
new NPObjectStub( new NPObjectStub(
npobject, channel_host_.get(), route_id, npobject, channel_host_.get(), route_id,
render_view_->modal_dialog_event()); render_view_->modal_dialog_event(), page_url_);
*success = true; *success = true;
*npobject_ptr = reinterpret_cast<intptr_t>(npobject); *npobject_ptr = reinterpret_cast<intptr_t>(npobject);
} }
...@@ -809,7 +813,8 @@ void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object, ...@@ -809,7 +813,8 @@ void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object,
for (size_t i = 0; i < arraysize(results); ++i) { for (size_t i = 0; i < arraysize(results); ++i) {
values->push_back(NPVariant_Param()); values->push_back(NPVariant_Param());
CreateNPVariantParam(results[i], NULL, &values->back(), false, NULL); CreateNPVariantParam(
results[i], NULL, &values->back(), false, NULL, page_url_);
} }
*success = true; *success = true;
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "chrome/common/ipc_message.h" #include "chrome/common/ipc_message.h"
#include "chrome/renderer/plugin_channel_host.h" #include "chrome/renderer/plugin_channel_host.h"
#include "googleurl/src/gurl.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "webkit/glue/webplugin.h" #include "webkit/glue/webplugin.h"
#include "webkit/glue/webplugin_delegate.h" #include "webkit/glue/webplugin_delegate.h"
class GURL;
struct NPObject; struct NPObject;
class NPObjectStub; class NPObjectStub;
struct NPVariant_Param; struct NPVariant_Param;
...@@ -204,6 +204,9 @@ class WebPluginDelegateProxy : public WebPluginDelegate, ...@@ -204,6 +204,9 @@ class WebPluginDelegateProxy : public WebPluginDelegate,
// This lets us know which portion of the backing store has been painted into. // This lets us know which portion of the backing store has been painted into.
gfx::Rect backing_store_painted_; gfx::Rect backing_store_painted_;
// The url of the main frame hosting the plugin.
GURL page_url_;
DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy); DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment