| 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" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 // Set how long it takes a tab to be created. | 174 // Set how long it takes a tab to be created. |
| 175 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); | 175 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); |
| 176 TabContents* tabContents = browser_->AddTabWithURL( | 176 TabContents* tabContents = browser_->AddTabWithURL( |
| 177 GURL(chrome::kChromeUINewTabURL), | 177 GURL(chrome::kChromeUINewTabURL), |
| 178 GURL(), | 178 GURL(), |
| 179 PageTransition::TYPED, | 179 PageTransition::TYPED, |
| 180 -1, // To indicate tab is inserted at end. | 180 -1, // To indicate tab is inserted at end. |
| 181 TabStripModel::ADD_SELECTED, | 181 TabStripModel::ADD_SELECTED, |
| 182 NULL, | 182 NULL, |
| 183 std::string()); | 183 std::string(), |
| 184 NULL); |
| 184 tabContents->set_new_tab_start_time(newTabStartTime); | 185 tabContents->set_new_tab_start_time(newTabStartTime); |
| 185 | 186 |
| 186 [aTab setTabContent:tabContents]; | 187 [aTab setTabContent:tabContents]; |
| 187 } | 188 } |
| 188 | 189 |
| 189 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { | 190 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { |
| 190 // This method gets called when a new tab is created so | 191 // This method gets called when a new tab is created so |
| 191 // the container and property are set here. | 192 // the container and property are set here. |
| 192 [aTab setContainer:self | 193 [aTab setContainer:self |
| 193 property:AppleScript::kTabsProperty]; | 194 property:AppleScript::kTabsProperty]; |
| 194 | 195 |
| 195 // Set how long it takes a tab to be created. | 196 // Set how long it takes a tab to be created. |
| 196 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); | 197 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); |
| 197 TabContents* tabContents = browser_->AddTabWithURL( | 198 TabContents* tabContents = browser_->AddTabWithURL( |
| 198 GURL(chrome::kChromeUINewTabURL), | 199 GURL(chrome::kChromeUINewTabURL), |
| 199 GURL(), | 200 GURL(), |
| 200 PageTransition::TYPED, | 201 PageTransition::TYPED, |
| 201 index, | 202 index, |
| 202 TabStripModel::ADD_SELECTED, | 203 TabStripModel::ADD_SELECTED, |
| 203 NULL, | 204 NULL, |
| 204 std::string()); | 205 std::string(), |
| 206 NULL); |
| 205 tabContents->set_new_tab_start_time(newTabStartTime); | 207 tabContents->set_new_tab_start_time(newTabStartTime); |
| 206 | 208 |
| 207 [aTab setTabContent:tabContents]; | 209 [aTab setTabContent:tabContents]; |
| 208 } | 210 } |
| 209 | 211 |
| 210 - (void)removeFromTabsAtIndex:(int)index { | 212 - (void)removeFromTabsAtIndex:(int)index { |
| 211 browser_->tabstrip_model()->DetachTabContentsAt(index); | 213 browser_->tabstrip_model()->DetachTabContentsAt(index); |
| 212 } | 214 } |
| 213 | 215 |
| 214 - (NSNumber*)orderedIndex{ | 216 - (NSNumber*)orderedIndex{ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 245 [[self nativeHandle] setValue:(id)value forKey:key]; | 247 [[self nativeHandle] setValue:(id)value forKey:key]; |
| 246 } | 248 } |
| 247 | 249 |
| 248 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command { | 250 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command { |
| 249 // window() can be NULL during startup. | 251 // window() can be NULL during startup. |
| 250 if (browser_->window()) | 252 if (browser_->window()) |
| 251 browser_->window()->Close(); | 253 browser_->window()->Close(); |
| 252 } | 254 } |
| 253 | 255 |
| 254 @end | 256 @end |
| OLD | NEW |