OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef APPS_APP_WEB_CONTENTS_HELPER_H_ | 5 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ |
6 #define APPS_APP_WEB_CONTENTS_HELPER_H_ | 6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ |
7 | 7 |
8 #include "content/public/common/console_message_level.h" | 8 #include "content/public/common/console_message_level.h" |
9 #include "content/public/common/media_stream_request.h" | 9 #include "content/public/common/media_stream_request.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 class WebGestureEvent; | 12 class WebGestureEvent; |
13 } | 13 } |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class BrowserContext; | 16 class BrowserContext; |
17 struct OpenURLParams; | 17 struct OpenURLParams; |
18 class WebContents; | 18 class WebContents; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 class Extension; | |
23 } | |
24 | |
25 namespace apps { | |
26 | 22 |
27 class AppDelegate; | 23 class AppDelegate; |
| 24 class Extension; |
28 | 25 |
29 // Provides common functionality for apps and launcher pages to respond to | 26 // Provides common functionality for apps and launcher pages to respond to |
30 // messages from a WebContents. | 27 // messages from a WebContents. |
31 class AppWebContentsHelper { | 28 class AppWebContentsHelper { |
32 public: | 29 public: |
33 AppWebContentsHelper(content::BrowserContext* browser_context, | 30 AppWebContentsHelper(content::BrowserContext* browser_context, |
34 const std::string& extension_id, | 31 const std::string& extension_id, |
35 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
36 AppDelegate* app_delegate); | 33 AppDelegate* app_delegate); |
37 | 34 |
38 // Returns true if the given |event| should not be handled by the renderer. | 35 // Returns true if the given |event| should not be handled by the renderer. |
39 static bool ShouldSuppressGestureEvent(const blink::WebGestureEvent& event); | 36 static bool ShouldSuppressGestureEvent(const blink::WebGestureEvent& event); |
40 | 37 |
41 // Opens a new URL inside the passed in WebContents. See WebContentsDelegate. | 38 // Opens a new URL inside the passed in WebContents. See WebContentsDelegate. |
42 content::WebContents* OpenURLFromTab( | 39 content::WebContents* OpenURLFromTab( |
43 const content::OpenURLParams& params) const; | 40 const content::OpenURLParams& params) const; |
44 | 41 |
45 // Requests to lock the mouse. See WebContentsDelegate. | 42 // Requests to lock the mouse. See WebContentsDelegate. |
46 void RequestToLockMouse() const; | 43 void RequestToLockMouse() const; |
47 | 44 |
48 // Asks permission to use the camera and/or microphone. See | 45 // Asks permission to use the camera and/or microphone. See |
49 // WebContentsDelegate. | 46 // WebContentsDelegate. |
50 void RequestMediaAccessPermission( | 47 void RequestMediaAccessPermission( |
51 const content::MediaStreamRequest& request, | 48 const content::MediaStreamRequest& request, |
52 const content::MediaResponseCallback& callback) const; | 49 const content::MediaResponseCallback& callback) const; |
53 | 50 |
54 private: | 51 private: |
55 const extensions::Extension* GetExtension() const; | 52 const Extension* GetExtension() const; |
56 | 53 |
57 // Helper method to add a message to the renderer's DevTools console. | 54 // Helper method to add a message to the renderer's DevTools console. |
58 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, | 55 void AddMessageToDevToolsConsole(content::ConsoleMessageLevel level, |
59 const std::string& message) const; | 56 const std::string& message) const; |
60 | 57 |
61 // The browser context with which this window is associated. | 58 // The browser context with which this window is associated. |
62 // AppWindowWebContentsDelegate does not own this object. | 59 // AppWindowWebContentsDelegate does not own this object. |
63 content::BrowserContext* browser_context_; | 60 content::BrowserContext* browser_context_; |
64 | 61 |
65 const std::string extension_id_; | 62 const std::string extension_id_; |
66 | 63 |
67 content::WebContents* web_contents_; | 64 content::WebContents* web_contents_; |
68 | 65 |
69 AppDelegate* app_delegate_; | 66 AppDelegate* app_delegate_; |
70 | 67 |
71 DISALLOW_COPY_AND_ASSIGN(AppWebContentsHelper); | 68 DISALLOW_COPY_AND_ASSIGN(AppWebContentsHelper); |
72 }; | 69 }; |
73 | 70 |
74 } // namespace apps | 71 } // namespace extensions |
75 | 72 |
76 #endif // APPS_APP_WEB_CONTENTS_HELPER_H_ | 73 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WEB_CONTENTS_HELPER_H_ |
OLD | NEW |