| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/location_bar_view_mac.h" | 5 #import "chrome/browser/cocoa/location_bar_view_mac.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 AutocompletePopupPositioner* positioner, | 49 AutocompletePopupPositioner* positioner, |
| 50 CommandUpdater* command_updater, | 50 CommandUpdater* command_updater, |
| 51 ToolbarModel* toolbar_model, | 51 ToolbarModel* toolbar_model, |
| 52 Profile* profile) | 52 Profile* profile) |
| 53 : edit_view_(new AutocompleteEditViewMac(this, positioner, toolbar_model, | 53 : edit_view_(new AutocompleteEditViewMac(this, positioner, toolbar_model, |
| 54 profile, command_updater, field)), | 54 profile, command_updater, field)), |
| 55 command_updater_(command_updater), | 55 command_updater_(command_updater), |
| 56 field_(field), | 56 field_(field), |
| 57 disposition_(CURRENT_TAB), | 57 disposition_(CURRENT_TAB), |
| 58 profile_(profile), | 58 profile_(profile), |
| 59 toolbar_model_(toolbar_model), |
| 59 transition_(PageTransition::TYPED) { | 60 transition_(PageTransition::TYPED) { |
| 60 } | 61 } |
| 61 | 62 |
| 62 LocationBarViewMac::~LocationBarViewMac() { | 63 LocationBarViewMac::~LocationBarViewMac() { |
| 63 // TODO(shess): Placeholder for omnibox changes. | 64 // TODO(shess): Placeholder for omnibox changes. |
| 64 } | 65 } |
| 65 | 66 |
| 66 std::wstring LocationBarViewMac::GetInputString() const { | 67 std::wstring LocationBarViewMac::GetInputString() const { |
| 67 return location_input_; | 68 return location_input_; |
| 68 } | 69 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // TODO(pkasting): Focus the edit a la Linux/Win | 101 // TODO(pkasting): Focus the edit a la Linux/Win |
| 101 } | 102 } |
| 102 | 103 |
| 103 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { | 104 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { |
| 104 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? | 105 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? |
| 105 edit_view_->SaveStateToTab(contents); | 106 edit_view_->SaveStateToTab(contents); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void LocationBarViewMac::Update(const TabContents* contents, | 109 void LocationBarViewMac::Update(const TabContents* contents, |
| 109 bool should_restore_state) { | 110 bool should_restore_state) { |
| 111 SetSecurityIcon(toolbar_model_->GetIcon()); |
| 110 // AutocompleteEditView restores state if the tab is non-NULL. | 112 // AutocompleteEditView restores state if the tab is non-NULL. |
| 111 edit_view_->Update(should_restore_state ? contents : NULL); | 113 edit_view_->Update(should_restore_state ? contents : NULL); |
| 112 } | 114 } |
| 113 | 115 |
| 114 void LocationBarViewMac::OnAutocompleteAccept(const GURL& url, | 116 void LocationBarViewMac::OnAutocompleteAccept(const GURL& url, |
| 115 WindowOpenDisposition disposition, | 117 WindowOpenDisposition disposition, |
| 116 PageTransition::Type transition, | 118 PageTransition::Type transition, |
| 117 const GURL& alternate_nav_url) { | 119 const GURL& alternate_nav_url) { |
| 118 if (!url.is_valid()) | 120 if (!url.is_valid()) |
| 119 return; | 121 return; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // makes me sad. I should fix that. | 216 // makes me sad. I should fix that. |
| 215 OnChangedImpl(field_, | 217 OnChangedImpl(field_, |
| 216 keyword, | 218 keyword, |
| 217 short_name, | 219 short_name, |
| 218 edit_view_->model()->is_keyword_hint(), | 220 edit_view_->model()->is_keyword_hint(), |
| 219 edit_view_->model()->show_search_hint(), | 221 edit_view_->model()->show_search_hint(), |
| 220 GetTabButtonImage()); | 222 GetTabButtonImage()); |
| 221 } | 223 } |
| 222 | 224 |
| 223 void LocationBarViewMac::OnInputInProgress(bool in_progress) { | 225 void LocationBarViewMac::OnInputInProgress(bool in_progress) { |
| 224 NOTIMPLEMENTED(); | 226 toolbar_model_->set_input_in_progress(in_progress); |
| 227 Update(NULL, false); |
| 225 } | 228 } |
| 226 | 229 |
| 227 void LocationBarViewMac::OnSetFocus() { | 230 void LocationBarViewMac::OnSetFocus() { |
| 228 } | 231 } |
| 229 | 232 |
| 230 SkBitmap LocationBarViewMac::GetFavIcon() const { | 233 SkBitmap LocationBarViewMac::GetFavIcon() const { |
| 231 NOTIMPLEMENTED(); | 234 NOTIMPLEMENTED(); |
| 232 return SkBitmap(); | 235 return SkBitmap(); |
| 233 } | 236 } |
| 234 | 237 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 249 NSImage* LocationBarViewMac::GetTabButtonImage() { | 252 NSImage* LocationBarViewMac::GetTabButtonImage() { |
| 250 if (!tab_button_image_) { | 253 if (!tab_button_image_) { |
| 251 SkBitmap* skiaBitmap = ResourceBundle::GetSharedInstance(). | 254 SkBitmap* skiaBitmap = ResourceBundle::GetSharedInstance(). |
| 252 GetBitmapNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB); | 255 GetBitmapNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB); |
| 253 if (skiaBitmap) { | 256 if (skiaBitmap) { |
| 254 tab_button_image_.reset([gfx::SkBitmapToNSImage(*skiaBitmap) retain]); | 257 tab_button_image_.reset([gfx::SkBitmapToNSImage(*skiaBitmap) retain]); |
| 255 } | 258 } |
| 256 } | 259 } |
| 257 return tab_button_image_; | 260 return tab_button_image_; |
| 258 } | 261 } |
| 262 |
| 263 void LocationBarViewMac::SetSecurityIcon(ToolbarModel::Icon security_icon) { |
| 264 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 265 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 266 switch (security_icon) { |
| 267 case ToolbarModel::LOCK_ICON: |
| 268 [cell setHintIcon:rb.GetNSImageNamed(IDR_LOCK)]; |
| 269 break; |
| 270 case ToolbarModel::WARNING_ICON: |
| 271 [cell setHintIcon:rb.GetNSImageNamed(IDR_WARNING)]; |
| 272 break; |
| 273 case ToolbarModel::NO_ICON: |
| 274 [cell setHintIcon:nil]; |
| 275 break; |
| 276 default: |
| 277 NOTREACHED(); |
| 278 break; |
| 279 } |
| 280 [field_ resetFieldEditorFrameIfNeeded]; |
| 281 } |
| OLD | NEW |