2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-02 23:43:23 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 08:30:26 +08:00
|
|
|
#include "atom/browser/browser.h"
|
2013-05-02 23:43:23 +08:00
|
|
|
|
2014-06-25 11:55:33 +08:00
|
|
|
#import "atom/browser/mac/atom_application.h"
|
|
|
|
#include "atom/browser/native_window.h"
|
|
|
|
#include "atom/browser/window_list.h"
|
2013-06-19 13:41:54 +08:00
|
|
|
#import "base/mac/bundle_locations.h"
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2013-05-02 23:43:23 +08:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2013-05-30 19:24:47 +08:00
|
|
|
void Browser::Focus() {
|
2013-06-26 17:22:24 +08:00
|
|
|
[[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
|
2013-05-30 19:24:47 +08:00
|
|
|
}
|
|
|
|
|
2013-12-05 10:26:01 +08:00
|
|
|
std::string Browser::GetExecutableFileVersion() const {
|
2013-06-19 13:41:54 +08:00
|
|
|
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
|
|
|
|
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
|
|
|
|
return base::SysNSStringToUTF8(version);
|
|
|
|
}
|
|
|
|
|
2013-12-05 10:42:04 +08:00
|
|
|
std::string Browser::GetExecutableFileProductName() const {
|
|
|
|
NSDictionary* infoDictionary = base::mac::OuterBundle().infoDictionary;
|
|
|
|
NSString *version = [infoDictionary objectForKey:@"CFBundleName"];
|
|
|
|
return base::SysNSStringToUTF8(version);
|
|
|
|
}
|
|
|
|
|
2013-08-06 16:19:56 +08:00
|
|
|
int Browser::DockBounce(BounceType type) {
|
2014-10-25 11:06:10 +08:00
|
|
|
return [[AtomApplication sharedApplication] requestUserAttention:(NSRequestUserAttentionType)type];
|
2013-08-06 16:19:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::DockCancelBounce(int rid) {
|
|
|
|
[[AtomApplication sharedApplication] cancelUserAttentionRequest:rid];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::DockSetBadgeText(const std::string& label) {
|
|
|
|
NSDockTile *tile = [[AtomApplication sharedApplication] dockTile];
|
|
|
|
[tile setBadgeLabel:base::SysUTF8ToNSString(label)];
|
|
|
|
}
|
|
|
|
|
2013-08-06 16:39:31 +08:00
|
|
|
std::string Browser::DockGetBadgeText() {
|
|
|
|
NSDockTile *tile = [[AtomApplication sharedApplication] dockTile];
|
|
|
|
return base::SysNSStringToUTF8([tile badgeLabel]);
|
|
|
|
}
|
|
|
|
|
2014-06-25 11:55:33 +08:00
|
|
|
void Browser::DockHide() {
|
|
|
|
WindowList* list = WindowList::GetInstance();
|
|
|
|
for (WindowList::iterator it = list->begin(); it != list->end(); ++it)
|
|
|
|
[(*it)->GetNativeWindow() setCanHide:NO];
|
|
|
|
|
|
|
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
|
|
|
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::DockShow() {
|
|
|
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
|
|
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
|
|
|
}
|
|
|
|
|
2013-05-02 23:43:23 +08:00
|
|
|
} // namespace atom
|