diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 20:14:27 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 20:14:27 +0000 |
commit | 6b723f8690dcdbdc4071a235aa67483dc18de329 (patch) | |
tree | c0d3b2f787bdef1927674687d9639cbea5dc3143 /chrome/browser/views/location_bar | |
parent | 9929dbb542aa4a8531ea4d9eadbb43b99d13f846 (diff) | |
download | chromium_src-6b723f8690dcdbdc4071a235aa67483dc18de329.zip chromium_src-6b723f8690dcdbdc4071a235aa67483dc18de329.tar.gz chromium_src-6b723f8690dcdbdc4071a235aa67483dc18de329.tar.bz2 |
Renames and moves match preview classes to instant. This doesn't
contain any changes other than renaming/moving, as such I'm TBRing.
BUG=54833
TEST=none
TBR=jcivelli@chromium.org
Review URL: http://codereview.chromium.org/3602015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61553 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/location_bar')
-rw-r--r-- | chrome/browser/views/location_bar/location_bar_view.cc | 97 | ||||
-rw-r--r-- | chrome/browser/views/location_bar/location_bar_view.h | 38 |
2 files changed, 67 insertions, 68 deletions
diff --git a/chrome/browser/views/location_bar/location_bar_view.cc b/chrome/browser/views/location_bar/location_bar_view.cc index 5af0fe5..8235e03 100644 --- a/chrome/browser/views/location_bar/location_bar_view.cc +++ b/chrome/browser/views/location_bar/location_bar_view.cc @@ -20,11 +20,11 @@ #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extensions_service.h" +#include "chrome/browser/instant/instant_controller.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/browser/tab_contents/match_preview.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/browser_dialogs.h" #include "chrome/browser/views/location_bar/content_setting_image_view.h" @@ -101,7 +101,7 @@ LocationBarView::LocationBarView(Profile* profile, show_focus_rect_(false), bubble_type_(FirstRun::MINIMAL_BUBBLE), template_url_model_(NULL), - update_match_preview_(true) { + update_instant_(true) { DCHECK(profile_); SetID(VIEW_ID_LOCATION_BAR); SetFocusable(true); @@ -717,34 +717,34 @@ void LocationBarView::OnMouseReleased(const views::MouseEvent& event, #endif void LocationBarView::OnAutocompleteWillClosePopup() { - if (!update_match_preview_) + if (!update_instant_) return; - MatchPreview* match_preview = delegate_->GetMatchPreview(); - if (match_preview && !match_preview->commit_on_mouse_up()) - match_preview->DestroyPreviewContents(); + InstantController* instant = delegate_->GetInstant(); + if (instant && !instant->commit_on_mouse_up()) + instant->DestroyPreviewContents(); } void LocationBarView::OnAutocompleteLosingFocus( gfx::NativeView view_gaining_focus) { SetSuggestedText(string16()); - MatchPreview* match_preview = delegate_->GetMatchPreview(); - if (!match_preview) + InstantController* instant = delegate_->GetInstant(); + if (!instant) return; - if (!match_preview->is_active() || !match_preview->GetPreviewContents()) + if (!instant->is_active() || !instant->GetPreviewContents()) return; switch (GetCommitType(view_gaining_focus)) { - case COMMIT_MATCH_PREVIEW_IMMEDIATELY: - match_preview->CommitCurrentPreview(MATCH_PREVIEW_COMMIT_FOCUS_LOST); + case COMMIT_INSTANT_IMMEDIATELY: + instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); break; - case COMMIT_MATCH_PREVIEW_ON_MOUSE_UP: - match_preview->SetCommitOnMouseUp(); + case COMMIT_INSTANT_ON_MOUSE_UP: + instant->SetCommitOnMouseUp(); break; - case REVERT_MATCH_PREVIEW: - match_preview->DestroyPreviewContents(); + case REVERT_INSTANT: + instant->DestroyPreviewContents(); break; default: NOTREACHED(); @@ -752,26 +752,26 @@ void LocationBarView::OnAutocompleteLosingFocus( } void LocationBarView::OnAutocompleteWillAccept() { - update_match_preview_ = false; + update_instant_ = false; } bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) { - MatchPreview* match_preview = delegate_->GetMatchPreview(); - if (!match_preview || !suggested_text_view_ || + InstantController* instant = delegate_->GetInstant(); + if (!instant || !suggested_text_view_ || suggested_text_view_->size().IsEmpty() || suggested_text_view_->GetText().empty()) { return false; } - // TODO(sky): I may need to route this through MatchPreview so that we don't + // TODO(sky): I may need to route this through InstantController so that we don't // fetch suggestions for the new combined text. location_entry_->SetUserText(typed_text + suggested_text_view_->GetText()); return true; } void LocationBarView::OnPopupBoundsChanged(const gfx::Rect& bounds) { - MatchPreview* match_preview = delegate_->GetMatchPreview(); - if (match_preview) - match_preview->SetOmniboxBounds(bounds); + InstantController* instant = delegate_->GetInstant(); + if (instant) + instant->SetOmniboxBounds(bounds); } void LocationBarView::OnAutocompleteAccept( @@ -808,10 +808,10 @@ void LocationBarView::OnAutocompleteAccept( } } - if (delegate_->GetMatchPreview()) - delegate_->GetMatchPreview()->DestroyPreviewContents(); + if (delegate_->GetInstant()) + delegate_->GetInstant()->DestroyPreviewContents(); - update_match_preview_ = true; + update_instant_ = true; } void LocationBarView::OnChanged() { @@ -821,17 +821,17 @@ void LocationBarView::OnChanged() { Layout(); SchedulePaint(); - MatchPreview* match_preview = delegate_->GetMatchPreview(); + InstantController* instant = delegate_->GetInstant(); string16 suggested_text; - if (update_match_preview_ && match_preview && GetTabContents()) { + if (update_instant_ && instant && GetTabContents()) { if (location_entry_->model()->user_input_in_progress() && location_entry_->model()->popup_model()->IsOpen()) { - match_preview->Update(GetTabContents(), - location_entry_->model()->CurrentMatch(), - WideToUTF16(location_entry_->GetText()), - &suggested_text); + instant->Update(GetTabContents(), + location_entry_->model()->CurrentMatch(), + WideToUTF16(location_entry_->GetText()), + &suggested_text); } else { - match_preview->DestroyPreviewContents(); + instant->DestroyPreviewContents(); } } @@ -1201,34 +1201,33 @@ void LocationBarView::OnTemplateURLModelChanged() { ShowFirstRunBubble(bubble_type_); } -LocationBarView::MatchPreviewCommitType LocationBarView::GetCommitType( +LocationBarView::InstantCommitType LocationBarView::GetCommitType( gfx::NativeView view_gaining_focus) { - // The MatchPreview is active. Destroy it if the user didn't click on the + // The InstantController is active. Destroy it if the user didn't click on the // TabContents (or one of its children). #if defined(OS_WIN) - MatchPreview* match_preview = delegate_->GetMatchPreview(); + InstantController* instant = delegate_->GetInstant(); RenderWidgetHostView* rwhv = - match_preview->GetPreviewContents()->GetRenderWidgetHostView(); + instant->GetPreviewContents()->GetRenderWidgetHostView(); if (!view_gaining_focus || !rwhv) - return REVERT_MATCH_PREVIEW; + return REVERT_INSTANT; - gfx::NativeView tab_view = - match_preview->GetPreviewContents()->GetNativeView(); + gfx::NativeView tab_view = instant->GetPreviewContents()->GetNativeView(); if (rwhv->GetNativeView() == view_gaining_focus || tab_view == view_gaining_focus) { - // Focus is going to the renderer. Only commit the match preview if the - // mouse is down. If the mouse isn't down it means someone else moved focus - // and we shouldn't commit. - if (match_preview->IsMouseDownFromActivate()) { - if (match_preview->IsShowingInstant()) { + // Focus is going to the renderer. Only commit instant if the mouse is + // down. If the mouse isn't down it means someone else moved focus and we + // shouldn't commit. + if (instant->IsMouseDownFromActivate()) { + if (instant->IsShowingInstant()) { // We're showing instant results. As instant results may shift when // committing we commit on the mouse up. This way a slow click still // works fine. - return COMMIT_MATCH_PREVIEW_ON_MOUSE_UP; + return COMMIT_INSTANT_ON_MOUSE_UP; } - return COMMIT_MATCH_PREVIEW_IMMEDIATELY; + return COMMIT_INSTANT_IMMEDIATELY; } - return REVERT_MATCH_PREVIEW; + return REVERT_INSTANT; } gfx::NativeView view_gaining_focus_ancestor = view_gaining_focus; while (view_gaining_focus_ancestor && @@ -1236,10 +1235,10 @@ LocationBarView::MatchPreviewCommitType LocationBarView::GetCommitType( view_gaining_focus_ancestor = ::GetParent(view_gaining_focus_ancestor); } return view_gaining_focus_ancestor != NULL ? - COMMIT_MATCH_PREVIEW_IMMEDIATELY : REVERT_MATCH_PREVIEW; + COMMIT_INSTANT_IMMEDIATELY : REVERT_INSTANT; #else // TODO: implement me. NOTIMPLEMENTED(); - return REVERT_MATCH_PREVIEW; + return REVERT_INSTANT; #endif } diff --git a/chrome/browser/views/location_bar/location_bar_view.h b/chrome/browser/views/location_bar/location_bar_view.h index 1b8762d..15c785d 100644 --- a/chrome/browser/views/location_bar/location_bar_view.h +++ b/chrome/browser/views/location_bar/location_bar_view.h @@ -36,9 +36,9 @@ class ContentSettingImageView; class EVBubbleView; class ExtensionAction; class GURL; +class InstantController; class KeywordHintView; class LocationIconView; -class MatchPreview; class PageActionWithBadgeView; class Profile; class SelectedKeywordView; @@ -73,8 +73,8 @@ class LocationBarView : public LocationBar, // Should return the current tab contents. virtual TabContents* GetTabContents() = 0; - // Returns the MatchPreview, or NULL if there isn't one. - virtual MatchPreview* GetMatchPreview() = 0; + // Returns the InstantController, or NULL if there isn't one. + virtual InstantController* GetInstant() = 0; // Called by the location bar view when the user starts typing in the edit. // This forces our security style to be UNKNOWN for the duration of the @@ -257,16 +257,16 @@ class LocationBarView : public LocationBar, private: typedef std::vector<ContentSettingImageView*> ContentSettingViews; - // Enumeration of what should happen to the match preview on focus lost. - enum MatchPreviewCommitType { - // The match preview should be committed immediately. - COMMIT_MATCH_PREVIEW_IMMEDIATELY, + // Enumeration of what should happen to instant on focus lost. + enum InstantCommitType { + // The instant preview should be committed immediately. + COMMIT_INSTANT_IMMEDIATELY, - // The match preview should be committed on mouse up. - COMMIT_MATCH_PREVIEW_ON_MOUSE_UP, + // The instant preview should be committed on mouse up. + COMMIT_INSTANT_ON_MOUSE_UP, - // The match preview should be reverted. - REVERT_MATCH_PREVIEW + // The instant preview should be reverted. + REVERT_INSTANT }; friend class PageActionImageView; @@ -311,9 +311,9 @@ class LocationBarView : public LocationBar, // Helper to show the first run info bubble. void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type); - // Returns what should happen to the MatchPreview as a result of focus being - // lost. - MatchPreviewCommitType GetCommitType(gfx::NativeView view_gaining_focus); + // Returns what should happen to the InstantController as a result of focus + // being lost. + InstantCommitType GetCommitType(gfx::NativeView view_gaining_focus); // Current profile. Not owned by us. Profile* profile_; @@ -403,11 +403,11 @@ class LocationBarView : public LocationBar, scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; #endif - // Should the match preview be updated? This is set to false in - // OnAutocompleteWillAccept and true in OnAutocompleteAccept. This is needed - // as prior to accepting an autocomplete suggestion the model is reverted - // which triggers resetting the match preview. - bool update_match_preview_; + // Should instant be updated? This is set to false in OnAutocompleteWillAccept + // and true in OnAutocompleteAccept. This is needed as prior to accepting an + // autocomplete suggestion the model is reverted which triggers resetting + // instant. + bool update_instant_; DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); }; |