OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/cocoa/applescript/tab_applescript.h" | 5 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 106 |
107 if ([self tempURL]) | 107 if ([self tempURL]) |
108 [self setURL:[self tempURL]]; | 108 [self setURL:[self tempURL]]; |
109 } | 109 } |
110 | 110 |
111 - (NSString*)URL { | 111 - (NSString*)URL { |
112 if (!webContents_) { | 112 if (!webContents_) { |
113 return nil; | 113 return nil; |
114 } | 114 } |
115 | 115 |
116 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); | 116 NavigationEntry* entry = |
117 webContents_->GetController().GetLastCommittedEntry(); | |
Charlie Reis
2013/11/12 01:09:29
@pinkerton:
My Cocoa skills are a bit rusty (or no
pink (ping after 24hrs)
2013/11/12 15:27:32
Sounds right, though my memory of NavigationContro
jww
2013/11/12 22:32:50
Done.
| |
117 if (!entry) { | 118 if (!entry) { |
118 return nil; | 119 return nil; |
119 } | 120 } |
120 const GURL& url = entry->GetVirtualURL(); | 121 const GURL& url = entry->GetVirtualURL(); |
121 return base::SysUTF8ToNSString(url.spec()); | 122 return base::SysUTF8ToNSString(url.spec()); |
122 } | 123 } |
123 | 124 |
124 - (void)setURL:(NSString*)aURL { | 125 - (void)setURL:(NSString*)aURL { |
125 // If a scripter sets a URL before the node is added save it at a temporary | 126 // If a scripter sets a URL before the node is added save it at a temporary |
126 // location. | 127 // location. |
127 if (!webContents_) { | 128 if (!webContents_) { |
128 [self setTempURL:aURL]; | 129 [self setTempURL:aURL]; |
129 return; | 130 return; |
130 } | 131 } |
131 | 132 |
132 GURL url(base::SysNSStringToUTF8(aURL)); | 133 GURL url(base::SysNSStringToUTF8(aURL)); |
133 // check for valid url. | 134 // check for valid url. |
134 if (!url.is_empty() && !url.is_valid()) { | 135 if (!url.is_empty() && !url.is_valid()) { |
135 AppleScript::SetError(AppleScript::errInvalidURL); | 136 AppleScript::SetError(AppleScript::errInvalidURL); |
136 return; | 137 return; |
137 } | 138 } |
138 | 139 |
139 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); | 140 NavigationEntry* entry = |
141 webContents_->GetController().GetLastCommittedEntry(); | |
Charlie Reis
2013/11/12 01:09:29
This looks correct, since we're trying to get the
pink (ping after 24hrs)
2013/11/12 15:27:32
agreed.
jww
2013/11/12 22:32:50
Done.
| |
140 if (!entry) | 142 if (!entry) |
141 return; | 143 return; |
142 | 144 |
143 const GURL& previousURL = entry->GetVirtualURL(); | 145 const GURL& previousURL = entry->GetVirtualURL(); |
144 webContents_->OpenURL(OpenURLParams( | 146 webContents_->OpenURL(OpenURLParams( |
145 url, | 147 url, |
146 content::Referrer(previousURL, blink::WebReferrerPolicyDefault), | 148 content::Referrer(previousURL, blink::WebReferrerPolicyDefault), |
147 CURRENT_TAB, | 149 CURRENT_TAB, |
148 content::PAGE_TRANSITION_TYPED, | 150 content::PAGE_TRANSITION_TYPED, |
149 false)); | 151 false)); |
150 } | 152 } |
151 | 153 |
152 - (NSString*)title { | 154 - (NSString*)title { |
153 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); | 155 NavigationEntry* entry = |
156 webContents_->GetController().GetLastCommittedEntry(); | |
Charlie Reis
2013/11/12 01:09:29
This should almost certainly be GetVisibleEntry, s
pink (ping after 24hrs)
2013/11/12 15:27:32
Sounds right, same caveat as above.
jww
2013/11/12 22:32:50
Done.
| |
154 if (!entry) | 157 if (!entry) |
155 return nil; | 158 return nil; |
156 | 159 |
157 string16 title = entry ? entry->GetTitle() : string16(); | 160 string16 title = entry ? entry->GetTitle() : string16(); |
158 return base::SysUTF16ToNSString(title); | 161 return base::SysUTF16ToNSString(title); |
159 } | 162 } |
160 | 163 |
161 - (NSNumber*)loading { | 164 - (NSNumber*)loading { |
162 BOOL loadingValue = webContents_->IsLoading() ? YES : NO; | 165 BOOL loadingValue = webContents_->IsLoading() ? YES : NO; |
163 return [NSNumber numberWithBool:loadingValue]; | 166 return [NSNumber numberWithBool:loadingValue]; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 string16 script = base::SysNSStringToUTF16( | 333 string16 script = base::SysNSStringToUTF16( |
331 [[command evaluatedArguments] objectForKey:@"javascript"]); | 334 [[command evaluatedArguments] objectForKey:@"javascript"]); |
332 view->ExecuteJavascriptInWebFrameCallbackResult(string16(), // frame_xpath | 335 view->ExecuteJavascriptInWebFrameCallbackResult(string16(), // frame_xpath |
333 script, | 336 script, |
334 callback); | 337 callback); |
335 | 338 |
336 return nil; | 339 return nil; |
337 } | 340 } |
338 | 341 |
339 @end | 342 @end |
OLD | NEW |