summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 19:33:52 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 19:33:52 +0000
commitb5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0 (patch)
tree9d14cf64e2cbeed63b232ba09a8c1274280d81b0 /chrome/browser/ui
parentbbdfcab9e264df0f264f56d8cb5f7ef61e5f96b6 (diff)
downloadchromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.zip
chromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.tar.gz
chromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.tar.bz2
Prefer ScopedNestableTaskAllower over manual save/restore
Cleanup. Changes various calls sites to use the ScopedNestableTaskAllower class to save/restore nestable task state. BUG=None TEST=Existing unit tests R=jar@chromium.org, scottbyer@chromium.org, sky@chromium.org, akalin@chromium.org, rsleevi@chromium.org, brettw@chromium.org, tony@chromium.org Review URL: https://chromiumcodereview.appspot.com/9384024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/views/simple_message_box_views.cc8
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc11
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc12
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc4
-rw-r--r--chrome/browser/ui/webui/downloads_dom_handler.cc2
5 files changed, 19 insertions, 18 deletions
diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc
index c644a4e..596b7d9 100644
--- a/chrome/browser/ui/views/simple_message_box_views.cc
+++ b/chrome/browser/ui/views/simple_message_box_views.cc
@@ -63,10 +63,10 @@ bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window,
aura::client::GetDispatcherClient()->RunWithDispatcher(dialog,
parent_window, true);
#else
- bool old_state = MessageLoopForUI::current()->NestableTasksAllowed();
- MessageLoopForUI::current()->SetNestableTasksAllowed(true);
- MessageLoopForUI::current()->RunWithDispatcher(dialog);
- MessageLoopForUI::current()->SetNestableTasksAllowed(old_state);
+ {
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current());
+ MessageLoopForUI::current()->RunWithDispatcher(dialog);
+ }
#endif
g_browser_process->ReleaseModule();
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc
index 795b967..ab1a843 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc
@@ -211,11 +211,12 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data,
// We need to enable recursive tasks on the message loop so we can get
// updates while in the system DoDragDrop loop.
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
- int result_op = aura::client::GetDragDropClient()->StartDragAndDrop(
- data, ConvertFromWeb(ops));
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
+ int result_op = 0;
+ {
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+ result_op = aura::client::GetDragDropClient()->StartDragAndDrop(
+ data, ConvertFromWeb(ops));
+ }
EndDrag(ConvertToWeb(result_op));
GetWebContents()->GetRenderViewHost()->DragSourceSystemDragEnded();
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc
index 2c289cb..58955a2 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc
@@ -312,12 +312,14 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
// We need to enable recursive tasks on the message loop so we can get
// updates while in the system DoDragDrop loop.
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
DWORD effect;
- DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_,
- web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect);
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
+ {
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+ DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
+ drag_source_,
+ web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops),
+ &effect);
+ }
// This works because WebDragSource::OnDragSourceDrop uses PostTask to
// dispatch the actual event.
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
index 4325e40..45dde04 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
@@ -362,10 +362,8 @@ void TabContentsViewViews::ShowContextMenu(
// Enable recursive tasks on the message loop so we can get updates while
// the context menu is being displayed.
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
context_menu_->RunMenuAt(screen_point.x(), screen_point.y());
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void TabContentsViewViews::ShowPopupMenu(const gfx::Rect& bounds,
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc
index 92ae005..7fbe6ac 100644
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc
@@ -268,7 +268,7 @@ void DownloadsDOMHandler::HandleDrag(const ListValue* args) {
gfx::NativeView view = web_ui()->GetWebContents()->GetNativeView();
{
// Enable nested tasks during DnD, while |DragDownload()| blocks.
- MessageLoop::ScopedNestableTaskAllower allower(MessageLoop::current());
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
download_util::DragDownload(file, icon, view);
}
}