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

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: Rebase. 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 494
495 bool handled; 495 bool handled;
496 if (decoration->AsButtonDecoration()) { 496 if (decoration->AsButtonDecoration()) {
497 ButtonDecoration* button = decoration->AsButtonDecoration(); 497 ButtonDecoration* button = decoration->AsButtonDecoration();
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:decorationRect
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];
514 focusEvent.reset();
511 515
512 // Set the proper state (hover or normal) once the mouse has been released, 516 // 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 517 // and call |OnMousePressed| if the button was released while the mouse was
514 // within the bounds of the button. 518 // 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])) { 519 if (NSMouseInRect(point, decorationRect, [controlView isFlipped])) {
518 button->SetButtonState(ButtonDecoration::kButtonStateHover); 520 button->SetButtonState(ButtonDecoration::kButtonStateHover);
519 [controlView setNeedsDisplay:YES]; 521 [controlView setNeedsDisplay:YES];
520 handled = decoration->AsButtonDecoration()->OnMousePressed( 522 handled = decoration->OnMousePressed(
521 [self frameForDecoration:decoration inFrame:cellFrame]); 523 [self frameForDecoration:decoration inFrame:cellFrame],
524 NSMakePoint(point.x - decorationRect.origin.x,
525 point.y - decorationRect.origin.y));
522 } else { 526 } else {
523 button->SetButtonState(ButtonDecoration::kButtonStateNormal); 527 button->SetButtonState(ButtonDecoration::kButtonStateNormal);
524 [controlView setNeedsDisplay:YES]; 528 [controlView setNeedsDisplay:YES];
525 handled = true; 529 handled = true;
526 } 530 }
527 } else { 531 } else {
528 handled = decoration->OnMousePressed(decorationRect); 532 const NSPoint mouseLocation = [theEvent locationInWindow];
533 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil];
534 handled = decoration->OnMousePressed(
535 decorationRect,
536 NSMakePoint(point.x - decorationRect.origin.x,
537 point.y - decorationRect.origin.y));
529 } 538 }
530 539
531 return handled ? YES : NO; 540 return handled ? YES : NO;
532 } 541 }
533 542
534 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:| 543 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:|
535 // messages. Retrieves the |ButtonDecoration| for the specified event (received 544 // messages. Retrieves the |ButtonDecoration| for the specified event (received
536 // from a tracking area), and returns |NULL| if no decoration matches. 545 // from a tracking area), and returns |NULL| if no decoration matches.
537 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent { 546 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent {
538 ButtonDecoration* bd = static_cast<ButtonDecoration*>( 547 ButtonDecoration* bd = static_cast<ButtonDecoration*>(
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 focusEvent_.reset([event retain]); 864 focusEvent_.reset([event retain]);
856 return; 865 return;
857 } 866 }
858 } 867 }
859 868
860 // Handle event immediately. 869 // Handle event immediately.
861 [self focusNotificationFor:event ofView:controlView]; 870 [self focusNotificationFor:event ofView:controlView];
862 } 871 }
863 872
864 @end 873 @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