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

Side by Side Diff: components/web_modal/web_contents_modal_dialog_manager.cc

Issue 14969012: components: Create web_modal component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-gtk-build Created 7 years, 7 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 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 5 #include "components/web_modal/web_contents_modal_dialog_manager.h"
6 6
7 #include "chrome/browser/ui/web_contents_modal_dialog_manager_delegate.h" 7 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
8 #include "chrome/common/render_messages.h"
9 #include "content/public/browser/navigation_details.h" 8 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
11 #include "content/public/browser/notification_details.h" 10 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
17 16
18 using content::WebContents; 17 using content::WebContents;
19 18
20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(WebContentsModalDialogManager); 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(web_modal::WebContentsModalDialogManager);
20
21 namespace web_modal {
21 22
22 WebContentsModalDialogManager::~WebContentsModalDialogManager() { 23 WebContentsModalDialogManager::~WebContentsModalDialogManager() {
23 DCHECK(child_dialogs_.empty()); 24 DCHECK(child_dialogs_.empty());
24 } 25 }
25 26
26 void WebContentsModalDialogManager::ShowDialog( 27 void WebContentsModalDialogManager::ShowDialog(
27 NativeWebContentsModalDialog dialog) { 28 NativeWebContentsModalDialog dialog) {
28 child_dialogs_.push_back(dialog); 29 child_dialogs_.push_back(dialog);
29 30
30 native_manager_->ManageDialog(dialog); 31 native_manager_->ManageDialog(dialog);
31 32
32 if (child_dialogs_.size() == 1) { 33 if (child_dialogs_.size() == 1) {
33 native_manager_->ShowDialog(dialog); 34 native_manager_->ShowDialog(dialog);
34 BlockWebContentsInteraction(true); 35 BlockWebContentsInteraction(true);
35 } 36 }
36 } 37 }
37 38
38 void WebContentsModalDialogManager::BlockWebContentsInteraction(bool blocked) { 39 void WebContentsModalDialogManager::BlockWebContentsInteraction(bool blocked) {
39 WebContents* contents = web_contents(); 40 WebContents* contents = web_contents();
40 if (!contents) { 41 if (!contents) {
41 // The WebContents has already disconnected. 42 // The WebContents has already disconnected.
42 return; 43 return;
43 } 44 }
44 45
45 // RenderViewHost may be NULL during shutdown. 46 // RenderViewHost may be NULL during shutdown.
46 content::RenderViewHost* host = contents->GetRenderViewHost(); 47 content::RenderViewHost* host = contents->GetRenderViewHost();
47 if (host) { 48 if (host)
48 host->SetIgnoreInputEvents(blocked); 49 host->SetIgnoreInputEvents(blocked);
49 host->Send(new ChromeViewMsg_SetVisuallyDeemphasized( 50
50 host->GetRoutingID(), blocked));
51 }
52 if (delegate_) 51 if (delegate_)
53 delegate_->SetWebContentsBlocked(contents, blocked); 52 delegate_->SetWebContentsBlocked(contents, blocked);
54 } 53 }
55 54
56 bool WebContentsModalDialogManager::IsShowingDialog() const { 55 bool WebContentsModalDialogManager::IsShowingDialog() const {
57 return dialog_count() > 0; 56 return dialog_count() > 0;
58 } 57 }
59 58
60 void WebContentsModalDialogManager::FocusTopmostDialog() { 59 void WebContentsModalDialogManager::FocusTopmostDialog() {
61 DCHECK(dialog_count()); 60 DCHECK(dialog_count());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 native_manager_->FocusDialog(*dialog_begin()); 142 native_manager_->FocusDialog(*dialog_begin());
144 } 143 }
145 144
146 void WebContentsModalDialogManager::WebContentsDestroyed(WebContents* tab) { 145 void WebContentsModalDialogManager::WebContentsDestroyed(WebContents* tab) {
147 // First cleanly close all child dialogs. 146 // First cleanly close all child dialogs.
148 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked 147 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked
149 // some of these to close. CloseAllDialogs is async, so it might get called 148 // some of these to close. CloseAllDialogs is async, so it might get called
150 // twice before it runs. 149 // twice before it runs.
151 CloseAllDialogs(); 150 CloseAllDialogs();
152 } 151 }
152
153 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698