Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / permissions / permission_service_context.h
blobe07366dc7195d03a39cf4053e48a25e8cf4b1b03
1 // Copyright 2014 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_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_vector.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
13 namespace content {
15 class PermissionService;
16 class PermissionServiceImpl;
17 class RenderFrameHost;
18 class RenderProcessHost;
20 // Provides information to a PermissionService. It is used by the
21 // PermissionService to handle request permission UI.
22 // There is one PermissionServiceContext per RenderFrameHost/RenderProcessHost
23 // which owns it. It then owns all PermissionService associated to their owner.
24 class PermissionServiceContext : public WebContentsObserver {
25 public:
26 explicit PermissionServiceContext(RenderFrameHost* render_frame_host);
27 explicit PermissionServiceContext(RenderProcessHost* render_process_host);
28 ~PermissionServiceContext() override;
30 void CreateService(mojo::InterfaceRequest<PermissionService> request);
32 // Called by a PermissionService identified as |service| when it has a
33 // connection error in order to get unregistered and killed.
34 void ServiceHadConnectionError(PermissionServiceImpl* service);
36 BrowserContext* GetBrowserContext() const;
37 GURL GetEmbeddingOrigin() const;
39 RenderFrameHost* render_frame_host() const;
41 private:
42 // WebContentsObserver
43 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
44 void RenderFrameHostChanged(RenderFrameHost* old_host,
45 RenderFrameHost* new_host) override;
46 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host,
47 const LoadCommittedDetails& details,
48 const FrameNavigateParams& params) override;
50 void CancelPendingOperations(RenderFrameHost*) const;
52 RenderFrameHost* render_frame_host_;
53 RenderProcessHost* render_process_host_;
54 ScopedVector<PermissionServiceImpl> services_;
56 DISALLOW_COPY_AND_ASSIGN(PermissionServiceContext);
59 } // namespace content
61 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_