OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
7 | 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/strings/string16.h" |
8 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
9 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 #include "extensions/common/stack_frame.h" |
10 | 13 |
11 namespace content { | 14 namespace content { |
12 class BrowserContext; | 15 class BrowserContext; |
13 } | 16 } |
14 | 17 |
15 namespace extensions { | 18 namespace extensions { |
16 class Extension; | 19 class Extension; |
17 struct Message; | 20 struct Message; |
18 | 21 |
19 // A web contents observer that's used for WebContents in renderer and extension | 22 // A web contents observer that's used for WebContents in renderer and extension |
20 // processes. Grants the renderer access to certain URL patterns for extensions, | 23 // processes. Grants the renderer access to certain URL patterns for extensions, |
21 // notifies the renderer that the extension was loaded and routes messages to | 24 // notifies the renderer that the extension was loaded and routes messages to |
22 // the MessageService. | 25 // the MessageService. |
23 class ExtensionWebContentsObserver | 26 class ExtensionWebContentsObserver |
24 : public content::WebContentsObserver, | 27 : public content::WebContentsObserver, |
25 public content::WebContentsUserData<ExtensionWebContentsObserver> { | 28 public content::WebContentsUserData<ExtensionWebContentsObserver> { |
26 public: | 29 public: |
27 virtual ~ExtensionWebContentsObserver(); | 30 virtual ~ExtensionWebContentsObserver(); |
28 | 31 |
29 private: | 32 private: |
30 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); | 33 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); |
31 friend class content::WebContentsUserData<ExtensionWebContentsObserver>; | 34 friend class content::WebContentsUserData<ExtensionWebContentsObserver>; |
32 | 35 |
33 // content::WebContentsObserver overrides. | 36 // content::WebContentsObserver overrides. |
34 virtual void RenderViewCreated( | 37 virtual void RenderViewCreated( |
35 content::RenderViewHost* render_view_host) OVERRIDE; | 38 content::RenderViewHost* render_view_host) OVERRIDE; |
36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
37 | 40 |
38 void OnPostMessage(int port_id, const Message& message); | 41 void OnPostMessage(int port_id, const Message& message); |
| 42 void OnDetailedConsoleMessageAdded(const base::string16& message, |
| 43 const base::string16& source, |
| 44 const StackTrace& stack_trace, |
| 45 int32 severity_level); |
| 46 |
39 | 47 |
40 // Gets the extension or app (if any) that is associated with a RVH. | 48 // Gets the extension or app (if any) that is associated with a RVH. |
41 const Extension* GetExtension(content::RenderViewHost* render_view_host); | 49 const Extension* GetExtension(content::RenderViewHost* render_view_host); |
42 | 50 |
43 // The browser context for the web contents this is observing. | 51 // The browser context for the web contents this is observing. |
44 content::BrowserContext* browser_context_; | 52 content::BrowserContext* browser_context_; |
45 | 53 |
46 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); | 54 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); |
47 }; | 55 }; |
48 | 56 |
49 } // namespace extensions | 57 } // namespace extensions |
50 | 58 |
51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |