diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/tab_contents/popup_menu_helper_mac.mm | 4 | ||||
-rw-r--r-- | content/common/chrome_application_mac.h | 2 | ||||
-rw-r--r-- | content/common/chrome_application_mac.mm | 2 | ||||
-rw-r--r-- | content/common/mac/scoped_sending_event.h | 49 | ||||
-rw-r--r-- | content/common/mac/scoped_sending_event.mm | 24 | ||||
-rw-r--r-- | content/common/mac/scoped_sending_event_unittest.mm | 38 | ||||
-rw-r--r-- | content/content_common.gypi | 2 | ||||
-rw-r--r-- | content/content_tests.gypi | 4 | ||||
-rw-r--r-- | content/test/content_test_suite.cc | 2 | ||||
-rw-r--r-- | content/test/mock_chrome_application_mac.h | 32 | ||||
-rw-r--r-- | content/test/mock_chrome_application_mac.mm | 28 |
11 files changed, 4 insertions, 183 deletions
diff --git a/content/browser/tab_contents/popup_menu_helper_mac.mm b/content/browser/tab_contents/popup_menu_helper_mac.mm index db861b6..29f502a 100644 --- a/content/browser/tab_contents/popup_menu_helper_mac.mm +++ b/content/browser/tab_contents/popup_menu_helper_mac.mm @@ -6,11 +6,11 @@ #include "content/browser/tab_contents/popup_menu_helper_mac.h" +#import "base/mac/scoped_sending_event.h" #include "base/memory/scoped_nsobject.h" #include "base/message_loop.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view_mac.h" -#import "content/common/mac/scoped_sending_event.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #import "ui/base/cocoa/base_view.h" @@ -54,7 +54,7 @@ void PopupMenuHelper::ShowPopupMenu( // setting flags in -[CrApplication sendEvent:], but since // web-content menus are initiated by IPC message the setup has to // be done manually. - content::mac::ScopedSendingEvent sending_event_scoper; + base::mac::ScopedSendingEvent sending_event_scoper; // Now run a SYNCHRONOUS NESTED EVENT LOOP until the pop-up is finished. [menu_runner runMenuInView:cocoa_view diff --git a/content/common/chrome_application_mac.h b/content/common/chrome_application_mac.h index 9778023..35e09a7 100644 --- a/content/common/chrome_application_mac.h +++ b/content/common/chrome_application_mac.h @@ -11,7 +11,7 @@ #import <AppKit/AppKit.h> #include "base/basictypes.h" -#import "content/common/mac/scoped_sending_event.h" +#import "base/mac/scoped_sending_event.h" @interface CrApplication : NSApplication<CrAppControlProtocol> { @private diff --git a/content/common/chrome_application_mac.mm b/content/common/chrome_application_mac.mm index deec8b3..81b341c 100644 --- a/content/common/chrome_application_mac.mm +++ b/content/common/chrome_application_mac.mm @@ -37,7 +37,7 @@ } - (void)sendEvent:(NSEvent*)event { - content::mac::ScopedSendingEvent sendingEventScoper; + base::mac::ScopedSendingEvent sendingEventScoper; [super sendEvent:event]; } 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 diff --git a/content/content_common.gypi b/content/content_common.gypi index 02b0a32..ad7cf85 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -181,8 +181,6 @@ 'common/mac/font_descriptor.mm', 'common/mac/font_loader.h', 'common/mac/font_loader.mm', - 'common/mac/scoped_sending_event.h', - 'common/mac/scoped_sending_event.mm', 'common/media/audio_messages.h', 'common/media/audio_stream_state.h', 'common/media/media_stream_messages.h', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 5dcd046..b9ba0be 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -74,8 +74,6 @@ 'test/browser_test_base.h', 'test/content_test_suite.cc', 'test/content_test_suite.h', - 'test/mock_chrome_application_mac.h', - 'test/mock_chrome_application_mac.mm', 'test/mock_keyboard.cc', 'test/mock_keyboard.h', 'test/mock_keyboard_driver_win.cc', @@ -228,8 +226,6 @@ 'browser/trace_subscriber_stdio_unittest.cc', 'common/mac/attributed_string_coder_unittest.mm', 'common/mac/font_descriptor_unittest.mm', - 'common/gamepad_seqlock_unittest.cc', - 'common/mac/scoped_sending_event_unittest.mm', 'common/gpu/gpu_feature_flags_unittest.cc', 'common/gpu/gpu_info_unittest.cc', 'common/hi_res_timer_manager_unittest.cc', diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc index c67f10a..7a87809 100644 --- a/content/test/content_test_suite.cc +++ b/content/test/content_test_suite.cc @@ -17,7 +17,6 @@ #if defined(OS_MACOSX) #include "base/mac/scoped_nsautorelease_pool.h" -#include "content/test/mock_chrome_application_mac.h" #endif namespace { @@ -68,7 +67,6 @@ ContentTestSuite::~ContentTestSuite() { void ContentTestSuite::Initialize() { #if defined(OS_MACOSX) base::mac::ScopedNSAutoreleasePool autorelease_pool; - mock_cr_app::RegisterMockCrControlApp(); #endif base::TestSuite::Initialize(); diff --git a/content/test/mock_chrome_application_mac.h b/content/test/mock_chrome_application_mac.h deleted file mode 100644 index c068962..0000000 --- a/content/test/mock_chrome_application_mac.h +++ /dev/null @@ -1,32 +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_TEST_MOCK_CHROME_APPLICATION_MAC_H_ -#define CONTENT_TEST_MOCK_CHROME_APPLICATION_MAC_H_ -#pragma once - -#if defined(__OBJC__) - -#import <AppKit/AppKit.h> - -#include "content/common/mac/scoped_sending_event.h" - -// Mock implementation supporting CrAppControlProtocol. Can be used -// in tests using ScopedSendingEvent to deal with nested message -// loops. Also implements CrAppProtocol so can be used as a -// replacement for MockCrApp (in base/). -@interface MockCrControlApp : NSApplication<CrAppControlProtocol> { - @private - BOOL isHandlingSendEvent_; -} -@end - -#endif // __OBJC__ - -// To be used to instantiate MockCrControlApp from C++ code. -namespace mock_cr_app { -void RegisterMockCrControlApp(); -} // namespace mock_cr_app - -#endif // CONTENT_TEST_MOCK_CHROME_APPLICATION_MAC_H_ diff --git a/content/test/mock_chrome_application_mac.mm b/content/test/mock_chrome_application_mac.mm deleted file mode 100644 index a5d4c0c..0000000 --- a/content/test/mock_chrome_application_mac.mm +++ /dev/null @@ -1,28 +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. - -#include "content/test/mock_chrome_application_mac.h" - -#include "testing/gtest/include/gtest/gtest.h" - -@implementation MockCrControlApp - -- (BOOL)isHandlingSendEvent { - return isHandlingSendEvent_; -} - -- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { - isHandlingSendEvent_ = handlingSendEvent; -} - -@end - -namespace mock_cr_app { - -void RegisterMockCrControlApp() { - NSApplication* app = [MockCrControlApp sharedApplication]; - ASSERT_TRUE([app conformsToProtocol:@protocol(CrAppControlProtocol)]); -} - -} // namespace mock_cr_app |