Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: ui/web_dialogs/web_dialog_web_contents_delegate.h

Issue 10868116: Pass result of blockage across content API when new tab blocked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 // This class implements (and mostly ignores) most of 14 // This class implements (and mostly ignores) most of
15 // content::WebContentsDelegate for use in a Web dialog. Subclasses need only 15 // content::WebContentsDelegate for use in a Web dialog. Subclasses need only
16 // override a few methods instead of the everything from 16 // override a few methods instead of the everything from
17 // content::WebContentsDelegate; this way, implementations on all platforms 17 // content::WebContentsDelegate; this way, implementations on all platforms
18 // behave consistently. 18 // behave consistently.
19 class WEB_DIALOGS_EXPORT WebDialogWebContentsDelegate 19 class WEB_DIALOGS_EXPORT WebDialogWebContentsDelegate
20 : public content::WebContentsDelegate { 20 : public content::WebContentsDelegate {
21 public: 21 public:
22 // Handles OpenURLFromTab and AddNewContents for WebDialogWebContentsDelegate. 22 // Handles OpenURLFromTab and AddNewContents for WebDialogWebContentsDelegate.
23 class WebContentsHandler { 23 class WebContentsHandler {
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 // Returns false if the new contents was blocked.
31 virtual bool AddNewContents(content::BrowserContext* context,
jam 2012/09/05 06:12:15 the only implementation of this is in chrome_web_c
31 content::WebContents* source, 32 content::WebContents* source,
32 content::WebContents* new_contents, 33 content::WebContents* new_contents,
33 WindowOpenDisposition disposition, 34 WindowOpenDisposition disposition,
34 const gfx::Rect& initial_pos, 35 const gfx::Rect& initial_pos,
35 bool user_gesture) = 0; 36 bool user_gesture) = 0;
36 }; 37 };
37 38
38 // context and handler must be non-NULL. 39 // context and handler must be non-NULL.
39 // Takes the ownership of handler. 40 // Takes the ownership of handler.
40 WebDialogWebContentsDelegate(content::BrowserContext* context, 41 WebDialogWebContentsDelegate(content::BrowserContext* context,
41 WebContentsHandler* handler); 42 WebContentsHandler* handler);
42 43
43 virtual ~WebDialogWebContentsDelegate(); 44 virtual ~WebDialogWebContentsDelegate();
44 45
45 // The returned browser context is guaranteed to be original if non-NULL. 46 // The returned browser context is guaranteed to be original if non-NULL.
46 content::BrowserContext* browser_context() const { 47 content::BrowserContext* browser_context() const {
47 return browser_context_; 48 return browser_context_;
48 } 49 }
49 50
50 // Calling this causes all following events sent from the 51 // Calling this causes all following events sent from the
51 // WebContents object to be ignored. It also makes all following 52 // WebContents object to be ignored. It also makes all following
52 // calls to browser_context() return NULL. 53 // calls to browser_context() return NULL.
53 void Detach(); 54 void Detach();
54 55
55 // content::WebContentsDelegate declarations. 56 // content::WebContentsDelegate declarations.
56 virtual content::WebContents* OpenURLFromTab( 57 virtual content::WebContents* OpenURLFromTab(
57 content::WebContents* source, 58 content::WebContents* source,
58 const content::OpenURLParams& params) OVERRIDE; 59 const content::OpenURLParams& params) OVERRIDE;
59 60
60 virtual void AddNewContents(content::WebContents* source, 61 virtual bool AddNewContents(content::WebContents* source,
61 content::WebContents* new_contents, 62 content::WebContents* new_contents,
62 WindowOpenDisposition disposition, 63 WindowOpenDisposition disposition,
63 const gfx::Rect& initial_pos, 64 const gfx::Rect& initial_pos,
64 bool user_gesture) OVERRIDE; 65 bool user_gesture) OVERRIDE;
65 virtual bool IsPopupOrPanel( 66 virtual bool IsPopupOrPanel(
66 const content::WebContents* source) const OVERRIDE; 67 const content::WebContents* source) const OVERRIDE;
67 virtual bool ShouldAddNavigationToHistory( 68 virtual bool ShouldAddNavigationToHistory(
68 const history::HistoryAddPageArgs& add_page_args, 69 const history::HistoryAddPageArgs& add_page_args,
69 content::NavigationType navigation_type) OVERRIDE; 70 content::NavigationType navigation_type) OVERRIDE;
70 71
71 private: 72 private:
72 // Weak pointer. Always an original profile. 73 // Weak pointer. Always an original profile.
73 content::BrowserContext* browser_context_; 74 content::BrowserContext* browser_context_;
74 75
75 scoped_ptr<WebContentsHandler> handler_; 76 scoped_ptr<WebContentsHandler> handler_;
76 77
77 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate); 78 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate);
78 }; 79 };
79 80
80 } // namespace ui 81 } // namespace ui
81 82
82 #endif // UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ 83 #endif // UI_WEB_DIALOGS_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_
OLDNEW
« no previous file with comments | « ui/views/controls/webview/web_dialog_view.cc ('k') | ui/web_dialogs/web_dialog_web_contents_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698