Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / ui / panels / panel_host.h
blobccca8415bc7e88c18f00b481bd7614bf4c4bd89d
1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/web_contents_delegate.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/common/page_zoom.h"
13 #include "extensions/browser/extension_function_dispatcher.h"
15 class FaviconTabHelper;
16 class GURL;
17 class Panel;
18 class PrefsTabHelper;
19 class Profile;
21 namespace content {
22 class WebContents;
25 namespace extensions {
26 class WindowController;
29 namespace gfx {
30 class Image;
31 class Rect;
34 // Helper class for Panel, implementing WebContents hosting and Extension
35 // delegates. Owned and used by Panel only.
36 class PanelHost : public content::WebContentsDelegate,
37 public content::WebContentsObserver,
38 public extensions::ExtensionFunctionDispatcher::Delegate {
39 public:
40 PanelHost(Panel* panel, Profile* profile);
41 ~PanelHost() override;
43 void Init(const GURL& url);
44 content::WebContents* web_contents() { return web_contents_.get(); }
45 void DestroyWebContents();
47 // Returns the icon for the current page.
48 gfx::Image GetPageIcon() const;
50 // content::WebContentsDelegate overrides.
51 content::WebContents* OpenURLFromTab(
52 content::WebContents* source,
53 const content::OpenURLParams& params) override;
54 void NavigationStateChanged(content::WebContents* source,
55 content::InvalidateTypes changed_flags) override;
56 void AddNewContents(content::WebContents* source,
57 content::WebContents* new_contents,
58 WindowOpenDisposition disposition,
59 const gfx::Rect& initial_rect,
60 bool user_gesture,
61 bool* was_blocked) override;
62 void ActivateContents(content::WebContents* contents) override;
63 void DeactivateContents(content::WebContents* contents) override;
64 void LoadingStateChanged(content::WebContents* source,
65 bool to_different_document) override;
66 void CloseContents(content::WebContents* source) override;
67 void MoveContents(content::WebContents* source,
68 const gfx::Rect& pos) override;
69 bool IsPopupOrPanel(const content::WebContents* source) const override;
70 void ContentsZoomChange(bool zoom_in) override;
71 void HandleKeyboardEvent(
72 content::WebContents* source,
73 const content::NativeWebKeyboardEvent& event) override;
74 void WebContentsFocused(content::WebContents* contents) override;
75 void ResizeDueToAutoResize(content::WebContents* web_contents,
76 const gfx::Size& new_size) override;
78 // content::WebContentsObserver overrides.
79 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
80 void RenderProcessGone(base::TerminationStatus status) override;
81 void WebContentsDestroyed() override;
82 bool OnMessageReceived(const IPC::Message& message) override;
84 // extensions::ExtensionFunctionDispatcher::Delegate overrides.
85 extensions::WindowController* GetExtensionWindowController() const override;
86 content::WebContents* GetAssociatedWebContents() const override;
88 // Actions on web contents.
89 void Reload();
90 void ReloadIgnoringCache();
91 void StopLoading();
92 void Zoom(content::PageZoom zoom);
94 private:
95 // Helper to close panel via the message loop.
96 void ClosePanel();
98 // Message handlers.
99 void OnRequest(const ExtensionHostMsg_Request_Params& params);
101 Panel* panel_; // Weak, owns us.
102 Profile* profile_;
103 extensions::ExtensionFunctionDispatcher extension_function_dispatcher_;
105 scoped_ptr<content::WebContents> web_contents_;
107 // The following factory is used to close the panel via the message loop.
108 base::WeakPtrFactory<PanelHost> weak_factory_;
110 DISALLOW_COPY_AND_ASSIGN(PanelHost);
113 #endif // CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_