1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_COCOA_ABOUT_IPC_CONTROLLER_H_
6#define CHROME_BROWSER_UI_COCOA_ABOUT_IPC_CONTROLLER_H_
7#pragma once
8
9#import <Cocoa/Cocoa.h>
10
11#include "base/memory/scoped_ptr.h"
12#include "ipc/ipc_logging.h"
13#include "ipc/ipc_message_utils.h"
14#include "third_party/GTM/Foundation/GTMRegex.h"
15
16// Must be included after IPC_MESSAGE_LOG_ENABLED gets defined
17#import "chrome/browser/ui/cocoa/about_ipc_dialog.h"
18
19#if defined(IPC_MESSAGE_LOG_ENABLED)
20
21// An objc wrapper for IPC::LogData to allow use of Cocoa bindings.
22@interface CocoaLogData : NSObject {
23 @private
24  IPC::LogData data_;
25}
26- (id)initWithLogData:(const IPC::LogData&)data;
27@end
28
29
30// A window controller that handles the about:ipc non-modal dialog.
31@interface AboutIPCController : NSWindowController {
32 @private
33  scoped_ptr<AboutIPCBridge> bridge_;
34  IBOutlet NSButton* startStopButton_;
35  IBOutlet NSTableView* tableView_;
36  IBOutlet NSArrayController* dataController_;
37  IBOutlet NSTextField* eventCount_;
38  IBOutlet NSTextField* filteredEventCount_;
39  IBOutlet NSTextField* userStringTextField1_;
40  IBOutlet NSTextField* userStringTextField2_;
41  IBOutlet NSTextField* userStringTextField3_;
42  // Count of filtered events.
43  int filteredEventCounter_;
44  // Cocoa-bound to check boxes for filtering messages.
45  // Each BOOL allows events that have that name prefix.
46  // E.g. if set, appCache_ allows events named AppCache*.
47  // The actual string to match is defined in the xib.
48  // The userStrings allow a user-specified prefix.
49  BOOL appCache_;
50  BOOL view_;
51  BOOL utilityHost_;
52  BOOL viewHost_;
53  BOOL plugin_;
54  BOOL npObject_;
55  BOOL devTools_;
56  BOOL pluginProcessing_;
57  BOOL userString1_;
58  BOOL userString2_;
59  BOOL userString3_;
60}
61
62+ (AboutIPCController*)sharedController;
63
64- (IBAction)startStop:(id)sender;
65- (IBAction)clear:(id)sender;
66
67// Called from our C++ bridge class.  To accomodate multithreaded
68// ownership issues, this method ACCEPTS OWNERSHIP of the arg passed
69// in.
70- (void)log:(CocoaLogData*)data;
71
72// Update visible state (e.g. Start/Stop button) based on logging run
73// state.  Does not change state.
74- (void)updateVisibleRunState;
75
76@end
77
78@interface AboutIPCController(TestingAPI)
79- (BOOL)filterOut:(CocoaLogData*)data;
80- (void)setDisplayViewMessages:(BOOL)display;
81@end
82
83#endif  // IPC_MESSAGE_LOG_ENABLED
84#endif  // CHROME_BROWSER_UI_COCOA_ABOUT_IPC_CONTROLLER_H_
85