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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm

Issue 233623002: Shows the info bubble when the location bar icon is clicked in the origin chip. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixes tests. Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/mac_logging.h" 9 #include "base/mac/mac_logging.h"
10 #include "chrome/browser/search/search.h" 10 #include "chrome/browser/search/search.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 498
499 button->SetButtonState(ButtonDecoration::kButtonStatePressed); 499 button->SetButtonState(ButtonDecoration::kButtonStatePressed);
500 [controlView setNeedsDisplay:YES]; 500 [controlView setNeedsDisplay:YES];
501 501
502 // Track the mouse until the user releases the button. 502 // Track the mouse until the user releases the button.
503 [self trackMouse:theEvent 503 [self trackMouse:theEvent
504 inRect:cellFrame 504 inRect:cellFrame
505 ofView:controlView 505 ofView:controlView
506 untilMouseUp:YES]; 506 untilMouseUp:YES];
507 507
508 const NSPoint mouseLocation = [[NSApp currentEvent] locationInWindow];
509 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil];
510
508 // Post delayed focus notification, if necessary. 511 // Post delayed focus notification, if necessary.
509 if (focusEvent.get()) 512 if (focusEvent.get() && !button->PreventFocus(point))
510 [self focusNotificationFor:focusEvent ofView:controlView]; 513 [self focusNotificationFor:focusEvent ofView:controlView];
511 514
512 // Set the proper state (hover or normal) once the mouse has been released, 515 // Set the proper state (hover or normal) once the mouse has been released,
513 // and call |OnMousePressed| if the button was released while the mouse was 516 // and call |OnMousePressed| if the button was released while the mouse was
514 // within the bounds of the button. 517 // within the bounds of the button.
515 const NSPoint mouseLocation = [[NSApp currentEvent] locationInWindow];
516 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil];
517 if (NSMouseInRect(point, decorationRect, [controlView isFlipped])) { 518 if (NSMouseInRect(point, decorationRect, [controlView isFlipped])) {
518 button->SetButtonState(ButtonDecoration::kButtonStateHover); 519 button->SetButtonState(ButtonDecoration::kButtonStateHover);
519 [controlView setNeedsDisplay:YES]; 520 [controlView setNeedsDisplay:YES];
520 handled = decoration->AsButtonDecoration()->OnMousePressed( 521 handled = decoration->AsButtonDecoration()->OnMousePressed(
groby-ooo-7-16 2014/05/02 01:31:11 You can remove "AsButtonDecoration" - all decorati
macourteau 2014/05/02 14:35:09 Done.
521 [self frameForDecoration:decoration inFrame:cellFrame]); 522 [self frameForDecoration:decoration inFrame:cellFrame],
groby-ooo-7-16 2014/05/02 01:31:11 Shouldn't this be decorationRect?
macourteau 2014/05/02 14:35:09 Done (and changed above for trackMouse as well, ev
523 NSMakePoint(point.x - decorationRect.origin.x,
524 point.y - decorationRect.origin.y));
522 } else { 525 } else {
523 button->SetButtonState(ButtonDecoration::kButtonStateNormal); 526 button->SetButtonState(ButtonDecoration::kButtonStateNormal);
524 [controlView setNeedsDisplay:YES]; 527 [controlView setNeedsDisplay:YES];
525 handled = true; 528 handled = true;
526 } 529 }
527 } else { 530 } else {
528 handled = decoration->OnMousePressed(decorationRect); 531 const NSPoint mouseLocation = [theEvent locationInWindow];
532 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil];
533 handled = decoration->OnMousePressed(
534 decorationRect,
535 NSMakePoint(point.x - decorationRect.origin.x,
536 point.y - decorationRect.origin.y));
529 } 537 }
530 538
531 return handled ? YES : NO; 539 return handled ? YES : NO;
532 } 540 }
533 541
534 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:| 542 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:|
535 // messages. Retrieves the |ButtonDecoration| for the specified event (received 543 // messages. Retrieves the |ButtonDecoration| for the specified event (received
536 // from a tracking area), and returns |NULL| if no decoration matches. 544 // from a tracking area), and returns |NULL| if no decoration matches.
537 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent { 545 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent {
538 ButtonDecoration* bd = static_cast<ButtonDecoration*>( 546 ButtonDecoration* bd = static_cast<ButtonDecoration*>(
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 focusEvent_.reset([event retain]); 863 focusEvent_.reset([event retain]);
856 return; 864 return;
857 } 865 }
858 } 866 }
859 867
860 // Handle event immediately. 868 // Handle event immediately.
861 [self focusNotificationFor:event ofView:controlView]; 869 [self focusNotificationFor:event ofView:controlView];
862 } 870 }
863 871
864 @end 872 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698