Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
11 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 11 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
12 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 12 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
13 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" 13 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h"
14 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h" 14 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field_cell.h"
15 #import "chrome/browser/ui/cocoa/nsview_additions.h" 15 #import "chrome/browser/ui/cocoa/nsview_additions.h"
16 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 16 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
17 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 17 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents.h"
20 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_view.h" 22 #include "content/public/browser/web_contents_view.h"
23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
24 #import "ui/base/cocoa/find_pasteboard.h" 24 #import "ui/base/cocoa/find_pasteboard.h"
25 #import "ui/base/cocoa/focus_tracker.h" 25 #import "ui/base/cocoa/focus_tracker.h"
26 26
27 using content::NativeWebKeyboardEvent; 27 using content::NativeWebKeyboardEvent;
28 28
29 const float kFindBarOpenDuration = 0.2; 29 const float kFindBarOpenDuration = 0.2;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 [[NSNotificationCenter defaultCenter] 67 [[NSNotificationCenter defaultCenter]
68 addObserver:self 68 addObserver:self
69 selector:@selector(findPboardUpdated:) 69 selector:@selector(findPboardUpdated:)
70 name:kFindPasteboardChangedNotification 70 name:kFindPasteboardChangedNotification
71 object:[FindPasteboard sharedInstance]]; 71 object:[FindPasteboard sharedInstance]];
72 } 72 }
73 return self; 73 return self;
74 } 74 }
75 75
76 - (void)dealloc { 76 - (void)dealloc {
77 // All animations should be explicitly stopped by the TabContentsWrapper 77 // All animations should be explicitly stopped by the TabContents
78 // before a tab is closed. 78 // before a tab is closed.
79 DCHECK(!showHideAnimation_.get()); 79 DCHECK(!showHideAnimation_.get());
80 DCHECK(!moveAnimation_.get()); 80 DCHECK(!moveAnimation_.get());
81 [[NSNotificationCenter defaultCenter] removeObserver:self]; 81 [[NSNotificationCenter defaultCenter] removeObserver:self];
82 [super dealloc]; 82 [super dealloc];
83 } 83 }
84 84
85 - (void)setFindBarBridge:(FindBarBridge*)findBarBridge { 85 - (void)setFindBarBridge:(FindBarBridge*)findBarBridge {
86 DCHECK(!findBarBridge_); // should only be called once. 86 DCHECK(!findBarBridge_); // should only be called once.
87 findBarBridge_ = findBarBridge; 87 findBarBridge_ = findBarBridge;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } else { 161 } else {
162 [containerView setFrame:newFrame]; 162 [containerView setFrame:newFrame];
163 } 163 }
164 } 164 }
165 165
166 // NSControl delegate method. 166 // NSControl delegate method.
167 - (void)controlTextDidChange:(NSNotification *)aNotification { 167 - (void)controlTextDidChange:(NSNotification *)aNotification {
168 if (!findBarBridge_) 168 if (!findBarBridge_)
169 return; 169 return;
170 170
171 TabContentsWrapper* tab_contents = 171 TabContents* tab_contents =
172 findBarBridge_->GetFindBarController()->tab_contents(); 172 findBarBridge_->GetFindBarController()->tab_contents();
173 if (!tab_contents) 173 if (!tab_contents)
174 return; 174 return;
175 FindTabHelper* find_tab_helper = tab_contents->find_tab_helper(); 175 FindTabHelper* find_tab_helper = tab_contents->find_tab_helper();
176 176
177 NSString* findText = [findText_ stringValue]; 177 NSString* findText = [findText_ stringValue];
178 suppressPboardUpdateActions_ = YES; 178 suppressPboardUpdateActions_ = YES;
179 [[FindPasteboard sharedInstance] setFindText:findText]; 179 [[FindPasteboard sharedInstance] setFindText:findText];
180 suppressPboardUpdateActions_ = NO; 180 suppressPboardUpdateActions_ = NO;
181 181
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } else if (command == @selector(pageUp:) || 215 } else if (command == @selector(pageUp:) ||
216 command == @selector(pageUpAndModifySelection:) || 216 command == @selector(pageUpAndModifySelection:) ||
217 command == @selector(scrollPageUp:) || 217 command == @selector(scrollPageUp:) ||
218 command == @selector(pageDown:) || 218 command == @selector(pageDown:) ||
219 command == @selector(pageDownAndModifySelection:) || 219 command == @selector(pageDownAndModifySelection:) ||
220 command == @selector(scrollPageDown:) || 220 command == @selector(scrollPageDown:) ||
221 command == @selector(scrollToBeginningOfDocument:) || 221 command == @selector(scrollToBeginningOfDocument:) ||
222 command == @selector(scrollToEndOfDocument:) || 222 command == @selector(scrollToEndOfDocument:) ||
223 command == @selector(moveUp:) || 223 command == @selector(moveUp:) ||
224 command == @selector(moveDown:)) { 224 command == @selector(moveDown:)) {
225 TabContentsWrapper* contents = 225 TabContents* contents =
226 findBarBridge_->GetFindBarController()->tab_contents(); 226 findBarBridge_->GetFindBarController()->tab_contents();
227 if (!contents) 227 if (!contents)
228 return NO; 228 return NO;
229 229
230 // Sanity-check to make sure we got a keyboard event. 230 // Sanity-check to make sure we got a keyboard event.
231 NSEvent* event = [NSApp currentEvent]; 231 NSEvent* event = [NSApp currentEvent];
232 if ([event type] != NSKeyDown && [event type] != NSKeyUp) 232 if ([event type] != NSKeyDown && [event type] != NSKeyUp)
233 return NO; 233 return NO;
234 234
235 // Forward the event to the renderer. 235 // Forward the event to the renderer.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 460
461 - (float)findBarHorizontalPosition { 461 - (float)findBarHorizontalPosition {
462 // Get the rect of the FindBar. 462 // Get the rect of the FindBar.
463 NSView* view = [self view]; 463 NSView* view = [self view];
464 NSRect frame = [view frame]; 464 NSRect frame = [view frame];
465 gfx::Rect view_rect(NSRectToCGRect(frame)); 465 gfx::Rect view_rect(NSRectToCGRect(frame));
466 466
467 if (!findBarBridge_ || !findBarBridge_->GetFindBarController()) 467 if (!findBarBridge_ || !findBarBridge_->GetFindBarController())
468 return frame.origin.x; 468 return frame.origin.x;
469 TabContentsWrapper* contents = 469 TabContents* contents =
470 findBarBridge_->GetFindBarController()->tab_contents(); 470 findBarBridge_->GetFindBarController()->tab_contents();
471 if (!contents) 471 if (!contents)
472 return frame.origin.x; 472 return frame.origin.x;
473 473
474 // Get the size of the container. 474 // Get the size of the container.
475 gfx::Rect container_rect( 475 gfx::Rect container_rect(
476 contents->web_contents()->GetView()->GetContainerSize()); 476 contents->web_contents()->GetView()->GetContainerSize());
477 477
478 // Position the FindBar on the top right corner. 478 // Position the FindBar on the top right corner.
479 view_rect.set_x( 479 view_rect.set_x(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 [view setFrame:frame]; 521 [view setFrame:frame];
522 } 522 }
523 } 523 }
524 524
525 - (void)prepopulateText:(NSString*)text stopSearch:(BOOL)stopSearch{ 525 - (void)prepopulateText:(NSString*)text stopSearch:(BOOL)stopSearch{
526 [self setFindText:text]; 526 [self setFindText:text];
527 527
528 // End the find session, hide the "x of y" text and disable the 528 // End the find session, hide the "x of y" text and disable the
529 // buttons, but do not close the find bar or raise the window here. 529 // buttons, but do not close the find bar or raise the window here.
530 if (stopSearch && findBarBridge_) { 530 if (stopSearch && findBarBridge_) {
531 TabContentsWrapper* contents = 531 TabContents* contents =
532 findBarBridge_->GetFindBarController()->tab_contents(); 532 findBarBridge_->GetFindBarController()->tab_contents();
533 if (contents) { 533 if (contents) {
534 FindTabHelper* find_tab_helper = contents->find_tab_helper(); 534 FindTabHelper* find_tab_helper = contents->find_tab_helper();
535 find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage); 535 find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
536 findBarBridge_->ClearResults(find_tab_helper->find_result()); 536 findBarBridge_->ClearResults(find_tab_helper->find_result());
537 } 537 }
538 } 538 }
539 539
540 // Has to happen after |ClearResults()| above. 540 // Has to happen after |ClearResults()| above.
541 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; 541 BOOL buttonsEnabled = [text length] > 0 ? YES : NO;
542 [previousButton_ setEnabled:buttonsEnabled]; 542 [previousButton_ setEnabled:buttonsEnabled];
543 [nextButton_ setEnabled:buttonsEnabled]; 543 [nextButton_ setEnabled:buttonsEnabled];
544 } 544 }
545 545
546 @end 546 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698