OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/public/browser/web_contents_delegate.h" | 10 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 class Rect; | 31 class Rect; |
32 } | 32 } |
33 | 33 |
34 // Helper class for Panel, implementing WebContents hosting and Extension | 34 // Helper class for Panel, implementing WebContents hosting and Extension |
35 // delegates. Owned and used by Panel only. | 35 // delegates. Owned and used by Panel only. |
36 class PanelHost : public content::WebContentsDelegate, | 36 class PanelHost : public content::WebContentsDelegate, |
37 public content::WebContentsObserver, | 37 public content::WebContentsObserver, |
38 public extensions::ExtensionFunctionDispatcher::Delegate { | 38 public extensions::ExtensionFunctionDispatcher::Delegate { |
39 public: | 39 public: |
40 PanelHost(Panel* panel, Profile* profile); | 40 PanelHost(Panel* panel, Profile* profile); |
41 virtual ~PanelHost(); | 41 ~PanelHost() override; |
42 | 42 |
43 void Init(const GURL& url); | 43 void Init(const GURL& url); |
44 content::WebContents* web_contents() { return web_contents_.get(); } | 44 content::WebContents* web_contents() { return web_contents_.get(); } |
45 void DestroyWebContents(); | 45 void DestroyWebContents(); |
46 | 46 |
47 // Returns the icon for the current page. | 47 // Returns the icon for the current page. |
48 gfx::Image GetPageIcon() const; | 48 gfx::Image GetPageIcon() const; |
49 | 49 |
50 // content::WebContentsDelegate overrides. | 50 // content::WebContentsDelegate overrides. |
51 virtual content::WebContents* OpenURLFromTab( | 51 content::WebContents* OpenURLFromTab( |
52 content::WebContents* source, | 52 content::WebContents* source, |
53 const content::OpenURLParams& params) override; | 53 const content::OpenURLParams& params) override; |
54 virtual void NavigationStateChanged( | 54 void NavigationStateChanged(const content::WebContents* source, |
55 const content::WebContents* source, | 55 content::InvalidateTypes changed_flags) override; |
56 content::InvalidateTypes changed_flags) override; | 56 void AddNewContents(content::WebContents* source, |
57 virtual void AddNewContents(content::WebContents* source, | 57 content::WebContents* new_contents, |
58 content::WebContents* new_contents, | 58 WindowOpenDisposition disposition, |
59 WindowOpenDisposition disposition, | 59 const gfx::Rect& initial_pos, |
60 const gfx::Rect& initial_pos, | 60 bool user_gesture, |
61 bool user_gesture, | 61 bool* was_blocked) override; |
62 bool* was_blocked) override; | 62 void ActivateContents(content::WebContents* contents) override; |
63 virtual void ActivateContents(content::WebContents* contents) override; | 63 void DeactivateContents(content::WebContents* contents) override; |
64 virtual void DeactivateContents(content::WebContents* contents) override; | 64 void LoadingStateChanged(content::WebContents* source, |
65 virtual void LoadingStateChanged(content::WebContents* source, | 65 bool to_different_document) override; |
66 bool to_different_document) override; | 66 void CloseContents(content::WebContents* source) override; |
67 virtual void CloseContents(content::WebContents* source) override; | 67 void MoveContents(content::WebContents* source, |
68 virtual void MoveContents(content::WebContents* source, | 68 const gfx::Rect& pos) override; |
69 const gfx::Rect& pos) override; | 69 bool IsPopupOrPanel(const content::WebContents* source) const override; |
70 virtual bool IsPopupOrPanel( | 70 void ContentsZoomChange(bool zoom_in) override; |
71 const content::WebContents* source) const override; | 71 void HandleKeyboardEvent( |
72 virtual void ContentsZoomChange(bool zoom_in) override; | |
73 virtual void HandleKeyboardEvent( | |
74 content::WebContents* source, | 72 content::WebContents* source, |
75 const content::NativeWebKeyboardEvent& event) override; | 73 const content::NativeWebKeyboardEvent& event) override; |
76 virtual void WebContentsFocused(content::WebContents* contents) override; | 74 void WebContentsFocused(content::WebContents* contents) override; |
77 virtual void ResizeDueToAutoResize(content::WebContents* web_contents, | 75 void ResizeDueToAutoResize(content::WebContents* web_contents, |
78 const gfx::Size& new_size) override; | 76 const gfx::Size& new_size) override; |
79 | 77 |
80 // content::WebContentsObserver overrides. | 78 // content::WebContentsObserver overrides. |
81 virtual void RenderViewCreated( | 79 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
82 content::RenderViewHost* render_view_host) override; | 80 void RenderProcessGone(base::TerminationStatus status) override; |
83 virtual void RenderProcessGone(base::TerminationStatus status) override; | 81 void WebContentsDestroyed() override; |
84 virtual void WebContentsDestroyed() override; | 82 bool OnMessageReceived(const IPC::Message& message) override; |
85 virtual bool OnMessageReceived(const IPC::Message& message) override; | |
86 | 83 |
87 // extensions::ExtensionFunctionDispatcher::Delegate overrides. | 84 // extensions::ExtensionFunctionDispatcher::Delegate overrides. |
88 virtual extensions::WindowController* GetExtensionWindowController() const | 85 extensions::WindowController* GetExtensionWindowController() const override; |
89 override; | 86 content::WebContents* GetAssociatedWebContents() const override; |
90 virtual content::WebContents* GetAssociatedWebContents() const override; | |
91 | 87 |
92 // Actions on web contents. | 88 // Actions on web contents. |
93 void Reload(); | 89 void Reload(); |
94 void ReloadIgnoringCache(); | 90 void ReloadIgnoringCache(); |
95 void StopLoading(); | 91 void StopLoading(); |
96 void Zoom(content::PageZoom zoom); | 92 void Zoom(content::PageZoom zoom); |
97 | 93 |
98 private: | 94 private: |
99 // Helper to close panel via the message loop. | 95 // Helper to close panel via the message loop. |
100 void ClosePanel(); | 96 void ClosePanel(); |
101 | 97 |
102 // Message handlers. | 98 // Message handlers. |
103 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 99 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
104 | 100 |
105 Panel* panel_; // Weak, owns us. | 101 Panel* panel_; // Weak, owns us. |
106 Profile* profile_; | 102 Profile* profile_; |
107 extensions::ExtensionFunctionDispatcher extension_function_dispatcher_; | 103 extensions::ExtensionFunctionDispatcher extension_function_dispatcher_; |
108 | 104 |
109 scoped_ptr<content::WebContents> web_contents_; | 105 scoped_ptr<content::WebContents> web_contents_; |
110 | 106 |
111 // The following factory is used to close the panel via the message loop. | 107 // The following factory is used to close the panel via the message loop. |
112 base::WeakPtrFactory<PanelHost> weak_factory_; | 108 base::WeakPtrFactory<PanelHost> weak_factory_; |
113 | 109 |
114 DISALLOW_COPY_AND_ASSIGN(PanelHost); | 110 DISALLOW_COPY_AND_ASSIGN(PanelHost); |
115 }; | 111 }; |
116 | 112 |
117 #endif // CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | 113 #endif // CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ |
OLD | NEW |