| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 411 } |
| 412 | 412 |
| 413 bool LocationBarViewMac::IsStarEnabled() const { | 413 bool LocationBarViewMac::IsStarEnabled() const { |
| 414 return browser_defaults::bookmarks_enabled && | 414 return browser_defaults::bookmarks_enabled && |
| 415 [field_ isEditable] && | 415 [field_ isEditable] && |
| 416 !GetToolbarModel()->input_in_progress() && | 416 !GetToolbarModel()->input_in_progress() && |
| 417 edit_bookmarks_enabled_.GetValue() && | 417 edit_bookmarks_enabled_.GetValue() && |
| 418 !IsBookmarkStarHiddenByExtension(); | 418 !IsBookmarkStarHiddenByExtension(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const { | 421 NSPoint LocationBarViewMac::GetBubblePointForDecoration( |
| 422 DCHECK(IsStarEnabled()); | 422 LocationBarDecoration* decoration) const { |
| 423 return [field_ bubblePointForDecoration:star_decoration_.get()]; | 423 if (decoration == star_decoration_.get()) |
| 424 DCHECK(IsStarEnabled()); |
| 425 |
| 426 return [field_ bubblePointForDecoration:decoration]; |
| 424 } | 427 } |
| 425 | 428 |
| 426 NSPoint LocationBarViewMac::GetSaveCreditCardBubblePoint() const { | 429 NSPoint LocationBarViewMac::GetSaveCreditCardBubblePoint() const { |
| 427 return [field_ bubblePointForDecoration:save_credit_card_decoration_.get()]; | 430 return [field_ bubblePointForDecoration:save_credit_card_decoration_.get()]; |
| 428 } | 431 } |
| 429 | 432 |
| 430 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { | |
| 431 return [field_ bubblePointForDecoration:translate_decoration_.get()]; | |
| 432 } | |
| 433 | |
| 434 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { | |
| 435 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()]; | |
| 436 } | |
| 437 | |
| 438 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { | 433 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { |
| 439 if (security_state_bubble_decoration_->IsVisible()) { | 434 return [field_ bubblePointForDecoration:GetPageInfoDecoration()]; |
| 440 return [field_ | |
| 441 bubblePointForDecoration:security_state_bubble_decoration_.get()]; | |
| 442 } else { | |
| 443 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; | |
| 444 } | |
| 445 } | 435 } |
| 446 | 436 |
| 447 void LocationBarViewMac::OnDecorationsChanged() { | 437 void LocationBarViewMac::OnDecorationsChanged() { |
| 448 // TODO(shess): The field-editor frame and cursor rects should not | 438 // TODO(shess): The field-editor frame and cursor rects should not |
| 449 // change, here. | 439 // change, here. |
| 450 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 440 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 451 for (auto* decoration : decorations) | 441 for (auto* decoration : decorations) |
| 452 UpdateAccessibilityViewPosition(decoration); | 442 UpdateAccessibilityViewPosition(decoration); |
| 453 [field_ updateMouseTracking]; | 443 [field_ updateMouseTracking]; |
| 454 [field_ resetFieldEditorFrameIfNeeded]; | 444 [field_ resetFieldEditorFrameIfNeeded]; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 708 |
| 719 return should_show_nonsecure_verbose_ && | 709 return should_show_nonsecure_verbose_ && |
| 720 (security == security_state::DANGEROUS || | 710 (security == security_state::DANGEROUS || |
| 721 security == security_state::HTTP_SHOW_WARNING); | 711 security == security_state::HTTP_SHOW_WARNING); |
| 722 } | 712 } |
| 723 | 713 |
| 724 bool LocationBarViewMac::IsLocationBarDark() const { | 714 bool LocationBarViewMac::IsLocationBarDark() const { |
| 725 return [[field_ window] inIncognitoModeWithSystemTheme]; | 715 return [[field_ window] inIncognitoModeWithSystemTheme]; |
| 726 } | 716 } |
| 727 | 717 |
| 718 LocationBarDecoration* LocationBarViewMac::GetPageInfoDecoration() const { |
| 719 if (security_state_bubble_decoration_->IsVisible()) |
| 720 return security_state_bubble_decoration_.get(); |
| 721 |
| 722 return location_icon_decoration_.get(); |
| 723 } |
| 724 |
| 728 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { | 725 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { |
| 729 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 726 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 730 profile())->GetTemplateURLForKeyword(keyword); | 727 profile())->GetTemplateURLForKeyword(keyword); |
| 731 if (template_url && | 728 if (template_url && |
| 732 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 729 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 733 return extensions::OmniboxAPI::Get(profile())-> | 730 return extensions::OmniboxAPI::Get(profile())-> |
| 734 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 731 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
| 735 } | 732 } |
| 736 | 733 |
| 737 SkColor icon_color = | 734 SkColor icon_color = |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 OnDecorationsChanged(); | 972 OnDecorationsChanged(); |
| 976 } | 973 } |
| 977 | 974 |
| 978 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 975 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 979 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 976 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 980 std::vector<NSView*> views; | 977 std::vector<NSView*> views; |
| 981 for (auto* decoration : decorations) | 978 for (auto* decoration : decorations) |
| 982 views.push_back(decoration->GetAccessibilityView()); | 979 views.push_back(decoration->GetAccessibilityView()); |
| 983 return views; | 980 return views; |
| 984 } | 981 } |
| OLD | NEW |