| 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 24 matching lines...) Expand all Loading... |
| 35 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" | 35 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" |
| 36 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 36 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 37 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" | 37 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" |
| 38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 39 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 39 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 40 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" | 40 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
| 41 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 41 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
| 42 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h
" | 42 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h
" |
| 43 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" | 43 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
| 44 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 44 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
| 45 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
| 45 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" | 46 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" |
| 46 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h" | 47 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h" |
| 47 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" | 48 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" |
| 48 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" | 49 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" |
| 49 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" | 50 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
| 50 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 51 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| 51 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" | 52 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" |
| 52 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 53 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| 53 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 54 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 54 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 55 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 55 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 56 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 56 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 57 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 58 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 59 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 58 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 60 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 59 #include "chrome/browser/ui/zoom/zoom_controller.h" | 61 #include "chrome/browser/ui/zoom/zoom_controller.h" |
| 60 #include "chrome/common/chrome_switches.h" | 62 #include "chrome/common/chrome_switches.h" |
| 61 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
| 62 #include "components/search_engines/template_url.h" | 64 #include "components/search_engines/template_url.h" |
| 63 #include "components/search_engines/template_url_service.h" | 65 #include "components/search_engines/template_url_service.h" |
| 64 #include "components/translate/core/browser/language_state.h" | 66 #include "components/translate/core/browser/language_state.h" |
| 65 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
| 66 #include "content/public/browser/web_contents.h" | 68 #include "content/public/browser/web_contents.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 ev_bubble_decoration_( | 126 ev_bubble_decoration_( |
| 125 new EVBubbleDecoration(location_icon_decoration_.get())), | 127 new EVBubbleDecoration(location_icon_decoration_.get())), |
| 126 star_decoration_(new StarDecoration(command_updater)), | 128 star_decoration_(new StarDecoration(command_updater)), |
| 127 translate_decoration_(new TranslateDecoration(command_updater)), | 129 translate_decoration_(new TranslateDecoration(command_updater)), |
| 128 zoom_decoration_(new ZoomDecoration(this)), | 130 zoom_decoration_(new ZoomDecoration(this)), |
| 129 keyword_hint_decoration_(new KeywordHintDecoration()), | 131 keyword_hint_decoration_(new KeywordHintDecoration()), |
| 130 mic_search_decoration_(new MicSearchDecoration(command_updater)), | 132 mic_search_decoration_(new MicSearchDecoration(command_updater)), |
| 131 generated_credit_card_decoration_( | 133 generated_credit_card_decoration_( |
| 132 new GeneratedCreditCardDecoration(this)), | 134 new GeneratedCreditCardDecoration(this)), |
| 133 search_button_decoration_(new SearchButtonDecoration(this)), | 135 search_button_decoration_(new SearchButtonDecoration(this)), |
| 136 manage_passwords_decoration_( |
| 137 new ManagePasswordsDecoration(command_updater)), |
| 134 browser_(browser), | 138 browser_(browser), |
| 135 weak_ptr_factory_(this) { | 139 weak_ptr_factory_(this) { |
| 136 | |
| 137 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 140 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 138 DCHECK_EQ(i, content_setting_decorations_.size()); | 141 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 139 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 142 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 140 content_setting_decorations_.push_back( | 143 content_setting_decorations_.push_back( |
| 141 new ContentSettingDecoration(type, this, profile)); | 144 new ContentSettingDecoration(type, this, profile)); |
| 142 } | 145 } |
| 143 | 146 |
| 144 registrar_.Add( | 147 registrar_.Add( |
| 145 this, chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 148 this, chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 146 content::NotificationService::AllSources()); | 149 content::NotificationService::AllSources()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 207 |
| 205 void LocationBarViewMac::FocusSearch() { | 208 void LocationBarViewMac::FocusSearch() { |
| 206 omnibox_view_->SetForcedQuery(); | 209 omnibox_view_->SetForcedQuery(); |
| 207 } | 210 } |
| 208 | 211 |
| 209 void LocationBarViewMac::UpdateContentSettingsIcons() { | 212 void LocationBarViewMac::UpdateContentSettingsIcons() { |
| 210 if (RefreshContentSettingsDecorations()) | 213 if (RefreshContentSettingsDecorations()) |
| 211 OnDecorationsChanged(); | 214 OnDecorationsChanged(); |
| 212 } | 215 } |
| 213 | 216 |
| 217 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() { |
| 218 WebContents* web_contents = GetWebContents(); |
| 219 if (!web_contents) |
| 220 return; |
| 221 ManagePasswordsUIController::FromWebContents(web_contents) |
| 222 ->UpdateIconAndBubbleState(manage_passwords_decoration_.get()); |
| 223 } |
| 224 |
| 214 void LocationBarViewMac::UpdatePageActions() { | 225 void LocationBarViewMac::UpdatePageActions() { |
| 215 size_t count_before = page_action_decorations_.size(); | 226 size_t count_before = page_action_decorations_.size(); |
| 216 RefreshPageActionDecorations(); | 227 RefreshPageActionDecorations(); |
| 217 Layout(); | 228 Layout(); |
| 218 if (page_action_decorations_.size() != count_before) { | 229 if (page_action_decorations_.size() != count_before) { |
| 219 content::NotificationService::current()->Notify( | 230 content::NotificationService::current()->Notify( |
| 220 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 231 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 221 content::Source<LocationBar>(this), | 232 content::Source<LocationBar>(this), |
| 222 content::NotificationService::NoDetails()); | 233 content::NotificationService::NoDetails()); |
| 223 } | 234 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 363 |
| 353 NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const { | 364 NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const { |
| 354 DCHECK(IsStarEnabled()); | 365 DCHECK(IsStarEnabled()); |
| 355 return [field_ bubblePointForDecoration:star_decoration_.get()]; | 366 return [field_ bubblePointForDecoration:star_decoration_.get()]; |
| 356 } | 367 } |
| 357 | 368 |
| 358 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { | 369 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { |
| 359 return [field_ bubblePointForDecoration:translate_decoration_.get()]; | 370 return [field_ bubblePointForDecoration:translate_decoration_.get()]; |
| 360 } | 371 } |
| 361 | 372 |
| 373 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { |
| 374 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()]; |
| 375 } |
| 376 |
| 362 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { | 377 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { |
| 363 if (origin_chip_decoration_ && origin_chip_decoration_->IsVisible()) { | 378 if (origin_chip_decoration_ && origin_chip_decoration_->IsVisible()) { |
| 364 return [field_ bubblePointForDecoration:origin_chip_decoration_.get()]; | 379 return [field_ bubblePointForDecoration:origin_chip_decoration_.get()]; |
| 365 } else if (ev_bubble_decoration_->IsVisible()) { | 380 } else if (ev_bubble_decoration_->IsVisible()) { |
| 366 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; | 381 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; |
| 367 } else { | 382 } else { |
| 368 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; | 383 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; |
| 369 } | 384 } |
| 370 } | 385 } |
| 371 | 386 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 396 [cell addLeftDecoration:origin_chip_decoration_.get()]; | 411 [cell addLeftDecoration:origin_chip_decoration_.get()]; |
| 397 [cell addLeftDecoration:location_icon_decoration_.get()]; | 412 [cell addLeftDecoration:location_icon_decoration_.get()]; |
| 398 [cell addLeftDecoration:selected_keyword_decoration_.get()]; | 413 [cell addLeftDecoration:selected_keyword_decoration_.get()]; |
| 399 if (!origin_chip_decoration_.get()) | 414 if (!origin_chip_decoration_.get()) |
| 400 [cell addLeftDecoration:ev_bubble_decoration_.get()]; | 415 [cell addLeftDecoration:ev_bubble_decoration_.get()]; |
| 401 [cell addRightDecoration:search_button_decoration_.get()]; | 416 [cell addRightDecoration:search_button_decoration_.get()]; |
| 402 [cell addRightDecoration:star_decoration_.get()]; | 417 [cell addRightDecoration:star_decoration_.get()]; |
| 403 [cell addRightDecoration:translate_decoration_.get()]; | 418 [cell addRightDecoration:translate_decoration_.get()]; |
| 404 [cell addRightDecoration:zoom_decoration_.get()]; | 419 [cell addRightDecoration:zoom_decoration_.get()]; |
| 405 [cell addRightDecoration:generated_credit_card_decoration_.get()]; | 420 [cell addRightDecoration:generated_credit_card_decoration_.get()]; |
| 421 [cell addRightDecoration:manage_passwords_decoration_.get()]; |
| 406 | 422 |
| 407 // Note that display order is right to left. | 423 // Note that display order is right to left. |
| 408 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 424 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
| 409 [cell addRightDecoration:page_action_decorations_[i]]; | 425 [cell addRightDecoration:page_action_decorations_[i]]; |
| 410 } | 426 } |
| 411 | 427 |
| 412 for (ScopedVector<ContentSettingDecoration>::iterator i = | 428 for (ScopedVector<ContentSettingDecoration>::iterator i = |
| 413 content_setting_decorations_.begin(); | 429 content_setting_decorations_.begin(); |
| 414 i != content_setting_decorations_.end(); ++i) { | 430 i != content_setting_decorations_.end(); ++i) { |
| 415 [cell addRightDecoration:*i]; | 431 [cell addRightDecoration:*i]; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 } | 801 } |
| 786 | 802 |
| 787 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 803 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
| 788 bool is_visible = !GetToolbarModel()->input_in_progress() && | 804 bool is_visible = !GetToolbarModel()->input_in_progress() && |
| 789 browser_->search_model()->voice_search_supported(); | 805 browser_->search_model()->voice_search_supported(); |
| 790 if (mic_search_decoration_->IsVisible() == is_visible) | 806 if (mic_search_decoration_->IsVisible() == is_visible) |
| 791 return false; | 807 return false; |
| 792 mic_search_decoration_->SetVisible(is_visible); | 808 mic_search_decoration_->SetVisible(is_visible); |
| 793 return true; | 809 return true; |
| 794 } | 810 } |
| OLD | NEW |