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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 new ManagePasswordsDecoration(command_updater)), | 136 new ManagePasswordsDecoration(command_updater)), |
137 browser_(browser), | 137 browser_(browser), |
138 weak_ptr_factory_(this) { | 138 weak_ptr_factory_(this) { |
139 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 139 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
140 DCHECK_EQ(i, content_setting_decorations_.size()); | 140 DCHECK_EQ(i, content_setting_decorations_.size()); |
141 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 141 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
142 content_setting_decorations_.push_back( | 142 content_setting_decorations_.push_back( |
143 new ContentSettingDecoration(type, this, profile)); | 143 new ContentSettingDecoration(type, this, profile)); |
144 } | 144 } |
145 | 145 |
146 registrar_.Add( | |
147 this, | |
148 extensions::NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED, | |
149 content::NotificationService::AllSources()); | |
150 content::Source<Profile> profile_source = content::Source<Profile>(profile); | 146 content::Source<Profile> profile_source = content::Source<Profile>(profile); |
151 registrar_.Add(this, | 147 registrar_.Add(this, |
152 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 148 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
153 profile_source); | 149 profile_source); |
154 registrar_.Add(this, | 150 registrar_.Add(this, |
155 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 151 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
156 profile_source); | 152 profile_source); |
157 | 153 |
158 edit_bookmarks_enabled_.Init( | 154 edit_bookmarks_enabled_.Init( |
159 prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 155 prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 WebContents* web_contents = GetWebContents(); | 216 WebContents* web_contents = GetWebContents(); |
221 if (!web_contents) | 217 if (!web_contents) |
222 return; | 218 return; |
223 ManagePasswordsUIController::FromWebContents(web_contents) | 219 ManagePasswordsUIController::FromWebContents(web_contents) |
224 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); | 220 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); |
225 } | 221 } |
226 | 222 |
227 void LocationBarViewMac::UpdatePageActions() { | 223 void LocationBarViewMac::UpdatePageActions() { |
228 RefreshPageActionDecorations(); | 224 RefreshPageActionDecorations(); |
229 Layout(); | 225 Layout(); |
| 226 |
| 227 [field_ updateMouseTracking]; |
| 228 [field_ setNeedsDisplay:YES]; |
230 } | 229 } |
231 | 230 |
232 void LocationBarViewMac::InvalidatePageActions() { | 231 void LocationBarViewMac::InvalidatePageActions() { |
233 DeletePageActionDecorations(); | 232 DeletePageActionDecorations(); |
234 Layout(); | 233 Layout(); |
235 } | 234 } |
236 | 235 |
237 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { | 236 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { |
238 // Not implemented on Mac. | 237 // Not implemented on Mac. |
239 } | 238 } |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return extensions::OmniboxAPI::Get(profile())-> | 616 return extensions::OmniboxAPI::Get(profile())-> |
618 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 617 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
619 } | 618 } |
620 | 619 |
621 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 620 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
622 } | 621 } |
623 | 622 |
624 void LocationBarViewMac::Observe(int type, | 623 void LocationBarViewMac::Observe(int type, |
625 const content::NotificationSource& source, | 624 const content::NotificationSource& source, |
626 const content::NotificationDetails& details) { | 625 const content::NotificationDetails& details) { |
627 switch (type) { | 626 DCHECK(type == extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED || |
628 case extensions::NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED: { | 627 type == extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED); |
629 if (content::Source<WebContents>(source).ptr() != GetWebContents()) | |
630 return; | |
631 | 628 |
632 [field_ updateMouseTracking]; | 629 Update(NULL); |
633 [field_ setNeedsDisplay:YES]; | |
634 break; | |
635 } | |
636 | |
637 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | |
638 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | |
639 Update(NULL); | |
640 break; | |
641 | |
642 default: | |
643 NOTREACHED() << "Unexpected notification"; | |
644 break; | |
645 } | |
646 } | 630 } |
647 | 631 |
648 void LocationBarViewMac::ModelChanged(const SearchModel::State& old_state, | 632 void LocationBarViewMac::ModelChanged(const SearchModel::State& old_state, |
649 const SearchModel::State& new_state) { | 633 const SearchModel::State& new_state) { |
650 if (UpdateMicSearchDecorationVisibility()) | 634 if (UpdateMicSearchDecorationVisibility()) |
651 Layout(); | 635 Layout(); |
652 } | 636 } |
653 | 637 |
654 void LocationBarViewMac::ActivatePageAction(const std::string& extension_id) { | 638 void LocationBarViewMac::ActivatePageAction(const std::string& extension_id) { |
655 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 639 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 } | 777 } |
794 | 778 |
795 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 779 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
796 bool is_visible = !GetToolbarModel()->input_in_progress() && | 780 bool is_visible = !GetToolbarModel()->input_in_progress() && |
797 browser_->search_model()->voice_search_supported(); | 781 browser_->search_model()->voice_search_supported(); |
798 if (mic_search_decoration_->IsVisible() == is_visible) | 782 if (mic_search_decoration_->IsVisible() == is_visible) |
799 return false; | 783 return false; |
800 mic_search_decoration_->SetVisible(is_visible); | 784 mic_search_decoration_->SetVisible(is_visible); |
801 return true; | 785 return true; |
802 } | 786 } |
OLD | NEW |