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

Side by Side Diff: chrome/browser/ui/views/extensions/device_permissions_dialog_view.cc

Issue 1070273003: Dismiss DevicePermissionsPrompt when the widgets are destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed pkasting@'s nits. Created 5 years, 8 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
« no previous file with comments | « chrome/browser/ui/views/extensions/device_permissions_dialog_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/device_permissions_dialog_view.h" 5 #include "chrome/browser/ui/views/extensions/device_permissions_dialog_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" 8 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "components/constrained_window/constrained_window_views.h" 10 #include "components/constrained_window/constrained_window_views.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 views::View* table_parent = table_view_->CreateParentIfNecessary(); 114 views::View* table_parent = table_view_->CreateParentIfNecessary();
115 AddChildView(table_parent); 115 AddChildView(table_parent);
116 layout->SetFlexForView(table_parent, 1); 116 layout->SetFlexForView(table_parent, 1);
117 } 117 }
118 118
119 DevicePermissionsDialogView::~DevicePermissionsDialogView() { 119 DevicePermissionsDialogView::~DevicePermissionsDialogView() {
120 RemoveAllChildViews(true); 120 RemoveAllChildViews(true);
121 } 121 }
122 122
123 bool DevicePermissionsDialogView::Cancel() { 123 void DevicePermissionsDialogView::DeleteDelegate() {
124 // Calling prompt_->Dismissed() here ensures it will be called regardless of
125 // how the view is closed, including shutdown of the entire view hierarchy.
124 prompt_->Dismissed(); 126 prompt_->Dismissed();
125 return true; 127 delete this;
126 } 128 }
127 129
128 bool DevicePermissionsDialogView::Accept() { 130 bool DevicePermissionsDialogView::Accept() {
129 for (int index : table_view_->selection_model().selected_indices()) { 131 for (int index : table_view_->selection_model().selected_indices()) {
130 prompt_->GrantDevicePermission(index); 132 prompt_->GrantDevicePermission(index);
131 } 133 }
132 prompt_->Dismissed();
133 return true; 134 return true;
134 } 135 }
135 136
136 base::string16 DevicePermissionsDialogView::GetDialogButtonLabel( 137 base::string16 DevicePermissionsDialogView::GetDialogButtonLabel(
137 ui::DialogButton button) const { 138 ui::DialogButton button) const {
138 if (button == ui::DIALOG_BUTTON_OK) { 139 if (button == ui::DIALOG_BUTTON_OK) {
139 return l10n_util::GetStringUTF16(IDS_DEVICE_PERMISSIONS_DIALOG_SELECT); 140 return l10n_util::GetStringUTF16(IDS_DEVICE_PERMISSIONS_DIALOG_SELECT);
140 } 141 }
141 return views::DialogDelegateView::GetDialogButtonLabel(button); 142 return views::DialogDelegateView::GetDialogButtonLabel(button);
142 } 143 }
143 144
144 ui::ModalType DevicePermissionsDialogView::GetModalType() const { 145 ui::ModalType DevicePermissionsDialogView::GetModalType() const {
145 return ui::MODAL_TYPE_CHILD; 146 return ui::MODAL_TYPE_CHILD;
146 } 147 }
147 148
148 base::string16 DevicePermissionsDialogView::GetWindowTitle() const { 149 base::string16 DevicePermissionsDialogView::GetWindowTitle() const {
149 return prompt_->GetHeading(); 150 return prompt_->GetHeading();
150 } 151 }
151 152
152 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const { 153 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const {
153 return gfx::Size(500, 250); 154 return gfx::Size(500, 250);
154 } 155 }
155 156
156 void ChromeDevicePermissionsPrompt::ShowDialog() { 157 void ChromeDevicePermissionsPrompt::ShowDialog() {
157 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
158 constrained_window::ShowWebModalDialogViews( 159 constrained_window::ShowWebModalDialogViews(
159 new DevicePermissionsDialogView(prompt()), web_contents()); 160 new DevicePermissionsDialogView(prompt()), web_contents());
160 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/device_permissions_dialog_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698