Index: chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm |
diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm |
index 70013f041d886eb5aa94239a9046d75455f96ab7..cea789c1c0927a83f526498127ea361412a38932 100644 |
--- a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm |
+++ b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm |
@@ -41,6 +41,7 @@ const float kFindBarCloseDuration = 0.15; |
const float kFindBarMoveDuration = 0.15; |
const float kRightEdgeOffset = 25; |
const int kMaxCharacters = 4000; |
+const int kUndefinedResultCount = -1; |
@interface FindBarCocoaController (PrivateMethods) <NSAnimationDelegate> |
// Returns the appropriate frame for a hidden find bar. |
@@ -75,6 +76,10 @@ const int kMaxCharacters = 4000; |
- (void)clearFindResultsForCurrentBrowser; |
- (BrowserWindowController*)browserWindowController; |
+ |
+// Returns the number of matches from the last find results of the active |
+// web contents. Returns kUndefinedResultCount if unable to determine the count. |
+- (int)lastNumberOfMatchesForActiveWebContents; |
@end |
@implementation FindBarCocoaController |
@@ -362,9 +367,8 @@ const int kMaxCharacters = 4000; |
- (void)setFocusAndSelection { |
[[findText_ window] makeFirstResponder:findText_]; |
+ BOOL buttonsEnabled = ([self lastNumberOfMatchesForActiveWebContents] != 0); |
- // Enable the buttons if the find text is non-empty. |
- BOOL buttonsEnabled = ([[findText_ stringValue] length] > 0) ? YES : NO; |
[previousButton_ setEnabled:buttonsEnabled]; |
[nextButton_ setEnabled:buttonsEnabled]; |
} |
@@ -668,4 +672,13 @@ const int kMaxCharacters = 4000; |
browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
} |
+- (int)lastNumberOfMatchesForActiveWebContents { |
+ if (!browser_) |
+ return kUndefinedResultCount; |
+ |
+ content::WebContents* contents = |
+ findBarBridge_->GetFindBarController()->web_contents(); |
+ FindTabHelper* findTabHelper = FindTabHelper::FromWebContents(contents); |
+ return findTabHelper->find_result().number_of_matches(); |
rohitrao (ping after 24h)
2017/07/26 14:55:31
For my own reference, number_of_matches() appears
|
+} |
@end |