File: global_error.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (118 lines) | stat: -rw-r--r-- 4,474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2012 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_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_
#define CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_

#include <vector>

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"

class Browser;
class GlobalErrorBubbleViewBase;

namespace gfx {
class Image;
}

// This object describes a single global error.
class GlobalError {
 public:
  enum Severity {
    SEVERITY_LOW,
    SEVERITY_MEDIUM,
    SEVERITY_HIGH,
  };

  GlobalError();
  virtual ~GlobalError();

  // Returns the error's severity level. If there are multiple errors,
  // the error with the highest severity will display in the menu. If not
  // overridden, this is based on the badge resource ID.
  virtual Severity GetSeverity();

  // Returns true if a menu item should be added to the app menu.
  virtual bool HasMenuItem() = 0;
  // Returns the command ID for the menu item.
  virtual int MenuItemCommandID() = 0;
  // Returns the label for the menu item.
  virtual base::string16 MenuItemLabel() = 0;
  // Returns the menu item icon.
  virtual gfx::Image MenuItemIcon();
  // Called when the user clicks on the menu item.
  virtual void ExecuteMenuItem(Browser* browser) = 0;

  // Returns true if a bubble view should be shown.
  virtual bool HasBubbleView() = 0;
  // Returns true if the bubble view has been shown.
  virtual bool HasShownBubbleView() = 0;
  // Called to show the bubble view.
  virtual void ShowBubbleView(Browser* browser) = 0;
  // Returns the bubble view.
  virtual GlobalErrorBubbleViewBase* GetBubbleView() = 0;
};

// This object describes a single global error that already comes with support
// for showing a standard Bubble UI. Derived classes just need to supply the
// content to be displayed in the bubble.
class GlobalErrorWithStandardBubble
    : public GlobalError,
      public base::SupportsWeakPtr<GlobalErrorWithStandardBubble> {
 public:
  GlobalErrorWithStandardBubble();
  ~GlobalErrorWithStandardBubble() override;

  // Returns an icon to use for the bubble view.
  virtual gfx::Image GetBubbleViewIcon();

  // Returns the title for the bubble view.
  virtual base::string16 GetBubbleViewTitle() = 0;
  // Returns the messages for the bubble view, one per line. Multiple messages
  // are only supported on Views.
  // TODO(yoz): Add multi-line support for GTK and Cocoa.
  virtual std::vector<base::string16> GetBubbleViewMessages() = 0;
  // Returns the accept button label for the bubble view.
  virtual base::string16 GetBubbleViewAcceptButtonLabel() = 0;
  // Returns true if the bubble needs a close(x) button.
  virtual bool ShouldShowCloseButton() const;
  // Returns true if the accept button needs elevation icon (only effective
  // on Windows platform).
  virtual bool ShouldAddElevationIconToAcceptButton();
  // Returns the cancel button label for the bubble view. To hide the cancel
  // button return an empty string.
  virtual base::string16 GetBubbleViewCancelButtonLabel() = 0;
  // Called when the bubble view is closed. |browser| is the Browser that the
  // bubble view was shown on.
  void BubbleViewDidClose(Browser* browser);
  // Notifies subclasses that the bubble view is closed. |browser| is the
  // Browser that the bubble view was shown on.
  virtual void OnBubbleViewDidClose(Browser* browser) = 0;
  // Called when the user clicks on the accept button. |browser| is the
  // Browser that the bubble view was shown on.
  virtual void BubbleViewAcceptButtonPressed(Browser* browser) = 0;
  // Called when the user clicks the cancel button. |browser| is the
  // Browser that the bubble view was shown on.
  virtual void BubbleViewCancelButtonPressed(Browser* browser) = 0;
  // Returns true if the bubble should close when focus is lost. If false, the
  // bubble will stick around until the user explicitly acknowledges it.
  // Defaults to true.
  virtual bool ShouldCloseOnDeactivate() const;

  // GlobalError overrides:
  bool HasBubbleView() override;
  bool HasShownBubbleView() override;
  void ShowBubbleView(Browser* browser) override;
  GlobalErrorBubbleViewBase* GetBubbleView() override;

 private:
  bool has_shown_bubble_view_;
  GlobalErrorBubbleViewBase* bubble_view_;

  DISALLOW_COPY_AND_ASSIGN(GlobalErrorWithStandardBubble);
};

#endif  // CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_