| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #import "chrome/browser/app_controller_mac.h" | 16 #import "chrome/browser/app_controller_mac.h" |
| 17 #include "chrome/browser/command_updater.h" | 17 #include "chrome/browser/command_updater.h" |
| 18 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
| 19 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 19 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 20 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 20 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 21 #include "chrome/browser/extensions/extension_action.h" | 21 #include "chrome/browser/extensions/extension_action.h" |
| 22 #include "chrome/browser/extensions/location_bar_controller.h" | 22 #include "chrome/browser/extensions/location_bar_controller.h" |
| 23 #include "chrome/browser/extensions/tab_helper.h" | 23 #include "chrome/browser/extensions/tab_helper.h" |
| 24 #include "chrome/browser/instant/instant_controller.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
| 26 #include "chrome/browser/search_engines/template_url_service.h" | 27 #include "chrome/browser/search_engines/template_url_service.h" |
| 27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 28 #include "chrome/browser/ui/browser_instant_controller.h" | 29 #include "chrome/browser/ui/browser_instant_controller.h" |
| 29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
| 30 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" | 31 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" |
| 31 #include "chrome/browser/ui/cocoa/event_utils.h" | 32 #include "chrome/browser/ui/cocoa/event_utils.h" |
| 32 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" | 33 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" |
| 33 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 34 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 [FirstRunBubbleController showForView:field_ | 168 [FirstRunBubbleController showForView:field_ |
| 168 offset:kOffset | 169 offset:kOffset |
| 169 browser:browser_ | 170 browser:browser_ |
| 170 profile:profile_]; | 171 profile:profile_]; |
| 171 } | 172 } |
| 172 | 173 |
| 173 string16 LocationBarViewMac::GetInputString() const { | 174 string16 LocationBarViewMac::GetInputString() const { |
| 174 return location_input_; | 175 return location_input_; |
| 175 } | 176 } |
| 176 | 177 |
| 177 void LocationBarViewMac::SetInstantSuggestion( | |
| 178 const InstantSuggestion& suggestion) { | |
| 179 omnibox_view_->model()->SetInstantSuggestion(suggestion); | |
| 180 } | |
| 181 | |
| 182 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { | 178 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { |
| 183 return disposition_; | 179 return disposition_; |
| 184 } | 180 } |
| 185 | 181 |
| 186 content::PageTransition LocationBarViewMac::GetPageTransition() const { | 182 content::PageTransition LocationBarViewMac::GetPageTransition() const { |
| 187 return transition_; | 183 return transition_; |
| 188 } | 184 } |
| 189 | 185 |
| 190 void LocationBarViewMac::AcceptInput() { | 186 void LocationBarViewMac::AcceptInput() { |
| 191 WindowOpenDisposition disposition = | 187 WindowOpenDisposition disposition = |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 } | 289 } |
| 294 | 290 |
| 295 void LocationBarViewMac::OnChanged() { | 291 void LocationBarViewMac::OnChanged() { |
| 296 // Update the location-bar icon. | 292 // Update the location-bar icon. |
| 297 const int resource_id = omnibox_view_->GetIcon(); | 293 const int resource_id = omnibox_view_->GetIcon(); |
| 298 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); | 294 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); |
| 299 location_icon_decoration_->SetImage(image); | 295 location_icon_decoration_->SetImage(image); |
| 300 ev_bubble_decoration_->SetImage(image); | 296 ev_bubble_decoration_->SetImage(image); |
| 301 Layout(); | 297 Layout(); |
| 302 | 298 |
| 303 if (browser_->instant_controller()) { | 299 if (GetInstant()) |
| 304 browser_->instant_controller()->SetOmniboxBounds( | 300 GetInstant()->SetOmniboxBounds(gfx::Rect(NSRectToCGRect([field_ frame]))); |
| 305 gfx::Rect(NSRectToCGRect([field_ frame]))); | |
| 306 } | |
| 307 } | 301 } |
| 308 | 302 |
| 309 void LocationBarViewMac::OnSelectionBoundsChanged() { | 303 void LocationBarViewMac::OnSelectionBoundsChanged() { |
| 310 NOTIMPLEMENTED(); | 304 NOTIMPLEMENTED(); |
| 311 } | 305 } |
| 312 | 306 |
| 313 void LocationBarViewMac::OnInputInProgress(bool in_progress) { | 307 void LocationBarViewMac::OnInputInProgress(bool in_progress) { |
| 314 toolbar_model_->SetInputInProgress(in_progress); | 308 toolbar_model_->SetInputInProgress(in_progress); |
| 315 Update(NULL, false); | 309 Update(NULL, false); |
| 316 } | 310 } |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 if (!toolbar_model_->GetInputInProgress() && | 783 if (!toolbar_model_->GetInputInProgress() && |
| 790 toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) { | 784 toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) { |
| 791 const TemplateURL* template_url = | 785 const TemplateURL* template_url = |
| 792 TemplateURLServiceFactory::GetForProfile(profile_)-> | 786 TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 793 GetDefaultSearchProvider(); | 787 GetDefaultSearchProvider(); |
| 794 if (template_url) | 788 if (template_url) |
| 795 return template_url->short_name(); | 789 return template_url->short_name(); |
| 796 } | 790 } |
| 797 return string16(); | 791 return string16(); |
| 798 } | 792 } |
| OLD | NEW |