1 // Copyright 2017 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.
4 
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_MANAGER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_MANAGER_H_
7 
8 #include "base/observer_list_types.h"
9 #include "content/common/content_export.h"
10 
11 namespace gfx {
12 class SelectionBound;
13 }
14 
15 namespace ui {
16 class TouchSelectionController;
17 class TouchSelectionControllerClient;
18 class TouchSelectionMenuClient;
19 }  // namespace ui
20 
21 namespace content {
22 
23 // This class defines an interface for a manager class that allows multiple
24 // TouchSelectionControllerClients to work together with a single
25 // TouchSelectionController.
26 class CONTENT_EXPORT TouchSelectionControllerClientManager {
27  public:
~TouchSelectionControllerClientManager()28   virtual ~TouchSelectionControllerClientManager() {}
29 
30   virtual void DidStopFlinging() = 0;
31 
32   // The manager uses this class' methods to notify observers about important
33   // events.
34   class CONTENT_EXPORT Observer : public base::CheckedObserver {
35    public:
36     // Warns observers the manager is shutting down. The manager's view may not
37     // be rigidly defined with respect to the lifetime of the client's views.
38     virtual void OnManagerWillDestroy(
39         TouchSelectionControllerClientManager* manager) = 0;
40   };
41 
42   // Clients call this method when their selection bounds change, so that the
43   // manager can determine which client should be considered the active client,
44   // i.e. receive the selection handles and (possibly) a quickmenu.
45   virtual void UpdateClientSelectionBounds(
46       const gfx::SelectionBound& start,
47       const gfx::SelectionBound& end,
48       ui::TouchSelectionControllerClient* client,
49       ui::TouchSelectionMenuClient* menu_client) = 0;
50 
51   // Used by clients to inform the manager that the client no longer wants to
52   // participate in touch selection editing, usually because the client's view
53   // is being destroyed or detached.
54   virtual void InvalidateClient(ui::TouchSelectionControllerClient* client) = 0;
55 
56   // Provides direct access to the TouchSelectionController that will be used
57   // with all clients accessing this manager. May return null values on Android.
58   virtual ui::TouchSelectionController* GetTouchSelectionController() = 0;
59 
60   // The following two functions allow clients (or their owners, etc.) to
61   // monitor the manager's lifetime.
62   virtual void AddObserver(Observer* observer) = 0;
63   virtual void RemoveObserver(Observer* observer) = 0;
64 };
65 
66 }  // namespace content
67 
68 #endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_SELECTION_CONTROLLER_CLIENT_MANAGER_H_
69