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..49d3d9802108f22144ffc12db5675e6d0ae37e18 |
| --- /dev/null |
| +++ b/components/bubble/bubble_controller.h |
| @@ -0,0 +1,42 @@ |
| +// 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_ |
| +#define COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/bubble/bubble_delegate.h" |
|
msw
2015/08/18 17:26:19
nit: remove this, forward-declare BubbleDelegate,
hcarmona
2015/08/18 23:08:48
Need BubbleCloseReason.
msw
2015/08/19 00:18:11
Acknowledged.
|
| + |
| +class BubbleUI; |
| + |
| +// BubbleController is responsible for the lifetime of the delegate and its UI. |
| +class BubbleController { |
|
msw
2015/08/18 17:26:19
Make this a SupportsWeakPtr subclass, remove the f
hcarmona
2015/08/18 23:08:48
I didn't use SupportsWeakPtr because it's necessar
msw
2015/08/19 00:18:11
So the problem is that SupportsWeakPtr's "internal
groby-ooo-7-16
2015/08/19 00:52:01
There's also the point that WeakPtrFactory is _by
hcarmona
2015/08/20 02:34:31
We now have better chaining, so we can use Support
msw
2015/08/21 01:48:30
With the Show/ShouldClose/etc. functions private,
|
| + public: |
| + explicit BubbleController(scoped_ptr<BubbleDelegate> delegate); |
| + virtual ~BubbleController(); |
| + |
| + // Will create and show the UI for the delegate. |
| + void Show(); |
| + |
| + // Will notify the bubble UI that it should update its anchor location. |
| + // Important when there's a UI change (ex: fullscreen transition). |
| + void UpdateAnchorPosition(); |
| + |
| + // Should clean up the delegate and its UI if it closed. |
|
msw
2015/08/18 17:26:19
nit: s/Should/Will/ to match other comments.
hcarmona
2015/08/18 23:08:48
Done.
|
| + // Returns true if the bubble was closed. |
| + bool ShouldClose(BubbleCloseReason reason); |
| + |
| + 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_ |