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 UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ | 5 #ifndef UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ |
6 #define UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ | 6 #define UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "content/public/browser/web_contents_delegate.h" | 9 #include "content/public/browser/web_contents_delegate.h" |
10 #include "ui/web_dialogs/web_dialogs_export.h" | 10 #include "ui/web_dialogs/web_dialogs_export.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 virtual ~WebContentsHandler() {} | 25 virtual ~WebContentsHandler() {} |
26 virtual content::WebContents* OpenURLFromTab( | 26 virtual content::WebContents* OpenURLFromTab( |
27 content::BrowserContext* context, | 27 content::BrowserContext* context, |
28 content::WebContents* source, | 28 content::WebContents* source, |
29 const content::OpenURLParams& params) = 0; | 29 const content::OpenURLParams& params) = 0; |
30 virtual void AddNewContents(content::BrowserContext* context, | 30 virtual void AddNewContents(content::BrowserContext* context, |
31 content::WebContents* source, | 31 content::WebContents* source, |
32 content::WebContents* new_contents, | 32 content::WebContents* new_contents, |
33 WindowOpenDisposition disposition, | 33 WindowOpenDisposition disposition, |
34 const gfx::Rect& initial_pos, | 34 const gfx::Rect& initial_rect, |
35 bool user_gesture) = 0; | 35 bool user_gesture) = 0; |
36 }; | 36 }; |
37 | 37 |
38 // context and handler must be non-NULL. | 38 // context and handler must be non-NULL. |
39 // Takes the ownership of handler. | 39 // Takes the ownership of handler. |
40 WebDialogWebContentsDelegate(content::BrowserContext* context, | 40 WebDialogWebContentsDelegate(content::BrowserContext* context, |
41 WebContentsHandler* handler); | 41 WebContentsHandler* handler); |
42 | 42 |
43 ~WebDialogWebContentsDelegate() override; | 43 ~WebDialogWebContentsDelegate() override; |
44 | 44 |
45 // The returned browser context is guaranteed to be original if non-NULL. | 45 // The returned browser context is guaranteed to be original if non-NULL. |
46 content::BrowserContext* browser_context() const { | 46 content::BrowserContext* browser_context() const { |
47 return browser_context_; | 47 return browser_context_; |
48 } | 48 } |
49 | 49 |
50 // Calling this causes all following events sent from the | 50 // Calling this causes all following events sent from the |
51 // WebContents object to be ignored. It also makes all following | 51 // WebContents object to be ignored. It also makes all following |
52 // calls to browser_context() return NULL. | 52 // calls to browser_context() return NULL. |
53 void Detach(); | 53 void Detach(); |
54 | 54 |
55 // content::WebContentsDelegate declarations. | 55 // content::WebContentsDelegate declarations. |
56 content::WebContents* OpenURLFromTab( | 56 content::WebContents* OpenURLFromTab( |
57 content::WebContents* source, | 57 content::WebContents* source, |
58 const content::OpenURLParams& params) override; | 58 const content::OpenURLParams& params) override; |
59 void AddNewContents(content::WebContents* source, | 59 void AddNewContents(content::WebContents* source, |
60 content::WebContents* new_contents, | 60 content::WebContents* new_contents, |
61 WindowOpenDisposition disposition, | 61 WindowOpenDisposition disposition, |
62 const gfx::Rect& initial_pos, | 62 const gfx::Rect& initial_rect, |
63 bool user_gesture, | 63 bool user_gesture, |
64 bool* was_blocked) override; | 64 bool* was_blocked) override; |
65 bool IsPopupOrPanel(const content::WebContents* source) const override; | 65 bool IsPopupOrPanel(const content::WebContents* source) const override; |
66 bool PreHandleGestureEvent(content::WebContents* source, | 66 bool PreHandleGestureEvent(content::WebContents* source, |
67 const blink::WebGestureEvent& event) override; | 67 const blink::WebGestureEvent& event) override; |
68 | 68 |
69 private: | 69 private: |
70 // Weak pointer. Always an original profile. | 70 // Weak pointer. Always an original profile. |
71 content::BrowserContext* browser_context_; | 71 content::BrowserContext* browser_context_; |
72 | 72 |
73 scoped_ptr<WebContentsHandler> handler_; | 73 scoped_ptr<WebContentsHandler> handler_; |
74 | 74 |
75 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate); | 75 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate); |
76 }; | 76 }; |
77 | 77 |
78 } // namespace ui | 78 } // namespace ui |
79 | 79 |
80 #endif // UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ | 80 #endif // UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ |
OLD | NEW |