Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_web_contents_observer.h
blob49b1b006934e994c781120d2a5f0b73f320579aa
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
8 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/browser/web_contents_user_data.h"
11 namespace content {
12 class BrowserContext;
15 namespace extensions {
16 class Extension;
17 struct Message;
19 // 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,
21 // notifies the renderer that the extension was loaded and routes messages to
22 // the MessageService.
23 class ExtensionWebContentsObserver
24 : public content::WebContentsObserver,
25 public content::WebContentsUserData<ExtensionWebContentsObserver> {
26 public:
27 virtual ~ExtensionWebContentsObserver();
29 private:
30 explicit ExtensionWebContentsObserver(content::WebContents* web_contents);
31 friend class content::WebContentsUserData<ExtensionWebContentsObserver>;
33 // content::WebContentsObserver overrides.
34 virtual void RenderViewCreated(
35 content::RenderViewHost* render_view_host) OVERRIDE;
36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
38 void OnPostMessage(int port_id, const Message& message);
40 // Gets the extension or app (if any) that is associated with a RVH.
41 const Extension* GetExtension(content::RenderViewHost* render_view_host);
43 // The browser context for the web contents this is observing.
44 content::BrowserContext* browser_context_;
46 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver);
49 } // namespace extensions
51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_