| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 save_credit_card_decoration_( | 114 save_credit_card_decoration_( |
| 115 new SaveCreditCardDecoration(command_updater)), | 115 new SaveCreditCardDecoration(command_updater)), |
| 116 star_decoration_(new StarDecoration(command_updater)), | 116 star_decoration_(new StarDecoration(command_updater)), |
| 117 translate_decoration_(new TranslateDecoration(command_updater)), | 117 translate_decoration_(new TranslateDecoration(command_updater)), |
| 118 zoom_decoration_(new ZoomDecoration(this)), | 118 zoom_decoration_(new ZoomDecoration(this)), |
| 119 keyword_hint_decoration_(new KeywordHintDecoration()), | 119 keyword_hint_decoration_(new KeywordHintDecoration()), |
| 120 manage_passwords_decoration_( | 120 manage_passwords_decoration_( |
| 121 new ManagePasswordsDecoration(command_updater, this)), | 121 new ManagePasswordsDecoration(command_updater, this)), |
| 122 browser_(browser), | 122 browser_(browser), |
| 123 location_bar_visible_(true), | 123 location_bar_visible_(true), |
| 124 should_show_secure_verbose_(true), | 124 should_show_secure_verbose_(false), |
| 125 should_show_nonsecure_verbose_(false), |
| 125 should_animate_secure_verbose_(false), | 126 should_animate_secure_verbose_(false), |
| 126 should_animate_nonsecure_verbose_(false), | 127 should_animate_nonsecure_verbose_(false), |
| 127 is_width_available_for_security_verbose_(false), | 128 is_width_available_for_security_verbose_(false), |
| 128 weak_ptr_factory_(this) { | 129 weak_ptr_factory_(this) { |
| 129 ScopedVector<ContentSettingImageModel> models = | 130 ScopedVector<ContentSettingImageModel> models = |
| 130 ContentSettingImageModel::GenerateContentSettingImageModels(); | 131 ContentSettingImageModel::GenerateContentSettingImageModels(); |
| 131 for (ContentSettingImageModel* model : models.get()) { | 132 for (ContentSettingImageModel* model : models.get()) { |
| 132 // ContentSettingDecoration takes ownership of its model. | 133 // ContentSettingDecoration takes ownership of its model. |
| 133 content_setting_decorations_.push_back( | 134 content_setting_decorations_.push_back( |
| 134 new ContentSettingDecoration(model, this, profile)); | 135 new ContentSettingDecoration(model, this, profile)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 145 | 146 |
| 146 [[field_ cell] setIsPopupMode: | 147 [[field_ cell] setIsPopupMode: |
| 147 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; | 148 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; |
| 148 | 149 |
| 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 150 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 150 if (command_line->HasSwitch(switches::kSecurityChip)) { | 151 if (command_line->HasSwitch(switches::kSecurityChip)) { |
| 151 std::string security_chip_flag = | 152 std::string security_chip_flag = |
| 152 command_line->GetSwitchValueASCII(switches::kSecurityChip); | 153 command_line->GetSwitchValueASCII(switches::kSecurityChip); |
| 153 should_show_secure_verbose_ = | 154 should_show_secure_verbose_ = |
| 154 security_chip_flag == switches::kSecurityChipShowAll; | 155 security_chip_flag == switches::kSecurityChipShowAll; |
| 156 should_show_nonsecure_verbose_ = |
| 157 security_chip_flag == switches::kSecurityChipShowAll || |
| 158 security_chip_flag == switches::kSecurityChipShowNonSecureOnly; |
| 155 } | 159 } |
| 156 | 160 |
| 157 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { | 161 if (command_line->HasSwitch(switches::kSecurityChipAnimation)) { |
| 158 std::string security_chip_animation_flag = | 162 std::string security_chip_animation_flag = |
| 159 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); | 163 command_line->GetSwitchValueASCII(switches::kSecurityChipAnimation); |
| 160 should_animate_secure_verbose_ = | 164 should_animate_secure_verbose_ = |
| 161 security_chip_animation_flag == switches::kSecurityChipAnimationAll; | 165 security_chip_animation_flag == switches::kSecurityChipAnimationAll; |
| 162 | 166 |
| 163 should_animate_nonsecure_verbose_ = | 167 should_animate_nonsecure_verbose_ = |
| 164 security_chip_animation_flag == | 168 security_chip_animation_flag == |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 675 |
| 672 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { | 676 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { |
| 673 return browser_->toolbar_model(); | 677 return browser_->toolbar_model(); |
| 674 } | 678 } |
| 675 | 679 |
| 676 WebContents* LocationBarViewMac::GetWebContents() { | 680 WebContents* LocationBarViewMac::GetWebContents() { |
| 677 return browser_->tab_strip_model()->GetActiveWebContents(); | 681 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 678 } | 682 } |
| 679 | 683 |
| 680 bool LocationBarViewMac::ShouldShowEVBubble() const { | 684 bool LocationBarViewMac::ShouldShowEVBubble() const { |
| 681 return (GetToolbarModel()->GetSecurityLevel(false) == | 685 return GetToolbarModel()->GetSecurityLevel(false) == |
| 682 security_state::SecurityStateModel::EV_SECURE) && | 686 security_state::SecurityStateModel::EV_SECURE; |
| 683 should_show_secure_verbose_; | |
| 684 } | 687 } |
| 685 | 688 |
| 686 bool LocationBarViewMac::ShouldShowSecurityState() const { | 689 bool LocationBarViewMac::ShouldShowSecurityState() const { |
| 690 if (omnibox_view_->IsEditingOrEmpty() || |
| 691 omnibox_view_->model()->is_keyword_hint()) { |
| 692 return false; |
| 693 } |
| 694 |
| 687 security_state::SecurityStateModel::SecurityLevel security = | 695 security_state::SecurityStateModel::SecurityLevel security = |
| 688 GetToolbarModel()->GetSecurityLevel(false); | 696 GetToolbarModel()->GetSecurityLevel(false); |
| 689 bool has_verbose_for_security = | |
| 690 security == security_state::SecurityStateModel::DANGEROUS || | |
| 691 security == security_state::SecurityStateModel::HTTP_SHOW_WARNING || | |
| 692 (IsSecureConnection(security) && should_show_secure_verbose_); | |
| 693 | 697 |
| 694 return has_verbose_for_security && !omnibox_view_->IsEditingOrEmpty() && | 698 if (security == security_state::SecurityStateModel::EV_SECURE) |
| 695 !omnibox_view_->model()->is_keyword_hint(); | 699 return true; |
| 700 else if (security == security_state::SecurityStateModel::SECURE) |
| 701 return should_show_secure_verbose_; |
| 702 |
| 703 return should_show_nonsecure_verbose_ && |
| 704 (security == security_state::SecurityStateModel::DANGEROUS || |
| 705 security == security_state::SecurityStateModel::HTTP_SHOW_WARNING); |
| 696 } | 706 } |
| 697 | 707 |
| 698 bool LocationBarViewMac::IsLocationBarDark() const { | 708 bool LocationBarViewMac::IsLocationBarDark() const { |
| 699 return [[field_ window] inIncognitoModeWithSystemTheme]; | 709 return [[field_ window] inIncognitoModeWithSystemTheme]; |
| 700 } | 710 } |
| 701 | 711 |
| 702 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { | 712 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { |
| 703 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 713 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 704 profile())->GetTemplateURLForKeyword(keyword); | 714 profile())->GetTemplateURLForKeyword(keyword); |
| 705 if (template_url && | 715 if (template_url && |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 OnDecorationsChanged(); | 953 OnDecorationsChanged(); |
| 944 } | 954 } |
| 945 | 955 |
| 946 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 956 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 947 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 957 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 948 std::vector<NSView*> views; | 958 std::vector<NSView*> views; |
| 949 for (auto* decoration : decorations) | 959 for (auto* decoration : decorations) |
| 950 views.push_back(decoration->GetAccessibilityView()); | 960 views.push_back(decoration->GetAccessibilityView()); |
| 951 return views; | 961 return views; |
| 952 } | 962 } |
| OLD | NEW |