| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 new EVBubbleDecoration(location_icon_decoration_.get())), | 124 new EVBubbleDecoration(location_icon_decoration_.get())), |
| 125 star_decoration_(new StarDecoration(command_updater)), | 125 star_decoration_(new StarDecoration(command_updater)), |
| 126 translate_decoration_(new TranslateDecoration(command_updater)), | 126 translate_decoration_(new TranslateDecoration(command_updater)), |
| 127 zoom_decoration_(new ZoomDecoration(this)), | 127 zoom_decoration_(new ZoomDecoration(this)), |
| 128 keyword_hint_decoration_(new KeywordHintDecoration()), | 128 keyword_hint_decoration_(new KeywordHintDecoration()), |
| 129 mic_search_decoration_(new MicSearchDecoration(command_updater)), | 129 mic_search_decoration_(new MicSearchDecoration(command_updater)), |
| 130 generated_credit_card_decoration_( | 130 generated_credit_card_decoration_( |
| 131 new GeneratedCreditCardDecoration(this)), | 131 new GeneratedCreditCardDecoration(this)), |
| 132 search_button_decoration_(new SearchButtonDecoration(this)), | 132 search_button_decoration_(new SearchButtonDecoration(this)), |
| 133 manage_passwords_decoration_( | 133 manage_passwords_decoration_( |
| 134 new ManagePasswordsDecoration(command_updater)), | 134 new ManagePasswordsDecoration(command_updater, this)), |
| 135 browser_(browser), | 135 browser_(browser), |
| 136 weak_ptr_factory_(this) { | 136 weak_ptr_factory_(this) { |
| 137 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 137 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 138 DCHECK_EQ(i, content_setting_decorations_.size()); | 138 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 139 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 139 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 140 content_setting_decorations_.push_back( | 140 content_setting_decorations_.push_back( |
| 141 new ContentSettingDecoration(type, this, profile)); | 141 new ContentSettingDecoration(type, this, profile)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 edit_bookmarks_enabled_.Init( | 144 edit_bookmarks_enabled_.Init( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (RefreshContentSettingsDecorations()) | 201 if (RefreshContentSettingsDecorations()) |
| 202 OnDecorationsChanged(); | 202 OnDecorationsChanged(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() { | 205 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() { |
| 206 WebContents* web_contents = GetWebContents(); | 206 WebContents* web_contents = GetWebContents(); |
| 207 if (!web_contents) | 207 if (!web_contents) |
| 208 return; | 208 return; |
| 209 ManagePasswordsUIController::FromWebContents(web_contents) | 209 ManagePasswordsUIController::FromWebContents(web_contents) |
| 210 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); | 210 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon()); |
| 211 OnDecorationsChanged(); |
| 211 } | 212 } |
| 212 | 213 |
| 213 void LocationBarViewMac::UpdatePageActions() { | 214 void LocationBarViewMac::UpdatePageActions() { |
| 214 RefreshPageActionDecorations(); | 215 RefreshPageActionDecorations(); |
| 215 Layout(); | 216 Layout(); |
| 216 | 217 |
| 217 [field_ updateMouseTracking]; | 218 [field_ updateMouseTracking]; |
| 218 [field_ setNeedsDisplay:YES]; | 219 [field_ setNeedsDisplay:YES]; |
| 219 } | 220 } |
| 220 | 221 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // near the top left corner (unanchored). | 520 // near the top left corner (unanchored). |
| 520 NOTREACHED(); | 521 NOTREACHED(); |
| 521 return NSZeroPoint; | 522 return NSZeroPoint; |
| 522 } | 523 } |
| 523 | 524 |
| 524 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); | 525 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); |
| 525 return [field_ convertPoint:bubble_point toView:nil]; | 526 return [field_ convertPoint:bubble_point toView:nil]; |
| 526 } | 527 } |
| 527 | 528 |
| 528 void LocationBarViewMac::Update(const WebContents* contents) { | 529 void LocationBarViewMac::Update(const WebContents* contents) { |
| 530 UpdateManagePasswordsIconAndBubble(); |
| 529 UpdateStarDecorationVisibility(); | 531 UpdateStarDecorationVisibility(); |
| 530 UpdateTranslateDecoration(); | 532 UpdateTranslateDecoration(); |
| 531 UpdateZoomDecoration(); | 533 UpdateZoomDecoration(); |
| 532 RefreshPageActionDecorations(); | 534 RefreshPageActionDecorations(); |
| 533 RefreshContentSettingsDecorations(); | 535 RefreshContentSettingsDecorations(); |
| 534 UpdateMicSearchDecorationVisibility(); | 536 UpdateMicSearchDecorationVisibility(); |
| 535 UpdateGeneratedCreditCardView(); | 537 UpdateGeneratedCreditCardView(); |
| 536 if (contents) | 538 if (contents) |
| 537 omnibox_view_->OnTabChanged(contents); | 539 omnibox_view_->OnTabChanged(contents); |
| 538 else | 540 else |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 } | 761 } |
| 760 | 762 |
| 761 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 763 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
| 762 bool is_visible = !GetToolbarModel()->input_in_progress() && | 764 bool is_visible = !GetToolbarModel()->input_in_progress() && |
| 763 browser_->search_model()->voice_search_supported(); | 765 browser_->search_model()->voice_search_supported(); |
| 764 if (mic_search_decoration_->IsVisible() == is_visible) | 766 if (mic_search_decoration_->IsVisible() == is_visible) |
| 765 return false; | 767 return false; |
| 766 mic_search_decoration_->SetVisible(is_visible); | 768 mic_search_decoration_->SetVisible(is_visible); |
| 767 return true; | 769 return true; |
| 768 } | 770 } |
| OLD | NEW |