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

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

Issue 22882007: Remove GetActiveEntry usage from chrome/browser/ui. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on ToT. Created 7 years, 2 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 | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/search/instant_controller.cc » ('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 = webContents_->GetController().GetVisibleEntry();
140 if (!entry) 140 if (!entry)
141 return; 141 return;
142 142
143 const GURL& previousURL = entry->GetVirtualURL(); 143 const GURL& previousURL = entry->GetVirtualURL();
144 webContents_->OpenURL(OpenURLParams( 144 webContents_->OpenURL(OpenURLParams(
145 url, 145 url,
146 content::Referrer(previousURL, WebKit::WebReferrerPolicyDefault), 146 content::Referrer(previousURL, WebKit::WebReferrerPolicyDefault),
147 CURRENT_TAB, 147 CURRENT_TAB,
148 content::PAGE_TRANSITION_TYPED, 148 content::PAGE_TRANSITION_TYPED,
149 false)); 149 false));
150 } 150 }
151 151
152 - (NSString*)title { 152 - (NSString*)title {
153 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); 153 NavigationEntry* entry = webContents_->GetController().GetVisibleEntry();
154 if (!entry) 154 if (!entry)
155 return nil; 155 return nil;
156 156
157 string16 title = entry ? entry->GetTitle() : string16(); 157 string16 title = entry ? entry->GetTitle() : string16();
158 return base::SysUTF16ToNSString(title); 158 return base::SysUTF16ToNSString(title);
159 } 159 }
160 160
161 - (NSNumber*)loading { 161 - (NSNumber*)loading {
162 BOOL loadingValue = webContents_->IsLoading() ? YES : NO; 162 BOOL loadingValue = webContents_->IsLoading() ? YES : NO;
163 return [NSNumber numberWithBool:loadingValue]; 163 return [NSNumber numberWithBool:loadingValue];
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 string16 script = base::SysNSStringToUTF16( 330 string16 script = base::SysNSStringToUTF16(
331 [[command evaluatedArguments] objectForKey:@"javascript"]); 331 [[command evaluatedArguments] objectForKey:@"javascript"]);
332 view->ExecuteJavascriptInWebFrameCallbackResult(string16(), // frame_xpath 332 view->ExecuteJavascriptInWebFrameCallbackResult(string16(), // frame_xpath
333 script, 333 script,
334 callback); 334 callback);
335 335
336 return nil; 336 return nil;
337 } 337 }
338 338
339 @end 339 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698