summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:08:04 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:08:04 +0000
commitd55aaa139da94452ebd6812bfa9241ba050978d9 (patch)
treec5fd3ad94b96114b9109fc92610cae3b9688014b /chrome/browser
parent50e8299eb26f3a289c35badb7e740eb109981cd1 (diff)
downloadchromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.zip
chromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.tar.gz
chromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.tar.bz2
Implement about:ipc dialog for Mac.
Convert IPC logging trigger from x-process waitable event to a messages sent to all processes. Review URL: http://codereview.chromium.org/192070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_about_handler.cc14
-rw-r--r--chrome/browser/browser_process.h8
-rw-r--r--chrome/browser/browser_process_impl.cc47
-rw-r--r--chrome/browser/browser_process_impl.h9
-rw-r--r--chrome/browser/cocoa/about_ipc_bridge.h32
-rw-r--r--chrome/browser/cocoa/about_ipc_bridge.mm21
-rw-r--r--chrome/browser/cocoa/about_ipc_controller.h83
-rw-r--r--chrome/browser/cocoa/about_ipc_controller.mm198
-rw-r--r--chrome/browser/cocoa/about_ipc_controller_unittest.mm51
-rw-r--r--chrome/browser/cocoa/about_ipc_dialog.h23
-rw-r--r--chrome/browser/cocoa/about_ipc_dialog.mm21
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc8
-rw-r--r--chrome/browser/sandbox_policy.cc16
-rw-r--r--chrome/browser/views/about_ipc_dialog.cc4
14 files changed, 512 insertions, 23 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 9f17f77..372b7ff 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -50,6 +50,8 @@
#include "chrome/browser/views/about_network_dialog.h"
#elif defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/chromeos_version_loader.h"
+#elif defined(OS_MACOSX)
+#include "chrome/browser/cocoa/about_ipc_dialog.h"
#endif
#if defined(USE_TCMALLOC)
@@ -845,14 +847,17 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) {
bool HandleNonNavigationAboutURL(const GURL& url) {
// About:network and IPC and currently buggy, so we disable it for official
// builds.
-#if defined(OS_WIN) && !defined(OFFICIAL_BUILD)
+#if !defined(OFFICIAL_BUILD)
+
+#if defined(OS_WIN)
if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUINetworkURL)) {
// Run the dialog. This will re-use the existing one if it's already up.
AboutNetworkDialog::RunDialog();
return true;
}
+#endif
-#ifdef IPC_MESSAGE_LOG_ENABLED
+#if !defined(OS_LINUX) && defined(IPC_MESSAGE_LOG_ENABLED)
if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) {
// Run the dialog. This will re-use the existing one if it's already up.
AboutIPCDialog::RunDialog();
@@ -860,8 +865,7 @@ bool HandleNonNavigationAboutURL(const GURL& url) {
}
#endif
-#else
- // TODO(port) Implement this.
-#endif
+#endif // OFFICIAL_BUILD
+
return false;
}
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index ef3b6d7..ff41250 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -14,6 +14,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "ipc/ipc_message.h"
class AutomationProviderList;
class Clipboard;
@@ -153,6 +154,13 @@ class BrowserProcess {
// case, we default to returning true.
virtual bool have_inspector_files() const = 0;
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ // Enable or disable IPC logging for the browser, all processes
+ // derived from ChildProcess (plugin etc), and all
+ // renderers.
+ virtual void SetIPCLoggingEnabled(bool enable) = 0;
+#endif
+
private:
// User-data-dir based profiles.
std::vector<std::wstring> user_data_dir_profiles_;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index f971e80..d842ede 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -32,6 +32,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "ipc/ipc_logging.h"
#if defined(OS_WIN)
#include "chrome/browser/automation/automation_provider_list.h"
@@ -42,6 +43,11 @@
#include "chrome/common/temp_scaffolding_stubs.h"
#endif
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+#include "chrome/common/plugin_messages.h"
+#include "chrome/common/render_messages.h"
+#endif
+
namespace {
// ----------------------------------------------------------------------------
@@ -452,6 +458,47 @@ void BrowserProcessImpl::CheckForInspectorFiles() {
NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
}
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
+ // First enable myself.
+ if (enable)
+ IPC::Logging::current()->Enable();
+ else
+ IPC::Logging::current()->Disable();
+
+ // Now tell subprocesses. Messages to ChildProcess-derived
+ // processes must be done on the IO thread.
+ io_thread()->message_loop()->PostTask
+ (FROM_HERE,
+ NewRunnableMethod(
+ this,
+ &BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses,
+ enable));
+
+ // Finally, tell the renderers which don't derive from ChildProcess.
+ // Messages to the renderers must be done on the UI (main) thread.
+ RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
+ for (RenderProcessHost* host = i.GetCurrentValue();
+ !i.IsAtEnd();
+ i.Advance()) {
+ host->Send(new ViewMsg_SetIPCLoggingEnabled(enable));
+ }
+}
+
+// Helper for SetIPCLoggingEnabled.
+void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
+ DCHECK(MessageLoop::current() ==
+ ChromeThread::GetMessageLoop(ChromeThread::IO));
+
+ ChildProcessHost::Iterator i; // default constr references a singleton
+ for (ChildProcessHost* host = *i; !i.Done(); ++i) {
+ host->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
+ }
+}
+
+#endif // IPC_MESSAGE_LOG_ENABLED
+
void BrowserProcessImpl::DoInspectorFilesCheck() {
// Runs on FILE thread.
DCHECK(file_thread_->message_loop() == MessageLoop::current());
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 5bf3509..4f094dd 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -19,6 +19,7 @@
#include "chrome/browser/automation/automation_provider_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
+#include "ipc/ipc_message.h"
#if defined(OS_WIN)
#include "sandbox/src/sandbox.h"
@@ -197,6 +198,10 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
return have_inspector_files_;
}
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ virtual void SetIPCLoggingEnabled(bool enable);
+#endif
+
private:
void CreateResourceDispatcherHost();
void CreatePrefService();
@@ -222,6 +227,10 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
void InitBrokerServices(sandbox::BrokerServices* broker_services);
#endif // defined(OS_WIN)
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ void SetIPCLoggingEnabledForChildProcesses(bool enabled);
+#endif
+
bool created_resource_dispatcher_host_;
scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
diff --git a/chrome/browser/cocoa/about_ipc_bridge.h b/chrome/browser/cocoa/about_ipc_bridge.h
new file mode 100644
index 0000000..6ac1ec0
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_bridge.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_ABOUT_IPC_BRIDGE_H_
+#define CHROME_BROWSER_COCOA_ABOUT_IPC_BRIDGE_H_
+
+#include "ipc/ipc_logging.h"
+#include "ipc/ipc_message_utils.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+@class AboutIPCController;
+
+// On Windows, the AboutIPCDialog is a views::View. On Mac we have a
+// Cocoa dialog. This class bridges from C++ to ObjC.
+class AboutIPCBridge : public IPC::Logging::Consumer {
+ public:
+ AboutIPCBridge(AboutIPCController* controller) : controller_(controller) { }
+ virtual ~AboutIPCBridge() { }
+
+ // IPC::Logging::Consumer implementation.
+ virtual void Log(const IPC::LogData& data);
+
+ private:
+ AboutIPCController* controller_; // weak; owns me
+ DISALLOW_COPY_AND_ASSIGN(AboutIPCBridge);
+};
+
+#endif // IPC_MESSAGE_LOG_ENABLED
+
+#endif // CHROME_BROWSER_COCOA_ABOUT_IPC_BRIDGE_H_
diff --git a/chrome/browser/cocoa/about_ipc_bridge.mm b/chrome/browser/cocoa/about_ipc_bridge.mm
new file mode 100644
index 0000000..ee02e94
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_bridge.mm
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/cocoa/about_ipc_bridge.h"
+#include "chrome/browser/cocoa/about_ipc_controller.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+void AboutIPCBridge::Log(const IPC::LogData& data) {
+ CocoaLogData* cocoa_data = [[CocoaLogData alloc] initWithLogData:data];
+ if ([NSThread isMainThread]) {
+ [controller_ log:cocoa_data];
+ } else {
+ [controller_ performSelectorOnMainThread:@selector(log:)
+ withObject:cocoa_data
+ waitUntilDone:NO];
+ }
+}
+
+#endif
diff --git a/chrome/browser/cocoa/about_ipc_controller.h b/chrome/browser/cocoa/about_ipc_controller.h
new file mode 100644
index 0000000..e907af7
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_controller.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_ABOUT_IPC_CONTROLLER_H_
+#define CHROME_BROWSER_COCOA_ABOUT_IPC_CONTROLLER_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_ptr.h"
+#include "ipc/ipc_logging.h"
+#include "ipc/ipc_message_utils.h"
+#include "third_party/GTM/Foundation/GTMRegex.h"
+
+// Must be included after IPC_MESSAGE_LOG_ENABLED gets defined
+#import "chrome/browser/cocoa/about_ipc_bridge.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+// An objc wrapper for IPC::LogData to allow use of Cocoa bindings.
+@interface CocoaLogData : NSObject {
+ @private
+ IPC::LogData data_;
+}
+- (id)initWithLogData:(const IPC::LogData&)data;
+@end
+
+
+// A window controller that handles the about:ipc non-modal dialog.
+@interface AboutIPCController : NSWindowController {
+ @private
+ scoped_ptr<AboutIPCBridge> bridge_;
+ IBOutlet NSButton* startStopButton_;
+ IBOutlet NSTableView* tableView_;
+ IBOutlet NSArrayController* dataController_;
+ IBOutlet NSTextField* eventCount_;
+ IBOutlet NSTextField* filteredEventCount_;
+ IBOutlet NSTextField* userStringTextField1_;
+ IBOutlet NSTextField* userStringTextField2_;
+ IBOutlet NSTextField* userStringTextField3_;
+ // Count of filtered events.
+ int filteredEventCounter_;
+ // Cocoa-bound to check boxes for filtering messages.
+ // Each BOOL allows events that have that name prefix.
+ // E.g. if set, appCache_ allows events named AppCache*.
+ // The actual string to match is defined in the xib.
+ // The userStrings allow a user-specified prefix.
+ BOOL appCache_;
+ BOOL view_;
+ BOOL utilityHost_;
+ BOOL viewHost_;
+ BOOL plugin_;
+ BOOL npObject_;
+ BOOL devTools_;
+ BOOL pluginProcessing_;
+ BOOL userString1_;
+ BOOL userString2_;
+ BOOL userString3_;
+}
+
++ (AboutIPCController*)sharedController;
+
+- (IBAction)startStop:(id)sender;
+- (IBAction)clear:(id)sender;
+
+// Called from our C++ bridge class. To accomodate multithreaded
+// ownership issues, this method ACCEPTS OWNERSHIP of the arg passed
+// in.
+- (void)log:(CocoaLogData*)data;
+
+// Update visible state (e.g. Start/Stop button) based on logging run
+// state. Does not change state.
+- (void)updateVisibleRunState;
+
+@end
+
+@interface AboutIPCController(TestingAPI)
+- (BOOL)filterOut:(CocoaLogData*)data;
+- (void)setDisplayViewMessages:(BOOL)display;
+@end
+
+#endif // IPC_MESSAGE_LOG_ENABLED
+#endif // CHROME_BROWSER_COCOA_ABOUT_IPC_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/about_ipc_controller.mm b/chrome/browser/cocoa/about_ipc_controller.mm
new file mode 100644
index 0000000..32a9933
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_controller.mm
@@ -0,0 +1,198 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "base/mac_util.h"
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+#include "base/time.h"
+#include "chrome/browser/browser_process.h"
+#import "chrome/browser/cocoa/about_ipc_controller.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+@implementation CocoaLogData
+
+- (id)initWithLogData:(const IPC::LogData&)data {
+ if ((self = [super init])) {
+ data_ = data;
+ // data_.message_name may not have been filled in if it originated
+ // somewhere other than the browser process.
+ IPC::Logging::GetMessageText(data_.type, &data_.message_name, NULL, NULL);
+ }
+ return self;
+}
+
+- (NSString*)time {
+ base::Time t = base::Time::FromInternalValue(data_.sent);
+ base::Time::Exploded exploded;
+ t.LocalExplode(&exploded);
+ return [NSString stringWithFormat:@"%02d:%02d:%02d.%03d",
+ exploded.hour, exploded.minute,
+ exploded.second, exploded.millisecond];
+}
+
+- (NSString*)channel {
+ return base::SysUTF8ToNSString(data_.channel);
+}
+
+- (NSString*)message {
+ if (data_.message_name == L"") {
+ int high = data_.type >> 12;
+ int low = data_.type - (high<<12);
+ return [NSString stringWithFormat:@"type=(%d,%d) 0x%x,0x%x",
+ high, low, high, low];
+ }
+ else {
+ return base::SysWideToNSString(data_.message_name);
+ }
+}
+
+- (NSString*)flags {
+ return base::SysWideToNSString(data_.flags);
+}
+
+- (NSString*)dispatch {
+ base::Time sent = base::Time::FromInternalValue(data_.sent);
+ int64 delta = (base::Time::FromInternalValue(data_.receive) -
+ sent).InMilliseconds();
+ return [NSString stringWithFormat:@"%d", delta ? (int)delta : 0];
+}
+
+- (NSString*)process {
+ base::TimeDelta delta = (base::Time::FromInternalValue(data_.dispatch) -
+ base::Time::FromInternalValue(data_.receive));
+ int64 t = delta.InMilliseconds();
+ return [NSString stringWithFormat:@"%d", t ? (int)t : 0];
+}
+
+- (NSString*)parameters {
+ return base::SysWideToNSString(data_.params);
+}
+
+@end
+
+namespace {
+AboutIPCController* gSharedController = nil;
+}
+
+@implementation AboutIPCController
+
++ (AboutIPCController*)sharedController {
+ if (gSharedController == nil)
+ gSharedController = [[AboutIPCController alloc] init];
+ return gSharedController;
+}
+
+- (id)init {
+ NSString* nibpath = [mac_util::MainAppBundle() pathForResource:@"AboutIPC"
+ ofType:@"nib"];
+ if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
+ // Default to all on
+ appCache_ = view_ = utilityHost_ = viewHost_ = plugin_ =
+ npObject_ = devTools_ = pluginProcessing_ = userString1_ =
+ userString2_ = userString3_ = YES;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ if (gSharedController == self)
+ gSharedController = nil;
+ if (g_browser_process)
+ g_browser_process->SetIPCLoggingEnabled(false); // just in case...
+ IPC::Logging::current()->SetConsumer(NULL);
+ [super dealloc];
+}
+
+- (void)awakeFromNib {
+ // Running Chrome with the --ipc-logging switch might cause it to
+ // be enabled before the about:ipc window comes up; accomodate.
+ [self updateVisibleRunState];
+
+ // We are now able to display information, so let'er rip.
+ bridge_.reset(new AboutIPCBridge(self));
+ IPC::Logging::current()->SetConsumer(bridge_.get());
+}
+
+// Delegate callback. Closing the window means there is no more need
+// for the me, the controller.
+- (void)windowWillClose:(NSNotification*)notification {
+ [self autorelease];
+}
+
+- (void)updateVisibleRunState {
+ if (IPC::Logging::current()->Enabled())
+ [startStopButton_ setTitle:@"Stop"];
+ else
+ [startStopButton_ setTitle:@"Start"];
+}
+
+- (IBAction)startStop:(id)sender {
+ g_browser_process->SetIPCLoggingEnabled(!IPC::Logging::current()->Enabled());
+ [self updateVisibleRunState];
+}
+
+- (IBAction)clear:(id)sender {
+ [dataController_ setContent:[NSMutableArray array]];
+ [eventCount_ setStringValue:@"0"];
+ [filteredEventCount_ setStringValue:@"0"];
+ filteredEventCounter_ = 0;
+}
+
+// Return YES if we should filter this out; else NO.
+// Just to be clear, [@"any string" hasPrefix:@""] returns NO.
+- (BOOL)filterOut:(CocoaLogData*)data {
+ NSString* name = [data message];
+ if ((appCache_) && [name hasPrefix:@"AppCache"])
+ return NO;
+ if ((view_) && [name hasPrefix:@"ViewMsg"])
+ return NO;
+ if ((utilityHost_) && [name hasPrefix:@"UtilityHost"])
+ return NO;
+ if ((viewHost_) && [name hasPrefix:@"ViewHost"])
+ return NO;
+ if ((plugin_) && [name hasPrefix:@"PluginMsg"])
+ return NO;
+ if ((npObject_) && [name hasPrefix:@"NPObject"])
+ return NO;
+ if ((devTools_) && [name hasPrefix:@"DevTools"])
+ return NO;
+ if ((pluginProcessing_) && [name hasPrefix:@"PluginProcessing"])
+ return NO;
+ if ((userString1_) && ([name hasPrefix:[userStringTextField1_ stringValue]]))
+ return NO;
+ if ((userString2_) && ([name hasPrefix:[userStringTextField2_ stringValue]]))
+ return NO;
+ if ((userString3_) && ([name hasPrefix:[userStringTextField3_ stringValue]]))
+ return NO;
+
+ // Special case the unknown type.
+ if ([name hasPrefix:@"type="])
+ return NO;
+
+ return YES; // filter out.
+}
+
+- (void)log:(CocoaLogData*)data {
+ if ([self filterOut:data]) {
+ [filteredEventCount_ setStringValue:[NSString stringWithFormat:@"%d",
+ ++filteredEventCounter_]];
+ return;
+ }
+ [dataController_ addObject:data];
+ NSUInteger count = [[dataController_ arrangedObjects] count];
+ // Uncomment if you want scroll-to-end behavior... but seems expensive.
+ // [tableView_ scrollRowToVisible:count-1];
+ [eventCount_ setStringValue:[NSString stringWithFormat:@"%d", count]];
+}
+
+- (void)setDisplayViewMessages:(BOOL)display {
+ view_ = display;
+}
+
+@end
+
+#endif // IPC_MESSAGE_LOG_ENABLED
+
diff --git a/chrome/browser/cocoa/about_ipc_controller_unittest.mm b/chrome/browser/cocoa/about_ipc_controller_unittest.mm
new file mode 100644
index 0000000..cff2281
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_controller_unittest.mm
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#import "base/scoped_nsobject.h"
+#import "chrome/browser/cocoa/about_ipc_controller.h"
+#include "chrome/browser/cocoa/browser_test_helper.h"
+#include "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+namespace {
+
+class AboutIPCControllerTest : public PlatformTest {
+ CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
+};
+
+TEST_F(AboutIPCControllerTest, TestFilter) {
+ scoped_nsobject<AboutIPCController> controller(
+ [[AboutIPCController alloc] init]);
+ [controller window]; // force nib load.
+ IPC::LogData data;
+
+ // Make sure generic names do NOT get filtered.
+ std::wstring names[] = { L"PluginProcessingIsMyLife",
+ L"ViewMsgFoo",
+ L"NPObjectHell" };
+ for (unsigned int i = 0; i < arraysize(names); i++) {
+ data.message_name = names[i];
+ scoped_nsobject<CocoaLogData> cdata([[CocoaLogData alloc]
+ initWithLogData:data]);
+ EXPECT_FALSE([controller filterOut:cdata.get()]);
+ }
+
+ // Flip a checkbox, see it filtered, flip back, all is fine.
+ data.message_name = L"ViewMsgFoo";
+ scoped_nsobject<CocoaLogData> cdata([[CocoaLogData alloc]
+ initWithLogData:data]);
+ [controller setDisplayViewMessages:NO];
+ EXPECT_TRUE([controller filterOut:cdata.get()]);
+ [controller setDisplayViewMessages:YES];
+ EXPECT_FALSE([controller filterOut:cdata.get()]);
+}
+
+} // namespace
+
+#endif // IPC_MESSAGE_LOG_ENABLED
diff --git a/chrome/browser/cocoa/about_ipc_dialog.h b/chrome/browser/cocoa/about_ipc_dialog.h
new file mode 100644
index 0000000..e190f7a
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_dialog.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_ABOUT_IPC_DIALOG_H_
+#define CHROME_BROWSER_COCOA_ABOUT_IPC_DIALOG_H_
+
+#include "ipc/ipc_message.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+namespace AboutIPCDialog {
+// The dialog is a singleton. If the dialog is already opened, it won't do
+// anything, so you can just blindly call this function all you want.
+// RunDialog() is Called from chrome/browser/browser_about_handler.cc
+// in response to an about:ipc URL.
+void RunDialog();
+};
+
+
+#endif /* IPC_MESSAGE_LOG_ENABLED */
+
+#endif /* CHROME_BROWSER_COCOA_ABOUT_IPC_DIALOG_H_ */
diff --git a/chrome/browser/cocoa/about_ipc_dialog.mm b/chrome/browser/cocoa/about_ipc_dialog.mm
new file mode 100644
index 0000000..d9b9448f
--- /dev/null
+++ b/chrome/browser/cocoa/about_ipc_dialog.mm
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/cocoa/about_ipc_dialog.h"
+#include "chrome/browser/cocoa/about_ipc_controller.h"
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+
+namespace AboutIPCDialog {
+
+void RunDialog() {
+ // The controller gets deallocated when then window is closed,
+ // so it is safe to "fire and forget".
+ AboutIPCController* controller = [AboutIPCController sharedController];
+ [[controller window] makeKeyAndOrderFront:controller];
+}
+
+}; // namespace AboutIPCDialog
+
+#endif // IPC_MESSAGE_LOG_ENABLED
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index fb91a80..4276efa 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -51,6 +51,8 @@
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_thread.h"
#include "grit/generated_resources.h"
+#include "ipc/ipc_logging.h"
+#include "ipc/ipc_message.h"
#include "ipc/ipc_switches.h"
#if defined(OS_WIN)
@@ -793,6 +795,12 @@ void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) {
#endif
}
}
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ bool enabled = IPC::Logging::current()->Enabled();
+ Send(new ViewMsg_SetIPCLoggingEnabled(enabled));
+#endif
+
}
// Static. This function can be called from any thread.
diff --git a/chrome/browser/sandbox_policy.cc b/chrome/browser/sandbox_policy.cc
index 13f4ee2..4be8a23 100644
--- a/chrome/browser/sandbox_policy.cc
+++ b/chrome/browser/sandbox_policy.cc
@@ -21,7 +21,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
#include "chrome/common/notification_service.h"
-#include "ipc/ipc_logging.h"
#include "sandbox/src/sandbox.h"
#include "webkit/glue/plugins/plugin_list.h"
@@ -180,21 +179,6 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy) {
if (result != sandbox::SBOX_ALL_OK)
return false;
-#ifdef IPC_MESSAGE_LOG_ENABLED
- // Add the policy for the IPC logging events.
- result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_SYNC,
- sandbox::TargetPolicy::EVENTS_ALLOW_ANY,
- IPC::Logging::GetEventName(true).c_str());
- if (result != sandbox::SBOX_ALL_OK)
- return false;
-
- result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_SYNC,
- sandbox::TargetPolicy::EVENTS_ALLOW_ANY,
- IPC::Logging::GetEventName(false).c_str());
- if (result != sandbox::SBOX_ALL_OK)
- return false;
-#endif
-
// Add the policy for debug message only in debug
#ifndef NDEBUG
std::wstring debug_message;
diff --git a/chrome/browser/views/about_ipc_dialog.cc b/chrome/browser/views/about_ipc_dialog.cc
index ea3c1c9..4ad5695 100644
--- a/chrome/browser/views/about_ipc_dialog.cc
+++ b/chrome/browser/views/about_ipc_dialog.cc
@@ -437,11 +437,11 @@ void AboutIPCDialog::ButtonPressed(
if (tracking_) {
track_toggle_->SetText(kStartTrackingLabel);
tracking_ = false;
- IPC::Logging::current()->Disable();
+ g_browser_process->SetIPCLoggingEnabled(false);
} else {
track_toggle_->SetText(kStopTrackingLabel);
tracking_ = true;
- IPC::Logging::current()->Enable();
+ g_browser_process->SetIPCLoggingEnabled(true);
}
track_toggle_->SchedulePaint();
} else if (button == clear_button_) {