OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/nsimage_cache_mac.h" | 9 #include "base/nsimage_cache_mac.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 SetSuggestedText(string16()); | 226 SetSuggestedText(string16()); |
227 } | 227 } |
228 | 228 |
229 void LocationBarViewMac::OnAutocompleteLosingFocus(gfx::NativeView unused) { | 229 void LocationBarViewMac::OnAutocompleteLosingFocus(gfx::NativeView unused) { |
230 SetSuggestedText(string16()); | 230 SetSuggestedText(string16()); |
231 | 231 |
232 InstantController* instant = browser_->instant(); | 232 InstantController* instant = browser_->instant(); |
233 if (!instant) | 233 if (!instant) |
234 return; | 234 return; |
235 | 235 |
236 if (!instant->is_active() || !instant->GetPreviewContents()) | |
237 return; | |
238 | |
239 // If |IsMouseDownFromActivate()| returns false, the RenderWidgetHostView did | 236 // If |IsMouseDownFromActivate()| returns false, the RenderWidgetHostView did |
240 // not receive a mouseDown event. Therefore, we should destroy the preview. | 237 // not receive a mouseDown event. Therefore, we should destroy the preview. |
241 // Otherwise, the RWHV was clicked, so we commit the preview. | 238 // Otherwise, the RWHV was clicked, so we commit the preview. |
242 if (!instant->IsMouseDownFromActivate()) | 239 if (!instant->is_displayable() || !instant->GetPreviewContents() || |
| 240 !instant->IsMouseDownFromActivate()) { |
243 instant->DestroyPreviewContents(); | 241 instant->DestroyPreviewContents(); |
244 else if (instant->IsShowingInstant()) | 242 } else if (instant->IsShowingInstant()) { |
245 instant->SetCommitOnMouseUp(); | 243 instant->SetCommitOnMouseUp(); |
246 else | 244 } else { |
247 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); | 245 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); |
| 246 } |
248 } | 247 } |
249 | 248 |
250 void LocationBarViewMac::OnAutocompleteWillAccept() { | 249 void LocationBarViewMac::OnAutocompleteWillAccept() { |
251 update_instant_ = false; | 250 update_instant_ = false; |
252 } | 251 } |
253 | 252 |
254 bool LocationBarViewMac::OnCommitSuggestedText(const std::wstring& typed_text) { | 253 bool LocationBarViewMac::OnCommitSuggestedText(const std::wstring& typed_text) { |
255 return edit_view_->CommitSuggestText(); | 254 return edit_view_->CommitSuggestText(); |
256 } | 255 } |
257 | 256 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 683 |
685 // These need to change anytime the layout changes. | 684 // These need to change anytime the layout changes. |
686 // TODO(shess): Anytime the field editor might have changed, the | 685 // TODO(shess): Anytime the field editor might have changed, the |
687 // cursor rects almost certainly should have changed. The tooltips | 686 // cursor rects almost certainly should have changed. The tooltips |
688 // might change even when the rects don't change. | 687 // might change even when the rects don't change. |
689 [field_ resetFieldEditorFrameIfNeeded]; | 688 [field_ resetFieldEditorFrameIfNeeded]; |
690 [field_ updateCursorAndToolTipRects]; | 689 [field_ updateCursorAndToolTipRects]; |
691 | 690 |
692 [field_ setNeedsDisplay:YES]; | 691 [field_ setNeedsDisplay:YES]; |
693 } | 692 } |
OLD | NEW |