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 25 matching lines...) Expand all Loading... |
36 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 36 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
38 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" | 38 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
39 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 39 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
40 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h
" | 40 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h
" |
41 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" | 41 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
42 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 42 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
43 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" | 43 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
44 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" | 44 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" |
45 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" | 45 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" |
46 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" | |
47 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" | 46 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
48 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 47 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
49 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" | 48 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" |
50 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 49 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
51 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 50 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
52 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 51 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
53 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 52 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
54 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 53 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
55 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 54 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
56 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 55 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 selected_keyword_decoration_(new SelectedKeywordDecoration()), | 105 selected_keyword_decoration_(new SelectedKeywordDecoration()), |
107 ev_bubble_decoration_( | 106 ev_bubble_decoration_( |
108 new EVBubbleDecoration(location_icon_decoration_.get())), | 107 new EVBubbleDecoration(location_icon_decoration_.get())), |
109 star_decoration_(new StarDecoration(command_updater)), | 108 star_decoration_(new StarDecoration(command_updater)), |
110 translate_decoration_(new TranslateDecoration(command_updater)), | 109 translate_decoration_(new TranslateDecoration(command_updater)), |
111 zoom_decoration_(new ZoomDecoration(this)), | 110 zoom_decoration_(new ZoomDecoration(this)), |
112 keyword_hint_decoration_(new KeywordHintDecoration()), | 111 keyword_hint_decoration_(new KeywordHintDecoration()), |
113 mic_search_decoration_(new MicSearchDecoration(command_updater)), | 112 mic_search_decoration_(new MicSearchDecoration(command_updater)), |
114 generated_credit_card_decoration_( | 113 generated_credit_card_decoration_( |
115 new GeneratedCreditCardDecoration(this)), | 114 new GeneratedCreditCardDecoration(this)), |
116 search_button_decoration_(new SearchButtonDecoration(this)), | |
117 manage_passwords_decoration_( | 115 manage_passwords_decoration_( |
118 new ManagePasswordsDecoration(command_updater, this)), | 116 new ManagePasswordsDecoration(command_updater, this)), |
119 browser_(browser), | 117 browser_(browser), |
120 weak_ptr_factory_(this) { | 118 weak_ptr_factory_(this) { |
121 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 119 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
122 DCHECK_EQ(i, content_setting_decorations_.size()); | 120 DCHECK_EQ(i, content_setting_decorations_.size()); |
123 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 121 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
124 content_setting_decorations_.push_back( | 122 content_setting_decorations_.push_back( |
125 new ContentSettingDecoration(type, this, profile)); | 123 new ContentSettingDecoration(type, this, profile)); |
126 } | 124 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 AutocompleteTextFieldCell* cell = [field_ cell]; | 388 AutocompleteTextFieldCell* cell = [field_ cell]; |
391 | 389 |
392 // Reset the left-hand decorations. | 390 // Reset the left-hand decorations. |
393 // TODO(shess): Shortly, this code will live somewhere else, like in | 391 // TODO(shess): Shortly, this code will live somewhere else, like in |
394 // the constructor. I am still wrestling with how best to deal with | 392 // the constructor. I am still wrestling with how best to deal with |
395 // right-hand decorations, which are not a static set. | 393 // right-hand decorations, which are not a static set. |
396 [cell clearDecorations]; | 394 [cell clearDecorations]; |
397 [cell addLeftDecoration:location_icon_decoration_.get()]; | 395 [cell addLeftDecoration:location_icon_decoration_.get()]; |
398 [cell addLeftDecoration:selected_keyword_decoration_.get()]; | 396 [cell addLeftDecoration:selected_keyword_decoration_.get()]; |
399 [cell addLeftDecoration:ev_bubble_decoration_.get()]; | 397 [cell addLeftDecoration:ev_bubble_decoration_.get()]; |
400 [cell addRightDecoration:search_button_decoration_.get()]; | |
401 [cell addRightDecoration:star_decoration_.get()]; | 398 [cell addRightDecoration:star_decoration_.get()]; |
402 [cell addRightDecoration:translate_decoration_.get()]; | 399 [cell addRightDecoration:translate_decoration_.get()]; |
403 [cell addRightDecoration:zoom_decoration_.get()]; | 400 [cell addRightDecoration:zoom_decoration_.get()]; |
404 [cell addRightDecoration:generated_credit_card_decoration_.get()]; | 401 [cell addRightDecoration:generated_credit_card_decoration_.get()]; |
405 [cell addRightDecoration:manage_passwords_decoration_.get()]; | 402 [cell addRightDecoration:manage_passwords_decoration_.get()]; |
406 | 403 |
407 // Note that display order is right to left. | 404 // Note that display order is right to left. |
408 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 405 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
409 [cell addRightDecoration:page_action_decorations_[i]]; | 406 [cell addRightDecoration:page_action_decorations_[i]]; |
410 } | 407 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 omnibox_view_->Update(); | 532 omnibox_view_->Update(); |
536 OnChanged(); | 533 OnChanged(); |
537 } | 534 } |
538 | 535 |
539 void LocationBarViewMac::OnChanged() { | 536 void LocationBarViewMac::OnChanged() { |
540 // Update the location-bar icon. | 537 // Update the location-bar icon. |
541 const int resource_id = omnibox_view_->GetIcon(); | 538 const int resource_id = omnibox_view_->GetIcon(); |
542 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); | 539 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); |
543 location_icon_decoration_->SetImage(image); | 540 location_icon_decoration_->SetImage(image); |
544 ev_bubble_decoration_->SetImage(image); | 541 ev_bubble_decoration_->SetImage(image); |
545 | |
546 ToolbarModel* toolbar_model = GetToolbarModel(); | |
547 const chrome::DisplaySearchButtonConditions conditions = | |
548 chrome::GetDisplaySearchButtonConditions(); | |
549 const bool meets_conditions = | |
550 (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) || | |
551 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && | |
552 (toolbar_model->WouldPerformSearchTermReplacement(true) || | |
553 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && | |
554 toolbar_model->input_in_progress()))); | |
555 search_button_decoration_->SetVisible( | |
556 ![[field_ cell] isPopupMode] && meets_conditions); | |
557 search_button_decoration_->SetIcon( | |
558 (resource_id == IDR_OMNIBOX_SEARCH) ? | |
559 IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW); | |
560 | |
561 Layout(); | 542 Layout(); |
562 | 543 |
563 InstantService* instant_service = | 544 InstantService* instant_service = |
564 InstantServiceFactory::GetForProfile(profile()); | 545 InstantServiceFactory::GetForProfile(profile()); |
565 if (instant_service) { | 546 if (instant_service) { |
566 gfx::Rect bounds(NSRectToCGRect([field_ frame])); | 547 gfx::Rect bounds(NSRectToCGRect([field_ frame])); |
567 instant_service->OnOmniboxStartMarginChanged(bounds.x()); | 548 instant_service->OnOmniboxStartMarginChanged(bounds.x()); |
568 } | 549 } |
569 } | 550 } |
570 | 551 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 } | 737 } |
757 | 738 |
758 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 739 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
759 bool is_visible = !GetToolbarModel()->input_in_progress() && | 740 bool is_visible = !GetToolbarModel()->input_in_progress() && |
760 browser_->search_model()->voice_search_supported(); | 741 browser_->search_model()->voice_search_supported(); |
761 if (mic_search_decoration_->IsVisible() == is_visible) | 742 if (mic_search_decoration_->IsVisible() == is_visible) |
762 return false; | 743 return false; |
763 mic_search_decoration_->SetVisible(is_visible); | 744 mic_search_decoration_->SetVisible(is_visible); |
764 return true; | 745 return true; |
765 } | 746 } |
OLD | NEW |