OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/applescript/window_applescript.h" | 5 #import "chrome/browser/cocoa/applescript/window_applescript.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/scoped_nsobject.h" | 8 #import "base/scoped_nsobject.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #import "chrome/browser/app_controller_mac.h" | 11 #import "chrome/browser/app_controller_mac.h" |
12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
| 14 #include "chrome/browser/browser_navigator.h" |
14 #include "chrome/browser/browser_window.h" | 15 #include "chrome/browser/browser_window.h" |
15 #import "chrome/browser/chrome_browser_application_mac.h" | 16 #import "chrome/browser/chrome_browser_application_mac.h" |
16 #include "chrome/browser/cocoa/applescript/constants_applescript.h" | 17 #include "chrome/browser/cocoa/applescript/constants_applescript.h" |
17 #include "chrome/browser/cocoa/applescript/error_applescript.h" | 18 #include "chrome/browser/cocoa/applescript/error_applescript.h" |
18 #import "chrome/browser/cocoa/applescript/tab_applescript.h" | 19 #import "chrome/browser/cocoa/applescript/tab_applescript.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
21 #include "chrome/browser/tabs/tab_strip_model.h" | 22 #include "chrome/browser/tabs/tab_strip_model.h" |
22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
23 | 24 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 179 } |
179 | 180 |
180 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { | 181 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { |
181 // This method gets called when a new tab is created so | 182 // This method gets called when a new tab is created so |
182 // the container and property are set here. | 183 // the container and property are set here. |
183 [aTab setContainer:self | 184 [aTab setContainer:self |
184 property:AppleScript::kTabsProperty]; | 185 property:AppleScript::kTabsProperty]; |
185 | 186 |
186 // Set how long it takes a tab to be created. | 187 // Set how long it takes a tab to be created. |
187 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); | 188 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); |
188 Browser::AddTabWithURLParams params(GURL(chrome::kChromeUINewTabURL), | 189 browser::NavigateParams params(browser_, |
189 PageTransition::TYPED); | 190 GURL(chrome::kChromeUINewTabURL), |
190 params.index = index; | 191 PageTransition::TYPED); |
191 TabContents* contents = browser_->AddTabWithURL(¶ms); | 192 params.disposition = NEW_FOREGROUND_TAB; |
192 contents->set_new_tab_start_time(newTabStartTime); | 193 params.tabstrip_index = index; |
| 194 browser::Navigate(¶ms); |
| 195 params.target_contents->set_new_tab_start_time(newTabStartTime); |
193 | 196 |
194 [aTab setTabContent:contents]; | 197 [aTab setTabContent:params.target_contents]; |
195 } | 198 } |
196 | 199 |
197 - (void)removeFromTabsAtIndex:(int)index { | 200 - (void)removeFromTabsAtIndex:(int)index { |
198 browser_->tabstrip_model()->DetachTabContentsAt(index); | 201 browser_->tabstrip_model()->DetachTabContentsAt(index); |
199 } | 202 } |
200 | 203 |
201 - (NSNumber*)orderedIndex{ | 204 - (NSNumber*)orderedIndex{ |
202 return [NSNumber numberWithInt:[[self nativeHandle] orderedIndex]]; | 205 return [NSNumber numberWithInt:[[self nativeHandle] orderedIndex]]; |
203 } | 206 } |
204 | 207 |
(...skipping 27 matching lines...) Expand all Loading... |
232 [[self nativeHandle] setValue:(id)value forKey:key]; | 235 [[self nativeHandle] setValue:(id)value forKey:key]; |
233 } | 236 } |
234 | 237 |
235 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command { | 238 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command { |
236 // window() can be NULL during startup. | 239 // window() can be NULL during startup. |
237 if (browser_->window()) | 240 if (browser_->window()) |
238 browser_->window()->Close(); | 241 browser_->window()->Close(); |
239 } | 242 } |
240 | 243 |
241 @end | 244 @end |
OLD | NEW |