• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 the Chromium Embedded Framework Authors. Portions copyright
2 // 2013 The Chromium Authors. All rights reserved. Use of this source code is
3 // governed by a BSD-style license that can be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
6 #define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
7 
8 #include <memory>
9 
10 #include "base/macros.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "extensions/browser/extension_host.h"
14 
15 class AlloyBrowserHostImpl;
16 
17 namespace content {
18 class WebContents;
19 }  // namespace content
20 
21 namespace extensions {
22 
23 // The ExtensionHost for an extension that backs a view in the browser UI. For
24 // example, this could be an extension popup or dialog, but not a background
25 // page. Object lifespan is managed by AlloyBrowserHostImpl. Based on
26 // chrome/browser/extensions/extension_view_host.h.
27 class CefExtensionViewHost : public ExtensionHost,
28                              public content::NotificationObserver {
29  public:
30   CefExtensionViewHost(AlloyBrowserHostImpl* browser,
31                        const Extension* extension,
32                        content::WebContents* host_contents,
33                        const GURL& url,
34                        mojom::ViewType host_type);
35   ~CefExtensionViewHost() override;
36 
37   // ExtensionHost methods:
38   void OnDidStopFirstLoad() override;
39   void LoadInitialURL() override;
40   bool IsBackgroundPage() const override;
41 
42   // content::WebContentsDelegate methods:
43   bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
44   bool PreHandleGestureEvent(content::WebContents* source,
45                              const blink::WebGestureEvent& event) override;
46 
47   // extensions::ExtensionFunctionDispatcher::Delegate methods:
48   content::WebContents* GetVisibleWebContents() const override;
49 
50   // content::NotificationObserver methods:
51   void Observe(int type,
52                const content::NotificationSource& source,
53                const content::NotificationDetails& details) override;
54 
55  private:
56   content::NotificationRegistrar registrar_;
57 
58   DISALLOW_COPY_AND_ASSIGN(CefExtensionViewHost);
59 };
60 
61 }  // namespace extensions
62 
63 #endif  // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_VIEW_HOST_H_
64