summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/match_preview.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/tab_contents/match_preview.h')
-rw-r--r--chrome/browser/tab_contents/match_preview.h74
1 files changed, 20 insertions, 54 deletions
diff --git a/chrome/browser/tab_contents/match_preview.h b/chrome/browser/tab_contents/match_preview.h
index 5b59528f..7d2d7f0 100644
--- a/chrome/browser/tab_contents/match_preview.h
+++ b/chrome/browser/tab_contents/match_preview.h
@@ -9,13 +9,15 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
-#include "base/timer.h"
#include "chrome/browser/search_engines/template_url_id.h"
+#include "chrome/browser/tab_contents/match_preview_commit_type.h"
+#include "chrome/browser/tab_contents/match_preview_loader_delegate.h"
#include "chrome/common/page_transition_types.h"
#include "gfx/rect.h"
#include "googleurl/src/gurl.h"
struct AutocompleteMatch;
+class LoaderManager;
class MatchPreviewDelegate;
class TabContents;
@@ -27,20 +29,8 @@ class TabContents;
// invoked on the delegate. Similarly the preview may be committed at any time
// by invoking |CommitCurrentPreview|, which results in |CommitMatchPreview|
// being invoked on the delegate.
-class MatchPreview {
+class MatchPreview : public MatchPreviewLoaderDelegate {
public:
- enum CommitType {
- // The commit is the result of the user pressing enter.
- COMMIT_PRESSED_ENTER,
-
- // The commit is the result of focus being lost. This typically corresponds
- // to a mouse click event.
- COMMIT_FOCUS_LOST,
-
- // Used internally.
- COMMIT_DESTROY
- };
-
explicit MatchPreview(MatchPreviewDelegate* delegate);
~MatchPreview();
@@ -67,13 +57,12 @@ class MatchPreview {
// Invoked when the user does some gesture that should trigger making the
// current previewed page the permanent page.
- void CommitCurrentPreview(CommitType type);
+ void CommitCurrentPreview(MatchPreviewCommitType type);
// Sets MatchPreview so that when the mouse is released the preview is
// committed.
void SetCommitOnMouseUp();
- // Returns true if the preview will be committed on mouse up.
bool commit_on_mouse_up() const { return commit_on_mouse_up_; }
// Returns true if the mouse is down as the result of activating the preview
@@ -83,13 +72,13 @@ class MatchPreview {
// Releases the preview TabContents passing ownership to the caller. This is
// intended to be called when the preview TabContents is committed. This does
// not notify the delegate.
- TabContents* ReleasePreviewContents(CommitType type);
+ TabContents* ReleasePreviewContents(MatchPreviewCommitType type);
// TabContents the match is being shown for.
TabContents* tab_contents() const { return tab_contents_; }
// The preview TabContents; may be null.
- TabContents* preview_contents() const { return preview_contents_.get(); }
+ TabContents* GetPreviewContents();
// Returns true if the preview TabContents is active. In some situations this
// may return false yet preview_contents() returns non-NULL.
@@ -100,16 +89,18 @@ class MatchPreview {
return last_transition_type_;
}
- const GURL& url() const { return url_; }
-
// Are we showing instant results?
- bool is_showing_instant() const { return template_url_id_ != 0; }
+ bool IsShowingInstant();
- private:
- class FrameLoadObserver;
- class PaintObserverImpl;
- class TabContentsDelegateImpl;
+ // MatchPreviewLoaderDelegate
+ virtual void ShowMatchPreviewLoader(MatchPreviewLoader* loader);
+ virtual void SetSuggestedTextFor(MatchPreviewLoader* loader,
+ const string16& text);
+ virtual gfx::Rect GetMatchPreviewBounds();
+ virtual bool ShouldCommitPreviewOnMouseUp();
+ virtual void CommitPreview(MatchPreviewLoader* loader);
+ private:
// Invoked when the page wants to update the suggested text. If |user_text_|
// starts with |suggested_text|, then the delegate is notified of the change,
// which results in updating the omnibox.
@@ -123,54 +114,29 @@ class MatchPreview {
// Invoked once the page has finished loading and the script has been sent.
void PageFinishedLoading();
- // Returns the bounds of the omnibox in terms of the preview tab contents.
- gfx::Rect GetOmniboxBoundsInTermsOfPreview();
-
- // Are we waiting for the preview page to finish loading?
- bool is_waiting_for_load() const {
- return frame_load_observer_.get() != NULL;
- }
+ // Returns true if we should show preview for |url|.
+ bool ShouldShowPreviewFor(const GURL& url);
MatchPreviewDelegate* delegate_;
// The TabContents last passed to |Update|.
TabContents* tab_contents_;
- // The url we're displaying.
- GURL url_;
-
- // Delegate of the preview TabContents. Used to detect when the user does some
- // gesture on the TabContents and the preview needs to be activated.
- scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_;
-
- // The preview TabContents; may be null.
- scoped_ptr<TabContents> preview_contents_;
-
// Has notification been sent out that the preview TabContents is ready to be
// shown?
bool is_active_;
- // The text the user typed in the omnibox.
- string16 user_text_;
-
- // The latest suggestion from the page.
- string16 complete_suggested_text_;
-
- // If we're showing instant results this is the ID of the TemplateURL driving
- // the results. A value of 0 means there is no TemplateURL.
- TemplateURLID template_url_id_;
-
// See description above setter.
gfx::Rect omnibox_bounds_;
- scoped_ptr<FrameLoadObserver> frame_load_observer_;
-
// See description above CommitOnMouseUp.
bool commit_on_mouse_up_;
// See description above getter.
PageTransition::Type last_transition_type_;
+ scoped_ptr<LoaderManager> loader_manager_;
+
DISALLOW_COPY_AND_ASSIGN(MatchPreview);
};