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_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_ | |
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
10 #include "content/public/browser/web_contents_delegate.h" | |
11 #include "content/public/browser/web_contents_observer.h" | |
12 | |
13 class Browser; | |
14 class WebIntentPicker; | |
15 | |
16 // This class is the policy delegate for the rendered page in the intents | |
17 // inline disposition bubble. It also acts as a router for extension messages, | |
18 // so we can invoke extension APIs in inline disposition contexts. | |
19 class WebIntentInlineDispositionDelegate | |
20 : public content::WebContentsDelegate, | |
21 public content::WebContentsObserver, | |
22 public ExtensionFunctionDispatcher::Delegate { | |
23 public: | |
24 // |picker| is notified when the web contents loading state changes. Must not | |
25 // be NULL. | |
26 // |contents| is the WebContents for the inline disposition. | |
27 // |browser| is the browser inline disposition was invoked from. | |
28 WebIntentInlineDispositionDelegate(WebIntentPicker* picker, | |
29 content::WebContents* contents, | |
30 Browser* browser); | |
31 virtual ~WebIntentInlineDispositionDelegate(); | |
32 | |
33 // WebContentsDelegate implementation. | |
34 virtual bool IsPopupOrPanel( | |
35 const content::WebContents* source) const OVERRIDE; | |
36 virtual content::WebContents* OpenURLFromTab( | |
37 content::WebContents* source, | |
38 const content::OpenURLParams& params) OVERRIDE; | |
39 virtual void AddNewContents(content::WebContents* source, | |
40 content::WebContents* new_contents, | |
41 WindowOpenDisposition disposition, | |
42 const gfx::Rect& initial_pos, | |
43 bool user_gesture, | |
44 bool* was_blocked) OVERRIDE; | |
45 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; | |
46 virtual void ResizeDueToAutoResize(content::WebContents* source, | |
47 const gfx::Size& pref_size) OVERRIDE; | |
48 virtual void HandleKeyboardEvent( | |
49 content::WebContents* source, | |
50 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
51 | |
52 // content::WebContentsObserver | |
53 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
54 virtual void RenderViewCreated( | |
55 content::RenderViewHost* render_view_host) OVERRIDE; | |
56 virtual void DocumentAvailableInMainFrame() OVERRIDE; | |
57 | |
58 // ExtensionFunctionDispatcher::Delegate | |
59 virtual extensions::WindowController* GetExtensionWindowController() | |
60 const OVERRIDE; | |
61 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
62 | |
63 // Message handlers. | |
64 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
65 | |
66 // Updates the inline render view with a new max and min size. | |
67 void SetRenderViewSizeLimits(); | |
68 | |
69 private: | |
70 // Picker to notify when loading state changes. Weak pointer. | |
71 WebIntentPicker* picker_; | |
72 | |
73 // The WebContents container. Weak pointer. | |
74 content::WebContents* web_contents_; | |
75 | |
76 Browser* browser_; // Weak pointer. | |
77 | |
78 // The RVH responsible for the RenderView. Weak pointer. | |
79 content::RenderViewHost* render_view_host_; | |
80 | |
81 // Dispatch handler for extension APIs. | |
82 ExtensionFunctionDispatcher extension_function_dispatcher_; | |
83 }; | |
84 | |
85 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_ | |
OLD | NEW |