| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "content/public/browser/web_contents_delegate.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 #include "content/public/common/page_zoom.h" | |
| 15 #include "extensions/browser/extension_function_dispatcher.h" | |
| 16 | |
| 17 class GURL; | |
| 18 class Panel; | |
| 19 class PrefsTabHelper; | |
| 20 class Profile; | |
| 21 | |
| 22 namespace content { | |
| 23 class SiteInstance; | |
| 24 class WebContents; | |
| 25 } | |
| 26 | |
| 27 namespace extensions { | |
| 28 class WindowController; | |
| 29 } | |
| 30 | |
| 31 namespace gfx { | |
| 32 class Image; | |
| 33 class Rect; | |
| 34 } | |
| 35 | |
| 36 // Helper class for Panel, implementing WebContents hosting and Extension | |
| 37 // delegates. Owned and used by Panel only. | |
| 38 class PanelHost : public content::WebContentsDelegate, | |
| 39 public content::WebContentsObserver, | |
| 40 public extensions::ExtensionFunctionDispatcher::Delegate { | |
| 41 public: | |
| 42 PanelHost(Panel* panel, Profile* profile); | |
| 43 ~PanelHost() override; | |
| 44 | |
| 45 void Init(const GURL& url, content::SiteInstance* source_site_instance); | |
| 46 content::WebContents* web_contents() { return web_contents_.get(); } | |
| 47 void DestroyWebContents(); | |
| 48 | |
| 49 // Returns the icon for the current page. | |
| 50 gfx::Image GetPageIcon() const; | |
| 51 | |
| 52 // content::WebContentsDelegate overrides. | |
| 53 content::WebContents* OpenURLFromTab( | |
| 54 content::WebContents* source, | |
| 55 const content::OpenURLParams& params) override; | |
| 56 void NavigationStateChanged(content::WebContents* source, | |
| 57 content::InvalidateTypes changed_flags) override; | |
| 58 void AddNewContents(content::WebContents* source, | |
| 59 content::WebContents* new_contents, | |
| 60 WindowOpenDisposition disposition, | |
| 61 const gfx::Rect& initial_rect, | |
| 62 bool user_gesture, | |
| 63 bool* was_blocked) override; | |
| 64 void ActivateContents(content::WebContents* contents) override; | |
| 65 void LoadingStateChanged(content::WebContents* source, | |
| 66 bool to_different_document) override; | |
| 67 void CloseContents(content::WebContents* source) override; | |
| 68 void MoveContents(content::WebContents* source, | |
| 69 const gfx::Rect& pos) override; | |
| 70 bool IsPopupOrPanel(const content::WebContents* source) const override; | |
| 71 void ContentsZoomChange(bool zoom_in) override; | |
| 72 void HandleKeyboardEvent( | |
| 73 content::WebContents* source, | |
| 74 const content::NativeWebKeyboardEvent& event) override; | |
| 75 void ResizeDueToAutoResize(content::WebContents* web_contents, | |
| 76 const gfx::Size& new_size) override; | |
| 77 | |
| 78 // content::WebContentsObserver overrides. | |
| 79 void RenderProcessGone(base::TerminationStatus status) override; | |
| 80 void WebContentsDestroyed() override; | |
| 81 | |
| 82 // extensions::ExtensionFunctionDispatcher::Delegate overrides. | |
| 83 extensions::WindowController* GetExtensionWindowController() const override; | |
| 84 content::WebContents* GetAssociatedWebContents() const override; | |
| 85 | |
| 86 // Actions on web contents. | |
| 87 void Reload(); | |
| 88 void ReloadBypassingCache(); | |
| 89 void StopLoading(); | |
| 90 void Zoom(content::PageZoom zoom); | |
| 91 | |
| 92 private: | |
| 93 // Helper to close panel via the message loop. | |
| 94 void ClosePanel(); | |
| 95 | |
| 96 Panel* panel_; // Weak, owns us. | |
| 97 Profile* profile_; | |
| 98 | |
| 99 std::unique_ptr<content::WebContents> web_contents_; | |
| 100 | |
| 101 // The following factory is used to close the panel via the message loop. | |
| 102 base::WeakPtrFactory<PanelHost> weak_factory_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(PanelHost); | |
| 105 }; | |
| 106 | |
| 107 #endif // CHROME_BROWSER_UI_PANELS_PANEL_HOST_H_ | |
| OLD | NEW |