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/window_applescript.h" | 5 #import "chrome/browser/ui/cocoa/applescript/window_applescript.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/memory/scoped_nsobject.h" | 8 #import "base/memory/scoped_nsobject.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/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 #import "chrome/browser/chrome_browser_application_mac.h" | 12 #import "chrome/browser/chrome_browser_application_mac.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
18 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/cocoa/applescript/constants_applescript.h" | 20 #include "chrome/browser/ui/cocoa/applescript/constants_applescript.h" |
21 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 21 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
22 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" | 22 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" |
23 #include "chrome/browser/ui/host_desktop.h" | 23 #include "chrome/browser/ui/host_desktop.h" |
| 24 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 | 28 |
28 @interface WindowAppleScript(WindowAppleScriptPrivateMethods) | 29 @interface WindowAppleScript(WindowAppleScriptPrivateMethods) |
29 // The NSWindow that corresponds to this window. | 30 // The NSWindow that corresponds to this window. |
30 - (NSWindow*)nativeHandle; | 31 - (NSWindow*)nativeHandle; |
31 @end | 32 @end |
32 | 33 |
33 @implementation WindowAppleScript | 34 @implementation WindowAppleScript |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // the container and property are set here. | 173 // the container and property are set here. |
173 [aTab setContainer:self | 174 [aTab setContainer:self |
174 property:AppleScript::kTabsProperty]; | 175 property:AppleScript::kTabsProperty]; |
175 | 176 |
176 // Set how long it takes a tab to be created. | 177 // Set how long it takes a tab to be created. |
177 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); | 178 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); |
178 content::WebContents* contents = chrome::AddSelectedTabWithURL( | 179 content::WebContents* contents = chrome::AddSelectedTabWithURL( |
179 browser_, | 180 browser_, |
180 GURL(chrome::kChromeUINewTabURL), | 181 GURL(chrome::kChromeUINewTabURL), |
181 content::PAGE_TRANSITION_TYPED); | 182 content::PAGE_TRANSITION_TYPED); |
182 contents->SetNewTabStartTime(newTabStartTime); | 183 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents); |
| 184 core_tab_helper->set_new_tab_start_time(newTabStartTime); |
183 [aTab setWebContents:contents]; | 185 [aTab setWebContents:contents]; |
184 } | 186 } |
185 | 187 |
186 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { | 188 - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { |
187 // This method gets called when a new tab is created so | 189 // This method gets called when a new tab is created so |
188 // the container and property are set here. | 190 // the container and property are set here. |
189 [aTab setContainer:self | 191 [aTab setContainer:self |
190 property:AppleScript::kTabsProperty]; | 192 property:AppleScript::kTabsProperty]; |
191 | 193 |
192 // Set how long it takes a tab to be created. | 194 // Set how long it takes a tab to be created. |
193 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); | 195 base::TimeTicks newTabStartTime = base::TimeTicks::Now(); |
194 chrome::NavigateParams params(browser_, GURL(chrome::kChromeUINewTabURL), | 196 chrome::NavigateParams params(browser_, GURL(chrome::kChromeUINewTabURL), |
195 content::PAGE_TRANSITION_TYPED); | 197 content::PAGE_TRANSITION_TYPED); |
196 params.disposition = NEW_FOREGROUND_TAB; | 198 params.disposition = NEW_FOREGROUND_TAB; |
197 params.tabstrip_index = index; | 199 params.tabstrip_index = index; |
198 chrome::Navigate(¶ms); | 200 chrome::Navigate(¶ms); |
199 params.target_contents->SetNewTabStartTime(newTabStartTime); | 201 CoreTabHelper* core_tab_helper = |
| 202 CoreTabHelper::FromWebContents(params.target_contents); |
| 203 core_tab_helper->set_new_tab_start_time(newTabStartTime); |
200 | 204 |
201 [aTab setWebContents:params.target_contents]; | 205 [aTab setWebContents:params.target_contents]; |
202 } | 206 } |
203 | 207 |
204 - (void)removeFromTabsAtIndex:(int)index { | 208 - (void)removeFromTabsAtIndex:(int)index { |
205 if (index < 0 || index >= browser_->tab_strip_model()->count()) | 209 if (index < 0 || index >= browser_->tab_strip_model()->count()) |
206 return; | 210 return; |
207 browser_->tab_strip_model()->CloseWebContentsAt( | 211 browser_->tab_strip_model()->CloseWebContentsAt( |
208 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 212 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
209 } | 213 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 GURL(), FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION); | 265 GURL(), FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION); |
262 } | 266 } |
263 } | 267 } |
264 | 268 |
265 - (void)handlesExitPresentationMode:(NSScriptCommand*)command { | 269 - (void)handlesExitPresentationMode:(NSScriptCommand*)command { |
266 if (browser_->window()) | 270 if (browser_->window()) |
267 browser_->window()->ExitFullscreen(); | 271 browser_->window()->ExitFullscreen(); |
268 } | 272 } |
269 | 273 |
270 @end | 274 @end |
OLD | NEW |