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

Unified Diff: chrome/browser/ui/tab_modal_dialog_delegate.h

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/browser/ui/tab_modal_dialog_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tab_modal_dialog_delegate.h
diff --git a/chrome/browser/ui/tab_modal_dialog_delegate.h b/chrome/browser/ui/tab_modal_dialog_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..585436adc0cc545f8b055011945812048031d709
--- /dev/null
+++ b/chrome/browser/ui/tab_modal_dialog_delegate.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_
+#define CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_
+#pragma once
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/string16.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace gfx {
+class Image;
+}
+class ConstrainedWindow;
+class TabContents;
+
+// This class acts as the delegate for a simple tab-modal dialog confirming
+// whether the user wants to execute a certain action.
+class TabModalDialogDelegate : public content::NotificationObserver {
+ public:
+ explicit TabModalDialogDelegate(TabContents* tab_contents);
+ virtual ~TabModalDialogDelegate();
+
+ void set_window(ConstrainedWindow* window) { window_ = window; }
+
+ void Accept();
+ void Cancel();
+
+ // The title of the dialog. Note that the title is not shown on all platforms.
+ virtual string16 GetTitle() = 0;
+ virtual string16 GetMessage() = 0;
+
+ // Icon to show for the dialog. If this method is not overridden, a default
+ // icon (like the application icon) is shown.
+ virtual gfx::Image* GetIcon();
+
+ // Title for the accept and the cancel buttons.
+ // The default implementation uses IDS_OK and IDS_CANCEL.
+ virtual string16 GetAcceptButtonTitle();
+ virtual string16 GetCancelButtonTitle();
+
+ // GTK stock icon names for the accept and cancel buttons, respectively.
+ // The icons are only used on GTK. If these methods are not overriden,
+ // the buttons have no stock icons.
+ virtual const char* GetAcceptButtonIcon();
+ virtual const char* GetCancelButtonIcon();
+
+ protected:
+ ConstrainedWindow* window() { return window_; }
+
+ // content::NotificationObserver implementation.
+ // Watch for a new load or a closed tab and dismiss the dialog if they occur.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ content::NotificationRegistrar registrar_;
+
+ private:
+ // Called when the user accepts or cancels the dialog, respectively.
+ virtual void OnAccepted() = 0;
+ virtual void OnCanceled() = 0;
+
+ // Close the dialog.
+ void CloseDialog();
+
+ ConstrainedWindow* window_;
+ // True iff we are in the process of closing, to avoid running callbacks
+ // multiple times.
+ bool closing_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabModalDialogDelegate);
+};
+
+#endif // CHROME_BROWSER_UI_TAB_MODAL_DIALOG_DELEGATE_H_
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/browser/ui/tab_modal_dialog_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698