diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 02:40:50 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 02:40:50 +0000 |
commit | b3a7033870585fff515df0c6e40ac2ac93b01db8 (patch) | |
tree | 5a36de90c758fc781f31d57e8e5f8d2197bf1337 /chrome | |
parent | 1e187afa75fe66d8525651c1f395c40e8227844d (diff) | |
download | chromium_src-b3a7033870585fff515df0c6e40ac2ac93b01db8.zip chromium_src-b3a7033870585fff515df0c6e40ac2ac93b01db8.tar.gz chromium_src-b3a7033870585fff515df0c6e40ac2ac93b01db8.tar.bz2 |
ui test fail. revert.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/app_modal_dialog_delegate.h | 36 | ||||
-rw-r--r-- | chrome/browser/app_modal_dialog_queue.cc | 12 | ||||
-rw-r--r-- | chrome/browser/app_modal_dialog_queue.h | 14 | ||||
-rw-r--r-- | chrome/browser/app_modal_dialog_queue_unittest.cc | 45 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 29 | ||||
-rw-r--r-- | chrome/browser/browser.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/jsmessage_box_handler_win.cc | 68 | ||||
-rw-r--r-- | chrome/browser/jsmessage_box_handler_win.h | 21 | ||||
-rw-r--r-- | chrome/test/unit/unittests.vcproj | 4 | ||||
-rw-r--r-- | chrome/views/app_modal_dialog_delegate.h | 25 | ||||
-rw-r--r-- | chrome/views/views.vcproj | 4 |
11 files changed, 91 insertions, 171 deletions
diff --git a/chrome/browser/app_modal_dialog_delegate.h b/chrome/browser/app_modal_dialog_delegate.h deleted file mode 100644 index 0bb546f..0000000 --- a/chrome/browser/app_modal_dialog_delegate.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2006-2008 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_APP_MODAL_DIALOG_DELEGATE_H_ -#define CHROME_BROWSER_APP_MODAL_DIALOG_DELEGATE_H_ - -#if defined(OS_WIN) -namespace views { -class DialogDelegate; -} -#endif - -class AppModalDialogDelegateTesting { - public: -#if defined(OS_WIN) - virtual views::DialogDelegate* GetDialogDelegate() = 0; -#endif -}; - -// Pure virtual interface for a window which is app modal. -class AppModalDialogDelegate { - public: - // Called by the app modal window queue when it is time to show this window. - virtual void ShowModalDialog() = 0; - - // Called by the app modal window queue to activate the window. - virtual void ActivateModalDialog() = 0; - - // Returns the interface used to control this dialog from testing. Should - // only be used in testing code. - virtual AppModalDialogDelegateTesting* GetTestingInterface() = 0; -}; - -#endif // #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_DELEGATE_H_ - diff --git a/chrome/browser/app_modal_dialog_queue.cc b/chrome/browser/app_modal_dialog_queue.cc index 0fd5dfb..6646bbc 100644 --- a/chrome/browser/app_modal_dialog_queue.cc +++ b/chrome/browser/app_modal_dialog_queue.cc @@ -7,14 +7,15 @@ #include "chrome/browser/browser_list.h" // static -std::queue<AppModalDialogDelegate*>* +std::queue<views::AppModalDialogDelegate*>* AppModalDialogQueue::app_modal_dialog_queue_ = NULL; -AppModalDialogDelegate* AppModalDialogQueue::active_dialog_ = NULL; +views::AppModalDialogDelegate* AppModalDialogQueue::active_dialog_ = NULL; // static -void AppModalDialogQueue::AddDialog(AppModalDialogDelegate* dialog) { +void AppModalDialogQueue::AddDialog(views::AppModalDialogDelegate* dialog) { + DCHECK(dialog->IsModal()); if (!app_modal_dialog_queue_) { - app_modal_dialog_queue_ = new std::queue<AppModalDialogDelegate*>; + app_modal_dialog_queue_ = new std::queue<views::AppModalDialogDelegate*>; ShowModalDialog(dialog); } @@ -40,7 +41,8 @@ void AppModalDialogQueue::ActivateModalDialog() { } // static -void AppModalDialogQueue::ShowModalDialog(AppModalDialogDelegate* dialog) { +void AppModalDialogQueue::ShowModalDialog( + views::AppModalDialogDelegate* dialog) { dialog->ShowModalDialog(); active_dialog_ = dialog; } diff --git a/chrome/browser/app_modal_dialog_queue.h b/chrome/browser/app_modal_dialog_queue.h index 9101c2e2..ff1b5f5 100644 --- a/chrome/browser/app_modal_dialog_queue.h +++ b/chrome/browser/app_modal_dialog_queue.h @@ -7,7 +7,7 @@ #include <queue> -#include "chrome/browser/app_modal_dialog_delegate.h" +#include "chrome/views/app_modal_dialog_delegate.h" // Keeps a queue of AppModalDialogDelegates, making sure only one app modal // dialog is shown at a time. @@ -23,7 +23,7 @@ class AppModalDialogQueue { // sloppy app modality. // Note: The AppModalDialogDelegate |dialog| must be window modal before it // can be added as app modal. - static void AddDialog(AppModalDialogDelegate* dialog); + static void AddDialog(views::AppModalDialogDelegate* dialog); // Removes the current dialog in the queue (the one that is being shown). // Shows the next dialog in the queue, if any is present. This does not @@ -45,20 +45,22 @@ class AppModalDialogQueue { } // Accessor for |active_dialog_|. - static AppModalDialogDelegate* active_dialog() { return 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(AppModalDialogDelegate* dialog); + static void ShowModalDialog(views::AppModalDialogDelegate* dialog); // Contains all app modal dialogs which are waiting to be shown, with the // currently modal dialog at the front of the queue. - static std::queue<AppModalDialogDelegate*>* + 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 AppModalDialogDelegate* active_dialog_; + static views::AppModalDialogDelegate* active_dialog_; }; #endif // CHROME_BROWSER_APP_MODAL_DIALOG_QUEUE_H__ diff --git a/chrome/browser/app_modal_dialog_queue_unittest.cc b/chrome/browser/app_modal_dialog_queue_unittest.cc deleted file mode 100644 index 6d7210b..0000000 --- a/chrome/browser/app_modal_dialog_queue_unittest.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2009 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. - -#include "base/basictypes.h" -#include "chrome/browser/app_modal_dialog_delegate.h" -#include "chrome/browser/app_modal_dialog_queue.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class TestModalDialogDelegate : public AppModalDialogDelegate { - public: - TestModalDialogDelegate() {} - virtual ~TestModalDialogDelegate() {} - - // Overridden from AppModalDialogDelegate: - virtual void ShowModalDialog() {} - virtual void ActivateModalDialog() {} - virtual AppModalDialogDelegateTesting* GetTestingInterface() { return NULL; } - - private: - DISALLOW_COPY_AND_ASSIGN(TestModalDialogDelegate); -}; - -} // namespace - -TEST(AppModalDialogQueueTest, MultipleDialogTest) { - TestModalDialogDelegate modal_dialog1, modal_dialog2; - AppModalDialogQueue::AddDialog(&modal_dialog1); - AppModalDialogQueue::AddDialog(&modal_dialog2); - - EXPECT_TRUE(AppModalDialogQueue::HasActiveDialog()); - EXPECT_EQ(&modal_dialog1, AppModalDialogQueue::active_dialog()); - - AppModalDialogQueue::ShowNextDialog(); - - EXPECT_TRUE(AppModalDialogQueue::HasActiveDialog()); - EXPECT_EQ(&modal_dialog2, AppModalDialogQueue::active_dialog()); - - AppModalDialogQueue::ShowNextDialog(); - - EXPECT_FALSE(AppModalDialogQueue::HasActiveDialog()); - EXPECT_EQ(NULL, AppModalDialogQueue::active_dialog()); -} diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 29e59b4..d5a13d1 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -8,7 +8,6 @@ #include "base/path_service.h" #include "base/thread.h" #include "chrome/app/chrome_dll_resource.h" -#include "chrome/browser/app_modal_dialog_delegate.h" #include "chrome/browser/app_modal_dialog_queue.h" #include "chrome/browser/automation/automation_provider_list.h" #include "chrome/browser/automation/ui_controls.h" @@ -34,7 +33,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/pref_service.h" -#include "chrome/views/dialog_delegate.h" +#include "chrome/views/app_modal_dialog_delegate.h" #include "chrome/views/window.h" #include "chrome/test/automation/automation_messages.h" #include "net/base/cookie_monster.h" @@ -1163,26 +1162,22 @@ void AutomationProvider::GetBrowserWindowCount(int* window_count) { void AutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button) { - *showing_dialog = AppModalDialogQueue::HasActiveDialog(); - *dialog_button = views::DialogDelegate::DIALOGBUTTON_NONE; - if (!*showing_dialog) - return; - - views::DialogDelegate* dialog_delegate = - AppModalDialogQueue::active_dialog()->GetTestingInterface()-> - GetDialogDelegate(); - *dialog_button = dialog_delegate->GetDialogButtons(); + views::AppModalDialogDelegate* dialog_delegate = + AppModalDialogQueue::active_dialog(); + *showing_dialog = (dialog_delegate != NULL); + if (*showing_dialog) + *dialog_button = dialog_delegate->GetDialogButtons(); + else + *dialog_button = views::DialogDelegate::DIALOGBUTTON_NONE; } void AutomationProvider::ClickAppModalDialogButton(int button, bool* success) { *success = false; - if (!AppModalDialogQueue::HasActiveDialog()) - return; - views::DialogDelegate* dialog_delegate = - AppModalDialogQueue::active_dialog()->GetTestingInterface()-> - GetDialogDelegate(); - if ((dialog_delegate->GetDialogButtons() & button) == button) { + views::AppModalDialogDelegate* dialog_delegate = + AppModalDialogQueue::active_dialog(); + if (dialog_delegate && + (dialog_delegate->GetDialogButtons() & button) == button) { views::DialogClientView* client_view = dialog_delegate->window()->client_view()->AsDialogClientView(); if ((button & views::DialogDelegate::DIALOGBUTTON_OK) == diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index fea4dea..e8ee21e 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -626,10 +626,6 @@ Name="Browser Window" > <File - RelativePath=".\app_modal_dialog_delegate.h" - > - </File> - <File RelativePath=".\app_modal_dialog_queue.cc" > </File> diff --git a/chrome/browser/jsmessage_box_handler_win.cc b/chrome/browser/jsmessage_box_handler_win.cc index 5add577..5026e8e 100644 --- a/chrome/browser/jsmessage_box_handler_win.cc +++ b/chrome/browser/jsmessage_box_handler_win.cc @@ -66,45 +66,6 @@ JavascriptMessageBoxHandler::~JavascriptMessageBoxHandler() { } ////////////////////////////////////////////////////////////////////////////// -// JavascriptMessageBoxHandler, views::AppModalDialogDelegate -// implementation: - -void JavascriptMessageBoxHandler::ShowModalDialog() { - // If the WebContents that created this dialog navigated away before this - // dialog became visible, simply show the next dialog if any. - if (!web_contents_) { - AppModalDialogQueue::ShowNextDialog(); - delete this; - return; - } - - web_contents_->Activate(); - HWND root_hwnd = GetAncestor(web_contents_->GetNativeView(), GA_ROOT); - dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); - dialog_->Show(); -} - -void JavascriptMessageBoxHandler::ActivateModalDialog() { - // Ensure that the dialog is visible and at the top of the z-order. These - // conditions may not be true if the dialog was opened on a different virtual - // desktop to the one the browser window is on. - dialog_->Show(); - dialog_->Activate(); -} - -AppModalDialogDelegateTesting* -JavascriptMessageBoxHandler::GetTestingInterface() { - return this; -} - -/////////////////////////////////////////////////////////////////////////////// -// JavascriptMessageBoxHandler, AppModalDialogDelegateTesting implementation: - -views::DialogDelegate* JavascriptMessageBoxHandler::GetDialogDelegate() { - return this; -} - -////////////////////////////////////////////////////////////////////////////// // JavascriptMessageBoxHandler, views::DialogDelegate implementation: int JavascriptMessageBoxHandler::GetDialogButtons() const { @@ -180,6 +141,33 @@ bool JavascriptMessageBoxHandler::Accept() { return true; } +////////////////////////////////////////////////////////////////////////////// +// JavascriptMessageBoxHandler, views::AppModalDialogDelegate +// implementation: + +void JavascriptMessageBoxHandler::ShowModalDialog() { + // If the WebContents that created this dialog navigated away before this + // dialog became visible, simply show the next dialog if any. + if (!web_contents_) { + AppModalDialogQueue::ShowNextDialog(); + delete this; + return; + } + + web_contents_->Activate(); + HWND root_hwnd = GetAncestor(web_contents_->GetNativeView(), GA_ROOT); + dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); + dialog_->Show(); +} + +void JavascriptMessageBoxHandler::ActivateModalDialog() { + // Ensure that the dialog is visible and at the top of the z-order. These + // conditions may not be true if the dialog was opened on a different virtual + // desktop to the one the browser window is on. + dialog_->Show(); + dialog_->Activate(); +} + /////////////////////////////////////////////////////////////////////////////// // JavascriptMessageBoxHandler, views::WindowDelegate implementation: @@ -190,7 +178,7 @@ views::View* JavascriptMessageBoxHandler::GetContentsView() { views::View* JavascriptMessageBoxHandler::GetInitiallyFocusedView() { if (message_box_view_->text_box()) return message_box_view_->text_box(); - return views::DialogDelegate::GetInitiallyFocusedView(); + return views::AppModalDialogDelegate::GetInitiallyFocusedView(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/jsmessage_box_handler_win.h b/chrome/browser/jsmessage_box_handler_win.h index 9e4804a..bac80dd 100644 --- a/chrome/browser/jsmessage_box_handler_win.h +++ b/chrome/browser/jsmessage_box_handler_win.h @@ -5,12 +5,11 @@ #ifndef CHROME_BROWSER_JSMESSAGE_BOX_HANDLER_WIN_H_ #define CHROME_BROWSER_JSMESSAGE_BOX_HANDLER_WIN_H_ -#include "chrome/browser/app_modal_dialog_delegate.h" #include "chrome/browser/jsmessage_box_handler.h" #include "chrome/common/ipc_message.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" -#include "chrome/views/dialog_delegate.h" +#include "chrome/views/app_modal_dialog_delegate.h" class MessageBoxView; class WebContents; @@ -19,10 +18,8 @@ class Window; } class JavascriptMessageBoxHandler - : public AppModalDialogDelegate, - public AppModalDialogDelegateTesting, - public NotificationObserver, - public views::DialogDelegate { + : public views::AppModalDialogDelegate, + public NotificationObserver { public: // Cross-platform code should use RunJavaScriptMessageBox. JavascriptMessageBoxHandler(WebContents* web_contents, @@ -33,14 +30,6 @@ class JavascriptMessageBoxHandler IPC::Message* reply_msg); virtual ~JavascriptMessageBoxHandler(); - // AppModalDialogDelegate Methods: - virtual void ShowModalDialog(); - virtual void ActivateModalDialog(); - virtual AppModalDialogDelegateTesting* GetTestingInterface(); - - // AppModalDialogDelegateTesting Methods: - virtual views::DialogDelegate* GetDialogDelegate(); - // views::DialogDelegate Methods: virtual int GetDialogButtons() const; virtual std::wstring GetWindowTitle() const; @@ -48,6 +37,10 @@ class JavascriptMessageBoxHandler virtual bool Cancel(); virtual bool Accept(); + // views::AppModalDialogDelegate + virtual void ShowModalDialog(); + virtual void ActivateModalDialog(); + // views::WindowDelegate Methods: virtual bool IsModal() const { return true; } virtual views::View* GetContentsView(); diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj index 3011530..e6ba858 100644 --- a/chrome/test/unit/unittests.vcproj +++ b/chrome/test/unit/unittests.vcproj @@ -375,10 +375,6 @@ Name="browser" > <File - RelativePath="..\..\browser\app_modal_dialog_queue_unittest.cc" - > - </File> - <File RelativePath="..\..\browser\renderer_host\audio_renderer_host_unittest.cc" > </File> diff --git a/chrome/views/app_modal_dialog_delegate.h b/chrome/views/app_modal_dialog_delegate.h new file mode 100644 index 0000000..b8fefb4 --- /dev/null +++ b/chrome/views/app_modal_dialog_delegate.h @@ -0,0 +1,25 @@ +// Copyright (c) 2006-2008 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_VIEWS_APP_MODAL_DIALOG_DELEGATE_H__ +#define CHROME_VIEWS_APP_MODAL_DIALOG_DELEGATE_H__ + +#include "chrome/views/dialog_delegate.h" + +namespace views { + +// Pure virtual interface for a window which is app modal. +class AppModalDialogDelegate : public DialogDelegate { + public: + // Called by the app modal window queue when it is time to show this window. + virtual void ShowModalDialog() = 0; + + // Called by the app modal window queue to activate the window. + virtual void ActivateModalDialog() = 0; +}; + +} // namespace views + +#endif // #ifndef CHROME_VIEWS_APP_MODAL_DIALOG_DELEGATE_H__ + diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj index 845f0eb..9656303 100644 --- a/chrome/views/views.vcproj +++ b/chrome/views/views.vcproj @@ -166,6 +166,10 @@ > </File> <File + RelativePath=".\app_modal_dialog_delegate.h" + > + </File> + <File RelativePath=".\background.cc" > </File> |