• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
6 #define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
7 
8 #include <memory>
9 
10 #include "base/observer_list.h"
11 #include "content/public/browser/web_contents_user_data.h"
12 #include "extensions/browser/extension_web_contents_observer.h"
13 #include "extensions/browser/script_executor.h"
14 
15 namespace extensions {
16 
17 // The CEF version of ExtensionWebContentsObserver.
18 class CefExtensionWebContentsObserver
19     : public ExtensionWebContentsObserver,
20       public content::WebContentsUserData<CefExtensionWebContentsObserver> {
21  public:
22   CefExtensionWebContentsObserver(const CefExtensionWebContentsObserver&) =
23       delete;
24   CefExtensionWebContentsObserver& operator=(
25       const CefExtensionWebContentsObserver&) = delete;
26 
27   ~CefExtensionWebContentsObserver() override;
28 
29   // Creates and initializes an instance of this class for the given
30   // |web_contents|, if it doesn't already exist.
31   static void CreateForWebContents(content::WebContents* web_contents);
32 
script_executor()33   ScriptExecutor* script_executor() { return script_executor_.get(); }
34 
35  private:
36   friend class content::WebContentsUserData<CefExtensionWebContentsObserver>;
37 
38   explicit CefExtensionWebContentsObserver(content::WebContents* web_contents);
39 
40   // content::WebContentsObserver overrides.
41   void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
42 
43   std::unique_ptr<ScriptExecutor> script_executor_;
44 
45   WEB_CONTENTS_USER_DATA_KEY_DECL();
46 };
47 
48 }  // namespace extensions
49 
50 #endif  // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_WEB_CONTENTS_OBSERVER_H_
51