Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 12089102: Make most code on mac compile with enable_web_intents=0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ffff Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())), 101 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())),
102 separator_decoration_(new SeparatorDecoration()), 102 separator_decoration_(new SeparatorDecoration()),
103 ev_bubble_decoration_( 103 ev_bubble_decoration_(
104 new EVBubbleDecoration(location_icon_decoration_.get(), 104 new EVBubbleDecoration(location_icon_decoration_.get(),
105 OmniboxViewMac::GetFieldFont())), 105 OmniboxViewMac::GetFieldFont())),
106 plus_decoration_(NULL), 106 plus_decoration_(NULL),
107 star_decoration_(new StarDecoration(command_updater)), 107 star_decoration_(new StarDecoration(command_updater)),
108 zoom_decoration_(new ZoomDecoration(toolbar_model)), 108 zoom_decoration_(new ZoomDecoration(toolbar_model)),
109 keyword_hint_decoration_( 109 keyword_hint_decoration_(
110 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())), 110 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())),
111 #if defined(ENABLE_WEB_INTENTS)
111 web_intents_button_decoration_( 112 web_intents_button_decoration_(
112 new WebIntentsButtonDecoration(this, OmniboxViewMac::GetFieldFont())), 113 new WebIntentsButtonDecoration(this, OmniboxViewMac::GetFieldFont())),
114 #endif
113 profile_(profile), 115 profile_(profile),
114 browser_(browser), 116 browser_(browser),
115 toolbar_model_(toolbar_model), 117 toolbar_model_(toolbar_model),
116 transition_(content::PageTransitionFromInt( 118 transition_(content::PageTransitionFromInt(
117 content::PAGE_TRANSITION_TYPED | 119 content::PAGE_TRANSITION_TYPED |
118 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), 120 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)),
119 weak_ptr_factory_(this) { 121 weak_ptr_factory_(this) {
120 if (extensions::FeatureSwitch::action_box()->IsEnabled()) { 122 if (extensions::FeatureSwitch::action_box()->IsEnabled()) {
121 plus_decoration_.reset(new PlusDecoration(this, browser_)); 123 plus_decoration_.reset(new PlusDecoration(this, browser_));
122 } 124 }
123 125
124 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 126 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
125 DCHECK_EQ(i, content_setting_decorations_.size()); 127 DCHECK_EQ(i, content_setting_decorations_.size());
126 ContentSettingsType type = static_cast<ContentSettingsType>(i); 128 ContentSettingsType type = static_cast<ContentSettingsType>(i);
127 content_setting_decorations_.push_back( 129 content_setting_decorations_.push_back(
128 new ContentSettingDecoration(type, this, profile_)); 130 new ContentSettingDecoration(type, this, profile_));
129 } 131 }
130 132
133 #if defined(ENABLE_WEB_INTENTS)
131 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 134 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
132 web_intents_button_decoration_->SetButtonImages( 135 web_intents_button_decoration_->SetButtonImages(
133 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L).ToNSImage(), 136 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L).ToNSImage(),
134 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C).ToNSImage(), 137 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C).ToNSImage(),
135 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R).ToNSImage()); 138 rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R).ToNSImage());
139 #endif
136 140
137 registrar_.Add(this, 141 registrar_.Add(this,
138 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 142 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
139 content::NotificationService::AllSources()); 143 content::NotificationService::AllSources());
140 registrar_.Add(this, 144 registrar_.Add(this,
141 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, 145 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED,
142 content::Source<Profile>(browser_->profile())); 146 content::Source<Profile>(browser_->profile()));
143 147
144 edit_bookmarks_enabled_.Init( 148 edit_bookmarks_enabled_.Init(
145 prefs::kEditBookmarksEnabled, 149 prefs::kEditBookmarksEnabled,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 DeletePageActionDecorations(); 239 DeletePageActionDecorations();
236 Layout(); 240 Layout();
237 if (page_action_decorations_.size() != count_before) { 241 if (page_action_decorations_.size() != count_before) {
238 content::NotificationService::current()->Notify( 242 content::NotificationService::current()->Notify(
239 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, 243 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
240 content::Source<LocationBar>(this), 244 content::Source<LocationBar>(this),
241 content::NotificationService::NoDetails()); 245 content::NotificationService::NoDetails());
242 } 246 }
243 } 247 }
244 248
249 #if defined(ENABLE_WEB_INTENTS)
245 void LocationBarViewMac::UpdateWebIntentsButton() { 250 void LocationBarViewMac::UpdateWebIntentsButton() {
246 RefreshWebIntentsButtonDecoration(); 251 RefreshWebIntentsButtonDecoration();
247 } 252 }
253 #endif
248 254
249 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { 255 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() {
250 // Not implemented on Mac. 256 // Not implemented on Mac.
251 } 257 }
252 258
253 void LocationBarViewMac::SaveStateToContents(WebContents* contents) { 259 void LocationBarViewMac::SaveStateToContents(WebContents* contents) {
254 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? 260 // TODO(shess): Why SaveStateToContents vs SaveStateToTab?
255 omnibox_view_->SaveStateToTab(contents); 261 omnibox_view_->SaveStateToTab(contents);
256 } 262 }
257 263
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 666
661 GURL url = toolbar_model_->GetURL(); 667 GURL url = toolbar_model_->GetURL();
662 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 668 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
663 page_action_decorations_[i]->UpdateVisibility( 669 page_action_decorations_[i]->UpdateVisibility(
664 toolbar_model_->GetInputInProgress() ? NULL : web_contents, 670 toolbar_model_->GetInputInProgress() ? NULL : web_contents,
665 url); 671 url);
666 } 672 }
667 } 673 }
668 674
669 void LocationBarViewMac::RefreshWebIntentsButtonDecoration() { 675 void LocationBarViewMac::RefreshWebIntentsButtonDecoration() {
676 #if defined(ENABLE_WEB_INTENTS)
670 WebContents* web_contents = GetWebContents(); 677 WebContents* web_contents = GetWebContents();
671 if (!web_contents) { 678 if (!web_contents) {
672 web_intents_button_decoration_->SetVisible(false); 679 web_intents_button_decoration_->SetVisible(false);
673 return; 680 return;
674 } 681 }
675 682
676 web_intents_button_decoration_->Update(web_contents); 683 web_intents_button_decoration_->Update(web_contents);
684 #endif
677 } 685 }
678 686
679 // TODO(shess): This function should over time grow to closely match 687 // TODO(shess): This function should over time grow to closely match
680 // the views Layout() function. 688 // the views Layout() function.
681 void LocationBarViewMac::Layout() { 689 void LocationBarViewMac::Layout() {
682 AutocompleteTextFieldCell* cell = [field_ cell]; 690 AutocompleteTextFieldCell* cell = [field_ cell];
683 691
684 // Reset the left-hand decorations. 692 // Reset the left-hand decorations.
685 // TODO(shess): Shortly, this code will live somewhere else, like in 693 // TODO(shess): Shortly, this code will live somewhere else, like in
686 // the constructor. I am still wrestling with how best to deal with 694 // the constructor. I am still wrestling with how best to deal with
(...skipping 11 matching lines...) Expand all
698 // Note that display order is right to left. 706 // Note that display order is right to left.
699 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 707 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
700 [cell addRightDecoration:page_action_decorations_[i]]; 708 [cell addRightDecoration:page_action_decorations_[i]];
701 } 709 }
702 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { 710 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) {
703 [cell addRightDecoration:content_setting_decorations_[i]]; 711 [cell addRightDecoration:content_setting_decorations_[i]];
704 } 712 }
705 713
706 [cell addRightDecoration:keyword_hint_decoration_.get()]; 714 [cell addRightDecoration:keyword_hint_decoration_.get()];
707 715
716 #if defined(ENABLE_WEB_INTENTS)
708 [cell addRightDecoration:web_intents_button_decoration_.get()]; 717 [cell addRightDecoration:web_intents_button_decoration_.get()];
718 #endif
719
709 [cell addRightDecoration:separator_decoration_.get()]; 720 [cell addRightDecoration:separator_decoration_.get()];
710 [cell addRightDecoration:search_token_decoration_.get()]; 721 [cell addRightDecoration:search_token_decoration_.get()];
711 722
712 // By default only the location icon is visible. 723 // By default only the location icon is visible.
713 location_icon_decoration_->SetVisible(true); 724 location_icon_decoration_->SetVisible(true);
714 selected_keyword_decoration_->SetVisible(false); 725 selected_keyword_decoration_->SetVisible(false);
715 ev_bubble_decoration_->SetVisible(false); 726 ev_bubble_decoration_->SetVisible(false);
716 keyword_hint_decoration_->SetVisible(false); 727 keyword_hint_decoration_->SetVisible(false);
717 separator_decoration_->SetVisible(false); 728 separator_decoration_->SetVisible(false);
718 search_token_decoration_->SetVisible(false); 729 search_token_decoration_->SetVisible(false);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 if (!toolbar_model_->GetInputInProgress() && 820 if (!toolbar_model_->GetInputInProgress() &&
810 toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) { 821 toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) {
811 const TemplateURL* template_url = 822 const TemplateURL* template_url =
812 TemplateURLServiceFactory::GetForProfile(profile_)-> 823 TemplateURLServiceFactory::GetForProfile(profile_)->
813 GetDefaultSearchProvider(); 824 GetDefaultSearchProvider();
814 if (template_url) 825 if (template_url)
815 return template_url->short_name(); 826 return template_url->short_name();
816 } 827 }
817 return string16(); 828 return string16();
818 } 829 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/extensions/shell_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698