Fix search results being clipped in app list.
[chromium-blink-merge.git] / extensions / browser / extension_web_contents_observer.h
blob993a8fe4cec02e6070e99b181891b02b85296d58
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "content/public/browser/web_contents_observer.h"
14 namespace content {
15 class BrowserContext;
16 class RenderViewHost;
17 class WebContents;
20 namespace extensions {
21 class Extension;
23 // A web contents observer used for renderer and extension processes. Grants the
24 // renderer access to certain URL scheme patterns for extensions and notifies
25 // the renderer that the extension was loaded.
27 // Extension system embedders must create an instance for every extension
28 // WebContents. It must be a subclass so that creating an instance via
29 // content::WebContentsUserData::CreateForWebContents() provides an object of
30 // the correct type. For an example, see ChromeExtensionWebContentsObserver.
31 class ExtensionWebContentsObserver : public content::WebContentsObserver {
32 protected:
33 explicit ExtensionWebContentsObserver(content::WebContents* web_contents);
34 ~ExtensionWebContentsObserver() override;
36 content::BrowserContext* browser_context() { return browser_context_; }
38 // content::WebContentsObserver overrides.
40 // A subclass should invoke this method to finish extension process setup.
41 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
43 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
45 // Per the documentation in WebContentsObserver, these two methods are
46 // appropriate to track the set of current RenderFrameHosts.
47 // NOTE: FrameDeleted() != RenderFrameDeleted().
48 void FrameDeleted(content::RenderFrameHost* render_frame_host) override;
49 void RenderFrameHostChanged(content::RenderFrameHost* old_host,
50 content::RenderFrameHost* new_host) override;
52 // Returns the extension or app associated with a render view host. Returns
53 // NULL if the render view host is not for a valid extension.
54 const Extension* GetExtension(content::RenderViewHost* render_view_host);
56 // Updates ViewType for RenderViewHost based on GetViewType(web_contents()).
57 void NotifyRenderViewType(content::RenderViewHost* render_view_host);
59 // Returns the extension or app ID associated with a render view host. Returns
60 // the empty string if the render view host is not for a valid extension.
61 static std::string GetExtensionId(content::RenderViewHost* render_view_host);
63 private:
64 // The BrowserContext associated with the WebContents being observed.
65 content::BrowserContext* browser_context_;
67 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver);
70 } // namespace extensions
72 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_