| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/mac/foundation_util.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/mac/sdk_forward_declarations.h" | 12 #include "base/mac/sdk_forward_declarations.h" |
| 12 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 14 #include "content/public/browser/native_web_keyboard_event.h" | 15 #include "content/public/browser/native_web_keyboard_event.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "content/shell/app/resource.h" | 17 #include "content/shell/app/resource.h" |
| 17 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 18 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 if ((self = [super init])) { | 33 if ((self = [super init])) { |
| 33 shell_ = shell; | 34 shell_ = shell; |
| 34 } | 35 } |
| 35 return self; | 36 return self; |
| 36 } | 37 } |
| 37 | 38 |
| 38 // Called when the window is about to close. Perform the self-destruction | 39 // Called when the window is about to close. Perform the self-destruction |
| 39 // sequence by getting rid of the shell and removing it and the window from | 40 // sequence by getting rid of the shell and removing it and the window from |
| 40 // the various global lists. By returning YES, we allow the window to be | 41 // the various global lists. By returning YES, we allow the window to be |
| 41 // removed from the screen. | 42 // removed from the screen. |
| 42 - (BOOL)windowShouldClose:(id)window { | 43 - (BOOL)windowShouldClose:(id)sender { |
| 44 NSWindow* window = base::mac::ObjCCastStrict<NSWindow>(sender); |
| 43 [window autorelease]; | 45 [window autorelease]; |
| 46 // Don't leave a dangling pointer if the window lives beyond |
| 47 // this method. See crbug.com/719830. |
| 48 [window setDelegate:nil]; |
| 44 delete shell_; | 49 delete shell_; |
| 45 [self release]; | 50 [self release]; |
| 46 | 51 |
| 47 return YES; | 52 return YES; |
| 48 } | 53 } |
| 49 | 54 |
| 50 - (void)performAction:(id)sender { | 55 - (void)performAction:(id)sender { |
| 51 shell_->ActionPerformed([sender tag]); | 56 shell_->ActionPerformed([sender tag]); |
| 52 } | 57 } |
| 53 | 58 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 [[event.os_event characters] isEqual:@"l"]) { | 324 [[event.os_event characters] isEqual:@"l"]) { |
| 320 [window_ makeFirstResponder:url_edit_view_]; | 325 [window_ makeFirstResponder:url_edit_view_]; |
| 321 return; | 326 return; |
| 322 } | 327 } |
| 323 | 328 |
| 324 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; | 329 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; |
| 325 } | 330 } |
| 326 } | 331 } |
| 327 | 332 |
| 328 } // namespace content | 333 } // namespace content |
| OLD | NEW |