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 CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
11 #include "extensions/browser/extension_web_contents_observer.h" | 11 #include "extensions/browser/extension_web_contents_observer.h" |
12 #include "extensions/common/stack_frame.h" | 12 #include "extensions/common/stack_frame.h" |
13 | 13 |
| 14 namespace content { |
| 15 class RenderFrameHost; |
| 16 } |
| 17 |
14 namespace extensions { | 18 namespace extensions { |
15 struct Message; | 19 struct Message; |
16 | 20 |
17 // An ExtensionWebContentsObserver that adds support for the extension error | 21 // An ExtensionWebContentsObserver that adds support for the extension error |
18 // console, reloading crashed extensions and routing extension messages between | 22 // console, reloading crashed extensions and routing extension messages between |
19 // renderers. | 23 // renderers. |
20 class ChromeExtensionWebContentsObserver | 24 class ChromeExtensionWebContentsObserver |
21 : public ExtensionWebContentsObserver, | 25 : public ExtensionWebContentsObserver, |
22 public content::WebContentsUserData<ChromeExtensionWebContentsObserver> { | 26 public content::WebContentsUserData<ChromeExtensionWebContentsObserver> { |
23 private: | 27 private: |
24 friend class content::WebContentsUserData<ChromeExtensionWebContentsObserver>; | 28 friend class content::WebContentsUserData<ChromeExtensionWebContentsObserver>; |
25 | 29 |
26 explicit ChromeExtensionWebContentsObserver( | 30 explicit ChromeExtensionWebContentsObserver( |
27 content::WebContents* web_contents); | 31 content::WebContents* web_contents); |
28 virtual ~ChromeExtensionWebContentsObserver(); | 32 virtual ~ChromeExtensionWebContentsObserver(); |
29 | 33 |
30 // content::WebContentsObserver overrides. | 34 // content::WebContentsObserver overrides. |
31 virtual void RenderViewCreated(content::RenderViewHost* render_view_host) | 35 virtual void RenderViewCreated(content::RenderViewHost* render_view_host) |
32 OVERRIDE; | 36 OVERRIDE; |
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 38 virtual bool OnMessageReceived( |
| 39 const IPC::Message& message, |
| 40 content::RenderFrameHost* render_frame_host) OVERRIDE; |
34 | 41 |
35 // Routes a message to the extensions MessageService. | 42 // Routes a message to the extensions MessageService. |
36 void OnPostMessage(int port_id, const Message& message); | 43 void OnPostMessage(int port_id, const Message& message); |
37 | 44 |
38 // Adds a message to the extensions ErrorConsole. | 45 // Adds a message to the extensions ErrorConsole. |
39 void OnDetailedConsoleMessageAdded(const base::string16& message, | 46 void OnDetailedConsoleMessageAdded(const base::string16& message, |
40 const base::string16& source, | 47 const base::string16& source, |
41 const StackTrace& stack_trace, | 48 const StackTrace& stack_trace, |
42 int32 severity_level); | 49 int32 severity_level); |
43 | 50 |
44 // Reloads an extension if it is on the terminated list. | 51 // Reloads an extension if it is on the terminated list. |
45 void ReloadIfTerminated(content::RenderViewHost* render_view_host); | 52 void ReloadIfTerminated(content::RenderViewHost* render_view_host); |
46 | 53 |
47 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionWebContentsObserver); | 54 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionWebContentsObserver); |
48 }; | 55 }; |
49 | 56 |
50 } // namespace extensions | 57 } // namespace extensions |
51 | 58 |
52 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
OLD | NEW |