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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 13 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 14 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 14 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" | 15 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" |
| 16 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" | 16 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" |
| 17 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 17 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 18 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 18 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 19 #import "chrome/browser/ui/cocoa/view_id_util.h" | |
| 19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 20 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 20 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 21 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/render_widget_host.h" | 24 #include "content/public/browser/render_widget_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "grit/components_strings.h" | 26 #include "grit/components_strings.h" |
| 26 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 27 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " | 28 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " |
| 28 #import "ui/base/cocoa/find_pasteboard.h" | 29 #import "ui/base/cocoa/find_pasteboard.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 } | 91 } |
| 91 return self; | 92 return self; |
| 92 } | 93 } |
| 93 | 94 |
| 94 - (void)dealloc { | 95 - (void)dealloc { |
| 95 [self browserWillBeDestroyed]; | 96 [self browserWillBeDestroyed]; |
| 96 [super dealloc]; | 97 [super dealloc]; |
| 97 } | 98 } |
| 98 | 99 |
| 99 - (void)browserWillBeDestroyed { | 100 - (void)browserWillBeDestroyed { |
| 101 view_id_util::UnsetID(previousButton_); | |
| 102 view_id_util::UnsetID(nextButton_); | |
| 103 view_id_util::UnsetID(closeButton_); | |
|
tapted
2016/02/10 00:56:01
I don't think this will fix the problem.
I think
Mario Pistrich
2016/02/10 01:14:29
Thanks for clarifying, I've added them to the if s
| |
| 104 | |
| 100 // All animations should have been explicitly stopped before a tab is closed. | 105 // All animations should have been explicitly stopped before a tab is closed. |
| 101 DCHECK(!showHideAnimation_.get()); | 106 DCHECK(!showHideAnimation_.get()); |
| 102 DCHECK(!moveAnimation_.get()); | 107 DCHECK(!moveAnimation_.get()); |
| 103 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 108 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 104 browser_ = nullptr; | 109 browser_ = nullptr; |
| 105 } | 110 } |
| 106 | 111 |
| 107 - (void)setFindBarBridge:(FindBarBridge*)findBarBridge { | 112 - (void)setFindBarBridge:(FindBarBridge*)findBarBridge { |
| 108 DCHECK(!findBarBridge_); // should only be called once. | 113 DCHECK(!findBarBridge_); // should only be called once. |
| 109 findBarBridge_ = findBarBridge; | 114 findBarBridge_ = findBarBridge; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 128 | 133 |
| 129 [closeButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_CLOSE)]; | 134 [closeButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_CLOSE)]; |
| 130 [previousButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_PREVIOUS)]; | 135 [previousButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_PREVIOUS)]; |
| 131 [nextButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_NEXT)]; | 136 [nextButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_NEXT)]; |
| 132 | 137 |
| 133 [findBarView_ setFrame:[self hiddenFindBarFrame]]; | 138 [findBarView_ setFrame:[self hiddenFindBarFrame]]; |
| 134 defaultWidth_ = NSWidth([findBarView_ frame]); | 139 defaultWidth_ = NSWidth([findBarView_ frame]); |
| 135 [[self view] setHidden:YES]; | 140 [[self view] setHidden:YES]; |
| 136 | 141 |
| 137 [self prepopulateText:[[FindPasteboard sharedInstance] findText]]; | 142 [self prepopulateText:[[FindPasteboard sharedInstance] findText]]; |
| 143 | |
| 144 // Set ViewIDs for the buttons which don't have their dedicated class. | |
| 145 // ViewID of |findText_| is handled by itself. | |
| 146 view_id_util::SetID(previousButton_, VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); | |
| 147 view_id_util::SetID(nextButton_, VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); | |
| 148 view_id_util::SetID(closeButton_, VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON); | |
| 138 } | 149 } |
| 139 | 150 |
| 140 - (IBAction)close:(id)sender { | 151 - (IBAction)close:(id)sender { |
| 141 if (findBarBridge_) { | 152 if (findBarBridge_) { |
| 142 findBarBridge_->GetFindBarController()->EndFindSession( | 153 findBarBridge_->GetFindBarController()->EndFindSession( |
| 143 FindBarController::kKeepSelectionOnPage, | 154 FindBarController::kKeepSelectionOnPage, |
| 144 FindBarController::kKeepResultsInFindBox); | 155 FindBarController::kKeepResultsInFindBox); |
| 145 } | 156 } |
| 146 } | 157 } |
| 147 | 158 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 } | 649 } |
| 639 | 650 |
| 640 - (BrowserWindowController*)browserWindowController { | 651 - (BrowserWindowController*)browserWindowController { |
| 641 if (!browser_) | 652 if (!browser_) |
| 642 return nil; | 653 return nil; |
| 643 return [BrowserWindowController | 654 return [BrowserWindowController |
| 644 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; | 655 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
| 645 } | 656 } |
| 646 | 657 |
| 647 @end | 658 @end |
| OLD | NEW |