| 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/mac/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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (!aProfile) { | 68 if (!aProfile) { |
| 69 [self release]; | 69 [self release]; |
| 70 return nil; | 70 return nil; |
| 71 } | 71 } |
| 72 | 72 |
| 73 if ((self = [super init])) { | 73 if ((self = [super init])) { |
| 74 browser_ = new Browser( | 74 browser_ = new Browser( |
| 75 Browser::CreateParams(aProfile, chrome::HOST_DESKTOP_TYPE_NATIVE)); | 75 Browser::CreateParams(aProfile, chrome::HOST_DESKTOP_TYPE_NATIVE)); |
| 76 chrome::NewTab(browser_); | 76 chrome::NewTab(browser_); |
| 77 browser_->window()->Show(); | 77 browser_->window()->Show(); |
| 78 scoped_nsobject<NSNumber> numID( | 78 base::scoped_nsobject<NSNumber> numID( |
| 79 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); | 79 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); |
| 80 [self setUniqueID:numID]; | 80 [self setUniqueID:numID]; |
| 81 } | 81 } |
| 82 return self; | 82 return self; |
| 83 } | 83 } |
| 84 | 84 |
| 85 - (id)initWithBrowser:(Browser*)aBrowser { | 85 - (id)initWithBrowser:(Browser*)aBrowser { |
| 86 if (!aBrowser) { | 86 if (!aBrowser) { |
| 87 [self release]; | 87 [self release]; |
| 88 return nil; | 88 return nil; |
| 89 } | 89 } |
| 90 | 90 |
| 91 if ((self = [super init])) { | 91 if ((self = [super init])) { |
| 92 // It is safe to be weak, if a window goes away (eg user closing a window) | 92 // It is safe to be weak, if a window goes away (eg user closing a window) |
| 93 // the applescript runtime calls appleScriptWindows in | 93 // the applescript runtime calls appleScriptWindows in |
| 94 // BrowserCrApplication and this particular window is never returned. | 94 // BrowserCrApplication and this particular window is never returned. |
| 95 browser_ = aBrowser; | 95 browser_ = aBrowser; |
| 96 scoped_nsobject<NSNumber> numID( | 96 base::scoped_nsobject<NSNumber> numID( |
| 97 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); | 97 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); |
| 98 [self setUniqueID:numID]; | 98 [self setUniqueID:numID]; |
| 99 } | 99 } |
| 100 return self; | 100 return self; |
| 101 } | 101 } |
| 102 | 102 |
| 103 - (NSWindow*)nativeHandle { | 103 - (NSWindow*)nativeHandle { |
| 104 // window() can be NULL during startup. | 104 // window() can be NULL during startup. |
| 105 if (browser_->window()) | 105 if (browser_->window()) |
| 106 return browser_->window()->GetNativeWindow(); | 106 return browser_->window()->GetNativeWindow(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 TabStripModel* tabStrip = browser_->tab_strip_model(); | 152 TabStripModel* tabStrip = browser_->tab_strip_model(); |
| 153 NSMutableArray* tabs = [NSMutableArray arrayWithCapacity:tabStrip->count()]; | 153 NSMutableArray* tabs = [NSMutableArray arrayWithCapacity:tabStrip->count()]; |
| 154 | 154 |
| 155 for (int i = 0; i < tabStrip->count(); ++i) { | 155 for (int i = 0; i < tabStrip->count(); ++i) { |
| 156 // Check to see if tab is closing. | 156 // Check to see if tab is closing. |
| 157 content::WebContents* webContents = tabStrip->GetWebContentsAt(i); | 157 content::WebContents* webContents = tabStrip->GetWebContentsAt(i); |
| 158 if (webContents->IsBeingDestroyed()) { | 158 if (webContents->IsBeingDestroyed()) { |
| 159 continue; | 159 continue; |
| 160 } | 160 } |
| 161 | 161 |
| 162 scoped_nsobject<TabAppleScript> tab( | 162 base::scoped_nsobject<TabAppleScript> tab( |
| 163 [[TabAppleScript alloc] initWithWebContents:webContents]); | 163 [[TabAppleScript alloc] initWithWebContents:webContents]); |
| 164 [tab setContainer:self | 164 [tab setContainer:self |
| 165 property:AppleScript::kTabsProperty]; | 165 property:AppleScript::kTabsProperty]; |
| 166 [tabs addObject:tab]; | 166 [tabs addObject:tab]; |
| 167 } | 167 } |
| 168 return tabs; | 168 return tabs; |
| 169 } | 169 } |
| 170 | 170 |
| 171 - (void)insertInTabs:(TabAppleScript*)aTab { | 171 - (void)insertInTabs:(TabAppleScript*)aTab { |
| 172 // This method gets called when a new tab is created so | 172 // This method gets called when a new tab is created so |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 GURL(), FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION); | 265 GURL(), FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 - (void)handlesExitPresentationMode:(NSScriptCommand*)command { | 269 - (void)handlesExitPresentationMode:(NSScriptCommand*)command { |
| 270 if (browser_->window()) | 270 if (browser_->window()) |
| 271 browser_->window()->ExitFullscreen(); | 271 browser_->window()->ExitFullscreen(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 @end | 274 @end |
| OLD | NEW |