• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_CONFIRM_BUBBLE_MODEL_H_
6 #define CHROME_BROWSER_UI_CONFIRM_BUBBLE_MODEL_H_
7 
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
10 
11 namespace gfx {
12 class Image;
13 }
14 
15 // An interface implemented by objects wishing to control an ConfirmBubbleView.
16 // To use this class to implement a bubble menu, we need two steps:
17 // 1. Implement a class derived from this class.
18 // 2. Call chrome::ShowConfirmBubble() with the class implemented in 1.
19 class ConfirmBubbleModel {
20  public:
21   enum BubbleButton {
22     BUTTON_NONE   = 0,
23     BUTTON_OK     = 1 << 0,
24     BUTTON_CANCEL = 1 << 1,
25   };
26 
27   ConfirmBubbleModel();
28   virtual ~ConfirmBubbleModel();
29 
30   // Returns the title string and the message string to be displayed for this
31   // bubble menu. These must not be empty strings.
32   virtual base::string16 GetTitle() const = 0;
33   virtual base::string16 GetMessageText() const = 0;
34 
35   // Returns an icon for the bubble. This image should be owned by the
36   // ResourceBundle and callers should not take ownership of it. Must not return
37   // NULL.
38   virtual gfx::Image* GetIcon() const = 0;
39 
40   // Return the buttons to be shown for this bubble menu. This function returns
41   // a combination of BubbleButton values, e.g. when we show both an OK button
42   // and a cancel button, it should return (BUTTON_OK | BUTTON_CANCEL). (This is
43   // the default implementation.)
44   virtual int GetButtons() const;
45 
46   // Return the label for the specified button. The default implementation
47   // returns "OK" for the OK button and "Cancel" for the Cancel button.
48   virtual base::string16 GetButtonLabel(BubbleButton button) const;
49 
50   // Called when the OK button is pressed.
51   virtual void Accept();
52 
53   // Called when the Cancel button is pressed.
54   virtual void Cancel();
55 
56   // Returns the text of the link to be displayed, if any. Otherwise returns
57   // and empty string.
58   virtual base::string16 GetLinkText() const;
59 
60   // Called when the Link is clicked.
61   virtual void LinkClicked();
62 
63  private:
64   DISALLOW_COPY_AND_ASSIGN(ConfirmBubbleModel);
65 };
66 
67 #endif  // CHROME_BROWSER_UI_CONFIRM_BUBBLE_MODEL_H_
68