| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/autocomplete_text_field_cell.h" | 5 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "gfx/font.h" | 9 #include "gfx/font.h" |
| 10 | 10 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 - (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list { | 267 - (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list { |
| 268 page_action_views_ = list; | 268 page_action_views_ = list; |
| 269 } | 269 } |
| 270 | 270 |
| 271 - (void)setLocationIconView:(LocationBarViewMac::LocationIconView*)view { | 271 - (void)setLocationIconView:(LocationBarViewMac::LocationIconView*)view { |
| 272 locationIconView_ = view; | 272 locationIconView_ = view; |
| 273 } | 273 } |
| 274 | 274 |
| 275 - (void)setStarIconView:(LocationBarViewMac::LocationBarImageView*)view { |
| 276 starIconView_ = view; |
| 277 } |
| 278 |
| 275 - (void)setSecurityLabelView:(LocationBarViewMac::LocationBarImageView*)view { | 279 - (void)setSecurityLabelView:(LocationBarViewMac::LocationBarImageView*)view { |
| 276 securityLabelView_ = view; | 280 securityLabelView_ = view; |
| 277 } | 281 } |
| 278 | 282 |
| 279 - (void)setContentSettingViewsList: | 283 - (void)setContentSettingViewsList: |
| 280 (LocationBarViewMac::ContentSettingViews*)views { | 284 (LocationBarViewMac::ContentSettingViews*)views { |
| 281 content_setting_views_ = views; | 285 content_setting_views_ = views; |
| 282 } | 286 } |
| 283 | 287 |
| 284 // Overriden to account for the hint strings and hint icons. | 288 // Overriden to account for the hint strings and hint icons. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 if (!locationIconView_ || !locationIconView_->IsVisible()) | 337 if (!locationIconView_ || !locationIconView_->IsVisible()) |
| 334 return NSZeroRect; | 338 return NSZeroRect; |
| 335 | 339 |
| 336 const NSSize imageSize = locationIconView_->GetImageSize(); | 340 const NSSize imageSize = locationIconView_->GetImageSize(); |
| 337 const CGFloat yOffset = floor((NSHeight(cellFrame) - imageSize.height) / 2); | 341 const CGFloat yOffset = floor((NSHeight(cellFrame) - imageSize.height) / 2); |
| 338 return NSMakeRect(NSMinX(cellFrame) + kLocationIconXOffset, | 342 return NSMakeRect(NSMinX(cellFrame) + kLocationIconXOffset, |
| 339 NSMinY(cellFrame) + yOffset, | 343 NSMinY(cellFrame) + yOffset, |
| 340 imageSize.width, imageSize.height); | 344 imageSize.width, imageSize.height); |
| 341 } | 345 } |
| 342 | 346 |
| 347 - (NSRect)starIconFrameForFrame:(NSRect)cellFrame { |
| 348 if (!starIconView_ || !starIconView_->IsVisible()) |
| 349 return NSZeroRect; |
| 350 |
| 351 // The star icon is always at the RHS. |
| 352 scoped_nsobject<AutocompleteTextFieldIcon> icon( |
| 353 [[AutocompleteTextFieldIcon alloc] initImageWithView:starIconView_]); |
| 354 cellFrame.size.width -= kHintXOffset; |
| 355 [icon positionInFrame:cellFrame]; |
| 356 return [icon rect]; |
| 357 } |
| 358 |
| 343 - (size_t)pageActionCount { | 359 - (size_t)pageActionCount { |
| 344 // page_action_views_ may be NULL during testing, or if the | 360 // page_action_views_ may be NULL during testing, or if the |
| 345 // containing LocationViewMac object has already been destructed | 361 // containing LocationViewMac object has already been destructed |
| 346 // (happens sometimes during window shutdown). | 362 // (happens sometimes during window shutdown). |
| 347 if (!page_action_views_) | 363 if (!page_action_views_) |
| 348 return 0; | 364 return 0; |
| 349 return page_action_views_->Count(); | 365 return page_action_views_->Count(); |
| 350 } | 366 } |
| 351 | 367 |
| 352 - (NSRect)pageActionFrameForIndex:(size_t)index inFrame:(NSRect)cellFrame { | 368 - (NSRect)pageActionFrameForIndex:(size_t)index inFrame:(NSRect)cellFrame { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 480 } |
| 465 | 481 |
| 466 // TODO(shess): Previous implementation of this method made a | 482 // TODO(shess): Previous implementation of this method made a |
| 467 // right-to-left array, so add the page-action items in that order. | 483 // right-to-left array, so add the page-action items in that order. |
| 468 // As part of the refactor mentioned above, lay everything out | 484 // As part of the refactor mentioned above, lay everything out |
| 469 // nicely left-to-right. | 485 // nicely left-to-right. |
| 470 for (size_t i = [self pageActionCount]; i-- > 0;) { | 486 for (size_t i = [self pageActionCount]; i-- > 0;) { |
| 471 views.push_back(page_action_views_->ViewAt(i)); | 487 views.push_back(page_action_views_->ViewAt(i)); |
| 472 } | 488 } |
| 473 | 489 |
| 490 // The star icon should always come last. |
| 491 if (starIconView_) |
| 492 views.push_back(starIconView_); |
| 493 |
| 474 // Load the visible views into |result|. | 494 // Load the visible views into |result|. |
| 475 for (std::vector<LocationBarViewMac::LocationBarImageView*>::const_iterator | 495 for (std::vector<LocationBarViewMac::LocationBarImageView*>::const_iterator |
| 476 iter = views.begin(); iter != views.end(); ++iter) { | 496 iter = views.begin(); iter != views.end(); ++iter) { |
| 477 if ((*iter)->IsVisible()) { | 497 if ((*iter)->IsVisible()) { |
| 478 scoped_nsobject<AutocompleteTextFieldIcon> icon( | 498 scoped_nsobject<AutocompleteTextFieldIcon> icon( |
| 479 [[AutocompleteTextFieldIcon alloc] initImageWithView:*iter]); | 499 [[AutocompleteTextFieldIcon alloc] initImageWithView:*iter]); |
| 480 [result addObject:icon]; | 500 [result addObject:icon]; |
| 481 } | 501 } |
| 482 } | 502 } |
| 483 | 503 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 icon = [self iconForEvent:theEvent inRect:cellFrame ofView:controlView]; | 557 icon = [self iconForEvent:theEvent inRect:cellFrame ofView:controlView]; |
| 538 if (icon) { | 558 if (icon) { |
| 539 [icon view]->OnMousePressed([icon rect]); | 559 [icon view]->OnMousePressed([icon rect]); |
| 540 return YES; | 560 return YES; |
| 541 } | 561 } |
| 542 | 562 |
| 543 return NO; | 563 return NO; |
| 544 } | 564 } |
| 545 | 565 |
| 546 @end | 566 @end |
| OLD | NEW |