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

Side by Side Diff: chrome/browser/ui/views/tab_modal_confirm_dialog_views.cc

Issue 17500003: Close web contents modal dialogs on content load start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compilation fixes, change "inhibit" variable names Created 7 years, 5 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/views/tab_modal_confirm_dialog_views.h" 5 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser_dialogs.h" 8 #include "chrome/browser/ui/browser_dialogs.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
(...skipping 21 matching lines...) Expand all
32 return new TabModalConfirmDialogViews( 32 return new TabModalConfirmDialogViews(
33 delegate, web_contents); 33 delegate, web_contents);
34 } 34 }
35 35
36 ////////////////////////////////////////////////////////////////////////////// 36 //////////////////////////////////////////////////////////////////////////////
37 // TabModalConfirmDialogViews, constructor & destructor: 37 // TabModalConfirmDialogViews, constructor & destructor:
38 38
39 TabModalConfirmDialogViews::TabModalConfirmDialogViews( 39 TabModalConfirmDialogViews::TabModalConfirmDialogViews(
40 TabModalConfirmDialogDelegate* delegate, 40 TabModalConfirmDialogDelegate* delegate,
41 content::WebContents* web_contents) 41 content::WebContents* web_contents)
42 : delegate_(delegate), 42 : web_contents_(web_contents),
43 delegate_(delegate),
43 dialog_(NULL), 44 dialog_(NULL),
44 browser_context_(web_contents->GetBrowserContext()) { 45 browser_context_(web_contents->GetBrowserContext()) {
45 views::MessageBoxView::InitParams init_params(delegate->GetMessage()); 46 views::MessageBoxView::InitParams init_params(delegate->GetMessage());
46 init_params.inter_row_vertical_spacing = 47 init_params.inter_row_vertical_spacing =
47 views::kUnrelatedControlVerticalSpacing; 48 views::kUnrelatedControlVerticalSpacing;
48 message_box_view_ = new views::MessageBoxView(init_params); 49 message_box_view_ = new views::MessageBoxView(init_params);
49 50
50 string16 link_text(delegate->GetLinkText()); 51 string16 link_text(delegate->GetLinkText());
51 if (!link_text.empty()) 52 if (!link_text.empty())
52 message_box_view_->SetLink(link_text, this); 53 message_box_view_->SetLink(link_text, this);
53 54
54 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 55 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
55 WebContentsModalDialogManager::FromWebContents(web_contents); 56 WebContentsModalDialogManager::FromWebContents(web_contents);
56 dialog_ = CreateWebContentsModalDialogViews( 57 dialog_ = CreateWebContentsModalDialogViews(
57 this, 58 this,
58 web_contents->GetView()->GetNativeView(), 59 web_contents->GetView()->GetNativeView(),
59 web_contents_modal_dialog_manager->delegate()-> 60 web_contents_modal_dialog_manager->delegate()->
60 GetWebContentsModalDialogHost()); 61 GetWebContentsModalDialogHost());
61 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); 62 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView());
62 delegate_->set_close_delegate(this); 63 delegate_->set_operations_delegate(this);
63 } 64 }
64 65
65 TabModalConfirmDialogViews::~TabModalConfirmDialogViews() { 66 TabModalConfirmDialogViews::~TabModalConfirmDialogViews() {
66 } 67 }
67 68
68 void TabModalConfirmDialogViews::AcceptTabModalDialog() { 69 void TabModalConfirmDialogViews::AcceptTabModalDialog() {
69 GetDialogClientView()->AcceptWindow(); 70 GetDialogClientView()->AcceptWindow();
70 } 71 }
71 72
72 void TabModalConfirmDialogViews::CancelTabModalDialog() { 73 void TabModalConfirmDialogViews::CancelTabModalDialog() {
73 GetDialogClientView()->CancelWindow(); 74 GetDialogClientView()->CancelWindow();
74 } 75 }
75 76
76 void TabModalConfirmDialogViews::CloseDialog() { 77 void TabModalConfirmDialogViews::CloseDialog() {
77 dialog_->Close(); 78 dialog_->Close();
78 } 79 }
79 80
81 void TabModalConfirmDialogViews::SetPreventCloseOnLoadStart(bool prevent) {
82 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
83 WebContentsModalDialogManager::FromWebContents(web_contents_);
84 web_contents_modal_dialog_manager->SetPreventCloseOnLoadStart(
85 dialog_->GetNativeView(), prevent);
86 }
87
80 ////////////////////////////////////////////////////////////////////////////// 88 //////////////////////////////////////////////////////////////////////////////
81 // TabModalConfirmDialogViews, views::LinkListener implementation: 89 // TabModalConfirmDialogViews, views::LinkListener implementation:
82 90
83 void TabModalConfirmDialogViews::LinkClicked(views::Link* source, 91 void TabModalConfirmDialogViews::LinkClicked(views::Link* source,
84 int event_flags) { 92 int event_flags) {
85 delegate_->LinkClicked(ui::DispositionFromEventFlags(event_flags)); 93 delegate_->LinkClicked(ui::DispositionFromEventFlags(event_flags));
86 } 94 }
87 95
88 ////////////////////////////////////////////////////////////////////////////// 96 //////////////////////////////////////////////////////////////////////////////
89 // TabModalConfirmDialogViews, views::DialogDelegate implementation: 97 // TabModalConfirmDialogViews, views::DialogDelegate implementation:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 delete this; 145 delete this;
138 } 146 }
139 147
140 ui::ModalType TabModalConfirmDialogViews::GetModalType() const { 148 ui::ModalType TabModalConfirmDialogViews::GetModalType() const {
141 #if defined(USE_ASH) 149 #if defined(USE_ASH)
142 return ui::MODAL_TYPE_CHILD; 150 return ui::MODAL_TYPE_CHILD;
143 #else 151 #else
144 return views::WidgetDelegate::GetModalType(); 152 return views::WidgetDelegate::GetModalType();
145 #endif 153 #endif
146 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698