| OLD | NEW |
| 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/webui/web_dialog_controller.h" | 5 #include "chrome/browser/ui/webui/web_dialog_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/webui/web_dialog_delegate.h" | 9 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
| 13 | 13 |
| 14 WebDialogController::WebDialogController( | 14 WebDialogController::WebDialogController( |
| 15 WebDialogDelegate* delegate, | 15 web_dialogs::WebDialogDelegate* delegate, |
| 16 Profile* profile, | 16 Profile* profile, |
| 17 Browser* browser) | 17 Browser* browser) |
| 18 : dialog_delegate_(delegate) { | 18 : dialog_delegate_(delegate) { |
| 19 // It's only safe to show an off the record profile under one of two | 19 // It's only safe to show an off the record profile under one of two |
| 20 // circumstances: | 20 // circumstances: |
| 21 // 1. For a modal dialog where the parent will maintain the profile. | 21 // 1. For a modal dialog where the parent will maintain the profile. |
| 22 // 2. If we have a browser which will keep the reference to this profile | 22 // 2. If we have a browser which will keep the reference to this profile |
| 23 // alive. The dialog will be closed if this browser is closed. | 23 // alive. The dialog will be closed if this browser is closed. |
| 24 DCHECK(!profile->IsOffTheRecord() || | 24 DCHECK(!profile->IsOffTheRecord() || |
| 25 delegate->GetDialogModalType() != ui::MODAL_TYPE_NONE || | 25 delegate->GetDialogModalType() != ui::MODAL_TYPE_NONE || |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 void WebDialogController::Observe( | 37 void WebDialogController::Observe( |
| 38 int type, | 38 int type, |
| 39 const content::NotificationSource& source, | 39 const content::NotificationSource& source, |
| 40 const content::NotificationDetails& details) { | 40 const content::NotificationDetails& details) { |
| 41 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING); | 41 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING); |
| 42 | 42 |
| 43 // If the browser creating this dialog is closed, close the dialog to prevent | 43 // If the browser creating this dialog is closed, close the dialog to prevent |
| 44 // using potentially destroyed profiles. | 44 // using potentially destroyed profiles. |
| 45 dialog_delegate_->OnDialogClosed(std::string()); | 45 dialog_delegate_->OnDialogClosed(std::string()); |
| 46 } | 46 } |
| OLD | NEW |