OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())), | 85 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())), |
86 ev_bubble_decoration_( | 86 ev_bubble_decoration_( |
87 new EVBubbleDecoration(location_icon_decoration_.get(), | 87 new EVBubbleDecoration(location_icon_decoration_.get(), |
88 OmniboxViewMac::GetFieldFont())), | 88 OmniboxViewMac::GetFieldFont())), |
89 star_decoration_(new StarDecoration(command_updater)), | 89 star_decoration_(new StarDecoration(command_updater)), |
90 keyword_hint_decoration_( | 90 keyword_hint_decoration_( |
91 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())), | 91 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())), |
92 profile_(profile), | 92 profile_(profile), |
93 browser_(browser), | 93 browser_(browser), |
94 toolbar_model_(toolbar_model), | 94 toolbar_model_(toolbar_model), |
95 transition_(PageTransition::TYPED | PageTransition::FROM_ADDRESS_BAR), | 95 transition_(content::PAGE_TRANSITION_TYPED | |
| 96 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), |
96 weak_ptr_factory_(this) { | 97 weak_ptr_factory_(this) { |
97 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 98 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
98 DCHECK_EQ(i, content_setting_decorations_.size()); | 99 DCHECK_EQ(i, content_setting_decorations_.size()); |
99 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 100 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
100 content_setting_decorations_.push_back( | 101 content_setting_decorations_.push_back( |
101 new ContentSettingDecoration(type, this, profile_)); | 102 new ContentSettingDecoration(type, this, profile_)); |
102 } | 103 } |
103 | 104 |
104 registrar_.Add(this, | 105 registrar_.Add(this, |
105 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 106 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 146 |
146 void LocationBarViewMac::SetSuggestedText(const string16& text, | 147 void LocationBarViewMac::SetSuggestedText(const string16& text, |
147 InstantCompleteBehavior behavior) { | 148 InstantCompleteBehavior behavior) { |
148 omnibox_view_->model()->SetSuggestedText(text, behavior); | 149 omnibox_view_->model()->SetSuggestedText(text, behavior); |
149 } | 150 } |
150 | 151 |
151 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { | 152 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { |
152 return disposition_; | 153 return disposition_; |
153 } | 154 } |
154 | 155 |
155 PageTransition::Type LocationBarViewMac::GetPageTransition() const { | 156 content::PageTransition LocationBarViewMac::GetPageTransition() const { |
156 return transition_; | 157 return transition_; |
157 } | 158 } |
158 | 159 |
159 void LocationBarViewMac::AcceptInput() { | 160 void LocationBarViewMac::AcceptInput() { |
160 WindowOpenDisposition disposition = | 161 WindowOpenDisposition disposition = |
161 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 162 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
162 omnibox_view_->model()->AcceptInput(disposition, false); | 163 omnibox_view_->model()->AcceptInput(disposition, false); |
163 } | 164 } |
164 | 165 |
165 void LocationBarViewMac::FocusLocation(bool select_all) { | 166 void LocationBarViewMac::FocusLocation(bool select_all) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 bool star_enabled = IsStarEnabled(); | 212 bool star_enabled = IsStarEnabled(); |
212 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 213 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
213 star_decoration_->SetVisible(star_enabled); | 214 star_decoration_->SetVisible(star_enabled); |
214 RefreshPageActionDecorations(); | 215 RefreshPageActionDecorations(); |
215 RefreshContentSettingsDecorations(); | 216 RefreshContentSettingsDecorations(); |
216 // OmniboxView restores state if the tab is non-NULL. | 217 // OmniboxView restores state if the tab is non-NULL. |
217 omnibox_view_->Update(should_restore_state ? contents : NULL); | 218 omnibox_view_->Update(should_restore_state ? contents : NULL); |
218 OnChanged(); | 219 OnChanged(); |
219 } | 220 } |
220 | 221 |
221 void LocationBarViewMac::OnAutocompleteAccept(const GURL& url, | 222 void LocationBarViewMac::OnAutocompleteAccept( |
222 WindowOpenDisposition disposition, | 223 const GURL& url, |
223 PageTransition::Type transition, | 224 WindowOpenDisposition disposition, |
224 const GURL& alternate_nav_url) { | 225 content::PageTransition transition, |
| 226 const GURL& alternate_nav_url) { |
225 // WARNING: don't add an early return here. The calls after the if must | 227 // WARNING: don't add an early return here. The calls after the if must |
226 // happen. | 228 // happen. |
227 if (url.is_valid()) { | 229 if (url.is_valid()) { |
228 location_input_ = UTF8ToUTF16(url.spec()); | 230 location_input_ = UTF8ToUTF16(url.spec()); |
229 disposition_ = disposition; | 231 disposition_ = disposition; |
230 transition_ = transition | PageTransition::FROM_ADDRESS_BAR; | 232 transition_ = transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR; |
231 | 233 |
232 if (command_updater_) { | 234 if (command_updater_) { |
233 if (!alternate_nav_url.is_valid()) { | 235 if (!alternate_nav_url.is_valid()) { |
234 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 236 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
235 } else { | 237 } else { |
236 AlternateNavURLFetcher* fetcher = | 238 AlternateNavURLFetcher* fetcher = |
237 new AlternateNavURLFetcher(alternate_nav_url); | 239 new AlternateNavURLFetcher(alternate_nav_url); |
238 // The AlternateNavURLFetcher will listen for the pending navigation | 240 // The AlternateNavURLFetcher will listen for the pending navigation |
239 // notification that will be issued as a result of the "open URL." It | 241 // notification that will be issued as a result of the "open URL." It |
240 // will automatically install itself into that navigation controller. | 242 // will automatically install itself into that navigation controller. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 639 |
638 [field_ setNeedsDisplay:YES]; | 640 [field_ setNeedsDisplay:YES]; |
639 } | 641 } |
640 | 642 |
641 bool LocationBarViewMac::IsStarEnabled() { | 643 bool LocationBarViewMac::IsStarEnabled() { |
642 return [field_ isEditable] && | 644 return [field_ isEditable] && |
643 browser_defaults::bookmarks_enabled && | 645 browser_defaults::bookmarks_enabled && |
644 !toolbar_model_->input_in_progress() && | 646 !toolbar_model_->input_in_progress() && |
645 edit_bookmarks_enabled_.GetValue(); | 647 edit_bookmarks_enabled_.GetValue(); |
646 } | 648 } |
OLD | NEW |