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 APPS_APP_WEB_CONTENTS_HELPER_H_
6 #define APPS_APP_WEB_CONTENTS_HELPER_H_
8 #include "content/public/common/console_message_level.h"
9 #include "content/public/common/media_stream_request.h"
12 class WebGestureEvent
;
21 namespace extensions
{
29 // Provides common functionality for apps and launcher pages to respond to
30 // messages from a WebContents.
31 class AppWebContentsHelper
{
33 AppWebContentsHelper(content::BrowserContext
* browser_context
,
34 const std::string
& extension_id
,
35 content::WebContents
* web_contents
,
36 AppDelegate
* app_delegate
);
38 // Returns true if the given |event| should not be handled by the renderer.
39 static bool ShouldSuppressGestureEvent(const blink::WebGestureEvent
& event
);
41 // Opens a new URL inside the passed in WebContents. See WebContentsDelegate.
42 content::WebContents
* OpenURLFromTab(
43 const content::OpenURLParams
& params
) const;
45 // Requests to lock the mouse. See WebContentsDelegate.
46 void RequestToLockMouse() const;
48 // Asks permission to use the camera and/or microphone. See
49 // WebContentsDelegate.
50 void RequestMediaAccessPermission(
51 const content::MediaStreamRequest
& request
,
52 const content::MediaResponseCallback
& callback
) const;
55 const extensions::Extension
* GetExtension() const;
57 // Helper method to add a message to the renderer's DevTools console.
58 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level
,
59 const std::string
& message
) const;
61 // The browser context with which this window is associated.
62 // AppWindowWebContentsDelegate does not own this object.
63 content::BrowserContext
* browser_context_
;
65 const std::string extension_id_
;
67 content::WebContents
* web_contents_
;
69 AppDelegate
* app_delegate_
;
71 DISALLOW_COPY_AND_ASSIGN(AppWebContentsHelper
);
76 #endif // APPS_APP_WEB_CONTENTS_HELPER_H_