This source file includes following definitions.
- closing_
- Cancel
- Accept
- Observe
- Close
- LinkClicked
- GetIcon
- GetAcceptButtonTitle
- GetCancelButtonTitle
- GetLinkText
- GetAcceptButtonIcon
- GetCancelButtonIcon
- OnAccepted
- OnCanceled
- OnLinkClicked
- OnClosed
- CloseDialog
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "chrome/browser/chrome_notification_types.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
using content::NavigationController;
using content::WebContents;
TabModalConfirmDialogDelegate::TabModalConfirmDialogDelegate(
WebContents* web_contents)
: close_delegate_(NULL),
closing_(false) {
NavigationController* controller = &web_contents->GetController();
registrar_.Add(this, content::NOTIFICATION_LOAD_START,
content::Source<NavigationController>(controller));
}
TabModalConfirmDialogDelegate::~TabModalConfirmDialogDelegate() {
close_delegate_ = NULL;
Cancel();
}
void TabModalConfirmDialogDelegate::Cancel() {
if (closing_)
return;
closing_ = true;
OnCanceled();
CloseDialog();
}
void TabModalConfirmDialogDelegate::Accept() {
if (closing_)
return;
closing_ = true;
OnAccepted();
CloseDialog();
}
void TabModalConfirmDialogDelegate::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(content::NOTIFICATION_LOAD_START, type);
Close();
}
void TabModalConfirmDialogDelegate::Close() {
if (closing_)
return;
closing_ = true;
OnClosed();
CloseDialog();
}
void TabModalConfirmDialogDelegate::LinkClicked(
WindowOpenDisposition disposition) {
if (closing_)
return;
OnLinkClicked(disposition);
}
gfx::Image* TabModalConfirmDialogDelegate::GetIcon() {
return NULL;
}
base::string16 TabModalConfirmDialogDelegate::GetAcceptButtonTitle() {
return l10n_util::GetStringUTF16(IDS_OK);
}
base::string16 TabModalConfirmDialogDelegate::GetCancelButtonTitle() {
return l10n_util::GetStringUTF16(IDS_CANCEL);
}
base::string16 TabModalConfirmDialogDelegate::GetLinkText() const {
return base::string16();
}
const char* TabModalConfirmDialogDelegate::GetAcceptButtonIcon() {
return NULL;
}
const char* TabModalConfirmDialogDelegate::GetCancelButtonIcon() {
return NULL;
}
void TabModalConfirmDialogDelegate::OnAccepted() {
}
void TabModalConfirmDialogDelegate::OnCanceled() {
}
void TabModalConfirmDialogDelegate::OnLinkClicked(
WindowOpenDisposition disposition) {
}
void TabModalConfirmDialogDelegate::OnClosed() {
}
void TabModalConfirmDialogDelegate::CloseDialog() {
if (close_delegate_)
close_delegate_->CloseDialog();
}