Chromium Code Reviews| 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 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 using content::WebContents; | 73 using content::WebContents; |
| 74 | 74 |
| 75 namespace { | 75 namespace { |
| 76 | 76 |
| 77 // Vertical space between the bottom edge of the location_bar and the first run | 77 // Vertical space between the bottom edge of the location_bar and the first run |
| 78 // bubble arrow point. | 78 // bubble arrow point. |
| 79 const static int kFirstRunBubbleYOffset = 1; | 79 const static int kFirstRunBubbleYOffset = 1; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 namespace chrome { | |
| 84 | |
| 85 NSString* const kShowToolbarNotification = @"ShowToolbarNotification"; | |
| 86 NSString* const kHideToolbarNotification = @"HideToolbarNotification"; | |
| 87 | |
| 88 } // namespace chrome | |
| 89 | |
| 83 // TODO(shess): This code is mostly copied from the gtk | 90 // TODO(shess): This code is mostly copied from the gtk |
| 84 // implementation. Make sure it's all appropriate and flesh it out. | 91 // implementation. Make sure it's all appropriate and flesh it out. |
| 85 | 92 |
| 86 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, | 93 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, |
| 87 CommandUpdater* command_updater, | 94 CommandUpdater* command_updater, |
| 88 Profile* profile, | 95 Profile* profile, |
| 89 Browser* browser) | 96 Browser* browser) |
| 90 : LocationBar(profile), | 97 : LocationBar(profile), |
| 91 ChromeOmniboxEditController(command_updater), | 98 ChromeOmniboxEditController(command_updater), |
| 92 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), | 99 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), |
| 93 field_(field), | 100 field_(field), |
| 94 location_icon_decoration_(new LocationIconDecoration(this)), | 101 location_icon_decoration_(new LocationIconDecoration(this)), |
| 95 selected_keyword_decoration_(new SelectedKeywordDecoration()), | 102 selected_keyword_decoration_(new SelectedKeywordDecoration()), |
| 96 ev_bubble_decoration_( | 103 ev_bubble_decoration_( |
| 97 new EVBubbleDecoration(location_icon_decoration_.get())), | 104 new EVBubbleDecoration(location_icon_decoration_.get())), |
| 98 star_decoration_(new StarDecoration(command_updater)), | 105 star_decoration_(new StarDecoration(command_updater)), |
| 99 translate_decoration_(new TranslateDecoration(command_updater)), | 106 translate_decoration_(new TranslateDecoration(command_updater)), |
| 100 zoom_decoration_(new ZoomDecoration(this)), | 107 zoom_decoration_(new ZoomDecoration(this)), |
| 101 keyword_hint_decoration_(new KeywordHintDecoration()), | 108 keyword_hint_decoration_(new KeywordHintDecoration()), |
| 102 mic_search_decoration_(new MicSearchDecoration(command_updater)), | 109 mic_search_decoration_(new MicSearchDecoration(command_updater)), |
| 103 manage_passwords_decoration_( | 110 manage_passwords_decoration_( |
| 104 new ManagePasswordsDecoration(command_updater, this)), | 111 new ManagePasswordsDecoration(command_updater, this)), |
| 105 browser_(browser), | 112 browser_(browser), |
| 113 show_location_bar_(true), | |
| 106 weak_ptr_factory_(this) { | 114 weak_ptr_factory_(this) { |
| 107 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 115 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 108 DCHECK_EQ(i, content_setting_decorations_.size()); | 116 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 109 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 117 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 110 content_setting_decorations_.push_back( | 118 content_setting_decorations_.push_back( |
| 111 new ContentSettingDecoration(type, this, profile)); | 119 new ContentSettingDecoration(type, this, profile)); |
| 112 } | 120 } |
| 113 | 121 |
| 114 edit_bookmarks_enabled_.Init( | 122 edit_bookmarks_enabled_.Init( |
| 115 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 123 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 [field_ updateMouseTracking]; | 201 [field_ updateMouseTracking]; |
| 194 [field_ setNeedsDisplay:YES]; | 202 [field_ setNeedsDisplay:YES]; |
| 195 } | 203 } |
| 196 | 204 |
| 197 void LocationBarViewMac::UpdateBookmarkStarVisibility() { | 205 void LocationBarViewMac::UpdateBookmarkStarVisibility() { |
| 198 star_decoration_->SetVisible(IsStarEnabled()); | 206 star_decoration_->SetVisible(IsStarEnabled()); |
| 199 } | 207 } |
| 200 | 208 |
| 201 void LocationBarViewMac::UpdateLocationBarVisibility(bool visible, | 209 void LocationBarViewMac::UpdateLocationBarVisibility(bool visible, |
| 202 bool animate) { | 210 bool animate) { |
| 203 // Not implemented on Mac. | 211 // TODO(dominickn): respect the |animate| value. |
| 212 if (visible != show_location_bar_) { | |
| 213 [[NSNotificationCenter defaultCenter] | |
|
tapted
2015/09/08 05:55:06
Something like
[[BrowserWindowController browserW
dominickn
2015/10/09 06:37:02
Done.
| |
| 214 postNotificationName:(visible ? chrome::kShowToolbarNotification | |
| 215 : chrome::kHideToolbarNotification) | |
| 216 object:nil]; | |
| 217 show_location_bar_ = visible; | |
| 218 [field_ setHidden:!visible]; | |
| 219 } | |
| 204 } | 220 } |
| 205 | 221 |
| 206 bool LocationBarViewMac::ShowPageActionPopup( | 222 bool LocationBarViewMac::ShowPageActionPopup( |
| 207 const extensions::Extension* extension, bool grant_active_tab) { | 223 const extensions::Extension* extension, bool grant_active_tab) { |
| 208 for (ScopedVector<PageActionDecoration>::iterator iter = | 224 for (ScopedVector<PageActionDecoration>::iterator iter = |
| 209 page_action_decorations_.begin(); | 225 page_action_decorations_.begin(); |
| 210 iter != page_action_decorations_.end(); ++iter) { | 226 iter != page_action_decorations_.end(); ++iter) { |
| 211 if ((*iter)->GetExtension() == extension) | 227 if ((*iter)->GetExtension() == extension) |
| 212 return (*iter)->ActivatePageAction(grant_active_tab); | 228 return (*iter)->ActivatePageAction(grant_active_tab); |
| 213 } | 229 } |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 } | 731 } |
| 716 | 732 |
| 717 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 733 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
| 718 bool is_visible = !GetToolbarModel()->input_in_progress() && | 734 bool is_visible = !GetToolbarModel()->input_in_progress() && |
| 719 browser_->search_model()->voice_search_supported(); | 735 browser_->search_model()->voice_search_supported(); |
| 720 if (mic_search_decoration_->IsVisible() == is_visible) | 736 if (mic_search_decoration_->IsVisible() == is_visible) |
| 721 return false; | 737 return false; |
| 722 mic_search_decoration_->SetVisible(is_visible); | 738 mic_search_decoration_->SetVisible(is_visible); |
| 723 return true; | 739 return true; |
| 724 } | 740 } |
| OLD | NEW |