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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui_thread_helpers.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "base/task.h"
10 #include "chrome/browser/chrome_thread.h"
11
12 // This is a wrapper for running Chrome Task objects from within a native run
13 // loop. A typical use case is when Chrome work needs to get done but the main
14 // message loop is blocked by a nested run loop (like an event tracking one).
15 // This can run specific tasks in that nested loop. This owns the task and will
16 // delete it and itself when done.
17 @interface UITaskHelperMac : NSObject {
18 @private
19 Task* task_;
20 }
21 - (id)initWithTask:(Task*)task;
22 - (void)runTask;
23 @end
24
25 @implementation UITaskHelperMac
26 - (id)initWithTask:(Task*)task {
27 if ((self = [super init])) {
28 task_ = task;
29 }
30 return self;
31 }
32
33 - (void)runTask {
34 task_->Run();
35 [self autorelease];
36 }
37
38 - (void)dealloc {
39 delete task_;
40 [super dealloc];
41 }
42 @end
43
44 namespace ui_thread_helpers {
45
46 bool PostTaskWhileRunningMenu(const tracked_objects::Location& from_here,
47 Task* task) {
48 // This deletes itself and the task after the task runs.
49 UITaskHelperMac* runner = [[UITaskHelperMac alloc] initWithTask:task];
50
51 // Schedule the selector in multiple modes in case this was called while a
52 // menu was not running.
53 NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode,
54 NSDefaultRunLoopMode,
55 nil];
56 [runner performSelectorOnMainThread:@selector(runTask)
57 withObject:nil
58 waitUntilDone:NO
59 modes:modes];
60 return true;
61 }
62
63 } // namespace ui_thread_helpers
OLDNEW
« 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