OLD | NEW |
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/location_bar_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 PageActionDecoration* decoration = GetPageActionDecoration(page_action); | 392 PageActionDecoration* decoration = GetPageActionDecoration(page_action); |
393 DCHECK(decoration); | 393 DCHECK(decoration); |
394 if (!decoration) | 394 if (!decoration) |
395 return; | 395 return; |
396 | 396 |
397 decoration->set_preview_enabled(preview_enabled); | 397 decoration->set_preview_enabled(preview_enabled); |
398 decoration->UpdateVisibility(contents, GURL(toolbar_model_->GetText())); | 398 decoration->UpdateVisibility(contents, GURL(toolbar_model_->GetText())); |
399 } | 399 } |
400 | 400 |
| 401 NSRect LocationBarViewMac::GetPageActionFrame(ExtensionAction* page_action) { |
| 402 PageActionDecoration* decoration = GetPageActionDecoration(page_action); |
| 403 if (!decoration) |
| 404 return NSZeroRect; |
| 405 |
| 406 AutocompleteTextFieldCell* cell = [field_ cell]; |
| 407 NSRect frame = [cell frameForDecoration:decoration inFrame:[field_ bounds]]; |
| 408 DCHECK(!NSIsEmptyRect(frame)); |
| 409 return frame; |
| 410 } |
| 411 |
401 NSPoint LocationBarViewMac::GetPageActionBubblePoint( | 412 NSPoint LocationBarViewMac::GetPageActionBubblePoint( |
402 ExtensionAction* page_action) { | 413 ExtensionAction* page_action) { |
403 PageActionDecoration* decoration = GetPageActionDecoration(page_action); | 414 PageActionDecoration* decoration = GetPageActionDecoration(page_action); |
404 if (!decoration) | 415 if (!decoration) |
405 return NSZeroPoint; | 416 return NSZeroPoint; |
406 | 417 |
407 AutocompleteTextFieldCell* cell = [field_ cell]; | 418 NSRect frame = GetPageActionFrame(page_action); |
408 NSRect frame = [cell frameForDecoration:decoration inFrame:[field_ bounds]]; | |
409 DCHECK(!NSIsEmptyRect(frame)); | |
410 if (NSIsEmptyRect(frame)) | 419 if (NSIsEmptyRect(frame)) |
411 return NSZeroPoint; | 420 return NSZeroPoint; |
412 | 421 |
413 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); | 422 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); |
414 return [field_ convertPoint:bubble_point toView:nil]; | 423 return [field_ convertPoint:bubble_point toView:nil]; |
415 } | 424 } |
416 | 425 |
417 NSRect LocationBarViewMac::GetBlockedPopupRect() const { | 426 NSRect LocationBarViewMac::GetBlockedPopupRect() const { |
418 const size_t kPopupIndex = CONTENT_SETTINGS_TYPE_POPUPS; | 427 const size_t kPopupIndex = CONTENT_SETTINGS_TYPE_POPUPS; |
419 const LocationBarDecoration* decoration = | 428 const LocationBarDecoration* decoration = |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 736 void LocationBarViewMac::UpdateChromeToMobileEnabled() { |
728 if (!chrome_to_mobile_decoration_.get()) | 737 if (!chrome_to_mobile_decoration_.get()) |
729 return; | 738 return; |
730 | 739 |
731 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); | 740 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); |
732 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && | 741 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && |
733 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasMobiles(); | 742 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasMobiles(); |
734 chrome_to_mobile_decoration_->SetVisible(enabled); | 743 chrome_to_mobile_decoration_->SetVisible(enabled); |
735 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); | 744 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); |
736 } | 745 } |
OLD | NEW |