summaryrefslogtreecommitdiffstats
path: root/content/common/mac
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 23:56:17 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 23:56:17 +0000
commitd47af217ea470077b039d9f4d49f529dd0eda6bd (patch)
treef55006b328a59a6f702a8921f0e74f8ef3d82be4 /content/common/mac
parent7f2c27ac648a224202f59da047e73e9821328f5d (diff)
downloadchromium_src-d47af217ea470077b039d9f4d49f529dd0eda6bd.zip
chromium_src-d47af217ea470077b039d9f4d49f529dd0eda6bd.tar.gz
chromium_src-d47af217ea470077b039d9f4d49f529dd0eda6bd.tar.bz2
[Mac] Move ScopedSendingEvent from content/common/mac to base/mac.
Also merge content/ MockCrControlApp into base/ MockCrApp. Also use MockCrApp in test_shell_tests, and slight tweak to autorelease pool in test_shell's initialization. BUG=102224 Review URL: http://codereview.chromium.org/8724004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/mac')
-rw-r--r--content/common/mac/scoped_sending_event.h49
-rw-r--r--content/common/mac/scoped_sending_event.mm24
-rw-r--r--content/common/mac/scoped_sending_event_unittest.mm38
3 files changed, 0 insertions, 111 deletions
diff --git a/content/common/mac/scoped_sending_event.h b/content/common/mac/scoped_sending_event.h
deleted file mode 100644
index 160edeb..0000000
--- a/content/common/mac/scoped_sending_event.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_
-#define CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_nsobject.h"
-#include "base/message_pump_mac.h"
-
-// Nested event loops can pump IPC messages, including
-// script-initiated tab closes, which could release objects that the
-// nested event loop might message. CrAppProtocol defines how to ask
-// the embedding NSApplication subclass if an event is currently being
-// handled, in which case such closes are deferred to the top-level
-// event loop.
-//
-// ScopedSendingEvent allows script-initiated event loops to work like
-// a nested event loop, as such events do not arrive via -sendEvent:.
-// CrAppControlProtocol lets ScopedSendingEvent tell the embedding
-// NSApplication what to return from -handlingSendEvent.
-
-@protocol CrAppControlProtocol<CrAppProtocol>
-- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
-@end
-
-namespace content {
-namespace mac {
-
-class ScopedSendingEvent {
- public:
- ScopedSendingEvent();
- ~ScopedSendingEvent();
-
- private:
- // The NSApp in control at the time the constructor was run, to be
- // sure the |handling_| setting is restored appropriately.
- NSObject<CrAppControlProtocol>* app_;
- BOOL handling_; // Value of -[app_ handlingSendEvent] at construction.
-
- DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent);
-};
-
-} // namespace mac
-} // namespace content
-
-#endif // CONTENT_COMMON_MAC_SCOPED_SENDING_EVENT_H_
diff --git a/content/common/mac/scoped_sending_event.mm b/content/common/mac/scoped_sending_event.mm
deleted file mode 100644
index bc4deac..0000000
--- a/content/common/mac/scoped_sending_event.mm
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2011 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.
-
-#import "content/common/mac/scoped_sending_event.h"
-
-#include "base/logging.h"
-
-namespace content {
-namespace mac {
-
-ScopedSendingEvent::ScopedSendingEvent()
- : app_(static_cast<NSObject<CrAppControlProtocol>*>(NSApp)) {
- DCHECK([app_ conformsToProtocol:@protocol(CrAppControlProtocol)]);
- handling_ = [app_ isHandlingSendEvent];
- [app_ setHandlingSendEvent:YES];
-}
-
-ScopedSendingEvent::~ScopedSendingEvent() {
- [app_ setHandlingSendEvent:handling_];
-}
-
-} // namespace mac
-} // namespace content
diff --git a/content/common/mac/scoped_sending_event_unittest.mm b/content/common/mac/scoped_sending_event_unittest.mm
deleted file mode 100644
index 510a821..0000000
--- a/content/common/mac/scoped_sending_event_unittest.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2011 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.
-
-#import "content/common/mac/scoped_sending_event.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// Sets the flag within scope, resets when leaving scope.
-TEST(ScopedSendingEventTest, SetHandlingSendEvent) {
- id<CrAppProtocol> app = NSApp;
- EXPECT_FALSE([app isHandlingSendEvent]);
- {
- content::mac::ScopedSendingEvent is_handling_send_event;
- EXPECT_TRUE([app isHandlingSendEvent]);
- }
- EXPECT_FALSE([app isHandlingSendEvent]);
-}
-
-// Nested call restores previous value rather than resetting flag.
-TEST(ScopedSendingEventTest, NestedSetHandlingSendEvent) {
- id<CrAppProtocol> app = NSApp;
- EXPECT_FALSE([app isHandlingSendEvent]);
- {
- content::mac::ScopedSendingEvent is_handling_send_event;
- EXPECT_TRUE([app isHandlingSendEvent]);
- {
- content::mac::ScopedSendingEvent nested_is_handling_send_event;
- EXPECT_TRUE([app isHandlingSendEvent]);
- }
- EXPECT_TRUE([app isHandlingSendEvent]);
- }
- EXPECT_FALSE([app isHandlingSendEvent]);
-}
-
-} // namespace