File: toolbar_actions_bar_bubble_delegate.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 (95 lines) | stat: -rw-r--r-- 3,615 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
// Copyright 2015 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_TOOLBAR_TOOLBAR_ACTIONS_BAR_BUBBLE_DELEGATE_H_
#define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_BUBBLE_DELEGATE_H_

#include <string>

#include "base/strings/string16.h"
#include "ui/gfx/vector_icons_public.h"

// A delegate for a generic bubble that hangs off the toolbar actions bar.
class ToolbarActionsBarBubbleDelegate {
 public:
  enum CloseAction {
    CLOSE_LEARN_MORE,
    CLOSE_EXECUTE,
    CLOSE_DISMISS_USER_ACTION,
    CLOSE_DISMISS_DEACTIVATION,
  };

  // Content populating an optional view, containing an image icon and/or
  // (linked) text, in the bubble.
  struct ExtraViewInfo {
    ExtraViewInfo()
        : resource_id(gfx::VectorIconId::VECTOR_ICON_NONE),
          is_text_linked(false) {}

    // The resource id referencing the image icon. If has a value of -1, then no
    // image icon will be added.
    gfx::VectorIconId resource_id;

    // Text in the view. If this is an empty string, no text will be added.
    base::string16 text;

    // If the struct's text is nonempty and this value is true, then a link of
    // the text is added. If this value is false, the text is not treated as a
    // link.
    bool is_text_linked;
  };

  virtual ~ToolbarActionsBarBubbleDelegate() {}

  // Returns true if the bubble should (still) be shown. Since bubbles are
  // sometimes shown asynchronously, they may be invalid by the time they would
  // be displayed.
  virtual bool ShouldShow() = 0;

  // Returns true if the bubble should close on deactivation.
  virtual bool ShouldCloseOnDeactivate() = 0;

  // Gets the text for the bubble's heading (title).
  virtual base::string16 GetHeadingText() = 0;

  // Gets the text for the bubble's body.
  // |anchored_to_action| is true if the bubble is being anchored to a specific
  // action (rather than the overflow menu or the full container).
  virtual base::string16 GetBodyText(bool anchored_to_action) = 0;

  // Gets the text for an optional item list to display. If this returns an
  // empty string, no list will be added.
  virtual base::string16 GetItemListText() = 0;

  // Gets the text for the main button on the bubble; this button will
  // correspond with ACTION_EXECUTE.
  virtual base::string16 GetActionButtonText() = 0;

  // Gets the text for a second button on the bubble; this button will
  // correspond with ACTION_DISMISS. If this returns an empty string, no
  // button will be added.
  virtual base::string16 GetDismissButtonText() = 0;

  // Gets the text for a "learn more" link-style button on the bubble; this
  // button will correspond with ACTION_LEARN_MORE. If this returns an empty
  // string, no button will be added.
  virtual base::string16 GetLearnMoreButtonText() = 0;

  // Returns the id of the action to point to, or the empty string if the
  // bubble should point to the center of the actions container.
  virtual std::string GetAnchorActionId() = 0;

  // Called when the bubble is shown.
  virtual void OnBubbleShown() = 0;

  // Called when the bubble is closed with the type of action the user took.
  virtual void OnBubbleClosed(CloseAction action) = 0;

  // Returns the ExtraViewInfo struct associated with the bubble delegate. If
  // this returns a nullptr, no extra view (image icon and/or (linked) text) is
  // added to the bubble.
  virtual std::unique_ptr<ExtraViewInfo> GetExtraViewInfo() = 0;
};

#endif  // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_BUBBLE_DELEGATE_H_