Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/ui/cocoa/applescript/tab_applescript.mm

Issue 59603009: Removed GetActiveEntry from several tabs related files in chrome/browser/ui. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = webContents_->GetController().GetVisibleEntry();
117 if (!entry) { 117 if (!entry) {
118 return nil; 118 return nil;
119 } 119 }
120 const GURL& url = entry->GetVirtualURL(); 120 const GURL& url = entry->GetVirtualURL();
121 return base::SysUTF8ToNSString(url.spec()); 121 return base::SysUTF8ToNSString(url.spec());
122 } 122 }
123 123
124 - (void)setURL:(NSString*)aURL { 124 - (void)setURL:(NSString*)aURL {
125 // If a scripter sets a URL before the node is added save it at a temporary 125 // If a scripter sets a URL before the node is added save it at a temporary
126 // location. 126 // location.
127 if (!webContents_) { 127 if (!webContents_) {
128 [self setTempURL:aURL]; 128 [self setTempURL:aURL];
129 return; 129 return;
130 } 130 }
131 131
132 GURL url(base::SysNSStringToUTF8(aURL)); 132 GURL url(base::SysNSStringToUTF8(aURL));
133 // check for valid url. 133 // check for valid url.
134 if (!url.is_empty() && !url.is_valid()) { 134 if (!url.is_empty() && !url.is_valid()) {
135 AppleScript::SetError(AppleScript::errInvalidURL); 135 AppleScript::SetError(AppleScript::errInvalidURL);
136 return; 136 return;
137 } 137 }
138 138
139 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); 139 NavigationEntry* entry =
140 webContents_->GetController().GetLastCommittedEntry();
140 if (!entry) 141 if (!entry)
141 return; 142 return;
142 143
143 const GURL& previousURL = entry->GetVirtualURL(); 144 const GURL& previousURL = entry->GetVirtualURL();
144 webContents_->OpenURL(OpenURLParams( 145 webContents_->OpenURL(OpenURLParams(
145 url, 146 url,
146 content::Referrer(previousURL, blink::WebReferrerPolicyDefault), 147 content::Referrer(previousURL, blink::WebReferrerPolicyDefault),
147 CURRENT_TAB, 148 CURRENT_TAB,
148 content::PAGE_TRANSITION_TYPED, 149 content::PAGE_TRANSITION_TYPED,
149 false)); 150 false));
150 } 151 }
151 152
152 - (NSString*)title { 153 - (NSString*)title {
153 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); 154 NavigationEntry* entry =
155 webContents_->GetController().GetVisibleEntry();
154 if (!entry) 156 if (!entry)
155 return nil; 157 return nil;
156 158
157 base::string16 title = entry ? entry->GetTitle() : base::string16(); 159 base::string16 title = entry ? entry->GetTitle() : base::string16();
158 return base::SysUTF16ToNSString(title); 160 return base::SysUTF16ToNSString(title);
159 } 161 }
160 162
161 - (NSNumber*)loading { 163 - (NSNumber*)loading {
162 BOOL loadingValue = webContents_->IsLoading() ? YES : NO; 164 BOOL loadingValue = webContents_->IsLoading() ? YES : NO;
163 return [NSNumber numberWithBool:loadingValue]; 165 return [NSNumber numberWithBool:loadingValue];
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 [[command evaluatedArguments] objectForKey:@"javascript"]); 333 [[command evaluatedArguments] objectForKey:@"javascript"]);
332 view->ExecuteJavascriptInWebFrameCallbackResult( 334 view->ExecuteJavascriptInWebFrameCallbackResult(
333 base::string16(), // frame_xpath 335 base::string16(), // frame_xpath
334 script, 336 script,
335 callback); 337 callback);
336 338
337 return nil; 339 return nil;
338 } 340 }
339 341
340 @end 342 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698