| 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 EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // renderer access to certain URL scheme patterns for extensions and notifies | 24 // renderer access to certain URL scheme patterns for extensions and notifies |
| 25 // the renderer that the extension was loaded. | 25 // the renderer that the extension was loaded. |
| 26 // | 26 // |
| 27 // Extension system embedders must create an instance for every extension | 27 // Extension system embedders must create an instance for every extension |
| 28 // WebContents. It must be a subclass so that creating an instance via | 28 // WebContents. It must be a subclass so that creating an instance via |
| 29 // content::WebContentsUserData::CreateForWebContents() provides an object of | 29 // content::WebContentsUserData::CreateForWebContents() provides an object of |
| 30 // the correct type. For an example, see ChromeExtensionWebContentsObserver. | 30 // the correct type. For an example, see ChromeExtensionWebContentsObserver. |
| 31 class ExtensionWebContentsObserver : public content::WebContentsObserver { | 31 class ExtensionWebContentsObserver : public content::WebContentsObserver { |
| 32 protected: | 32 protected: |
| 33 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); | 33 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); |
| 34 virtual ~ExtensionWebContentsObserver(); | 34 ~ExtensionWebContentsObserver() override; |
| 35 | 35 |
| 36 content::BrowserContext* browser_context() { return browser_context_; } | 36 content::BrowserContext* browser_context() { return browser_context_; } |
| 37 | 37 |
| 38 // content::WebContentsObserver overrides. | 38 // content::WebContentsObserver overrides. |
| 39 | 39 |
| 40 // A subclass should invoke this method to finish extension process setup. | 40 // A subclass should invoke this method to finish extension process setup. |
| 41 virtual void RenderViewCreated(content::RenderViewHost* render_view_host) | 41 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
| 42 override; | |
| 43 | 42 |
| 44 // Returns the extension or app associated with a render view host. Returns | 43 // Returns the extension or app associated with a render view host. Returns |
| 45 // NULL if the render view host is not for a valid extension. | 44 // NULL if the render view host is not for a valid extension. |
| 46 const Extension* GetExtension(content::RenderViewHost* render_view_host); | 45 const Extension* GetExtension(content::RenderViewHost* render_view_host); |
| 47 | 46 |
| 48 // Updates ViewType for RenderViewHost based on GetViewType(web_contents()). | 47 // Updates ViewType for RenderViewHost based on GetViewType(web_contents()). |
| 49 void NotifyRenderViewType(content::RenderViewHost* render_view_host); | 48 void NotifyRenderViewType(content::RenderViewHost* render_view_host); |
| 50 | 49 |
| 51 // Returns the extension or app ID associated with a render view host. Returns | 50 // Returns the extension or app ID associated with a render view host. Returns |
| 52 // the empty string if the render view host is not for a valid extension. | 51 // the empty string if the render view host is not for a valid extension. |
| 53 static std::string GetExtensionId(content::RenderViewHost* render_view_host); | 52 static std::string GetExtensionId(content::RenderViewHost* render_view_host); |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 // The BrowserContext associated with the WebContents being observed. | 55 // The BrowserContext associated with the WebContents being observed. |
| 57 content::BrowserContext* browser_context_; | 56 content::BrowserContext* browser_context_; |
| 58 | 57 |
| 59 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); | 58 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 } // namespace extensions | 61 } // namespace extensions |
| 63 | 62 |
| 64 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ | 63 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |