clang-format objc files (#12673)
This commit is contained in:
parent
94236bf4eb
commit
12a57ff1c2
54 changed files with 1298 additions and 1033 deletions
|
@ -62,8 +62,7 @@ namespace extensions {
|
|||
// static
|
||||
GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
|
||||
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
static GlobalShortcutListenerMac* instance =
|
||||
new GlobalShortcutListenerMac();
|
||||
static GlobalShortcutListenerMac* instance = new GlobalShortcutListenerMac();
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -126,8 +125,8 @@ void GlobalShortcutListenerMac::OnHotKeyEvent(EventHotKeyID hot_key_id) {
|
|||
bool GlobalShortcutListenerMac::OnMediaOrVolumeKeyEvent(
|
||||
int media_or_volume_key_code) {
|
||||
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
ui::KeyboardCode key_code = MediaOrVolumeKeyCodeToKeyboardCode(
|
||||
media_or_volume_key_code);
|
||||
ui::KeyboardCode key_code =
|
||||
MediaOrVolumeKeyCodeToKeyboardCode(media_or_volume_key_code);
|
||||
// Create an accelerator corresponding to the keyCode.
|
||||
ui::Accelerator accelerator(key_code, 0);
|
||||
// Look for a match with a bound hot_key.
|
||||
|
@ -181,8 +180,8 @@ void GlobalShortcutListenerMac::UnregisterAcceleratorImpl(
|
|||
accelerator_ids_.erase(accelerator);
|
||||
|
||||
if (IsMediaOrVolumeKey(accelerator)) {
|
||||
// If we unregistered a media/volume key, and now no media/volume keys are registered,
|
||||
// stop the media/volume key tap.
|
||||
// If we unregistered a media/volume key, and now no media/volume keys are
|
||||
// registered, stop the media/volume key tap.
|
||||
if (!IsAnyMediaOrVolumeKeyRegistered())
|
||||
StopWatchingMediaOrVolumeKeys();
|
||||
} else {
|
||||
|
@ -195,7 +194,8 @@ void GlobalShortcutListenerMac::UnregisterAcceleratorImpl(
|
|||
}
|
||||
|
||||
bool GlobalShortcutListenerMac::RegisterHotKey(
|
||||
const ui::Accelerator& accelerator, KeyId hot_key_id) {
|
||||
const ui::Accelerator& accelerator,
|
||||
KeyId hot_key_id) {
|
||||
EventHotKeyID event_hot_key_id;
|
||||
|
||||
// Signature uniquely identifies the application that owns this hot_key.
|
||||
|
@ -209,13 +209,14 @@ bool GlobalShortcutListenerMac::RegisterHotKey(
|
|||
modifiers |= (accelerator.IsAltDown() ? optionKey : 0);
|
||||
modifiers |= (accelerator.IsCmdDown() ? cmdKey : 0);
|
||||
|
||||
int key_code = ui::MacKeyCodeForWindowsKeyCode(accelerator.key_code(), 0,
|
||||
NULL, NULL);
|
||||
int key_code =
|
||||
ui::MacKeyCodeForWindowsKeyCode(accelerator.key_code(), 0, NULL, NULL);
|
||||
|
||||
// Register the event hot key.
|
||||
EventHotKeyRef hot_key_ref;
|
||||
OSStatus status = RegisterEventHotKey(key_code, modifiers, event_hot_key_id,
|
||||
GetApplicationEventTarget(), 0, &hot_key_ref);
|
||||
OSStatus status =
|
||||
RegisterEventHotKey(key_code, modifiers, event_hot_key_id,
|
||||
GetApplicationEventTarget(), 0, &hot_key_ref);
|
||||
if (status != noErr)
|
||||
return false;
|
||||
|
||||
|
@ -243,31 +244,28 @@ void GlobalShortcutListenerMac::StartWatchingMediaOrVolumeKeys() {
|
|||
DCHECK(event_tap_source_ == NULL);
|
||||
|
||||
// Add an event tap to intercept the system defined media/volume key events.
|
||||
event_tap_ = CGEventTapCreate(kCGSessionEventTap,
|
||||
kCGHeadInsertEventTap,
|
||||
kCGEventTapOptionDefault,
|
||||
CGEventMaskBit(NX_SYSDEFINED),
|
||||
EventTapCallback,
|
||||
this);
|
||||
event_tap_ = CGEventTapCreate(
|
||||
kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault,
|
||||
CGEventMaskBit(NX_SYSDEFINED), EventTapCallback, this);
|
||||
if (event_tap_ == NULL) {
|
||||
LOG(ERROR) << "Error: failed to create event tap.";
|
||||
return;
|
||||
}
|
||||
|
||||
event_tap_source_ = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault,
|
||||
event_tap_, 0);
|
||||
event_tap_source_ =
|
||||
CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, event_tap_, 0);
|
||||
if (event_tap_source_ == NULL) {
|
||||
LOG(ERROR) << "Error: failed to create new run loop source.";
|
||||
return;
|
||||
}
|
||||
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), event_tap_source_,
|
||||
kCFRunLoopCommonModes);
|
||||
kCFRunLoopCommonModes);
|
||||
}
|
||||
|
||||
void GlobalShortcutListenerMac::StopWatchingMediaOrVolumeKeys() {
|
||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), event_tap_source_,
|
||||
kCFRunLoopCommonModes);
|
||||
kCFRunLoopCommonModes);
|
||||
// Ensure both event tap and source are initialized.
|
||||
DCHECK(event_tap_ != NULL);
|
||||
DCHECK(event_tap_source_ != NULL);
|
||||
|
@ -288,8 +286,8 @@ void GlobalShortcutListenerMac::StartWatchingHotKeys() {
|
|||
EventTypeSpec event_type;
|
||||
event_type.eventClass = kEventClassKeyboard;
|
||||
event_type.eventKind = kEventHotKeyPressed;
|
||||
InstallApplicationEventHandler(
|
||||
hot_key_function, 1, &event_type, this, &event_handler_);
|
||||
InstallApplicationEventHandler(hot_key_function, 1, &event_type, this,
|
||||
&event_handler_);
|
||||
}
|
||||
|
||||
void GlobalShortcutListenerMac::StopWatchingHotKeys() {
|
||||
|
@ -323,8 +321,10 @@ bool GlobalShortcutListenerMac::IsAnyHotKeyRegistered() {
|
|||
// Returning event causes the event to propagate to other applications.
|
||||
// Returning NULL prevents the event from propagating.
|
||||
// static
|
||||
CGEventRef GlobalShortcutListenerMac::EventTapCallback(
|
||||
CGEventTapProxy proxy, CGEventType type, CGEventRef event, void* refcon) {
|
||||
CGEventRef GlobalShortcutListenerMac::EventTapCallback(CGEventTapProxy proxy,
|
||||
CGEventType type,
|
||||
CGEventRef event,
|
||||
void* refcon) {
|
||||
GlobalShortcutListenerMac* shortcut_listener =
|
||||
static_cast<GlobalShortcutListenerMac*>(refcon);
|
||||
|
||||
|
@ -341,8 +341,7 @@ CGEventRef GlobalShortcutListenerMac::EventTapCallback(
|
|||
}
|
||||
|
||||
// Ignore events that are not system defined media/volume keys.
|
||||
if (type != NX_SYSDEFINED ||
|
||||
[ns_event type] != NSSystemDefined ||
|
||||
if (type != NX_SYSDEFINED || [ns_event type] != NSSystemDefined ||
|
||||
[ns_event subtype] != kSystemDefinedEventMediaAndVolumeKeysSubtype) {
|
||||
return event;
|
||||
}
|
||||
|
@ -354,10 +353,8 @@ CGEventRef GlobalShortcutListenerMac::EventTapCallback(
|
|||
int key_code = (data1 & 0xFFFF0000) >> 16;
|
||||
if (key_code != NX_KEYTYPE_PLAY && key_code != NX_KEYTYPE_NEXT &&
|
||||
key_code != NX_KEYTYPE_PREVIOUS && key_code != NX_KEYTYPE_FAST &&
|
||||
key_code != NX_KEYTYPE_REWIND &&
|
||||
key_code != NX_KEYTYPE_SOUND_UP &&
|
||||
key_code != NX_KEYTYPE_SOUND_DOWN &&
|
||||
key_code != NX_KEYTYPE_MUTE) {
|
||||
key_code != NX_KEYTYPE_REWIND && key_code != NX_KEYTYPE_SOUND_UP &&
|
||||
key_code != NX_KEYTYPE_SOUND_DOWN && key_code != NX_KEYTYPE_MUTE) {
|
||||
return event;
|
||||
}
|
||||
|
||||
|
@ -381,11 +378,14 @@ CGEventRef GlobalShortcutListenerMac::EventTapCallback(
|
|||
|
||||
// static
|
||||
OSStatus GlobalShortcutListenerMac::HotKeyHandler(
|
||||
EventHandlerCallRef next_handler, EventRef event, void* user_data) {
|
||||
EventHandlerCallRef next_handler,
|
||||
EventRef event,
|
||||
void* user_data) {
|
||||
// Extract the hotkey from the event.
|
||||
EventHotKeyID hot_key_id;
|
||||
OSStatus result = GetEventParameter(event, kEventParamDirectObject,
|
||||
typeEventHotKeyID, NULL, sizeof(hot_key_id), NULL, &hot_key_id);
|
||||
OSStatus result =
|
||||
GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL,
|
||||
sizeof(hot_key_id), NULL, &hot_key_id);
|
||||
if (result != noErr)
|
||||
return result;
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ int64_t MonitorFinder::GetMonitor() {
|
|||
}
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI,
|
||||
FROM_HERE,
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&MonitorFinder::FetchMonitorFromWidget, this));
|
||||
return display_id_;
|
||||
}
|
||||
|
|
|
@ -49,16 +49,13 @@ class TtsPlatformImplMac;
|
|||
|
||||
class TtsPlatformImplMac : public TtsPlatformImpl {
|
||||
public:
|
||||
bool PlatformImplAvailable() override {
|
||||
return true;
|
||||
}
|
||||
bool PlatformImplAvailable() override { return true; }
|
||||
|
||||
bool Speak(
|
||||
int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) override;
|
||||
bool Speak(int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) override;
|
||||
|
||||
bool StopSpeaking() override;
|
||||
|
||||
|
@ -101,12 +98,11 @@ TtsPlatformImpl* TtsPlatformImpl::GetInstance() {
|
|||
return TtsPlatformImplMac::GetInstance();
|
||||
}
|
||||
|
||||
bool TtsPlatformImplMac::Speak(
|
||||
int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) {
|
||||
bool TtsPlatformImplMac::Speak(int utterance_id,
|
||||
const std::string& utterance,
|
||||
const std::string& lang,
|
||||
const VoiceData& voice,
|
||||
const UtteranceContinuousParameters& params) {
|
||||
// TODO: convert SSML to SAPI xml. http://crbug.com/88072
|
||||
utterance_ = utterance;
|
||||
paused_ = false;
|
||||
|
@ -119,9 +115,8 @@ bool TtsPlatformImplMac::Speak(
|
|||
// apply to the current utterance or a previous utterance. In
|
||||
// experimentation, the overhead of constructing and destructing a
|
||||
// NSSpeechSynthesizer is minimal.
|
||||
speech_synthesizer_.reset(
|
||||
[[SingleUseSpeechSynthesizer alloc]
|
||||
initWithUtterance:utterance_nsstring]);
|
||||
speech_synthesizer_.reset([[SingleUseSpeechSynthesizer alloc]
|
||||
initWithUtterance:utterance_nsstring]);
|
||||
[speech_synthesizer_ setDelegate:delegate_];
|
||||
|
||||
if (!voice.native_voice_identifier.empty()) {
|
||||
|
@ -136,9 +131,9 @@ bool TtsPlatformImplMac::Speak(
|
|||
|
||||
if (params.rate >= 0.0) {
|
||||
// The TTS api defines rate via words per minute. Let 200 be the default.
|
||||
[speech_synthesizer_
|
||||
setObject:[NSNumber numberWithInt:params.rate * 200]
|
||||
forProperty:NSSpeechRateProperty error:nil];
|
||||
[speech_synthesizer_ setObject:[NSNumber numberWithInt:params.rate * 200]
|
||||
forProperty:NSSpeechRateProperty
|
||||
error:nil];
|
||||
}
|
||||
|
||||
if (params.pitch >= 0.0) {
|
||||
|
@ -150,15 +145,15 @@ bool TtsPlatformImplMac::Speak(
|
|||
error:&errorCode];
|
||||
int defaultPitch = defaultPitchObj ? [defaultPitchObj intValue] : 48;
|
||||
int newPitch = static_cast<int>(defaultPitch * (0.5 * params.pitch + 0.5));
|
||||
[speech_synthesizer_
|
||||
setObject:[NSNumber numberWithInt:newPitch]
|
||||
forProperty:NSSpeechPitchBaseProperty error:nil];
|
||||
[speech_synthesizer_ setObject:[NSNumber numberWithInt:newPitch]
|
||||
forProperty:NSSpeechPitchBaseProperty
|
||||
error:nil];
|
||||
}
|
||||
|
||||
if (params.volume >= 0.0) {
|
||||
[speech_synthesizer_
|
||||
setObject: [NSNumber numberWithFloat:params.volume]
|
||||
forProperty:NSSpeechVolumeProperty error:nil];
|
||||
[speech_synthesizer_ setObject:[NSNumber numberWithFloat:params.volume]
|
||||
forProperty:NSSpeechVolumeProperty
|
||||
error:nil];
|
||||
}
|
||||
|
||||
bool success = [speech_synthesizer_ startSpeakingRetainedUtterance];
|
||||
|
@ -182,8 +177,8 @@ void TtsPlatformImplMac::Pause() {
|
|||
if (speech_synthesizer_.get() && utterance_id_ && !paused_) {
|
||||
[speech_synthesizer_ pauseSpeakingAtBoundary:NSSpeechImmediateBoundary];
|
||||
paused_ = true;
|
||||
TtsController::GetInstance()->OnTtsEvent(
|
||||
utterance_id_, TTS_EVENT_PAUSE, last_char_index_, "");
|
||||
TtsController::GetInstance()->OnTtsEvent(utterance_id_, TTS_EVENT_PAUSE,
|
||||
last_char_index_, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,8 +186,8 @@ void TtsPlatformImplMac::Resume() {
|
|||
if (speech_synthesizer_.get() && utterance_id_ && paused_) {
|
||||
[speech_synthesizer_ continueSpeaking];
|
||||
paused_ = false;
|
||||
TtsController::GetInstance()->OnTtsEvent(
|
||||
utterance_id_, TTS_EVENT_RESUME, last_char_index_, "");
|
||||
TtsController::GetInstance()->OnTtsEvent(utterance_id_, TTS_EVENT_RESUME,
|
||||
last_char_index_, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,11 +255,10 @@ void TtsPlatformImplMac::GetVoices(std::vector<VoiceData>* outVoices) {
|
|||
}
|
||||
}
|
||||
|
||||
void TtsPlatformImplMac::OnSpeechEvent(
|
||||
NSSpeechSynthesizer* sender,
|
||||
TtsEventType event_type,
|
||||
int char_index,
|
||||
const std::string& error_message) {
|
||||
void TtsPlatformImplMac::OnSpeechEvent(NSSpeechSynthesizer* sender,
|
||||
TtsEventType event_type,
|
||||
int char_index,
|
||||
const std::string& error_message) {
|
||||
// Don't send events from an utterance that's already completed.
|
||||
// This depends on the fact that we construct a new NSSpeechSynthesizer
|
||||
// each time we call Speak.
|
||||
|
@ -274,8 +268,7 @@ void TtsPlatformImplMac::OnSpeechEvent(
|
|||
if (event_type == TTS_EVENT_END)
|
||||
char_index = utterance_.size();
|
||||
TtsController* controller = TtsController::GetInstance();
|
||||
controller->OnTtsEvent(
|
||||
utterance_id_, event_type, char_index, error_message);
|
||||
controller->OnTtsEvent(utterance_id_, event_type, char_index, error_message);
|
||||
last_char_index_ = char_index;
|
||||
}
|
||||
|
||||
|
@ -286,8 +279,7 @@ TtsPlatformImplMac::TtsPlatformImplMac() {
|
|||
delegate_.reset([[ChromeTtsDelegate alloc] initWithPlatformImplMac:this]);
|
||||
}
|
||||
|
||||
TtsPlatformImplMac::~TtsPlatformImplMac() {
|
||||
}
|
||||
TtsPlatformImplMac::~TtsPlatformImplMac() {}
|
||||
|
||||
// static
|
||||
TtsPlatformImplMac* TtsPlatformImplMac::GetInstance() {
|
||||
|
@ -311,17 +303,17 @@ TtsPlatformImplMac* TtsPlatformImplMac::GetInstance() {
|
|||
- (void)speechSynthesizer:(NSSpeechSynthesizer*)sender
|
||||
willSpeakWord:(NSRange)character_range
|
||||
ofString:(NSString*)string {
|
||||
ttsImplMac_->OnSpeechEvent(sender, TTS_EVENT_WORD,
|
||||
character_range.location, "");
|
||||
ttsImplMac_->OnSpeechEvent(sender, TTS_EVENT_WORD, character_range.location,
|
||||
"");
|
||||
}
|
||||
|
||||
- (void)speechSynthesizer:(NSSpeechSynthesizer*)sender
|
||||
didEncounterErrorAtIndex:(NSUInteger)character_index
|
||||
ofString:(NSString*)string
|
||||
message:(NSString*)message {
|
||||
didEncounterErrorAtIndex:(NSUInteger)character_index
|
||||
ofString:(NSString*)string
|
||||
message:(NSString*)message {
|
||||
std::string message_utf8 = base::SysNSStringToUTF8(message);
|
||||
ttsImplMac_->OnSpeechEvent(sender, TTS_EVENT_ERROR, character_index,
|
||||
message_utf8);
|
||||
message_utf8);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,7 +15,7 @@ class ColorChooserMac;
|
|||
|
||||
// A Listener class to act as a event target for NSColorPanel and send
|
||||
// the results to the C++ class, ColorChooserMac.
|
||||
@interface ColorPanelCocoa : NSObject<NSWindowDelegate> {
|
||||
@interface ColorPanelCocoa : NSObject <NSWindowDelegate> {
|
||||
@private
|
||||
// We don't call DidChooseColor if the change wasn't caused by the user
|
||||
// interacting with the panel.
|
||||
|
@ -65,8 +65,7 @@ ColorChooserMac* ColorChooserMac::Open(content::WebContents* web_contents,
|
|||
if (current_color_chooser_)
|
||||
current_color_chooser_->End();
|
||||
DCHECK(!current_color_chooser_);
|
||||
current_color_chooser_ =
|
||||
new ColorChooserMac(web_contents, initial_color);
|
||||
current_color_chooser_ = new ColorChooserMac(web_contents, initial_color);
|
||||
return current_color_chooser_;
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ void ColorChooserMac::End() {
|
|||
DCHECK(current_color_chooser_ == this);
|
||||
current_color_chooser_ = NULL;
|
||||
if (web_contents_)
|
||||
web_contents_->DidEndColorChooser();
|
||||
web_contents_->DidEndColorChooser();
|
||||
}
|
||||
|
||||
void ColorChooserMac::SetSelectedColor(SkColor color) {
|
||||
|
|
|
@ -235,8 +235,8 @@ NSBundle* OuterAppBundle() {
|
|||
|
||||
bool GetUserDataDirectoryForBrowserBundle(NSBundle* bundle,
|
||||
base::FilePath* result) {
|
||||
std::unique_ptr<char, base::FreeDeleter>
|
||||
product_dir_name(ProductDirNameForBundle(bundle));
|
||||
std::unique_ptr<char, base::FreeDeleter> product_dir_name(
|
||||
ProductDirNameForBundle(bundle));
|
||||
return GetDefaultUserDataDirectoryForProduct(product_dir_name.get(), result);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
|||
std::unique_ptr<PdfMetafileSkia> draft_metafile;
|
||||
PdfMetafileSkia* initial_render_metafile = print_preview_context_.metafile();
|
||||
|
||||
bool render_to_draft = print_preview_context_.IsModifiable() &&
|
||||
is_print_ready_metafile_sent_;
|
||||
bool render_to_draft =
|
||||
print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_;
|
||||
|
||||
if (render_to_draft) {
|
||||
draft_metafile.reset(new PdfMetafileSkia(SkiaDocumentType::PDF));
|
||||
|
@ -69,8 +69,8 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
|||
gfx::Size page_size;
|
||||
RenderPage(printParams, page_number, print_preview_context_.prepared_frame(),
|
||||
true, initial_render_metafile, &page_size, NULL);
|
||||
print_preview_context_.RenderedPreviewPage(
|
||||
base::TimeTicks::Now() - begin_time);
|
||||
print_preview_context_.RenderedPreviewPage(base::TimeTicks::Now() -
|
||||
begin_time);
|
||||
|
||||
if (draft_metafile.get()) {
|
||||
draft_metafile->FinishDocument();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue