Commit a92ac8eb authored by sdefresne's avatar sdefresne Committed by Commit bot

[iOS] Upstream //ios/chrome/browser/ui/commands changes

ShowSigninCommand is a command to perform a sign in operation.

Modernize other commands to use "instancetype", "NS_DESIGNATED_INITIALIZER",
"NS_UNAVAILABLE" for the initializers and "@synthetize" for the properties.

Remove unused ShowAccountsSettingsCommand.

BUG=429756

Review URL: https://codereview.chromium.org/1124173004

Cr-Commit-Position: refs/heads/master@{#329627}
parent 71712ae1
...@@ -7,18 +7,28 @@ ...@@ -7,18 +7,28 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
} }
// Command sent to clear the browsing data associated with a browser state. // Command sent to clear the browsing data associated with a browser state.
@interface ClearBrowsingDataCommand : NSObject @interface ClearBrowsingDataCommand : GenericChromeCommand
// Mark inherited initializer as unavailable to prevent calling it by mistake.
- (instancetype)initWithTag:(NSInteger)tag NS_UNAVAILABLE;
// Initializes a command intented to clear browsing data for |browserState|
// that correspong to removal mask |mask|.
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
mask:(int)mask; mask:(int)mask NS_DESIGNATED_INITIALIZER;
// When executed this command will remove browsing data for this BrowserState.
@property(nonatomic, readonly) ios::ChromeBrowserState* browserState;
@property(nonatomic, readonly, assign) ios::ChromeBrowserState* browserState; // Removal mask: see BrowsingDataRemover::RemoveDataMask.
@property(nonatomic, readonly, assign) int mask; @property(nonatomic, readonly) int mask;
@end @end
......
...@@ -7,17 +7,19 @@ ...@@ -7,17 +7,19 @@
#include "base/logging.h" #include "base/logging.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
@implementation ClearBrowsingDataCommand { @implementation ClearBrowsingDataCommand
ios::ChromeBrowserState* _browserState; // Weak.
int _mask; // Removal mask: see BrowsingDataRemover::RemoveDataMask.
}
@synthesize browserState = _browserState; @synthesize browserState = _browserState;
@synthesize mask = _mask; @synthesize mask = _mask;
- (instancetype)initWithTag:(NSInteger)tag {
NOTREACHED();
return nil;
}
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
mask:(int)mask { mask:(int)mask {
self = [super init]; self = [super initWithTag:IDC_CLEAR_BROWSING_DATA_IOS];
if (self) { if (self) {
DCHECK(browserState); DCHECK(browserState);
_browserState = browserState; _browserState = browserState;
...@@ -26,8 +28,4 @@ ...@@ -26,8 +28,4 @@
return self; return self;
} }
- (NSInteger)tag {
return IDC_CLEAR_BROWSING_DATA_IOS;
}
@end @end
...@@ -10,14 +10,18 @@ ...@@ -10,14 +10,18 @@
// Generic command that can be passed to |chromeExecuteCommand|. // Generic command that can be passed to |chromeExecuteCommand|.
@interface GenericChromeCommand : NSObject @interface GenericChromeCommand : NSObject
@property(nonatomic, assign) NSInteger tag; // Mark inherited initializer as unavailable to prevent calling it by mistake.
- (instancetype)init NS_UNAVAILABLE;
// Designated initializer. // Initializes the GenericChromeCommand with given |tag|.
- (instancetype)initWithTag:(NSInteger)tag; - (instancetype)initWithTag:(NSInteger)tag NS_DESIGNATED_INITIALIZER;
// Convenience method to execute this command on the main window. // Convenience method to execute this command on the main window.
- (void)executeOnMainWindow; - (void)executeOnMainWindow;
// Command tag.
@property(nonatomic, assign) NSInteger tag;
@end @end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_GENERIC_CHROME_COMMAND_H_ #endif // IOS_CHROME_BROWSER_UI_COMMANDS_GENERIC_CHROME_COMMAND_H_
...@@ -9,16 +9,10 @@ ...@@ -9,16 +9,10 @@
#include "base/logging.h" #include "base/logging.h"
#import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
@implementation GenericChromeCommand { @implementation GenericChromeCommand
NSInteger _tag;
}
@synthesize tag = _tag; @synthesize tag = _tag;
- (instancetype)init {
return [self initWithTag:0];
}
- (instancetype)initWithTag:(NSInteger)tag { - (instancetype)initWithTag:(NSInteger)tag {
self = [super init]; self = [super init];
if (self) { if (self) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define IDC_VOICE_SEARCH 40902 #define IDC_VOICE_SEARCH 40902
#define IDC_NEW_INCOGNITO_TAB 40903 #define IDC_NEW_INCOGNITO_TAB 40903
#define IDC_CLOSE_ALL_TABS 40904 #define IDC_CLOSE_ALL_TABS 40904
#define IDC_SHOW_SIGNIN_IOS 40905
#define IDC_SWITCH_BROWSER_MODES 40906 #define IDC_SWITCH_BROWSER_MODES 40906
#define IDC_FIND_CLOSE 40907 #define IDC_FIND_CLOSE 40907
#define IDC_FIND_UPDATE 40908 #define IDC_FIND_UPDATE 40908
......
...@@ -19,30 +19,43 @@ class GURL; ...@@ -19,30 +19,43 @@ class GURL;
// A command to open a new tab. // A command to open a new tab.
@interface OpenUrlCommand : GenericChromeCommand @interface OpenUrlCommand : GenericChromeCommand
// Whether or not this URL command comes from a chrome context (e.g., settings), // Mark inherited initializer as unavailable to prevent calling it by mistake.
// as opposed to a web page context. - (instancetype)initWithTag:(NSInteger)tag NS_UNAVAILABLE;
@property(nonatomic, readonly) BOOL fromChrome;
// Initializes a command intended to open a URL as a link from a page. // Initializes a command intended to open a URL as a link from a page.
// Designated initializer. - (instancetype)initWithURL:(const GURL&)url
- (id)initWithURL:(const GURL&)url referrer:(const web::Referrer&)referrer
referrer:(const web::Referrer&)referrer windowName:(NSString*)windowName
windowName:(NSString*)windowName inIncognito:(BOOL)inIncognito
inIncognito:(BOOL)inIncognito inBackground:(BOOL)inBackground
inBackground:(BOOL)inBackground appendTo:(OpenPosition)append NS_DESIGNATED_INITIALIZER;
appendTo:(OpenPosition)append;
// Initializes a command intended to open a URL from browser chrome (e.g., // Initializes a command intended to open a URL from browser chrome (e.g.,
// settings). This will always open in a new foreground tab in non-incognito // settings). This will always open in a new foreground tab in non-incognito
// mode. // mode.
- (id)initWithURLFromChrome:(const GURL&)url; - (instancetype)initWithURLFromChrome:(const GURL&)url;
- (const GURL&)url; // URL to open.
- (const web::Referrer&)referrer; @property(nonatomic, readonly) const GURL& url;
- (NSString*)windowName;
- (BOOL)inIncognito; // Referrer for the URL.
- (BOOL)inBackground; @property(nonatomic, readonly) const web::Referrer& referrer;
- (OpenPosition)appendTo;
// Name of the window.
@property(nonatomic, readonly) NSString* windowName;
// Whether this URL command requests opening in incognito or not.
@property(nonatomic, readonly) BOOL inIncognito;
// Whether this URL command requests opening in background or not.
@property(nonatomic, readonly) BOOL inBackground;
// Whether or not this URL command comes from a chrome context (e.g., settings),
// as opposed to a web page context.
@property(nonatomic, readonly) BOOL fromChrome;
// Location where the new tab should be opened.
@property(nonatomic, readonly) OpenPosition appendTo;
@end @end
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#import "ios/chrome/browser/ui/commands/open_url_command.h" #import "ios/chrome/browser/ui/commands/open_url_command.h"
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#include "ios/web/public/referrer.h" #include "ios/web/public/referrer.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -12,24 +14,28 @@ ...@@ -12,24 +14,28 @@
GURL _url; GURL _url;
web::Referrer _referrer; web::Referrer _referrer;
base::scoped_nsobject<NSString> _windowName; base::scoped_nsobject<NSString> _windowName;
BOOL _inIncognito;
BOOL _inBackground;
BOOL _fromChrome;
OpenPosition _appendTo;
} }
@synthesize inIncognito = _inIncognito;
@synthesize inBackground = _inBackground;
@synthesize fromChrome = _fromChrome; @synthesize fromChrome = _fromChrome;
@synthesize appendTo = _appendTo;
- (id)initWithURL:(const GURL&)url - (instancetype)initWithTag:(NSInteger)tag {
referrer:(const web::Referrer&)referrer NOTREACHED();
windowName:(NSString*)windowName return nil;
inIncognito:(BOOL)inIncognito }
inBackground:(BOOL)inBackground
appendTo:(OpenPosition)appendTo { - (instancetype)initWithURL:(const GURL&)url
if ((self = [super init])) { referrer:(const web::Referrer&)referrer
windowName:(NSString*)windowName
inIncognito:(BOOL)inIncognito
inBackground:(BOOL)inBackground
appendTo:(OpenPosition)appendTo {
if ((self = [super initWithTag:IDC_OPEN_URL])) {
_url = url; _url = url;
_referrer = referrer; _referrer = referrer;
_windowName.reset([windowName retain]); _windowName.reset([windowName copy]);
_inIncognito = inIncognito; _inIncognito = inIncognito;
_inBackground = inBackground; _inBackground = inBackground;
_appendTo = appendTo; _appendTo = appendTo;
...@@ -37,7 +43,7 @@ ...@@ -37,7 +43,7 @@
return self; return self;
} }
- (id)initWithURLFromChrome:(const GURL&)url { - (instancetype)initWithURLFromChrome:(const GURL&)url {
if ((self = [self initWithURL:url if ((self = [self initWithURL:url
referrer:web::Referrer() referrer:web::Referrer()
windowName:nil windowName:nil
...@@ -61,16 +67,4 @@ ...@@ -61,16 +67,4 @@
return _windowName.get(); return _windowName.get();
} }
- (BOOL)inIncognito {
return _inIncognito;
}
- (BOOL)inBackground {
return _inBackground;
}
- (OpenPosition)appendTo {
return _appendTo;
}
@end @end
...@@ -7,10 +7,15 @@ ...@@ -7,10 +7,15 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
class GURL; class GURL;
// Set up for testing command that can be passed to |chromeExecuteCommand|. // Set up for testing command that can be passed to |chromeExecuteCommand|.
@interface SetUpForTestingCommand : NSObject @interface SetUpForTestingCommand : GenericChromeCommand
// Mark inherited initializer as unavailable to prevent calling it by mistake.
- (instancetype)initWithTag:(NSInteger)tag NS_UNAVAILABLE;
// Initializes this command by parsing the url query. // Initializes this command by parsing the url query.
- (instancetype)initWithURL:(const GURL&)url; - (instancetype)initWithURL:(const GURL&)url;
...@@ -18,11 +23,17 @@ class GURL; ...@@ -18,11 +23,17 @@ class GURL;
// Initializes this command. // Initializes this command.
- (instancetype)initWithClearBrowsingData:(BOOL)clearBrowsingData - (instancetype)initWithClearBrowsingData:(BOOL)clearBrowsingData
closeTabs:(BOOL)closeTabs closeTabs:(BOOL)closeTabs
numberOfNewTabs:(NSInteger)numberOfNewTabs; numberOfNewTabs:(NSInteger)numberOfNewTabs
NS_DESIGNATED_INITIALIZER;
// Whether the browsing data should be cleared.
@property(nonatomic, readonly) BOOL clearBrowsingData;
// Whether the existing tabs should be closed.
@property(nonatomic, readonly) BOOL closeTabs;
@property(nonatomic, readonly, assign) BOOL clearBrowsingData; // The number of new tabs to create.
@property(nonatomic, readonly, assign) BOOL closeTabs; @property(nonatomic, readonly) NSInteger numberOfNewTabs;
@property(nonatomic, assign) NSInteger numberOfNewTabs;
@end @end
......
...@@ -5,45 +5,44 @@ ...@@ -5,45 +5,44 @@
#import "ios/chrome/browser/ui/commands/set_up_for_testing_command.h" #import "ios/chrome/browser/ui/commands/set_up_for_testing_command.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#import "net/base/mac/url_conversions.h" #include "net/base/url_util.h"
#import "third_party/google_toolbox_for_mac/src/Foundation/GTMNSDictionary+URLArguments.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace { namespace {
// Clear all browsing data. // Clear all browsing data.
NSString* const kClearBrowsingData = @"clearBrowsingData"; const char kClearBrowsingData[] = "clearBrowsingData";
// Close existing tabs. // Close existing tabs.
NSString* const kCloseTabs = @"closeTabs"; const char kCloseTabs[] = "closeTabs";
// Number of new tabs. // Number of new tabs.
NSString* const kNumberOfNewTabs = @"numberOfNewTabs"; const char kNumberOfNewTabs[] = "numberOfNewTabs";
} // namespace } // namespace
@implementation SetUpForTestingCommand { @implementation SetUpForTestingCommand
// Whether the browsing data should be cleared.
BOOL _clearBrowsingData;
// Whether the existing tabs should be closed.
BOOL _closeTabs;
// The number of new tabs to create.
NSInteger _numberOfNewTabs;
}
@synthesize clearBrowsingData = _clearBrowsingData; @synthesize clearBrowsingData = _clearBrowsingData;
@synthesize closeTabs = _closeTabs; @synthesize closeTabs = _closeTabs;
@synthesize numberOfNewTabs = _numberOfNewTabs; @synthesize numberOfNewTabs = _numberOfNewTabs;
- (instancetype)initWithURL:(const GURL&)url { - (instancetype)initWithTag:(NSInteger)tag {
// TODO(ios): Rewrite to use GetValueForKeyInQuery. NOTREACHED();
NSURL* nsurl = net::NSURLWithGURL(url); return nil;
DCHECK(nsurl); }
NSDictionary* urlArguments =
[NSDictionary gtm_dictionaryWithHttpArgumentsString:nsurl.query];
BOOL clearBrowsingData =
[urlArguments objectForKey:kClearBrowsingData] != nil;
BOOL closeTabs = [urlArguments objectForKey:kCloseTabs] != nil;
NSInteger numberOfNewTabs =
[[urlArguments objectForKey:kNumberOfNewTabs] integerValue];
- (instancetype)initWithURL:(const GURL&)url {
std::string value;
int numberOfNewTabs = 0;
if (net::GetValueForKeyInQuery(url, kNumberOfNewTabs, &value)) {
if (!base::StringToInt(value, &numberOfNewTabs) || numberOfNewTabs < 0) {
// Ignore incorrect value for "numberOfNewTabs".
numberOfNewTabs = 0;
}
}
std::string ignored;
bool clearBrowsingData =
net::GetValueForKeyInQuery(url, kClearBrowsingData, &ignored);
bool closeTabs = net::GetValueForKeyInQuery(url, kCloseTabs, &ignored);
return [self initWithClearBrowsingData:clearBrowsingData return [self initWithClearBrowsingData:clearBrowsingData
closeTabs:closeTabs closeTabs:closeTabs
numberOfNewTabs:numberOfNewTabs]; numberOfNewTabs:numberOfNewTabs];
...@@ -52,7 +51,7 @@ NSString* const kNumberOfNewTabs = @"numberOfNewTabs"; ...@@ -52,7 +51,7 @@ NSString* const kNumberOfNewTabs = @"numberOfNewTabs";
- (instancetype)initWithClearBrowsingData:(BOOL)clearBrowsingData - (instancetype)initWithClearBrowsingData:(BOOL)clearBrowsingData
closeTabs:(BOOL)closeTabs closeTabs:(BOOL)closeTabs
numberOfNewTabs:(NSInteger)numberOfNewTabs { numberOfNewTabs:(NSInteger)numberOfNewTabs {
self = [super init]; self = [super initWithTag:IDC_SETUP_FOR_TESTING];
if (self) { if (self) {
_clearBrowsingData = clearBrowsingData; _clearBrowsingData = clearBrowsingData;
_closeTabs = closeTabs; _closeTabs = closeTabs;
...@@ -61,8 +60,4 @@ NSString* const kNumberOfNewTabs = @"numberOfNewTabs"; ...@@ -61,8 +60,4 @@ NSString* const kNumberOfNewTabs = @"numberOfNewTabs";
return self; return self;
} }
- (NSInteger)tag {
return IDC_SETUP_FOR_TESTING;
}
@end @end
...@@ -20,6 +20,7 @@ TEST_F(SetUpForTestingCommandTest, InitNoArguments) { ...@@ -20,6 +20,7 @@ TEST_F(SetUpForTestingCommandTest, InitNoArguments) {
[[SetUpForTestingCommand alloc] initWithURL:url]); [[SetUpForTestingCommand alloc] initWithURL:url]);
EXPECT_FALSE([command clearBrowsingData]); EXPECT_FALSE([command clearBrowsingData]);
EXPECT_FALSE([command closeTabs]); EXPECT_FALSE([command closeTabs]);
EXPECT_EQ(0, [command numberOfNewTabs]);
} }
TEST_F(SetUpForTestingCommandTest, InitClearBrowsingData) { TEST_F(SetUpForTestingCommandTest, InitClearBrowsingData) {
...@@ -58,6 +59,15 @@ TEST_F(SetUpForTestingCommandTest, InitWithBadNumberOfNewTabs) { ...@@ -58,6 +59,15 @@ TEST_F(SetUpForTestingCommandTest, InitWithBadNumberOfNewTabs) {
EXPECT_EQ(0, [command numberOfNewTabs]); EXPECT_EQ(0, [command numberOfNewTabs]);
} }
TEST_F(SetUpForTestingCommandTest, InitWithNegativeNumberOfNewTabs) {
GURL url("chrome://setupfortesting?numberOfNewTabs=-3");
base::scoped_nsobject<SetUpForTestingCommand> command(
[[SetUpForTestingCommand alloc] initWithURL:url]);
EXPECT_FALSE([command clearBrowsingData]);
EXPECT_FALSE([command closeTabs]);
EXPECT_EQ(0, [command numberOfNewTabs]);
}
TEST_F(SetUpForTestingCommandTest, InitWithArguments) { TEST_F(SetUpForTestingCommandTest, InitWithArguments) {
GURL url( GURL url(
"chrome://setupfortesting?clearBrowsingData&closeTabs&numberOfNewTabs=5"); "chrome://setupfortesting?clearBrowsingData&closeTabs&numberOfNewTabs=5");
...@@ -74,6 +84,7 @@ TEST_F(SetUpForTestingCommandTest, InitWithBadArguments) { ...@@ -74,6 +84,7 @@ TEST_F(SetUpForTestingCommandTest, InitWithBadArguments) {
[[SetUpForTestingCommand alloc] initWithURL:url]); [[SetUpForTestingCommand alloc] initWithURL:url]);
EXPECT_FALSE([command clearBrowsingData]); EXPECT_FALSE([command clearBrowsingData]);
EXPECT_FALSE([command closeTabs]); EXPECT_FALSE([command closeTabs]);
EXPECT_EQ(0, [command numberOfNewTabs]);
} }
} // namespace } // namespace
// Copyright 2014 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 IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_ACCOUNTS_SETTINGS_COMMAND_H_
#define IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_ACCOUNTS_SETTINGS_COMMAND_H_
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
// A command to show the accounts settings screen.
@interface ShowAccountsSettingCommand : GenericChromeCommand
@end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_ACCOUNTS_SETTINGS_COMMAND_H_
// Copyright 2014 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 "ios/chrome/browser/ui/commands/show_accounts_settings_command.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
@implementation ShowAccountsSettingCommand
- (instancetype)init {
return [super initWithTag:IDC_SHOW_ACCOUNTS_SETTINGS];
}
@end
...@@ -15,18 +15,35 @@ class FilePath; ...@@ -15,18 +15,35 @@ class FilePath;
@interface ShowMailComposerCommand : GenericChromeCommand @interface ShowMailComposerCommand : GenericChromeCommand
// Mark inherited initializer as unavailable to prevent calling it by mistake.
- (instancetype)initWithTag:(NSInteger)tag NS_UNAVAILABLE;
// Initializes a command designed to open the mail composer with pre-filled
// recipients, subject, body.
- (instancetype)initWithToRecipient:(NSString*)toRecipient - (instancetype)initWithToRecipient:(NSString*)toRecipient
subject:(NSString*)subject subject:(NSString*)subject
body:(NSString*)body body:(NSString*)body
emailNotConfiguredAlertTitleId:(int)alertTitleId emailNotConfiguredAlertTitleId:(int)alertTitleId
emailNotConfiguredAlertMessageId:(int)alertMessageId; emailNotConfiguredAlertMessageId:(int)alertMessageId
NS_DESIGNATED_INITIALIZER;
@property(nonatomic, readonly, assign) NSArray* toRecipients;
@property(nonatomic, readonly, assign) NSString* subject; // List of email recipients.
@property(nonatomic, readonly, assign) NSString* body; @property(nonatomic, readonly) NSArray* toRecipients;
@property(nonatomic, assign) base::FilePath textFileToAttach;
@property(nonatomic, readonly, assign) int emailNotConfiguredAlertTitleId; // Pre-filled default email subject.
@property(nonatomic, readonly, assign) int emailNotConfiguredAlertMessageId; @property(nonatomic, readonly) NSString* subject;
// Pre-filled default email body.
@property(nonatomic, readonly) NSString* body;
// Path to file to attach to email.
@property(nonatomic, assign) const base::FilePath& textFileToAttach;
// Identifier for alert if the email title is empty.
@property(nonatomic, readonly) int emailNotConfiguredAlertTitleId;
// Identifier for alert if the email body is empty.
@property(nonatomic, readonly) int emailNotConfiguredAlertMessageId;
@end @end
......
...@@ -14,26 +14,29 @@ ...@@ -14,26 +14,29 @@
base::scoped_nsobject<NSString> _subject; base::scoped_nsobject<NSString> _subject;
base::scoped_nsobject<NSString> _body; base::scoped_nsobject<NSString> _body;
base::FilePath _textFileToAttach; base::FilePath _textFileToAttach;
// Alert message ids for the case when no email account is configured.
int _emailNotConfiguredAlertTitleId;
int _emailNotConfiguredAlertMessageId;
} }
@synthesize textFileToAttach; @synthesize emailNotConfiguredAlertTitleId = _emailNotConfiguredAlertTitleId;
@synthesize emailNotConfiguredAlertMessageId =
_emailNotConfiguredAlertMessageId;
- (id)initWithToRecipient:(NSString*)toRecipient - (instancetype)initWithTag:(NSInteger)tag {
NOTREACHED();
return nil;
}
- (instancetype)initWithToRecipient:(NSString*)toRecipient
subject:(NSString*)subject subject:(NSString*)subject
body:(NSString*)body body:(NSString*)body
emailNotConfiguredAlertTitleId:(int)alertTitleId emailNotConfiguredAlertTitleId:(int)alertTitleId
emailNotConfiguredAlertMessageId:(int)alertMessageId { emailNotConfiguredAlertMessageId:(int)alertMessageId {
DCHECK(alertTitleId); DCHECK(alertTitleId);
DCHECK(alertMessageId); DCHECK(alertMessageId);
self = [super init]; self = [super initWithTag:IDC_SHOW_MAIL_COMPOSER];
if (self) { if (self) {
self.tag = IDC_SHOW_MAIL_COMPOSER;
_toRecipients.reset([@[ toRecipient ] retain]); _toRecipients.reset([@[ toRecipient ] retain]);
_subject.reset([subject retain]); _subject.reset([subject copy]);
_body.reset([body retain]); _body.reset([body copy]);
_emailNotConfiguredAlertTitleId = alertTitleId; _emailNotConfiguredAlertTitleId = alertTitleId;
_emailNotConfiguredAlertMessageId = alertMessageId; _emailNotConfiguredAlertMessageId = alertMessageId;
} }
...@@ -52,12 +55,12 @@ ...@@ -52,12 +55,12 @@
return _body.get(); return _body.get();
} }
- (int)emailNotConfiguredAlertTitleId { - (const base::FilePath&)textFileToAttach {
return _emailNotConfiguredAlertTitleId; return _textFileToAttach;
} }
- (int)emailNotConfiguredAlertMessageId { - (void)setTextFileToAttach:(const base::FilePath&)textFileToAttach {
return _emailNotConfiguredAlertMessageId; _textFileToAttach = textFileToAttach;
} }
@end @end
// Copyright 2014 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 IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_SIGNIN_COMMAND_H_
#define IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_SIGNIN_COMMAND_H_
#import <Foundation/Foundation.h>
#include "ios/chrome/browser/authentication/constants.h"
#include "ios/chrome/browser/ui/commands/generic_chrome_command.h"
typedef void (^ShowSigninCommandCompletionCallback)(BOOL succeeded,
BOOL profileWasSwapped);
enum AuthenticationOperation {
// Operation to cancel the current authentication operation and dismiss any
// UI presented by this operation.
AUTHENTICATION_OPERATION_DISMISS,
// Operation to start a re-authenticate operation. The user is presented with
// the SSOAuth re-authenticate web page.
AUTHENTICATION_OPERATION_REAUTHENTICATE,
// Operation to start a sign-in operation. The user is presented with the
// SSOAuth sign in page (SSOAuth account picker or SSOAuth sign-in web page).
AUTHENTICATION_OPERATION_SIGNIN,
};
// A command to perform a sign in operation.
@interface ShowSigninCommand : GenericChromeCommand
// Mark inherited initializer as unavailable to prevent calling it by mistake.
- (instancetype)initWithTag:(NSInteger)tag NS_UNAVAILABLE;
// Initializes a command to perform the specified operation with a
// SigninInteractionController and invoke a possibly-nil callback when finished.
- (instancetype)initWithOperation:(AuthenticationOperation)operation
signInSource:(SignInSource)signInSource
callback:(ShowSigninCommandCompletionCallback)callback
NS_DESIGNATED_INITIALIZER;
// Initializes a ShowSigninCommand with a nil callback.
- (instancetype)initWithOperation:(AuthenticationOperation)operation
signInSource:(SignInSource)signInSource;
// The callback to be invoked after the operation is complete.
@property(nonatomic, readonly) ShowSigninCommandCompletionCallback callback;
// The operation to perform during the sign-in flow.
@property(nonatomic, readonly) AuthenticationOperation operation;
// The source of this authentication operation.
@property(nonatomic, readonly) SignInSource signInSource;
@end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_SHOW_SIGNIN_COMMAND_H_
// Copyright 2014 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 "ios/chrome/browser/ui/commands/show_signin_command.h"
#include "base/logging.h"
#include "base/mac/scoped_block.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
@implementation ShowSigninCommand {
base::mac::ScopedBlock<ShowSigninCommandCompletionCallback> _callback;
}
@synthesize operation = _operation;
@synthesize signInSource = _signInSource;
- (instancetype)initWithTag:(NSInteger)tag {
NOTREACHED();
return nil;
}
- (instancetype)initWithOperation:(AuthenticationOperation)operation
signInSource:(SignInSource)signInSource
callback:
(ShowSigninCommandCompletionCallback)callback {
if ((self = [super initWithTag:IDC_SHOW_SIGNIN_IOS])) {
_operation = operation;
_signInSource = signInSource;
_callback.reset(callback, base::scoped_policy::RETAIN);
}
return self;
}
- (instancetype)initWithOperation:(AuthenticationOperation)operation
signInSource:(SignInSource)signInSource {
return
[self initWithOperation:operation signInSource:signInSource callback:nil];
}
- (ShowSigninCommandCompletionCallback)callback {
return _callback.get();
}
@end
...@@ -2,17 +2,16 @@ ...@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/chrome/browser/ui/show_privacy_settings_util.h" #import "ios/chrome/browser/ui/show_privacy_settings_util.h"
#include "base/mac/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
#include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h" #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
void ShowClearBrowsingData() { void ShowClearBrowsingData() {
base::scoped_nsobject<GenericChromeCommand> command( base::scoped_nsobject<GenericChromeCommand> command(
[[GenericChromeCommand alloc] init]); [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_PRIVACY_SETTINGS]);
[command setTag:IDC_SHOW_PRIVACY_SETTINGS];
UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; UIWindow* main_window = [[UIApplication sharedApplication] keyWindow];
[main_window chromeExecuteCommand:command]; [main_window chromeExecuteCommand:command];
} }
...@@ -230,10 +230,10 @@ ...@@ -230,10 +230,10 @@
'browser/ui/commands/open_url_command.mm', 'browser/ui/commands/open_url_command.mm',
'browser/ui/commands/set_up_for_testing_command.h', 'browser/ui/commands/set_up_for_testing_command.h',
'browser/ui/commands/set_up_for_testing_command.mm', 'browser/ui/commands/set_up_for_testing_command.mm',
'browser/ui/commands/show_accounts_settings_command.h',
'browser/ui/commands/show_accounts_settings_command.mm',
'browser/ui/commands/show_mail_composer_command.h', 'browser/ui/commands/show_mail_composer_command.h',
'browser/ui/commands/show_mail_composer_command.mm', 'browser/ui/commands/show_mail_composer_command.mm',
'browser/ui/commands/show_signin_command.h',
'browser/ui/commands/show_signin_command.mm',
'browser/ui/file_locations.h', 'browser/ui/file_locations.h',
'browser/ui/file_locations.mm', 'browser/ui/file_locations.mm',
'browser/ui/image_util.h', 'browser/ui/image_util.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment