| 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/tab_modal_confirm_dialog_delegate.h" | 5 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/constrained_window.h" | 7 #include "chrome/browser/ui/constrained_window.h" |
| 8 #include "chrome/common/chrome_notification_types.h" |
| 8 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
| 9 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
| 10 #include "content/public/browser/notification_types.h" | |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 | 14 |
| 15 using content::NavigationController; | 15 using content::NavigationController; |
| 16 using content::WebContents; | 16 using content::WebContents; |
| 17 | 17 |
| 18 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate( | 18 TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate( |
| 19 WebContents* web_contents) | 19 WebContents* web_contents) |
| 20 : window_(NULL), | 20 : window_(NULL), |
| 21 closing_(false) { | 21 closing_(false) { |
| 22 NavigationController* controller = &web_contents->GetController(); | 22 NavigationController* controller = &web_contents->GetController(); |
| 23 registrar_.Add(this, content::NOTIFICATION_LOAD_START, | 23 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
| 24 content::Source<NavigationController>(controller)); | 24 content::Source<NavigationController>(controller)); |
| 25 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, | 25 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, |
| 26 content::Source<NavigationController>(controller)); | 26 content::Source<NavigationController>(controller)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { | 29 TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() { |
| 30 // If we end up here, the constrained window has been closed, so make sure we | 30 // If we end up here, the constrained window has been closed, so make sure we |
| 31 // don't close it again. | 31 // don't close it again. |
| 32 window_ = NULL; | 32 window_ = NULL; |
| 33 // Make sure everything is cleaned up. | 33 // Make sure everything is cleaned up. |
| 34 Cancel(); | 34 Cancel(); |
| 35 } | 35 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 void TabModalConfirmDialogDelegate::Observe( | 58 void TabModalConfirmDialogDelegate::Observe( |
| 59 int type, | 59 int type, |
| 60 const content::NotificationSource& source, | 60 const content::NotificationSource& source, |
| 61 const content::NotificationDetails& details) { | 61 const content::NotificationDetails& details) { |
| 62 // Close the dialog if we load a page (because the action might not apply to | 62 // Close the dialog if we load a page (because the action might not apply to |
| 63 // the same page anymore) or if the tab is closed. | 63 // the same page anymore) or if the tab is closed. |
| 64 if (type == content::NOTIFICATION_LOAD_START || | 64 if (type == content::NOTIFICATION_LOAD_START || |
| 65 type == content::NOTIFICATION_TAB_CLOSING) { | 65 type == chrome::NOTIFICATION_TAB_CLOSING) { |
| 66 Cancel(); | 66 Cancel(); |
| 67 } else { | 67 } else { |
| 68 NOTREACHED(); | 68 NOTREACHED(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { | 72 gfx::Image* TabModalConfirmDialogDelegate::GetIcon() { |
| 73 return NULL; | 73 return NULL; |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 92 void TabModalConfirmDialogDelegate::OnAccepted() { | 92 void TabModalConfirmDialogDelegate::OnAccepted() { |
| 93 } | 93 } |
| 94 | 94 |
| 95 void TabModalConfirmDialogDelegate::OnCanceled() { | 95 void TabModalConfirmDialogDelegate::OnCanceled() { |
| 96 } | 96 } |
| 97 | 97 |
| 98 void TabModalConfirmDialogDelegate::CloseDialog() { | 98 void TabModalConfirmDialogDelegate::CloseDialog() { |
| 99 if (window_) | 99 if (window_) |
| 100 window_->CloseConstrainedWindow(); | 100 window_->CloseConstrainedWindow(); |
| 101 } | 101 } |
| OLD | NEW |