| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 146 registrar_.Add( |
| 147 this, | 147 this, |
| 148 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 148 extensions::NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED, |
| 149 content::NotificationService::AllSources()); | 149 content::NotificationService::AllSources()); |
| 150 content::Source<Profile> profile_source = content::Source<Profile>(profile); | 150 content::Source<Profile> profile_source = content::Source<Profile>(profile); |
| 151 registrar_.Add(this, | 151 registrar_.Add(this, |
| 152 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 152 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 153 profile_source); | 153 profile_source); |
| 154 registrar_.Add(this, | 154 registrar_.Add(this, |
| 155 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 155 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 156 profile_source); | 156 profile_source); |
| 157 | 157 |
| 158 edit_bookmarks_enabled_.Init( | 158 edit_bookmarks_enabled_.Init( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() { | 219 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() { |
| 220 WebContents* web_contents = GetWebContents(); | 220 WebContents* web_contents = GetWebContents(); |
| 221 if (!web_contents) | 221 if (!web_contents) |
| 222 return; | 222 return; |
| 223 ManagePasswordsUIController::FromWebContents(web_contents) | 223 ManagePasswordsUIController::FromWebContents(web_contents) |
| 224 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); | 224 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void LocationBarViewMac::UpdatePageActions() { | 227 void LocationBarViewMac::UpdatePageActions() { |
| 228 size_t count_before = page_action_decorations_.size(); | |
| 229 RefreshPageActionDecorations(); | 228 RefreshPageActionDecorations(); |
| 230 Layout(); | 229 Layout(); |
| 231 if (page_action_decorations_.size() != count_before) { | |
| 232 content::NotificationService::current()->Notify( | |
| 233 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | |
| 234 content::Source<LocationBar>(this), | |
| 235 content::NotificationService::NoDetails()); | |
| 236 } | |
| 237 } | 230 } |
| 238 | 231 |
| 239 void LocationBarViewMac::InvalidatePageActions() { | 232 void LocationBarViewMac::InvalidatePageActions() { |
| 240 size_t count_before = page_action_decorations_.size(); | |
| 241 DeletePageActionDecorations(); | 233 DeletePageActionDecorations(); |
| 242 Layout(); | 234 Layout(); |
| 243 if (page_action_decorations_.size() != count_before) { | |
| 244 content::NotificationService::current()->Notify( | |
| 245 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | |
| 246 content::Source<LocationBar>(this), | |
| 247 content::NotificationService::NoDetails()); | |
| 248 } | |
| 249 } | 235 } |
| 250 | 236 |
| 251 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { | 237 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { |
| 252 // Not implemented on Mac. | 238 // Not implemented on Mac. |
| 253 } | 239 } |
| 254 | 240 |
| 255 void LocationBarViewMac::UpdateGeneratedCreditCardView() { | 241 void LocationBarViewMac::UpdateGeneratedCreditCardView() { |
| 256 generated_credit_card_decoration_->Update(); | 242 generated_credit_card_decoration_->Update(); |
| 257 } | 243 } |
| 258 | 244 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 614 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
| 629 } | 615 } |
| 630 | 616 |
| 631 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 617 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
| 632 } | 618 } |
| 633 | 619 |
| 634 void LocationBarViewMac::Observe(int type, | 620 void LocationBarViewMac::Observe(int type, |
| 635 const content::NotificationSource& source, | 621 const content::NotificationSource& source, |
| 636 const content::NotificationDetails& details) { | 622 const content::NotificationDetails& details) { |
| 637 switch (type) { | 623 switch (type) { |
| 638 case extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { | 624 case extensions::NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED: { |
| 639 WebContents* contents = GetWebContents(); | 625 if (content::Source<WebContents>(source).ptr() != GetWebContents()) |
| 640 if (content::Details<WebContents>(contents) != details) | |
| 641 return; | 626 return; |
| 642 | 627 |
| 643 [field_ updateMouseTracking]; | 628 [field_ updateMouseTracking]; |
| 644 [field_ setNeedsDisplay:YES]; | 629 [field_ setNeedsDisplay:YES]; |
| 645 break; | 630 break; |
| 646 } | 631 } |
| 647 | 632 |
| 648 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | 633 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 649 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | 634 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
| 650 Update(NULL); | 635 Update(NULL); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 789 } |
| 805 | 790 |
| 806 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 791 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
| 807 bool is_visible = !GetToolbarModel()->input_in_progress() && | 792 bool is_visible = !GetToolbarModel()->input_in_progress() && |
| 808 browser_->search_model()->voice_search_supported(); | 793 browser_->search_model()->voice_search_supported(); |
| 809 if (mic_search_decoration_->IsVisible() == is_visible) | 794 if (mic_search_decoration_->IsVisible() == is_visible) |
| 810 return false; | 795 return false; |
| 811 mic_search_decoration_->SetVisible(is_visible); | 796 mic_search_decoration_->SetVisible(is_visible); |
| 812 return true; | 797 return true; |
| 813 } | 798 } |
| OLD | NEW |