Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / bubble / bubble_delegate.h
blobf53b94b12d19d5d14cbf0c3a667f65e7ff45ffdf
1 // Copyright 2015 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 COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_
6 #define COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "components/bubble/bubble_close_reason.h"
13 class BubbleUi;
15 // Inherit from this class to define a bubble. A bubble is a small transient UI
16 // surface anchored to a parent window. Most bubbles are dismissed when they
17 // lose focus.
18 class BubbleDelegate {
19 public:
20 BubbleDelegate();
21 virtual ~BubbleDelegate();
23 // Called by BubbleController to notify a bubble of an event that the bubble
24 // might want to close on. Return true if the bubble should close for the
25 // specified reason.
26 virtual bool ShouldClose(BubbleCloseReason reason);
28 // Called by BubbleController to build the UI that will represent this bubble.
29 // BubbleDelegate should not keep a reference to this newly created UI.
30 virtual scoped_ptr<BubbleUi> BuildBubbleUi() = 0;
32 // Called to update an existing UI. This is the same BubbleUi that was created
33 // in |BuildBubbleUi|.
34 // Return true to indicate the UI was updated.
35 virtual bool UpdateBubbleUi(BubbleUi* bubble_ui);
37 // Used to identify a bubble for collecting metrics.
38 virtual std::string GetName() const = 0;
40 private:
41 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate);
44 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_