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

Side by Side Diff: chrome/browser/ui/webui/html_dialog_controller.cc

Issue 10214001: WebDialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/html_dialog_controller.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/common/chrome_notification_types.h"
10 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/notification_source.h"
12
13 HtmlDialogController::HtmlDialogController(HtmlDialogUIDelegate* delegate,
14 Profile* profile,
15 Browser* browser)
16 : dialog_delegate_(delegate) {
17 // It's only safe to show an off the record profile under one of two
18 // circumstances:
19 // 1. For a modal dialog where the parent will maintain the profile.
20 // 2. If we have a browser which will keep the reference to this profile
21 // alive. The dialog will be closed if this browser is closed.
22 DCHECK(!profile->IsOffTheRecord() ||
23 delegate->GetDialogModalType() != ui::MODAL_TYPE_NONE ||
24 (browser && browser->profile() == profile));
25 // If we're passed a browser it should own the profile we're using.
26 DCHECK(!browser || browser->profile() == profile);
27 if (browser) {
28 registrar_.Add(this,
29 chrome::NOTIFICATION_BROWSER_CLOSING,
30 content::Source<Browser>(browser));
31 }
32 }
33
34 // content::NotificationObserver implementation:
35 void HtmlDialogController::Observe(
36 int type,
37 const content::NotificationSource& source,
38 const content::NotificationDetails& details) {
39 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING);
40
41 // If the browser creating this dialog is closed, close the dialog to prevent
42 // using potentially destroyed profiles.
43 dialog_delegate_->OnDialogClosed(std::string());
44 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_controller.h ('k') | chrome/browser/ui/webui/html_dialog_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698