diff options
Diffstat (limited to 'chrome/browser/instant')
| -rw-r--r-- | chrome/browser/instant/instant_browsertest.cc | 3 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_controller.cc | 20 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_controller.h | 11 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_delegate.h | 6 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_loader.cc | 46 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_loader.h | 11 | ||||
| -rw-r--r-- | chrome/browser/instant/instant_loader_manager.cc | 3 |
7 files changed, 56 insertions, 44 deletions
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc index 449cf4e..2259618 100644 --- a/chrome/browser/instant/instant_browsertest.cc +++ b/chrome/browser/instant/instant_browsertest.cc @@ -16,6 +16,7 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/in_process_browser_test.h" @@ -68,7 +69,7 @@ class InstantTest : public InProcessBrowserTest { // Wait for instant to load and ensure it is in the state we expect. void SetupPreview() { - preview_ = browser()->instant()->GetPreviewContents(); + preview_ = browser()->instant()->GetPreviewContents()->tab_contents(); ASSERT_TRUE(preview_); ui_test_utils::WaitForNavigation(&preview_->controller()); diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 54c12dd..c6587fa 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -19,6 +19,7 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" @@ -155,8 +156,7 @@ void InstantController::Disable(Profile* profile) { UMA_HISTOGRAM_CUSTOM_COUNTS(name, delta.InMinutes(), 1, 60 * 24 * 10, 50); } - -void InstantController::Update(TabContents* tab_contents, +void InstantController::Update(TabContentsWrapper* tab_contents, const AutocompleteMatch& match, const string16& user_text, string16* suggested_text) { @@ -230,9 +230,9 @@ bool InstantController::IsCurrent() { void InstantController::CommitCurrentPreview(InstantCommitType type) { DCHECK(loader_manager_.get()); DCHECK(loader_manager_->current_loader()); - TabContents* tab = ReleasePreviewContents(type); + TabContentsWrapper* tab = ReleasePreviewContents(type); delegate_->CommitInstant(tab); - CompleteRelease(tab); + CompleteRelease(tab->tab_contents()); } void InstantController::SetCommitOnMouseUp() { @@ -251,13 +251,14 @@ void InstantController::OnAutocompleteLostFocus( return; RenderWidgetHostView* rwhv = - GetPreviewContents()->GetRenderWidgetHostView(); + GetPreviewContents()->tab_contents()->GetRenderWidgetHostView(); if (!view_gaining_focus || !rwhv) { DestroyPreviewContents(); return; } - gfx::NativeView tab_view = GetPreviewContents()->GetNativeView(); + gfx::NativeView tab_view = + GetPreviewContents()->tab_contents()->GetNativeView(); // Focus is going to the renderer. if (rwhv->GetNativeView() == view_gaining_focus || tab_view == view_gaining_focus) { @@ -299,12 +300,13 @@ void InstantController::OnAutocompleteLostFocus( DestroyPreviewContents(); } -TabContents* InstantController::ReleasePreviewContents(InstantCommitType type) { +TabContentsWrapper* InstantController::ReleasePreviewContents( + InstantCommitType type) { if (!loader_manager_.get()) return NULL; scoped_ptr<InstantLoader> loader(loader_manager_->ReleaseCurrentLoader()); - TabContents* tab = loader->ReleasePreviewContents(type); + TabContentsWrapper* tab = loader->ReleasePreviewContents(type); ClearBlacklist(); is_active_ = false; @@ -319,7 +321,7 @@ void InstantController::CompleteRelease(TabContents* tab) { tab->SetAllContentsBlocked(false); } -TabContents* InstantController::GetPreviewContents() { +TabContentsWrapper* InstantController::GetPreviewContents() { return loader_manager_.get() ? loader_manager_->current_loader()->preview_contents() : NULL; } diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 1d989cb..f4e464c 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -26,6 +26,7 @@ class InstantLoaderManager; class PrefService; class Profile; class TabContents; +class TabContentsWrapper; class TemplateURL; // InstantController maintains a TabContents that is intended to give a preview @@ -77,7 +78,7 @@ class InstantController : public InstantLoaderDelegate { // the url is empty and there is a preview TabContents it is destroyed. If url // is non-empty and the preview TabContents has not been created it is // created. - void Update(TabContents* tab_contents, + void Update(TabContentsWrapper* tab_contents, const AutocompleteMatch& match, const string16& user_text, string16* suggested_text); @@ -120,17 +121,17 @@ class InstantController : public InstantLoaderDelegate { // not notify the delegate. // WARNING: be sure and invoke CompleteRelease after adding the returned // TabContents to a tabstrip. - TabContents* ReleasePreviewContents(InstantCommitType type); + TabContentsWrapper* ReleasePreviewContents(InstantCommitType type); // Does cleanup after the preview contents has been added to the tabstrip. // Invoke this if you explicitly invoke ReleasePreviewContents. void CompleteRelease(TabContents* tab); // TabContents the match is being shown for. - TabContents* tab_contents() const { return tab_contents_; } + TabContentsWrapper* tab_contents() const { return tab_contents_; } // The preview TabContents; may be null. - TabContents* GetPreviewContents(); + TabContentsWrapper* GetPreviewContents(); // Returns true if the preview TabContents is active. In some situations this // may return false yet preview_contents() returns non-NULL. @@ -193,7 +194,7 @@ class InstantController : public InstantLoaderDelegate { InstantDelegate* delegate_; // The TabContents last passed to |Update|. - TabContents* tab_contents_; + TabContentsWrapper* tab_contents_; // Has notification been sent out that the preview TabContents is ready to be // shown? diff --git a/chrome/browser/instant/instant_delegate.h b/chrome/browser/instant/instant_delegate.h index 90f58a2..32d94e6 100644 --- a/chrome/browser/instant/instant_delegate.h +++ b/chrome/browser/instant/instant_delegate.h @@ -8,7 +8,7 @@ #include "base/string16.h" -class TabContents; +class TabContentsWrapper; namespace gfx { class Rect; @@ -24,7 +24,7 @@ class InstantDelegate { virtual void PrepareForInstant() = 0; // Invoked when the instant TabContents should be shown. - virtual void ShowInstant(TabContents* preview_contents) = 0; + virtual void ShowInstant(TabContentsWrapper* preview_contents) = 0; // Invoked when the instant TabContents should be hidden. virtual void HideInstant() = 0; @@ -32,7 +32,7 @@ class InstantDelegate { // Invoked when the user does something that should result in the preview // TabContents becoming the active TabContents. The delegate takes ownership // of the supplied TabContents. - virtual void CommitInstant(TabContents* preview_contents) = 0; + virtual void CommitInstant(TabContentsWrapper* preview_contents) = 0; // Invoked when the suggested text is to change to |text|. virtual void SetSuggestedText(const string16& text) = 0; diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index a74f26f..30c8ba6 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -26,6 +26,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -152,7 +153,7 @@ class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate { // Commits the currently buffered history. void CommitHistory() { - TabContents* tab = loader_->preview_contents(); + TabContents* tab = loader_->preview_contents()->tab_contents(); if (tab->profile()->IsOffTheRecord()) return; @@ -310,7 +311,7 @@ class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate { virtual void OnSetSuggestions(int32 page_id, const std::vector<std::string>& suggestions) { - TabContents* source = loader_->preview_contents(); + TabContentsWrapper* source = loader_->preview_contents(); if (!source->controller().GetActiveEntry() || page_id != source->controller().GetActiveEntry()->page_id()) return; @@ -324,7 +325,7 @@ class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate { } virtual void OnInstantSupportDetermined(int32 page_id, bool result) { - TabContents* source = loader_->preview_contents(); + TabContents* source = loader_->preview_contents()->tab_contents(); if (!source->controller().GetActiveEntry() || page_id != source->controller().GetActiveEntry()->page_id()) return; @@ -390,7 +391,7 @@ InstantLoader::~InstantLoader() { preview_contents_.reset(NULL); } -void InstantLoader::Update(TabContents* tab_contents, +void InstantLoader::Update(TabContentsWrapper* tab_contents, const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, @@ -407,18 +408,19 @@ void InstantLoader::Update(TabContents* tab_contents, bool created_preview_contents; if (preview_contents_.get() == NULL) { - preview_contents_.reset( - new TabContents(tab_contents->profile(), NULL, MSG_ROUTING_NONE, - NULL, NULL)); - preview_contents_->SetAllContentsBlocked(true); + TabContents* new_contents = + new TabContents( + tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); + preview_contents_.reset(new TabContentsWrapper(new_contents)); + new_contents->SetAllContentsBlocked(true); // Propagate the max page id. That way if we end up merging the two // NavigationControllers (which happens if we commit) none of the page ids // will overlap. - int32 max_page_id = tab_contents->GetMaxPageID(); + int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID(); if (max_page_id != -1) preview_contents_->controller().set_max_restored_page_id(max_page_id + 1); - preview_contents_->set_delegate(preview_tab_contents_delegate_.get()); + new_contents->set_delegate(preview_tab_contents_delegate_.get()); gfx::Rect tab_bounds; tab_contents->view()->GetContainerBounds(&tab_bounds); @@ -428,8 +430,8 @@ void InstantLoader::Update(TabContents* tab_contents, // If |preview_contents_| does not currently have a RWHV, we will call // SetTakesFocusOnlyOnMouseDown() as a result of the // RENDER_VIEW_HOST_CHANGED notification. - if (preview_contents_->GetRenderWidgetHostView()) { - preview_contents_->GetRenderWidgetHostView()-> + if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { + preview_contents_->tab_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(true); } registrar_.Add( @@ -438,7 +440,7 @@ void InstantLoader::Update(TabContents* tab_contents, Source<NavigationController>(&preview_contents_->controller())); #endif - preview_contents_->ShowContents(); + preview_contents_->tab_contents()->ShowContents(); created_preview_contents = true; } else { created_preview_contents = false; @@ -484,7 +486,8 @@ void InstantLoader::Update(TabContents* tab_contents, preview_contents_->controller().LoadURL( instant_url, GURL(), transition_type); frame_load_observer_.reset( - new FrameLoadObserver(preview_contents(), user_text_)); + new FrameLoadObserver(preview_contents()->tab_contents(), + user_text_)); } } else { DCHECK(template_url_id_ == 0); @@ -515,7 +518,8 @@ bool InstantLoader::IsMouseDownFromActivate() { return preview_tab_contents_delegate_->is_mouse_down_from_activate(); } -TabContents* InstantLoader::ReleasePreviewContents(InstantCommitType type) { +TabContentsWrapper* InstantLoader::ReleasePreviewContents( + InstantCommitType type) { if (!preview_contents_.get()) return NULL; @@ -540,11 +544,11 @@ TabContents* InstantLoader::ReleasePreviewContents(InstantCommitType type) { preview_tab_contents_delegate_->CommitHistory(); // Destroy the paint observer. // RenderWidgetHostView may be null during shutdown. - if (preview_contents_->GetRenderWidgetHostView()) { - preview_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost()-> - set_paint_observer(NULL); + if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { + preview_contents_->tab_contents()->GetRenderWidgetHostView()-> + GetRenderWidgetHost()->set_paint_observer(NULL); #if defined(OS_MACOSX) - preview_contents_->GetRenderWidgetHostView()-> + preview_contents_->tab_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(false); registrar_.Remove( this, @@ -626,8 +630,8 @@ void InstantLoader::Observe(NotificationType type, const NotificationDetails& details) { #if defined(OS_MACOSX) if (type.value == NotificationType::RENDER_VIEW_HOST_CHANGED) { - if (preview_contents_->GetRenderWidgetHostView()) { - preview_contents_->GetRenderWidgetHostView()-> + if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { + preview_contents_->tab_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(true); } return; diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h index b2dfb66..223fffb 100644 --- a/chrome/browser/instant/instant_loader.h +++ b/chrome/browser/instant/instant_loader.h @@ -21,6 +21,7 @@ class InstantLoaderDelegate; class InstantLoaderManagerTest; class TabContents; +class TabContentsWrapper; class TemplateURL; // InstantLoader does the loading of a particular URL for InstantController. @@ -40,7 +41,7 @@ class InstantLoader : public NotificationObserver { // Invoked to load a URL. |tab_contents| is the TabContents the preview is // going to be shown on top of and potentially replace. - void Update(TabContents* tab_contents, + void Update(TabContentsWrapper* tab_contents, const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, @@ -59,7 +60,7 @@ class InstantLoader : public NotificationObserver { // 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(InstantCommitType type); + TabContentsWrapper* ReleasePreviewContents(InstantCommitType type); // Calls through to method of same name on delegate. bool ShouldCommitInstantOnMouseUp(); @@ -74,7 +75,9 @@ class InstantLoader : public NotificationObserver { const NotificationDetails& details); // The preview TabContents; may be null. - TabContents* preview_contents() const { return preview_contents_.get(); } + TabContentsWrapper* preview_contents() const { + return preview_contents_.get(); + } // Returns true if the preview TabContents is ready to be shown. bool ready() const { return ready_; } @@ -145,7 +148,7 @@ class InstantLoader : public NotificationObserver { scoped_ptr<TabContentsDelegateImpl> preview_tab_contents_delegate_; // The preview TabContents; may be null. - scoped_ptr<TabContents> preview_contents_; + scoped_ptr<TabContentsWrapper> preview_contents_; // Is the preview_contents ready to be shown? bool ready_; diff --git a/chrome/browser/instant/instant_loader_manager.cc b/chrome/browser/instant/instant_loader_manager.cc index 3020f2f..f2bdd9f 100644 --- a/chrome/browser/instant/instant_loader_manager.cc +++ b/chrome/browser/instant/instant_loader_manager.cc @@ -8,6 +8,7 @@ #include "chrome/browser/instant/instant_loader.h" #include "chrome/browser/instant/instant_loader_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" InstantLoaderManager::InstantLoaderManager( InstantLoaderDelegate* loader_delegate) @@ -67,7 +68,7 @@ InstantLoader* InstantLoaderManager::UpdateLoader( // preview_contents() may be null for tests. if (!current_loader_->template_url_id() && current_loader_->preview_contents()) { - current_loader_->preview_contents()->Stop(); + current_loader_->preview_contents()->tab_contents()->Stop(); } pending_loader_ = loader; } |
