Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: extensions/browser/extension_web_contents_observer.h

Issue 652793002: Add service registration for apps APIs implemented as mojo services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set>
8 #include <string> 9 #include <string>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
13 14
14 namespace content { 15 namespace content {
15 class BrowserContext; 16 class BrowserContext;
17 class RenderFrameHost;
16 class RenderViewHost; 18 class RenderViewHost;
17 class WebContents; 19 class WebContents;
18 } 20 }
19 21
20 namespace extensions { 22 namespace extensions {
21 class Extension; 23 class Extension;
22 24
23 // A web contents observer used for renderer and extension processes. Grants the 25 // A web contents observer used for renderer and extension processes. Grants the
24 // renderer access to certain URL scheme patterns for extensions and notifies 26 // renderer access to certain URL scheme patterns for extensions and notifies
25 // the renderer that the extension was loaded. 27 // the renderer that the extension was loaded.
26 // 28 //
27 // Extension system embedders must create an instance for every extension 29 // Extension system embedders must create an instance for every extension
28 // WebContents. It must be a subclass so that creating an instance via 30 // WebContents. It must be a subclass so that creating an instance via
29 // content::WebContentsUserData::CreateForWebContents() provides an object of 31 // content::WebContentsUserData::CreateForWebContents() provides an object of
30 // the correct type. For an example, see ChromeExtensionWebContentsObserver. 32 // the correct type. For an example, see ChromeExtensionWebContentsObserver.
31 class ExtensionWebContentsObserver : public content::WebContentsObserver { 33 class ExtensionWebContentsObserver : public content::WebContentsObserver {
32 protected: 34 protected:
33 explicit ExtensionWebContentsObserver(content::WebContents* web_contents); 35 explicit ExtensionWebContentsObserver(content::WebContents* web_contents);
34 virtual ~ExtensionWebContentsObserver(); 36 virtual ~ExtensionWebContentsObserver();
35 37
36 content::BrowserContext* browser_context() { return browser_context_; } 38 content::BrowserContext* browser_context() { return browser_context_; }
37 39
38 // content::WebContentsObserver overrides. 40 // content::WebContentsObserver overrides.
39 41
42 virtual void RenderFrameCreated(
43 content::RenderFrameHost* render_frame_host) override;
44
45 virtual void RenderFrameDeleted(
46 content::RenderFrameHost* render_frame_host) override;
47
40 // A subclass should invoke this method to finish extension process setup. 48 // A subclass should invoke this method to finish extension process setup.
41 virtual void RenderViewCreated(content::RenderViewHost* render_view_host) 49 virtual void RenderViewCreated(content::RenderViewHost* render_view_host)
42 override; 50 override;
43 51
44 // Returns the extension or app associated with a render view host. Returns 52 // 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. 53 // NULL if the render view host is not for a valid extension.
46 const Extension* GetExtension(content::RenderViewHost* render_view_host); 54 const Extension* GetExtension(content::RenderViewHost* render_view_host);
47 55
48 // Updates ViewType for RenderViewHost based on GetViewType(web_contents()). 56 // Updates ViewType for RenderViewHost based on GetViewType(web_contents()).
49 void NotifyRenderViewType(content::RenderViewHost* render_view_host); 57 void NotifyRenderViewType(content::RenderViewHost* render_view_host);
50 58
51 // Returns the extension or app ID associated with a render view host. Returns 59 // 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. 60 // the empty string if the render view host is not for a valid extension.
53 static std::string GetExtensionId(content::RenderViewHost* render_view_host); 61 static std::string GetExtensionId(content::RenderViewHost* render_view_host);
54 62
55 private: 63 private:
56 // The BrowserContext associated with the WebContents being observed. 64 // The BrowserContext associated with the WebContents being observed.
57 content::BrowserContext* browser_context_; 65 content::BrowserContext* browser_context_;
58 66
67 // The set of RenderFrameHosts that we have seen be created, but not deleted.
68 std::set<content::RenderFrameHost*> known_render_frame_hosts_;
69
59 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver); 70 DISALLOW_COPY_AND_ASSIGN(ExtensionWebContentsObserver);
60 }; 71 };
61 72
62 } // namespace extensions 73 } // namespace extensions
63 74
64 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_ 75 #endif // EXTENSIONS_BROWSER_EXTENSION_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698