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

Unified Diff: chrome/browser/ui_thread_helpers_mac.mm

Issue 3183013: [Mac] Don't close the Wrench menu after using the zoom buttons if the menu was opened sticky. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: nits Created 10 years, 4 months 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_thread_helpers_linux.cc ('k') | chrome/browser/ui_thread_helpers_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui_thread_helpers_mac.mm
diff --git a/chrome/browser/ui_thread_helpers_mac.mm b/chrome/browser/ui_thread_helpers_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d9adc03f9504c7c55b72faeb29989007d04ec305
--- /dev/null
+++ b/chrome/browser/ui_thread_helpers_mac.mm
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 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 "chrome/browser/ui_thread_helpers.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/task.h"
+#include "chrome/browser/chrome_thread.h"
+
+// This is a wrapper for running Chrome Task objects from within a native run
+// loop. A typical use case is when Chrome work needs to get done but the main
+// message loop is blocked by a nested run loop (like an event tracking one).
+// This can run specific tasks in that nested loop. This owns the task and will
+// delete it and itself when done.
+@interface UITaskHelperMac : NSObject {
+ @private
+ Task* task_;
+}
+- (id)initWithTask:(Task*)task;
+- (void)runTask;
+@end
+
+@implementation UITaskHelperMac
+- (id)initWithTask:(Task*)task {
+ if ((self = [super init])) {
+ task_ = task;
+ }
+ return self;
+}
+
+- (void)runTask {
+ task_->Run();
+ [self autorelease];
+}
+
+- (void)dealloc {
+ delete task_;
+ [super dealloc];
+}
+@end
+
+namespace ui_thread_helpers {
+
+bool PostTaskWhileRunningMenu(const tracked_objects::Location& from_here,
+ Task* task) {
+ // This deletes itself and the task after the task runs.
+ UITaskHelperMac* runner = [[UITaskHelperMac alloc] initWithTask:task];
+
+ // Schedule the selector in multiple modes in case this was called while a
+ // menu was not running.
+ NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode,
+ NSDefaultRunLoopMode,
+ nil];
+ [runner performSelectorOnMainThread:@selector(runTask)
+ withObject:nil
+ waitUntilDone:NO
+ modes:modes];
+ return true;
+}
+
+} // namespace ui_thread_helpers
« no previous file with comments | « chrome/browser/ui_thread_helpers_linux.cc ('k') | chrome/browser/ui_thread_helpers_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698