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

Side by Side Diff: chrome/browser/ui/web_contents_modal_dialog_manager.h

Issue 12045037: Refactor modality-specific behavior from ConstrainedWindowViews to WebContentsModalDialogManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Android link error Created 7 years, 10 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 CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ 5 #ifndef CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_
6 #define CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ 6 #define CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h"
10 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h" 13 #include "content/public/browser/web_contents_user_data.h"
14 #include "ui/gfx/native_widget_types.h"
12 15
13 class WebContentsModalDialog; 16 class WebContentsModalDialog;
14 class WebContentsModalDialogManagerDelegate; 17 class WebContentsModalDialogManagerDelegate;
15 18
16 // Per-WebContents class to manage WebContents-modal dialogs. 19 // Per-WebContents class to manage WebContents-modal dialogs.
17 class WebContentsModalDialogManager 20 class WebContentsModalDialogManager
18 : public content::WebContentsObserver, 21 : public content::WebContentsObserver,
19 public content::WebContentsUserData<WebContentsModalDialogManager> { 22 public content::WebContentsUserData<WebContentsModalDialogManager> {
20 public: 23 public:
21 virtual ~WebContentsModalDialogManager(); 24 virtual ~WebContentsModalDialogManager();
22 25
23 WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; } 26 WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; }
24 void set_delegate(WebContentsModalDialogManagerDelegate* d) { delegate_ = d; } 27 void set_delegate(WebContentsModalDialogManagerDelegate* d) { delegate_ = d; }
25 28
29 static NativeWebContentsModalDialogManager* CreateNativeManager(
30 WebContentsModalDialogManager* manager);
31
26 // Adds the given dialog to the list of child dialogs. The dialog will notify 32 // Adds the given dialog to the list of child dialogs. The dialog will notify
27 // via WillClose() when it is being destroyed. 33 // via WillClose() when it is being destroyed.
28 void AddDialog(WebContentsModalDialog* dialog); 34 void AddDialog(WebContentsModalDialog* dialog);
29 35
30 // Called when a WebContentsModalDialogs we own is about to be closed. 36 // Called when a WebContentsModalDialogs we own is about to be closed.
31 void WillClose(WebContentsModalDialog* dialog); 37 void WillClose(WebContentsModalDialog* dialog);
32 38
33 // Blocks/unblocks interaction with renderer process. 39 // Blocks/unblocks interaction with renderer process.
34 void BlockWebContentsInteraction(bool blocked); 40 void BlockWebContentsInteraction(bool blocked);
35 41
36 // Returns true if a dialog is currently being shown. 42 // Returns true if a dialog is currently being shown.
37 bool IsShowingDialog() const; 43 bool IsShowingDialog() const;
38 44
39 // Focus the topmost modal dialog. IsShowingDialog() must be true when 45 // Focus the topmost modal dialog. IsShowingDialog() must be true when
40 // calling this function. 46 // calling this function.
41 void FocusTopmostDialog(); 47 void FocusTopmostDialog();
42 48
43 // For testing. 49 // For testing.
44 class TestApi { 50 class TestApi {
45 public: 51 public:
46 explicit TestApi(WebContentsModalDialogManager* manager) 52 explicit TestApi(WebContentsModalDialogManager* manager)
47 : manager_(manager) {} 53 : manager_(manager) {}
48 54
49 void CloseAllDialogs() { manager_->CloseAllDialogs(); } 55 void CloseAllDialogs() { manager_->CloseAllDialogs(); }
56 void ResetNativeManager(NativeWebContentsModalDialogManager* delegate) {
57 manager_->native_manager_.reset(delegate);
58 }
50 59
51 private: 60 private:
52 WebContentsModalDialogManager* manager_; 61 WebContentsModalDialogManager* manager_;
53 62
54 DISALLOW_COPY_AND_ASSIGN(TestApi); 63 DISALLOW_COPY_AND_ASSIGN(TestApi);
55 }; 64 };
56 65
57 private: 66 private:
58 explicit WebContentsModalDialogManager(content::WebContents* web_contents); 67 explicit WebContentsModalDialogManager(content::WebContents* web_contents);
59 friend class content::WebContentsUserData<WebContentsModalDialogManager>; 68 friend class content::WebContentsUserData<WebContentsModalDialogManager>;
(...skipping 19 matching lines...) Expand all
79 // Overridden from content::WebContentsObserver: 88 // Overridden from content::WebContentsObserver:
80 virtual void DidNavigateMainFrame( 89 virtual void DidNavigateMainFrame(
81 const content::LoadCommittedDetails& details, 90 const content::LoadCommittedDetails& details,
82 const content::FrameNavigateParams& params) OVERRIDE; 91 const content::FrameNavigateParams& params) OVERRIDE;
83 virtual void DidGetIgnoredUIEvent() OVERRIDE; 92 virtual void DidGetIgnoredUIEvent() OVERRIDE;
84 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; 93 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
85 94
86 // Delegate for notifying our owner about stuff. Not owned by us. 95 // Delegate for notifying our owner about stuff. Not owned by us.
87 WebContentsModalDialogManagerDelegate* delegate_; 96 WebContentsModalDialogManagerDelegate* delegate_;
88 97
98 // Delegate for native UI-specific functions on the dialog.
99 scoped_ptr<NativeWebContentsModalDialogManager> native_manager_;
100
89 // All active dialogs. 101 // All active dialogs.
90 WebContentsModalDialogList child_dialogs_; 102 WebContentsModalDialogList child_dialogs_;
91 103
92 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager); 104 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManager);
93 }; 105 };
94 106
95 #endif // CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_ 107 #endif // CHROME_BROWSER_UI_WEB_CONTENTS_MODAL_DIALOG_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/web_intent_picker_views.cc ('k') | chrome/browser/ui/web_contents_modal_dialog_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698