Chromium Code Reviews| 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/toolbar/back_forward_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "chrome/browser/ui/cocoa/menu_button.h" | 10 #import "chrome/browser/ui/cocoa/menu_button.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 backForwardMenu_.reset([[NSMenu alloc] initWithTitle:@""]); | 33 backForwardMenu_.reset([[NSMenu alloc] initWithTitle:@""]); |
| 34 DCHECK(backForwardMenu_.get()); | 34 DCHECK(backForwardMenu_.get()); |
| 35 [backForwardMenu_ setDelegate:self]; | 35 [backForwardMenu_ setDelegate:self]; |
| 36 | 36 |
| 37 [button_ setAttachedMenu:backForwardMenu_]; | 37 [button_ setAttachedMenu:backForwardMenu_]; |
| 38 [button_ setOpenMenuOnClick:NO]; | 38 [button_ setOpenMenuOnClick:NO]; |
| 39 } | 39 } |
| 40 return self; | 40 return self; |
| 41 } | 41 } |
| 42 | 42 |
| 43 - (void)browserWillBeDestroyed { | |
| 44 backForwardMenu_.reset(); | |
|
tapted
2015/07/06 07:26:18
This is a scoped_nsobject -- reset() may do nothin
jackhou1
2015/07/07 03:27:27
Cleared more things, and reset model_.
| |
| 45 } | |
| 46 | |
| 43 // Methods as delegate: | 47 // Methods as delegate: |
| 44 | 48 |
| 45 // Called by backForwardMenu_ just before tracking begins. | 49 // Called by backForwardMenu_ just before tracking begins. |
| 46 //TODO(viettrungluu): should we do anything for chapter stops (see model)? | 50 //TODO(viettrungluu): should we do anything for chapter stops (see model)? |
| 47 - (void)menuNeedsUpdate:(NSMenu*)menu { | 51 - (void)menuNeedsUpdate:(NSMenu*)menu { |
| 48 DCHECK(menu == backForwardMenu_); | 52 DCHECK(menu == backForwardMenu_); |
| 49 | 53 |
| 50 // Remove old menu items (backwards order is as good as any). | 54 // Remove old menu items (backwards order is as good as any). |
| 51 for (NSInteger i = [menu numberOfItems]; i > 0; i--) | 55 for (NSInteger i = [menu numberOfItems]; i > 0; i--) |
| 52 [menu removeItemAtIndex:(i - 1)]; | 56 [menu removeItemAtIndex:(i - 1)]; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // Action methods: | 94 // Action methods: |
| 91 | 95 |
| 92 - (void)executeMenuItem:(id)sender { | 96 - (void)executeMenuItem:(id)sender { |
| 93 DCHECK([sender isKindOfClass:[NSMenuItem class]]); | 97 DCHECK([sender isKindOfClass:[NSMenuItem class]]); |
| 94 int menuID = [sender tag]; | 98 int menuID = [sender tag]; |
| 95 int event_flags = ui::EventFlagsFromNative([NSApp currentEvent]); | 99 int event_flags = ui::EventFlagsFromNative([NSApp currentEvent]); |
| 96 model_->ActivatedAt(menuID, event_flags); | 100 model_->ActivatedAt(menuID, event_flags); |
| 97 } | 101 } |
| 98 | 102 |
| 99 @end // @implementation BackForwardMenuController | 103 @end // @implementation BackForwardMenuController |
| OLD | NEW |