Fix code styling problems

This commit is contained in:
Cheng Zhao 2016-05-05 12:26:23 +09:00
parent 3f2a25d07c
commit 7268f434b2
9 changed files with 51 additions and 36 deletions

View file

@ -250,11 +250,14 @@ void App::OnFinishLaunching() {
Emit("ready"); Emit("ready");
} }
void App::OnContinueUserActivity(bool* prevent_default, #if defined(OS_MACOSX)
const std::string& type, void App::OnContinueUserActivity(
const std::map<std::string, std::string>& user_info) { bool* prevent_default,
const std::string& type,
const std::map<std::string, std::string>& user_info) {
*prevent_default = Emit("continue-activity", type, user_info); *prevent_default = Emit("continue-activity", type, user_info);
} }
#endif
void App::OnLogin(LoginHandler* login_handler) { void App::OnLogin(LoginHandler* login_handler) {
v8::Locker locker(isolate()); v8::Locker locker(isolate());

View file

@ -72,9 +72,12 @@ class App : public AtomBrowserClient::Delegate,
void OnWillFinishLaunching() override; void OnWillFinishLaunching() override;
void OnFinishLaunching() override; void OnFinishLaunching() override;
void OnLogin(LoginHandler* login_handler) override; void OnLogin(LoginHandler* login_handler) override;
void OnContinueUserActivity(bool* prevent_default, #if defined(OS_MACOSX)
const std::string& type, void OnContinueUserActivity(
const std::map<std::string, std::string>& user_info) override; bool* prevent_default,
const std::string& type,
const std::map<std::string, std::string>& user_info) override;
#endif
// content::ContentBrowserClient: // content::ContentBrowserClient:
void AllowCertificateError( void AllowCertificateError(

View file

@ -138,9 +138,9 @@ void Browser::Activate(bool has_visible_windows) {
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
bool Browser::ContinueUserActivity(const std::string& type, bool Browser::ContinueUserActivity(
const std::map<std::string, const std::string& type,
std::string>& user_info) { const std::map<std::string, std::string>& user_info) {
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, FOR_EACH_OBSERVER(BrowserObserver,
observers_, observers_,

View file

@ -101,8 +101,9 @@ class Browser : public WindowListObserver {
std::string GetCurrentActivityType(); std::string GetCurrentActivityType();
// Resumes an activity via hand-off. // Resumes an activity via hand-off.
bool ContinueUserActivity(const std::string& type, bool ContinueUserActivity(
const std::map<std::string, std::string>& user_info); const std::string& type,
const std::map<std::string, std::string>& user_info);
// Bounce the dock icon. // Bounce the dock icon.
enum BounceType { enum BounceType {

View file

@ -87,17 +87,20 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) {
void Browser::SetAppUserModelID(const base::string16& name) { void Browser::SetAppUserModelID(const base::string16& name) {
} }
void Browser::SetUserActivity(const std::string& type, const std::map<std::string, std::string>& user_info) { void Browser::SetUserActivity(
const std::string& type,
const std::map<std::string, std::string>& user_info) {
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()]; NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
NSUserActivity* user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns]; NSUserActivity* user_activity =
[[NSUserActivity alloc] initWithActivityType:type_ns];
base::scoped_nsobject<NSMutableDictionary> user_info_args([[NSMutableDictionary alloc] init]); base::scoped_nsobject<NSMutableDictionary> user_info_args(
[[NSMutableDictionary alloc] init]);
for (auto const &pair : user_info) { for (auto const &pair : user_info) {
NSString* value_ns = [NSString stringWithUTF8String:pair.second.c_str()]; NSString* value_ns = [NSString stringWithUTF8String:pair.second.c_str()];
NSString* key_ns = [NSString stringWithUTF8String:pair.first.c_str()]; NSString* key_ns = [NSString stringWithUTF8String:pair.first.c_str()];
[user_info_args.get() setObject:value_ns [user_info_args.get() setObject:value_ns forKey:key_ns];
forKey:key_ns];
} }
user_activity.userInfo = user_info_args.get(); user_activity.userInfo = user_info_args.get();
@ -107,7 +110,8 @@ void Browser::SetUserActivity(const std::string& type, const std::map<std::strin
} }
std::string Browser::GetCurrentActivityType() { std::string Browser::GetCurrentActivityType() {
NSUserActivity* user_activity = [[AtomApplication sharedApplication] getCurrentActivity]; NSUserActivity* user_activity =
[[AtomApplication sharedApplication] getCurrentActivity];
return base::SysNSStringToUTF8(user_activity.activityType); return base::SysNSStringToUTF8(user_activity.activityType);
} }

View file

@ -8,6 +8,8 @@
#include <string> #include <string>
#include <map> #include <map>
#include "build/build_config.h"
namespace atom { namespace atom {
class LoginHandler; class LoginHandler;
@ -46,10 +48,13 @@ class BrowserObserver {
// The browser requests HTTP login. // The browser requests HTTP login.
virtual void OnLogin(LoginHandler* login_handler) {} virtual void OnLogin(LoginHandler* login_handler) {}
#if defined(OS_MACOSX)
// The browser wants to resume a user activity via handoff. (OS X only) // The browser wants to resume a user activity via handoff. (OS X only)
virtual void OnContinueUserActivity(bool* prevent_default, virtual void OnContinueUserActivity(
const std::string& type, bool* prevent_default,
const std::map<std::string, std::string>& user_info) {} const std::string& type,
const std::map<std::string, std::string>& user_info) {}
#endif
protected: protected:
virtual ~BrowserObserver() {} virtual ~BrowserObserver() {}

View file

@ -21,7 +21,6 @@
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent; - (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
- (NSUserActivity*)getCurrentActivity; - (NSUserActivity*)getCurrentActivity;
- (void)setCurrentActivity:(NSUserActivity*)userActivity; - (void)setCurrentActivity:(NSUserActivity*)userActivity;
@end @end

View file

@ -59,9 +59,9 @@
return flag; return flag;
} }
- (BOOL)application:(NSApplication *)sender - (BOOL)application:(NSApplication*)sender
continueUserActivity:(NSUserActivity *)userActivity continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler { restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler {
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType)); std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
std::map<std::string, std::string> user_info; std::map<std::string, std::string> user_info;

View file

@ -118,15 +118,15 @@ Returns:
* `event` Event * `event` Event
* `type` String - A string identifying the event. Maps to [`NSUserActivity.activityType`](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType). * `type` String - A string identifying the event. Maps to [`NSUserActivity.activityType`](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType).
* `userInfo` Object - Contains app-specific state stored by the activity on * `userInfo` Object - Contains app-specific state stored by the activity on
another device. Currently only string data is supported. another device. Currently only string data is supported.
Emitted during [handoff](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html) when an activity from a different device wants to be Emitted during [handoff][handoff] when an activity from a different device wants
resumed. You should call `event.preventDefault()` if you want to handle this to be resumed. You should call `event.preventDefault()` if you want to handle
event. this event.
A user activity can be continued only in an app that has the same developer A user activity can be continued only in an app that has the same developer Team
Team ID as the activity's source app and that supports the activity's type. ID as the activity's source app and that supports the activity's type.
Supported activity types are specified in the app's Info.plist under the Supported activity types are specified in the app's `Info.plist` under the
`NSUserActivityTypes` key. `NSUserActivityTypes` key.
### Event: 'browser-window-blur' ### Event: 'browser-window-blur'
@ -503,12 +503,12 @@ app.on('ready', function() {
### `app.setUserActivity(type, userInfo)` _OS X_ ### `app.setUserActivity(type, userInfo)` _OS X_
* `type` String - Uniquely identifies the activity. It's recommended to use a * `type` String - Uniquely identifies the activity. It's recommended to use a
reverse-DNS string. reverse-DNS string.
* `userInfo` Object - App-specific state to store for use by another device. * `userInfo` Object - App-specific state to store for use by another device.
Currently only string data is supported. Currently only string data is supported.
Creates an `NSUserActivity` and sets it as the current activity. The activity Creates an `NSUserActivity` and sets it as the current activity. The activity
is eligible for [handoff](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html) to another device afterward. is eligible for [handoff][handoff] to another device afterward.
### `app.getCurrentActivityType()` _OS X_ ### `app.getCurrentActivityType()` _OS X_
@ -600,5 +600,5 @@ Sets the `image` associated with this dock icon.
[tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks [tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
[CFBundleURLTypes]: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115 [CFBundleURLTypes]: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115
[LSCopyDefaultHandlerForURLScheme]: [LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/#//apple_ref/c/func/LSCopyDefaultHandlerForURLScheme
https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/#//apple_ref/c/func/LSCopyDefaultHandlerForURLScheme [handoff]: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html