OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 5 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
6 | 6 |
| 7 #include "base/logging.h" |
7 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
8 #include "ios/web/public/referrer.h" | 10 #include "ios/web/public/referrer.h" |
9 #include "url/gurl.h" | 11 #include "url/gurl.h" |
10 | 12 |
11 @implementation OpenUrlCommand { | 13 @implementation OpenUrlCommand { |
12 GURL _url; | 14 GURL _url; |
13 web::Referrer _referrer; | 15 web::Referrer _referrer; |
14 base::scoped_nsobject<NSString> _windowName; | 16 base::scoped_nsobject<NSString> _windowName; |
15 BOOL _inIncognito; | |
16 BOOL _inBackground; | |
17 BOOL _fromChrome; | |
18 OpenPosition _appendTo; | |
19 } | 17 } |
20 | 18 |
| 19 @synthesize inIncognito = _inIncognito; |
| 20 @synthesize inBackground = _inBackground; |
21 @synthesize fromChrome = _fromChrome; | 21 @synthesize fromChrome = _fromChrome; |
| 22 @synthesize appendTo = _appendTo; |
22 | 23 |
23 - (id)initWithURL:(const GURL&)url | 24 - (instancetype)initWithTag:(NSInteger)tag { |
24 referrer:(const web::Referrer&)referrer | 25 NOTREACHED(); |
25 windowName:(NSString*)windowName | 26 return nil; |
26 inIncognito:(BOOL)inIncognito | 27 } |
27 inBackground:(BOOL)inBackground | 28 |
28 appendTo:(OpenPosition)appendTo { | 29 - (instancetype)initWithURL:(const GURL&)url |
29 if ((self = [super init])) { | 30 referrer:(const web::Referrer&)referrer |
| 31 windowName:(NSString*)windowName |
| 32 inIncognito:(BOOL)inIncognito |
| 33 inBackground:(BOOL)inBackground |
| 34 appendTo:(OpenPosition)appendTo { |
| 35 if ((self = [super initWithTag:IDC_OPEN_URL])) { |
30 _url = url; | 36 _url = url; |
31 _referrer = referrer; | 37 _referrer = referrer; |
32 _windowName.reset([windowName retain]); | 38 _windowName.reset([windowName copy]); |
33 _inIncognito = inIncognito; | 39 _inIncognito = inIncognito; |
34 _inBackground = inBackground; | 40 _inBackground = inBackground; |
35 _appendTo = appendTo; | 41 _appendTo = appendTo; |
36 } | 42 } |
37 return self; | 43 return self; |
38 } | 44 } |
39 | 45 |
40 - (id)initWithURLFromChrome:(const GURL&)url { | 46 - (instancetype)initWithURLFromChrome:(const GURL&)url { |
41 if ((self = [self initWithURL:url | 47 if ((self = [self initWithURL:url |
42 referrer:web::Referrer() | 48 referrer:web::Referrer() |
43 windowName:nil | 49 windowName:nil |
44 inIncognito:NO | 50 inIncognito:NO |
45 inBackground:NO | 51 inBackground:NO |
46 appendTo:kLastTab])) { | 52 appendTo:kLastTab])) { |
47 _fromChrome = YES; | 53 _fromChrome = YES; |
48 } | 54 } |
49 return self; | 55 return self; |
50 } | 56 } |
51 | 57 |
52 - (const GURL&)url { | 58 - (const GURL&)url { |
53 return _url; | 59 return _url; |
54 } | 60 } |
55 | 61 |
56 - (const web::Referrer&)referrer { | 62 - (const web::Referrer&)referrer { |
57 return _referrer; | 63 return _referrer; |
58 } | 64 } |
59 | 65 |
60 - (NSString*)windowName { | 66 - (NSString*)windowName { |
61 return _windowName.get(); | 67 return _windowName.get(); |
62 } | 68 } |
63 | 69 |
64 - (BOOL)inIncognito { | |
65 return _inIncognito; | |
66 } | |
67 | |
68 - (BOOL)inBackground { | |
69 return _inBackground; | |
70 } | |
71 | |
72 - (OpenPosition)appendTo { | |
73 return _appendTo; | |
74 } | |
75 | |
76 @end | 70 @end |
OLD | NEW |