summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 22:41:42 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-16 22:41:42 +0000
commitb6ad1cab92ed9e9c1734d1801482cfa8ffd3b4b1 (patch)
tree0d1a8598536ed29830e4e8a4cdbcd90b5f0dbd87 /chrome
parent16f3bd95e3f2bd39f6d64f91326bb3cdf894cedc (diff)
downloadchromium_src-b6ad1cab92ed9e9c1734d1801482cfa8ffd3b4b1.zip
chromium_src-b6ad1cab92ed9e9c1734d1801482cfa8ffd3b4b1.tar.gz
chromium_src-b6ad1cab92ed9e9c1734d1801482cfa8ffd3b4b1.tar.bz2
Pull app modal dialog handling out of the BrowserList to remove the ChromeViews dependency. (Required for porting).
TEST=Open two browser windows. In one, enter "javascript:alert('Foo');" into the address bar and hit enter. Click on the other window. The modal dialog should be focused and the window it was opened over should flash in the taskbar, Review URL: http://codereview.chromium.org/18179 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/app_modal_dialog_queue.cc7
-rw-r--r--chrome/browser/app_modal_dialog_queue.h14
-rw-r--r--chrome/browser/automation/automation_provider.cc5
-rw-r--r--chrome/browser/browser_list.cc20
-rw-r--r--chrome/browser/browser_list.h17
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
6 files changed, 22 insertions, 43 deletions
diff --git a/chrome/browser/app_modal_dialog_queue.cc b/chrome/browser/app_modal_dialog_queue.cc
index 0bcceb0..6646bbc 100644
--- a/chrome/browser/app_modal_dialog_queue.cc
+++ b/chrome/browser/app_modal_dialog_queue.cc
@@ -9,6 +9,7 @@
// static
std::queue<views::AppModalDialogDelegate*>*
AppModalDialogQueue::app_modal_dialog_queue_ = NULL;
+views::AppModalDialogDelegate* AppModalDialogQueue::active_dialog_ = NULL;
// static
void AppModalDialogQueue::AddDialog(views::AppModalDialogDelegate* dialog) {
@@ -24,7 +25,7 @@ void AppModalDialogQueue::AddDialog(views::AppModalDialogDelegate* dialog) {
// static
void AppModalDialogQueue::ShowNextDialog() {
app_modal_dialog_queue_->pop();
- BrowserList::SetShowingAppModalDialog(NULL);
+ active_dialog_ = NULL;
if (!app_modal_dialog_queue_->empty()) {
ShowModalDialog(app_modal_dialog_queue_->front());
} else {
@@ -43,7 +44,5 @@ void AppModalDialogQueue::ActivateModalDialog() {
void AppModalDialogQueue::ShowModalDialog(
views::AppModalDialogDelegate* dialog) {
dialog->ShowModalDialog();
- BrowserList::SetShowingAppModalDialog(dialog);
+ active_dialog_ = dialog;
}
-
-
diff --git a/chrome/browser/app_modal_dialog_queue.h b/chrome/browser/app_modal_dialog_queue.h
index d1748a1..ff1b5f5 100644
--- a/chrome/browser/app_modal_dialog_queue.h
+++ b/chrome/browser/app_modal_dialog_queue.h
@@ -39,6 +39,16 @@ class AppModalDialogQueue {
// this condition).
static void ActivateModalDialog();
+ // Returns true if there is currently an active app modal dialog box.
+ static bool HasActiveDialog() {
+ return active_dialog_ != NULL;
+ }
+
+ // Accessor for |active_dialog_|.
+ static views::AppModalDialogDelegate* active_dialog() {
+ return active_dialog_;
+ }
+
private:
// Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
static void ShowModalDialog(views::AppModalDialogDelegate* dialog);
@@ -47,6 +57,10 @@ class AppModalDialogQueue {
// currently modal dialog at the front of the queue.
static std::queue<views::AppModalDialogDelegate*>*
app_modal_dialog_queue_;
+
+ // The currently active app-modal dialog box's delegate. NULL if there is no
+ // active app-modal dialog box.
+ static views::AppModalDialogDelegate* active_dialog_;
};
#endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index c014b8f..36cec74 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -6,6 +6,7 @@
#include "base/path_service.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/app_modal_dialog_queue.h"
#include "chrome/browser/automation/automation_provider_list.h"
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/automation/url_request_failed_dns_job.h"
@@ -1086,7 +1087,7 @@ void AutomationProvider::GetBrowserWindowCount(const IPC::Message& message) {
void AutomationProvider::GetShowingAppModalDialog(const IPC::Message& message) {
views::AppModalDialogDelegate* dialog_delegate =
- BrowserList::GetShowingAppModalDialog();
+ AppModalDialogQueue::active_dialog();
Send(new AutomationMsg_ShowingAppModalDialogResponse(
message.routing_id(), dialog_delegate != NULL,
dialog_delegate ? dialog_delegate->GetDialogButtons() :
@@ -1098,7 +1099,7 @@ void AutomationProvider::ClickAppModalDialogButton(const IPC::Message& message,
bool success = false;
views::AppModalDialogDelegate* dialog_delegate =
- BrowserList::GetShowingAppModalDialog();
+ AppModalDialogQueue::active_dialog();
if (dialog_delegate &&
(dialog_delegate->GetDialogButtons() & button) == button) {
views::DialogClientView* client_view =
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index ea64570..90ccb56 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -159,26 +159,6 @@ bool BrowserList::HasBrowserWithProfile(Profile* profile) {
}
// static
-views::AppModalDialogDelegate* BrowserList::app_modal_dialog_ = NULL;
-
-// static
-void BrowserList::SetShowingAppModalDialog(
- views::AppModalDialogDelegate* dialog) {
- DCHECK(!(app_modal_dialog_ && dialog));
- app_modal_dialog_ = dialog;
-}
-
-// static
-views::AppModalDialogDelegate* BrowserList::GetShowingAppModalDialog() {
- return app_modal_dialog_;
-}
-
-// static
-bool BrowserList::IsShowingAppModalDialog() {
- return app_modal_dialog_ != NULL;
-}
-
-// static
BrowserList::list_type BrowserList::last_active_browsers_;
// static
diff --git a/chrome/browser/browser_list.h b/chrome/browser/browser_list.h
index e7ec88e..72262a9 100644
--- a/chrome/browser/browser_list.h
+++ b/chrome/browser/browser_list.h
@@ -10,11 +10,6 @@
#include "chrome/browser/browser.h"
-namespace views {
-class AppModalDialogDelegate;
-};
-class WebContents;
-
// Stores a list of all Browser objects.
class BrowserList {
public:
@@ -69,14 +64,6 @@ class BrowserList {
// Returns true if there is at least one Browser with the specified profile.
static bool HasBrowserWithProfile(Profile* profile);
- // Sets the passed dialog delegate as the currently showing dialog.
- static void SetShowingAppModalDialog(views::AppModalDialogDelegate* dialog);
- static views::AppModalDialogDelegate* GetShowingAppModalDialog();
-
- // True if the last active browser is application modal, false otherwise. See
- // SetIsShowingAppModalDialog for more details.
- static bool IsShowingAppModalDialog();
-
static const_iterator begin() {
return browsers_.begin();
}
@@ -119,11 +106,9 @@ class BrowserList {
static list_type browsers_;
static std::vector<Observer*> observers_;
static list_type last_active_browsers_;
-
- // Set to the currently showing modal dialog delegate if any, NULL otherwise.
- static views::AppModalDialogDelegate* app_modal_dialog_;
};
+class WebContents;
// Iterates through all web view hosts in all browser windows. Because the
// renderers act asynchronously, getting a host through this interface does
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 9c28a59..9930cc1 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -250,7 +250,7 @@ void BrowserView::AddViewToDropList(views::View* view) {
bool BrowserView::ActivateAppModalDialog() const {
// If another browser is app modal, flash and activate the modal browser.
- if (BrowserList::IsShowingAppModalDialog()) {
+ if (AppModalDialogQueue::HasActiveDialog()) {
Browser* active_browser = BrowserList::GetLastActive();
if (active_browser && (browser_ != active_browser)) {
active_browser->window()->FlashFrame();