Chromium Code Reviews| Index: components/bubble/bubble_controller.h |
| diff --git a/components/bubble/bubble_controller.h b/components/bubble/bubble_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c4c48eb4497e397f1fc4fec3e95405f7b286225 |
| --- /dev/null |
| +++ b/components/bubble/bubble_controller.h |
| @@ -0,0 +1,60 @@ |
| +// 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_CONTROLLER_H__ |
|
msw
2015/08/13 03:37:22
nit: remove extra trailing underscore here and bel
hcarmona
2015/08/15 02:03:19
Done.
|
| +#define COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H__ |
| + |
| +#include "base/callback_forward.h" |
|
msw
2015/08/13 03:37:22
nit: remove if not needed.
hcarmona
2015/08/15 02:03:19
Done.
|
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/bubble/bubble_ui.h" |
|
msw
2015/08/13 03:37:22
nit: forward declare BubbleUI (like BubbleDelegate
hcarmona
2015/08/15 02:03:19
Done.
|
| +#include "ui/gfx/native_widget_types.h" |
|
msw
2015/08/13 03:37:22
nit: remove if not needed.
hcarmona
2015/08/15 02:03:19
Done.
|
| + |
| +class BubbleDelegate; |
| + |
| +enum BubbleCloseReason { |
| + // Bubble was closed without any user interaction. |
| + BUBBLE_CLOSE_IGNORE, |
| + |
| + // User did not interact with the bubble, but changed tab. |
|
msw
2015/08/13 03:37:22
What's the value of distinguishing this from *_IGN
groby-ooo-7-16
2015/08/13 18:44:38
There's potentially a different meaning to this -
msw
2015/08/13 19:18:58
Okay, reasonable, but perhaps better generalized a
|
| + BUBBLE_CLOSE_TABSWITCH, |
| + |
| + // User dismissed the bubble. (ESC, close, etc) |
|
msw
2015/08/13 03:37:22
nit: period after "etc"
hcarmona
2015/08/15 02:03:19
Done.
|
| + BUBBLE_CLOSE_CLOSE, |
| + |
| + // User selected the "Allow" option in a bubble. |
|
msw
2015/08/13 03:37:22
Most bubbles won't have "Allow" and "Deny" options
groby-ooo-7-16
2015/08/13 18:44:38
This definitely refers to the positive/negative re
msw
2015/08/13 19:18:58
That might be okay, but allow/deny is much more pe
hcarmona
2015/08/15 02:03:19
Done.
|
| + BUBBLE_CLOSE_ALLOW, |
| + |
| + // User selected the "Deny" option in a bubble. |
| + BUBBLE_CLOSE_DENY, |
| +}; |
| + |
| +// BubbleController is responisble for the lifetime of the delegate and it's UI. |
|
msw
2015/08/13 03:37:22
nit: no apostrophe in "its" here.
msw
2015/08/13 19:18:58
nit: responsible spelling.
hcarmona
2015/08/15 02:03:19
Done.
hcarmona
2015/08/15 02:03:19
Done.
|
| +class BubbleController { |
| + public: |
| + explicit BubbleController(scoped_ptr<BubbleDelegate> delegate); |
| + virtual ~BubbleController(); |
| + |
| + void Show(); |
| + void Hide(BubbleCloseReason reason); |
| + void UpdateAnchorPosition(); |
| + bool ShouldUpdateBubble(); |
|
msw
2015/08/13 03:37:22
nit: add comments here and for other non-obvious f
hcarmona
2015/08/15 02:03:19
Done.
|
| + |
| + bool ShouldClose() const; |
|
msw
2015/08/13 03:37:22
nit: ShouldCloseOnHide? add comments here and for
hcarmona
2015/08/15 02:03:19
Acknowledged.
|
| + void Close(); |
| + |
| + bool MatchesContext(void* context) const; |
|
msw
2015/08/13 03:37:22
nit: add comments here and for other non-obvious f
hcarmona
2015/08/15 02:03:19
Done.
|
| + |
| + base::WeakPtr<BubbleController> AsWeakPtr(); |
| + |
| + private: |
| + scoped_ptr<BubbleDelegate> delegate_; |
| + scoped_ptr<BubbleUI> bubble_ui_; |
| + |
| + base::WeakPtrFactory<BubbleController> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BubbleController); |
| +}; |
| + |
| +#endif // COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H__ |