blob: b312ad9c0bfae4e0a3783f8810f1fc7b8049082e [file] [log] [blame]
// Copyright 2013 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/shell/browser/shell_application_mac.h"
#include "base/auto_reset.h"
#include "base/observer_list.h"
#include "content/public/browser/native_event_processor_mac.h"
#include "content/public/browser/native_event_processor_observer_mac.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "url/gurl.h"
@interface ShellCrApplication ()<NativeEventProcessor> {
base::ObserverList<content::NativeEventProcessorObserver>::Unchecked
observers_;
}
@end
@implementation ShellCrApplication
- (BOOL)isHandlingSendEvent {
return handlingSendEvent_;
}
- (void)sendEvent:(NSEvent*)event {
base::AutoReset<BOOL> scoper(&handlingSendEvent_, YES);
content::ScopedNotifyNativeEventProcessorObserver scopedObserverNotifier(
&observers_, event);
[super sendEvent:event];
}
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
handlingSendEvent_ = handlingSendEvent;
}
- (IBAction)newDocument:(id)sender {
content::ShellBrowserContext* browserContext =
content::ShellContentBrowserClient::Get()->browser_context();
content::Shell::CreateNewWindow(browserContext,
GURL(url::kAboutBlankURL),
NULL,
gfx::Size());
}
- (void)addNativeEventProcessorObserver:
(content::NativeEventProcessorObserver*)observer {
observers_.AddObserver(observer);
}
- (void)removeNativeEventProcessorObserver:
(content::NativeEventProcessorObserver*)observer {
observers_.RemoveObserver(observer);
}
@end