Home | History | Annotate | Download | only in cocoa
      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_HUNG_RENDERER_CONTROLLER_H_
      6 #define CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
      7 #pragma once
      8 
      9 // A controller for the Mac hung renderer dialog window.  Only one
     10 // instance of this controller can exist at any time, although a given
     11 // controller is destroyed when its window is closed.
     12 //
     13 // The dialog itself displays a list of frozen tabs, all of which
     14 // share a render process.  Since there can only be a single dialog
     15 // open at a time, if showForTabContents is called for a different
     16 // tab, the dialog is repurposed to show a warning for the new tab.
     17 //
     18 // The caller is required to call endForTabContents before deleting
     19 // any TabContents object.
     20 
     21 #import <Cocoa/Cocoa.h>
     22 
     23 #import "base/mac/cocoa_protocols.h"
     24 #import "base/memory/scoped_nsobject.h"
     25 
     26 @class MultiKeyEquivalentButton;
     27 class TabContents;
     28 
     29 @interface HungRendererController : NSWindowController<NSTableViewDataSource> {
     30  @private
     31   IBOutlet MultiKeyEquivalentButton* waitButton_;
     32   IBOutlet NSButton* killButton_;
     33   IBOutlet NSTableView* tableView_;
     34   IBOutlet NSImageView* imageView_;
     35   IBOutlet NSTextField* messageView_;
     36 
     37   // The TabContents for which this dialog is open.  Should never be
     38   // NULL while this dialog is open.
     39   TabContents* hungContents_;
     40 
     41   // Backing data for |tableView_|.  Titles of each TabContents that
     42   // shares a renderer process with |hungContents_|.
     43   scoped_nsobject<NSArray> hungTitles_;
     44 
     45   // Favicons of each TabContents that shares a renderer process with
     46   // |hungContents_|.
     47   scoped_nsobject<NSArray> hungFavicons_;
     48 }
     49 
     50 // Kills the hung renderers.
     51 - (IBAction)kill:(id)sender;
     52 
     53 // Waits longer for the renderers to respond.
     54 - (IBAction)wait:(id)sender;
     55 
     56 // Modifies the dialog to show a warning for the given tab contents.
     57 // The dialog will contain a list of all tabs that share a renderer
     58 // process with |contents|.  The caller must not delete any tab
     59 // contents without first calling endForTabContents.
     60 - (void)showForTabContents:(TabContents*)contents;
     61 
     62 // Notifies the dialog that |contents| is either responsive or closed.
     63 // If |contents| shares the same render process as the tab contents
     64 // this dialog was created for, this function will close the dialog.
     65 // If |contents| has a different process, this function does nothing.
     66 - (void)endForTabContents:(TabContents*)contents;
     67 
     68 @end  // HungRendererController
     69 
     70 
     71 @interface HungRendererController (JustForTesting)
     72 - (NSButton*)killButton;
     73 - (MultiKeyEquivalentButton*)waitButton;
     74 @end
     75 
     76 #endif  // CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
     77