| 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_security_verbose_(false), | 126 should_animate_security_verbose_(false), |
| 126 is_width_available_for_security_verbose_(false), | 127 is_width_available_for_security_verbose_(false), |
| 127 weak_ptr_factory_(this) { | 128 weak_ptr_factory_(this) { |
| 128 ScopedVector<ContentSettingImageModel> models = | 129 ScopedVector<ContentSettingImageModel> models = |
| 129 ContentSettingImageModel::GenerateContentSettingImageModels(); | 130 ContentSettingImageModel::GenerateContentSettingImageModels(); |
| 130 for (ContentSettingImageModel* model : models.get()) { | 131 for (ContentSettingImageModel* model : models.get()) { |
| 131 // ContentSettingDecoration takes ownership of its model. | 132 // ContentSettingDecoration takes ownership of its model. |
| 132 content_setting_decorations_.push_back( | 133 content_setting_decorations_.push_back( |
| 133 new ContentSettingDecoration(model, this, profile)); | 134 new ContentSettingDecoration(model, this, profile)); |
| 134 } | 135 } |
| 135 models.weak_clear(); | 136 models.weak_clear(); |
| 136 | 137 |
| 137 edit_bookmarks_enabled_.Init( | 138 edit_bookmarks_enabled_.Init( |
| 138 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 139 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 139 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, | 140 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, |
| 140 base::Unretained(this))); | 141 base::Unretained(this))); |
| 141 | 142 |
| 142 zoom::ZoomEventManager::GetForBrowserContext(profile) | 143 zoom::ZoomEventManager::GetForBrowserContext(profile) |
| 143 ->AddZoomEventManagerObserver(this); | 144 ->AddZoomEventManagerObserver(this); |
| 144 | 145 |
| 145 [[field_ cell] setIsPopupMode: | 146 [[field_ cell] setIsPopupMode: |
| 146 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; | 147 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; |
| 147 | 148 |
| 148 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 149 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 149 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { | 150 if (command_line->HasSwitch(switches::kMaterialSecurityVerbose)) { |
| 150 std::string security_verbose_flag = | 151 std::string security_verbose_flag = |
| 151 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); | 152 command_line->GetSwitchValueASCII(switches::kMaterialSecurityVerbose); |
| 152 | |
| 153 should_show_secure_verbose_ = | 153 should_show_secure_verbose_ = |
| 154 security_verbose_flag == | 154 security_verbose_flag == |
| 155 switches::kMaterialSecurityVerboseShowAllAnimated || | 155 switches::kMaterialSecurityVerboseShowAllAnimated || |
| 156 security_verbose_flag == | 156 security_verbose_flag == |
| 157 switches::kMaterialSecurityVerboseShowAllNonAnimated; | 157 switches::kMaterialSecurityVerboseShowAllNonAnimated; |
| 158 | 158 |
| 159 should_show_nonsecure_verbose_ = true; |
| 160 |
| 159 should_animate_security_verbose_ = | 161 should_animate_security_verbose_ = |
| 160 security_verbose_flag == | 162 security_verbose_flag == |
| 161 switches::kMaterialSecurityVerboseShowAllAnimated || | 163 switches::kMaterialSecurityVerboseShowAllAnimated || |
| 162 security_verbose_flag == | 164 security_verbose_flag == |
| 163 switches::kMaterialSecurityVerboseShowNonSecureAnimated; | 165 switches::kMaterialSecurityVerboseShowNonSecureAnimated; |
| 164 } | 166 } |
| 165 | 167 |
| 166 // Sets images for the decorations, and performs a layout. This call ensures | 168 // Sets images for the decorations, and performs a layout. This call ensures |
| 167 // that this class is in a consistent state after initialization. | 169 // that this class is in a consistent state after initialization. |
| 168 OnChanged(); | 170 OnChanged(); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 670 |
| 669 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { | 671 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { |
| 670 return browser_->toolbar_model(); | 672 return browser_->toolbar_model(); |
| 671 } | 673 } |
| 672 | 674 |
| 673 WebContents* LocationBarViewMac::GetWebContents() { | 675 WebContents* LocationBarViewMac::GetWebContents() { |
| 674 return browser_->tab_strip_model()->GetActiveWebContents(); | 676 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 675 } | 677 } |
| 676 | 678 |
| 677 bool LocationBarViewMac::ShouldShowEVBubble() const { | 679 bool LocationBarViewMac::ShouldShowEVBubble() const { |
| 678 return (GetToolbarModel()->GetSecurityLevel(false) == | 680 return GetToolbarModel()->GetSecurityLevel(false) == |
| 679 security_state::SecurityStateModel::EV_SECURE) && | 681 security_state::SecurityStateModel::EV_SECURE; |
| 680 should_show_secure_verbose_; | |
| 681 } | 682 } |
| 682 | 683 |
| 683 bool LocationBarViewMac::ShouldShowSecurityState() const { | 684 bool LocationBarViewMac::ShouldShowSecurityState() const { |
| 685 if (omnibox_view_->IsEditingOrEmpty() || |
| 686 omnibox_view_->model()->is_keyword_hint()) { |
| 687 return false; |
| 688 } |
| 689 |
| 684 security_state::SecurityStateModel::SecurityLevel security = | 690 security_state::SecurityStateModel::SecurityLevel security = |
| 685 GetToolbarModel()->GetSecurityLevel(false); | 691 GetToolbarModel()->GetSecurityLevel(false); |
| 686 bool has_verbose_for_security = | 692 if (security == security_state::SecurityStateModel::EV_SECURE) |
| 687 security == security_state::SecurityStateModel::DANGEROUS || | 693 return true; |
| 688 (IsSecureConnection(security) && should_show_secure_verbose_); | 694 else if (security == security_state::SecurityStateModel::SECURE) |
| 695 return should_show_secure_verbose_; |
| 689 | 696 |
| 690 return has_verbose_for_security && !omnibox_view_->IsEditingOrEmpty() && | 697 return should_show_nonsecure_verbose_ && |
| 691 !omnibox_view_->model()->is_keyword_hint(); | 698 security == security_state::SecurityStateModel::DANGEROUS; |
| 692 } | 699 } |
| 693 | 700 |
| 694 bool LocationBarViewMac::IsLocationBarDark() const { | 701 bool LocationBarViewMac::IsLocationBarDark() const { |
| 695 return [[field_ window] inIncognitoModeWithSystemTheme]; | 702 return [[field_ window] inIncognitoModeWithSystemTheme]; |
| 696 } | 703 } |
| 697 | 704 |
| 698 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { | 705 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { |
| 699 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 706 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 700 profile())->GetTemplateURLForKeyword(keyword); | 707 profile())->GetTemplateURLForKeyword(keyword); |
| 701 if (template_url && | 708 if (template_url && |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 OnDecorationsChanged(); | 939 OnDecorationsChanged(); |
| 933 } | 940 } |
| 934 | 941 |
| 935 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 942 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 936 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 943 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 937 std::vector<NSView*> views; | 944 std::vector<NSView*> views; |
| 938 for (auto* decoration : decorations) | 945 for (auto* decoration : decorations) |
| 939 views.push_back(decoration->GetAccessibilityView()); | 946 views.push_back(decoration->GetAccessibilityView()); |
| 940 return views; | 947 return views; |
| 941 } | 948 } |
| OLD | NEW |