Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / public / browser / presentation_service_delegate.h
blob817cd282a8f246eac8ac6a2e7bda0ccba940f5f7
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 CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
8 #include "base/callback.h"
9 #include "content/common/content_export.h"
10 #include "content/public/browser/presentation_session.h"
12 namespace content {
14 class PresentationScreenAvailabilityListener;
16 // An interface implemented by embedders to handle presentation API calls
17 // forwarded from PresentationServiceImpl.
18 class CONTENT_EXPORT PresentationServiceDelegate {
19 public:
20 // Observer interface to listen for changes to PresentationServiceDelegate.
21 class CONTENT_EXPORT Observer {
22 public:
23 // Called when the PresentationServiceDelegate is being destroyed.
24 virtual void OnDelegateDestroyed() = 0;
26 protected:
27 virtual ~Observer() {}
30 using PresentationSessionSuccessCallback =
31 base::Callback<void(const PresentationSessionInfo&)>;
32 using PresentationSessionErrorCallback =
33 base::Callback<void(const PresentationError&)>;
35 virtual ~PresentationServiceDelegate() {}
37 // Registers an observer with this class to listen for updates to this class.
38 // This class does not own the observer.
39 // It is an error to add an observer if it has already been added before.
40 virtual void AddObserver(Observer* observer) = 0;
41 // Unregisters an observer with this class.
42 virtual void RemoveObserver(Observer* observer) = 0;
44 // Registers |listener| to continuously listen for
45 // availability updates for a presentation URL, originated from the frame
46 // given by |render_process_id| and |render_frame_id|.
47 // This class does not own |listener|.
48 // Returns true on success.
49 // This call will return false if a listener with the same presentation URL
50 // from the same frame is already registered.
51 virtual bool AddScreenAvailabilityListener(
52 int render_process_id,
53 int render_frame_id,
54 PresentationScreenAvailabilityListener* listener) = 0;
56 // Unregisters |listener| originated from the frame given by
57 // |render_process_id| and |render_frame_id| from this class. The listener
58 // will no longer receive availability updates.
59 virtual void RemoveScreenAvailabilityListener(
60 int render_process_id,
61 int render_frame_id,
62 PresentationScreenAvailabilityListener* listener) = 0;
64 // Resets the presentation state for the frame given by |render_process_id|
65 // and |render_frame_id|.
66 // This unregisters all listeners associated with the given frame, and clears
67 // the default presentation URL and ID set for the frame.
68 virtual void Reset(
69 int render_process_id,
70 int render_frame_id) = 0;
72 // Sets the default presentation URL and ID for frame given by
73 // |render_process_id| and |render_frame_id|.
74 // If |default_presentation_url| is empty, the default presentation URL will
75 // be cleared.
76 virtual void SetDefaultPresentationUrl(
77 int render_process_id,
78 int render_frame_id,
79 const std::string& default_presentation_url,
80 const std::string& default_presentation_id) = 0;
82 // Starts a new presentation session.
83 // Typically, the embedder will allow the user to select a screen to show
84 // |presentation_url|.
85 // |render_process_id|, |render_frame_id|: ID of originating frame.
86 // |presentation_url|: URL of the presentation.
87 // |presentation_id|: The caller may provide an non-empty string to be used
88 // as the ID of the presentation. If empty, the default presentation ID
89 // will be used. If both are empty, the embedder will automatically generate
90 // one.
91 // |success_cb|: Invoked with session info, if presentation session started
92 // successfully.
93 // |error_cb|: Invoked with error reason, if presentation session did not
94 // start.
95 virtual void StartSession(
96 int render_process_id,
97 int render_frame_id,
98 const std::string& presentation_url,
99 const std::string& presentation_id,
100 const PresentationSessionSuccessCallback& success_cb,
101 const PresentationSessionErrorCallback& error_cb) = 0;
103 // Joins an existing presentation session. Unlike StartSession(), this
104 // does not bring a screen list UI.
105 // |render_process_id|, |render_frame_id|: ID for originating frame.
106 // |presentation_url|: URL of the presentation.
107 // |presentation_id|: The ID of the presentation to join.
108 // |success_cb|: Invoked with session info, if presentation session joined
109 // successfully.
110 // |error_cb|: Invoked with error reason, if joining failed.
111 virtual void JoinSession(
112 int render_process_id,
113 int render_frame_id,
114 const std::string& presentation_url,
115 const std::string& presentation_id,
116 const PresentationSessionSuccessCallback& success_cb,
117 const PresentationSessionErrorCallback& error_cb) = 0;
120 } // namespace content
122 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_