Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / extensions / browser / app_window / app_web_contents_helper.h
blobea4f13e55f5d93d31c7b418b1a66aeda62c808d7
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 EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_
6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_
8 #include "content/public/common/console_message_level.h"
9 #include "content/public/common/media_stream_request.h"
11 namespace blink {
12 class WebGestureEvent;
15 namespace content {
16 class BrowserContext;
17 struct OpenURLParams;
18 class WebContents;
21 namespace extensions {
23 class AppDelegate;
24 class Extension;
26 // Provides common functionality for apps and launcher pages to respond to
27 // messages from a WebContents.
28 class AppWebContentsHelper {
29 public:
30 AppWebContentsHelper(content::BrowserContext* browser_context,
31 const std::string& extension_id,
32 content::WebContents* web_contents,
33 AppDelegate* app_delegate);
35 // Returns true if the given |event| should not be handled by the renderer.
36 static bool ShouldSuppressGestureEvent(const blink::WebGestureEvent& event);
38 // Opens a new URL inside the passed in WebContents. See WebContentsDelegate.
39 content::WebContents* OpenURLFromTab(
40 const content::OpenURLParams& params) const;
42 // Requests to lock the mouse. See WebContentsDelegate.
43 void RequestToLockMouse() const;
45 // Asks permission to use the camera and/or microphone. See
46 // WebContentsDelegate.
47 void RequestMediaAccessPermission(
48 const content::MediaStreamRequest& request,
49 const content::MediaResponseCallback& callback) const;
51 // Checks permission to use the camera or microphone. See
52 // WebContentsDelegate.
53 bool CheckMediaAccessPermission(const GURL& security_origin,
54 content::MediaStreamType type) const;
56 private:
57 const Extension* GetExtension() const;
59 // Helper method to add a message to the renderer's DevTools console.
60 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level,
61 const std::string& message) const;
63 // The browser context with which this window is associated.
64 // AppWindowWebContentsDelegate does not own this object.
65 content::BrowserContext* browser_context_;
67 const std::string extension_id_;
69 content::WebContents* web_contents_;
71 AppDelegate* app_delegate_;
73 DISALLOW_COPY_AND_ASSIGN(AppWebContentsHelper);
76 } // namespace extensions
78 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_