1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
8 // A controller for the Mac hung renderer dialog window. Only one
9 // instance of this controller can exist at any time, although a given
10 // controller is destroyed when its window is closed.
12 // The dialog itself displays a list of frozen tabs, all of which
13 // share a render process. Since there can only be a single dialog
14 // open at a time, if showForWebContents is called for a different
15 // tab, the dialog is repurposed to show a warning for the new tab.
17 // The caller is required to call endForWebContents before deleting
18 // any WebContents object.
20 #import <Cocoa/Cocoa.h>
22 #import "base/mac/scoped_nsobject.h"
23 #import "base/memory/scoped_ptr.h"
25 @
class MultiKeyEquivalentButton
;
26 class HungRendererWebContentsObserverBridge
;
32 @interface HungRendererController
: NSWindowController
<NSTableViewDataSource
> {
34 IBOutlet MultiKeyEquivalentButton
* waitButton_
;
35 IBOutlet NSButton
* killButton_
;
36 IBOutlet NSTableView
* tableView_
;
37 IBOutlet NSImageView
* imageView_
;
38 IBOutlet NSTextField
* messageView_
;
40 // The WebContents for which this dialog is open. Should never be
41 // NULL while this dialog is open.
42 content::WebContents
* hungContents_
;
44 // Observes |hungContents_| in case it closes while the panel is up.
45 scoped_ptr
<HungRendererWebContentsObserverBridge
> hungContentsObserver_
;
47 // Backing data for |tableView_|. Titles of each WebContents that
48 // shares a renderer process with |hungContents_|.
49 base::scoped_nsobject
<NSArray
> hungTitles_
;
51 // Favicons of each WebContents that shares a renderer process with
53 base::scoped_nsobject
<NSArray
> hungFavicons_
;
56 // Shows or hides the hung renderer dialog for the given WebContents.
57 + (void)showForWebContents
:(content::WebContents
*)contents
;
58 + (void)endForWebContents
:(content::WebContents
*)contents
;
60 // Kills the hung renderers.
61 - (IBAction
)kill
:(id
)sender
;
63 // Waits longer for the renderers to respond.
64 - (IBAction
)wait
:(id
)sender
;
66 // Modifies the dialog to show a warning for the given tab contents.
67 // The dialog will contain a list of all tabs that share a renderer
68 // process with |contents|. The caller must not delete any tab
69 // contents without first calling endForWebContents.
70 - (void)showForWebContents
:(content::WebContents
*)contents
;
72 // Notifies the dialog that |contents| is either responsive or closed.
73 // If |contents| shares the same render process as the tab contents
74 // this dialog was created for, this function will close the dialog.
75 // If |contents| has a different process, this function does nothing.
76 - (void)endForWebContents
:(content::WebContents
*)contents
;
78 // Called by |hungContentsObserver_| to indicate that |hungContents_|
80 - (void)renderProcessGone
;
82 @end
// HungRendererController
85 @interface
HungRendererController (JustForTesting
)
86 - (NSButton
*)killButton
;
87 - (MultiKeyEquivalentButton
*)waitButton
;
90 #endif // CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_