| 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 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 StoreStateToTab(tab, state); | 195 StoreStateToTab(tab, state); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void AutocompleteEditViewMac::Update( | 198 void AutocompleteEditViewMac::Update( |
| 199 const TabContents* tab_for_state_restoring) { | 199 const TabContents* tab_for_state_restoring) { |
| 200 // TODO(shess): It seems like if the tab is non-NULL, then this code | 200 // TODO(shess): It seems like if the tab is non-NULL, then this code |
| 201 // shouldn't need to be called at all. When coded that way, I find | 201 // shouldn't need to be called at all. When coded that way, I find |
| 202 // that the field isn't always updated correctly. Figure out why | 202 // that the field isn't always updated correctly. Figure out why |
| 203 // this is. Maybe this method should be refactored into more | 203 // this is. Maybe this method should be refactored into more |
| 204 // specific cases. | 204 // specific cases. |
| 205 const std::wstring text = toolbar_model_->GetText(); | 205 const bool user_visible = |
| 206 const bool user_visible = model_->UpdatePermanentText(text); | 206 model_->UpdatePermanentText(toolbar_model_->GetText()); |
| 207 | 207 |
| 208 if (tab_for_state_restoring) { | 208 if (tab_for_state_restoring) { |
| 209 RevertAll(); | 209 RevertAll(); |
| 210 | 210 |
| 211 const AutocompleteEditViewMacState* state = | 211 const AutocompleteEditViewMacState* state = |
| 212 GetStateFromTab(tab_for_state_restoring); | 212 GetStateFromTab(tab_for_state_restoring); |
| 213 if (state) { | 213 if (state) { |
| 214 // Should restore the user's text via SetUserText(). | 214 // Should restore the user's text via SetUserText(). |
| 215 model_->RestoreState(state->model_state); | 215 model_->RestoreState(state->model_state); |
| 216 | 216 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 230 #endif | 230 #endif |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 } else if (user_visible) { | 233 } else if (user_visible) { |
| 234 // Restore everything to the baseline look. | 234 // Restore everything to the baseline look. |
| 235 RevertAll(); | 235 RevertAll(); |
| 236 // TODO(shess): Figure out how this case is used, to make sure | 236 // TODO(shess): Figure out how this case is used, to make sure |
| 237 // we're getting the selection and popup right. | 237 // we're getting the selection and popup right. |
| 238 | 238 |
| 239 } else { | 239 } else { |
| 240 // TODO(shess): Figure out how this case is used, to make sure | 240 // TODO(shess): This corresponds to _win and _gtk, except those |
| 241 // we're getting the selection and popup right. | 241 // guard it with a test for whether the security level changed. |
| 242 UpdateAndStyleText(text); | 242 // But AFAICT, that can only change if the text changed, and that |
| 243 // code compares the toolbar_model_ security level with the local |
| 244 // security level. Dig in and figure out why this isn't a no-op |
| 245 // that should go away. |
| 246 UpdateAndStyleText(GetText()); |
| 243 } | 247 } |
| 244 } | 248 } |
| 245 | 249 |
| 246 void AutocompleteEditViewMac::OpenURL(const GURL& url, | 250 void AutocompleteEditViewMac::OpenURL(const GURL& url, |
| 247 WindowOpenDisposition disposition, | 251 WindowOpenDisposition disposition, |
| 248 PageTransition::Type transition, | 252 PageTransition::Type transition, |
| 249 const GURL& alternate_nav_url, | 253 const GURL& alternate_nav_url, |
| 250 size_t selected_line, | 254 size_t selected_line, |
| 251 const std::wstring& keyword) { | 255 const std::wstring& keyword) { |
| 252 // TODO(shess): Why is the caller passing an invalid url in the | 256 // TODO(shess): Why is the caller passing an invalid url in the |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 317 |
| 314 // TODO(shess): Verify that we should be stealing focus at this | 318 // TODO(shess): Verify that we should be stealing focus at this |
| 315 // point. | 319 // point. |
| 316 SetSelectedRange(NSMakeRange(0, GetText().size())); | 320 SetSelectedRange(NSMakeRange(0, GetText().size())); |
| 317 } | 321 } |
| 318 | 322 |
| 319 void AutocompleteEditViewMac::RevertAll() { | 323 void AutocompleteEditViewMac::RevertAll() { |
| 320 ClosePopup(); | 324 ClosePopup(); |
| 321 model_->Revert(); | 325 model_->Revert(); |
| 322 | 326 |
| 327 // TODO(shess): This should be a no-op, the results from GetText() |
| 328 // could only get there via UpdateAndStyleText() in the first place. |
| 329 // Dig into where this code can be called from and see if this line |
| 330 // can be removed. |
| 323 UpdateAndStyleText(GetText()); | 331 UpdateAndStyleText(GetText()); |
| 324 controller_->OnChanged(); | 332 controller_->OnChanged(); |
| 325 } | 333 } |
| 326 | 334 |
| 327 void AutocompleteEditViewMac::UpdatePopup() { | 335 void AutocompleteEditViewMac::UpdatePopup() { |
| 328 model_->SetInputInProgress(true); | 336 model_->SetInputInProgress(true); |
| 329 if (!model_->has_focus()) | 337 if (!model_->has_focus()) |
| 330 return; | 338 return; |
| 331 | 339 |
| 332 // TODO(shess): | 340 // TODO(shess): |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // TODO(shess): Figure out where the selection belongs. On GTK, | 624 // TODO(shess): Figure out where the selection belongs. On GTK, |
| 617 // it's set to the start of the text. | 625 // it's set to the start of the text. |
| 618 } | 626 } |
| 619 | 627 |
| 620 // Signal that we've lost focus when the window resigns key. | 628 // Signal that we've lost focus when the window resigns key. |
| 621 - (void)windowDidResignKey:(NSNotification*)notification { | 629 - (void)windowDidResignKey:(NSNotification*)notification { |
| 622 edit_view_->OnDidResignKey(); | 630 edit_view_->OnDidResignKey(); |
| 623 } | 631 } |
| 624 | 632 |
| 625 @end | 633 @end |
| OLD | NEW |