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

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

Issue 2511043002: [Mac] Omnibox icons active states (Closed)
Patch Set: Cleaned up Created 4 years, 1 month 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
OLDNEW
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
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 706
717 return should_show_nonsecure_verbose_ && 707 return should_show_nonsecure_verbose_ &&
718 (security == security_state::SecurityStateModel::DANGEROUS || 708 (security == security_state::SecurityStateModel::DANGEROUS ||
719 security == security_state::SecurityStateModel::HTTP_SHOW_WARNING); 709 security == security_state::SecurityStateModel::HTTP_SHOW_WARNING);
720 } 710 }
721 711
722 bool LocationBarViewMac::IsLocationBarDark() const { 712 bool LocationBarViewMac::IsLocationBarDark() const {
723 return [[field_ window] inIncognitoModeWithSystemTheme]; 713 return [[field_ window] inIncognitoModeWithSystemTheme];
724 } 714 }
725 715
716 LocationBarDecoration* LocationBarViewMac::GetPageInfoDecoration() const {
717 if (security_state_bubble_decoration_->IsVisible())
718 return security_state_bubble_decoration_.get();
719
720 return location_icon_decoration_.get();
721 }
722
726 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { 723 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) {
727 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( 724 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
728 profile())->GetTemplateURLForKeyword(keyword); 725 profile())->GetTemplateURLForKeyword(keyword);
729 if (template_url && 726 if (template_url &&
730 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { 727 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) {
731 return extensions::OmniboxAPI::Get(profile())-> 728 return extensions::OmniboxAPI::Get(profile())->
732 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); 729 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage();
733 } 730 }
734 731
735 SkColor icon_color = 732 SkColor icon_color =
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 OnDecorationsChanged(); 964 OnDecorationsChanged();
968 } 965 }
969 966
970 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 967 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
971 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 968 std::vector<LocationBarDecoration*> decorations = GetDecorations();
972 std::vector<NSView*> views; 969 std::vector<NSView*> views;
973 for (auto* decoration : decorations) 970 for (auto* decoration : decorations)
974 views.push_back(decoration->GetAccessibilityView()); 971 views.push_back(decoration->GetAccessibilityView());
975 return views; 972 return views;
976 } 973 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698