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

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

Issue 2381373003: Fixed the issue shows keyword hint when omnibox loses its focus. (Closed)
Patch Set: Created 4 years, 2 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
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 location_icon_decoration_->SetVisible(false); 488 location_icon_decoration_->SetVisible(false);
489 selected_keyword_decoration_->SetVisible(true); 489 selected_keyword_decoration_->SetVisible(true);
490 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); 490 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword);
491 // Note: the first time through this code path the 491 // Note: the first time through this code path the
492 // |selected_keyword_decoration_| has no image set because under Material 492 // |selected_keyword_decoration_| has no image set because under Material
493 // Design we need to set its color, which we cannot do until we know the 493 // Design we need to set its color, which we cannot do until we know the
494 // theme (by being installed in a browser window). 494 // theme (by being installed in a browser window).
495 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); 495 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
496 } else if (!keyword.empty() && is_keyword_hint) { 496 } else if (!keyword.empty() && is_keyword_hint) {
497 keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword); 497 keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword);
498 keyword_hint_decoration_->SetVisible(true); 498 if (focus_state_ == OMNIBOX_FOCUS_VISIBLE) {
499 keyword_hint_decoration_->SetVisible(true);
500 }
499 } else if (ShouldShowEVBubble()) { 501 } else if (ShouldShowEVBubble()) {
500 // Switch from location icon to show the EV bubble instead. 502 // Switch from location icon to show the EV bubble instead.
501 location_icon_decoration_->SetVisible(false); 503 location_icon_decoration_->SetVisible(false);
502 security_state_bubble_decoration_->SetVisible(true); 504 security_state_bubble_decoration_->SetVisible(true);
503 505
504 base::string16 label(GetToolbarModel()->GetEVCertName()); 506 base::string16 label(GetToolbarModel()->GetEVCertName());
505 security_state_bubble_decoration_->SetFullLabel( 507 security_state_bubble_decoration_->SetFullLabel(
506 base::SysUTF16ToNSString(label)); 508 base::SysUTF16ToNSString(label));
507 509
508 // This is true for EV certificate since the certificate should be 510 // This is true for EV certificate since the certificate should be
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 679 }
678 680
679 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { 681 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const {
680 return browser_->toolbar_model(); 682 return browser_->toolbar_model();
681 } 683 }
682 684
683 WebContents* LocationBarViewMac::GetWebContents() { 685 WebContents* LocationBarViewMac::GetWebContents() {
684 return browser_->tab_strip_model()->GetActiveWebContents(); 686 return browser_->tab_strip_model()->GetActiveWebContents();
685 } 687 }
686 688
689 void LocationBarViewMac::OnFocusChanged(OmniboxFocusState state) {
690 focus_state_ = state;
691
692 Layout();
693 }
694
687 bool LocationBarViewMac::ShouldShowEVBubble() const { 695 bool LocationBarViewMac::ShouldShowEVBubble() const {
688 return (GetToolbarModel()->GetSecurityLevel(false) == 696 return (GetToolbarModel()->GetSecurityLevel(false) ==
689 security_state::SecurityStateModel::EV_SECURE) && 697 security_state::SecurityStateModel::EV_SECURE) &&
690 should_show_secure_verbose_; 698 should_show_secure_verbose_;
691 } 699 }
692 700
693 bool LocationBarViewMac::ShouldShowSecurityState() const { 701 bool LocationBarViewMac::ShouldShowSecurityState() const {
694 security_state::SecurityStateModel::SecurityLevel security = 702 security_state::SecurityStateModel::SecurityLevel security =
695 GetToolbarModel()->GetSecurityLevel(false); 703 GetToolbarModel()->GetSecurityLevel(false);
696 bool has_verbose_for_security = 704 bool has_verbose_for_security =
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 OnDecorationsChanged(); 955 OnDecorationsChanged();
948 } 956 }
949 957
950 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { 958 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() {
951 std::vector<LocationBarDecoration*> decorations = GetDecorations(); 959 std::vector<LocationBarDecoration*> decorations = GetDecorations();
952 std::vector<NSView*> views; 960 std::vector<NSView*> views;
953 for (auto* decoration : decorations) 961 for (auto* decoration : decorations)
954 views.push_back(decoration->GetAccessibilityView()); 962 views.push_back(decoration->GetAccessibilityView());
955 return views; 963 return views;
956 } 964 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/omnibox/chrome_omnibox_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698