Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: components/bubble/bubble_delegate.h

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac Changes to test trybots Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/bubble/bubble_delegate.h
diff --git a/components/bubble/bubble_delegate.h b/components/bubble/bubble_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..385fb31f0287319211189f6e923aa0746b7c382c
--- /dev/null
+++ b/components/bubble/bubble_delegate.h
@@ -0,0 +1,69 @@
+// 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 COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_
+#define COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_
+
+#include "base/memory/scoped_ptr.h"
+
+class BubbleUI;
+
+// List of reasons why a bubble might close. These correspond to various events
+// from the UI. Not all platforms will receive all events.
+enum BubbleCloseReason {
+ // Bubble was closed without any user interaction.
+ BUBBLE_CLOSE_IGNORE,
msw 2015/08/18 17:26:19 nit: maybe rename IGNORE to LOST_FOCUS?
hcarmona 2015/08/18 23:08:48 Done.
+
+ // User did not interact with the bubble, but changed tab.
+ BUBBLE_CLOSE_TABSWITCH,
msw 2015/08/18 17:26:19 nit: maybe rename this TABSWITCHED to match TABDET
hcarmona 2015/08/18 23:08:48 Done.
+
+ // User did not interact with the bubble, but changed tab.
msw 2015/08/18 17:26:19 nit: s/changed/detached the/ ?
hcarmona 2015/08/18 23:08:48 Done.
+ BUBBLE_CLOSE_TABDETACHED,
+
+ // User dismissed the bubble. (ESC, close, etc.)
+ BUBBLE_CLOSE_USER_DISMISSED,
+
+ // There has been a navigation event. (Link, URL typed, refresh, etc.)
+ BUBBLE_CLOSE_NAVIGATION,
+
+ // Window has entered fullscreen mode. Will also be called for immersive
msw 2015/08/18 17:26:19 nit: "entered or exited" or maybe toggled?
hcarmona 2015/08/18 23:08:48 Done.
+ // fullscreen.
+ BUBBLE_CLOSE_FULLSCREEN,
+
+ // User selected the "Accept" option in a bubble.
msw 2015/08/18 17:26:19 nit: Consider "The user selected an affirmative re
hcarmona 2015/08/18 23:08:48 Done.
+ BUBBLE_CLOSE_ACCEPT,
+
+ // User selected the "Cancel" option in a bubble.
msw 2015/08/18 17:26:19 nit: Consider "The user selected a negative respon
hcarmona 2015/08/18 23:08:48 Done.
+ BUBBLE_CLOSE_CANCEL,
+
+ // The bubble WILL be closed regardless of return value for |ShouldClose|.
+ // Ex: BubbleManager is being destroyed.
msw 2015/08/18 17:26:19 nit: "The associated BubbleManager" or maybe "The
hcarmona 2015/08/18 23:08:48 Done.
+ BUBBLE_CLOSE_FORCED,
+};
+
+// Inherit from this class to define a bubble. A bubble is a small piece of UI
msw 2015/08/18 17:26:19 nit: maybe remove "A bubble is a small piece of UI
hcarmona 2015/08/18 23:08:48 Done.
+// that's intended to ask a user a question. Most bubbles are dismissed when
+// they lose focus.
+class BubbleDelegate {
+ public:
+ BubbleDelegate() {}
+ virtual ~BubbleDelegate() {}
+
+ // Called by BubbleController to notify a bubble of an event that the bubble
+ // might want to close on. Return true if the bubble should close for the
+ // specified reason.
+ // IMPORTANT: DO NOT SHOW OR HIDE OTHER BUBBLES IN THIS FUNCTION.
msw 2015/08/18 17:26:19 I wonder how tough it would be to support this, an
hcarmona 2015/08/18 23:08:48 It doesn't sound very hard to fix this. I like you
msw 2015/08/19 00:18:11 I think it would be good to tackle in this CL, unl
hcarmona 2015/08/20 02:34:31 Done.
+ // If closing this bubble needs to chain with other bubbles, please chain in
msw 2015/08/18 17:26:19 nit: consider "If closing this bubble should show
hcarmona 2015/08/18 23:08:48 Done.
+ // the destructor.
+ virtual bool ShouldClose(BubbleCloseReason reason);
+
+ // Called by BubbleController to build the UI that will represent this bubble.
+ // BubbleDelegate should not keep a reference to this newly created UI.
+ virtual scoped_ptr<BubbleUI> BuildBubbleUI() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BubbleDelegate);
+};
+
+#endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698