summaryrefslogtreecommitdiffstats
path: root/ash/accelerators
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-11 01:19:48 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-11 01:19:48 +0000
commit7d8dce44a24a628b361a668550fedcbe5c78f03b (patch)
tree6502fab22a7c53b5774f63189d03adb61d1b292a /ash/accelerators
parentd080d3e45d72575612058097b338c9aad8ef481c (diff)
downloadchromium_src-7d8dce44a24a628b361a668550fedcbe5c78f03b.zip
chromium_src-7d8dce44a24a628b361a668550fedcbe5c78f03b.tar.gz
chromium_src-7d8dce44a24a628b361a668550fedcbe5c78f03b.tar.bz2
Use the default dispatcher where possible for nested message loops.
Notable changes: * Add QuitNestedMessageLoop() to client::DispatcherClient, which can be used to terminate a nested loop started by RunWithDispatcher(). * FirstRunDialog is no longer a MessagePumpDispatcher. The default dispatcher is used instead, and QuitNestedMessageLoop() is called to terminate the loop instead of returning POST_DISPATCH_QUIT_LOOP from the Dispatch() override. This change was previously committed in r253723 and r254089, but reverted in r253744 and r254095 because some interactive_ui_tests on windows bots failed on SimpleMessageBoxViews related change. So this CL aims to reland that CL without the change in SimpleMessageBoxViews for now. BUG=342338 R=sky@chromium.org Review URL: https://codereview.chromium.org/192743007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators')
-rw-r--r--ash/accelerators/accelerator_dispatcher.cc8
-rw-r--r--ash/accelerators/accelerator_dispatcher.h4
-rw-r--r--ash/accelerators/nested_dispatcher_controller.cc8
-rw-r--r--ash/accelerators/nested_dispatcher_controller.h5
4 files changed, 20 insertions, 5 deletions
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc
index 0395ee7..91ea13b 100644
--- a/ash/accelerators/accelerator_dispatcher.cc
+++ b/ash/accelerators/accelerator_dispatcher.cc
@@ -70,7 +70,6 @@ AcceleratorDispatcher::AcceleratorDispatcher(
aura::Window* associated_window)
: nested_dispatcher_(nested_dispatcher),
associated_window_(associated_window) {
- DCHECK(nested_dispatcher_);
associated_window_->AddObserver(this);
}
@@ -121,10 +120,13 @@ uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) {
return POST_DISPATCH_NONE;
}
- return nested_dispatcher_->Dispatch(key_event.native_event());
+ return nested_dispatcher_
+ ? nested_dispatcher_->Dispatch(key_event.native_event())
+ : POST_DISPATCH_PERFORM_DEFAULT;
}
- return nested_dispatcher_->Dispatch(event);
+ return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event)
+ : POST_DISPATCH_PERFORM_DEFAULT;
}
} // namespace ash
diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h
index a7ae40a..a46368c 100644
--- a/ash/accelerators/accelerator_dispatcher.h
+++ b/ash/accelerators/accelerator_dispatcher.h
@@ -15,8 +15,8 @@ namespace ash {
// Dispatcher for handling accelerators from menu.
//
// Wraps a nested dispatcher to which control is passed if no accelerator key
-// has been pressed.
-// TODO(pkotwicz): Port AcceleratorDispatcher to mac.
+// has been pressed. If the nested dispatcher is NULL, then the control is
+// passed back to the default dispatcher.
// TODO(pkotwicz): Add support for a |nested_dispatcher| which sends
// events to a system IME.
class ASH_EXPORT AcceleratorDispatcher : public base::MessagePumpDispatcher,
diff --git a/ash/accelerators/nested_dispatcher_controller.cc b/ash/accelerators/nested_dispatcher_controller.cc
index c551e94..6977f07 100644
--- a/ash/accelerators/nested_dispatcher_controller.cc
+++ b/ash/accelerators/nested_dispatcher_controller.cc
@@ -6,6 +6,7 @@
#include "ash/accelerators/accelerator_dispatcher.h"
#include "ash/shell.h"
+#include "base/auto_reset.h"
#include "base/run_loop.h"
namespace ash {
@@ -27,7 +28,14 @@ void NestedDispatcherController::RunWithDispatcher(
// TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them
// use run_loop.QuitClosure().
base::RunLoop run_loop(&dispatcher);
+ base::AutoReset<base::Closure> reset_closure(&quit_closure_,
+ run_loop.QuitClosure());
run_loop.Run();
}
+void NestedDispatcherController::QuitNestedMessageLoop() {
+ CHECK(!quit_closure_.is_null());
+ quit_closure_.Run();
+}
+
} // namespace ash
diff --git a/ash/accelerators/nested_dispatcher_controller.h b/ash/accelerators/nested_dispatcher_controller.h
index 958cbae..1f8b52e 100644
--- a/ash/accelerators/nested_dispatcher_controller.h
+++ b/ash/accelerators/nested_dispatcher_controller.h
@@ -6,6 +6,7 @@
#define ASH_ACCELERATORS_NESTED_DISPATCHER_CONTROLLER_H_
#include "ash/ash_export.h"
+#include "base/callback.h"
#include "base/message_loop/message_loop.h"
#include "ui/aura/client/dispatcher_client.h"
#include "ui/aura/window.h"
@@ -22,10 +23,14 @@ class ASH_EXPORT NestedDispatcherController
NestedDispatcherController();
virtual ~NestedDispatcherController();
+ // aura::client::DispatcherClient:
virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher,
aura::Window* associated_window) OVERRIDE;
+ virtual void QuitNestedMessageLoop() OVERRIDE;
private:
+ base::Closure quit_closure_;
+
DISALLOW_COPY_AND_ASSIGN(NestedDispatcherController);
};