Chromium Code Reviews| Index: chrome/browser/instant/instant_loader.cc |
| =================================================================== |
| --- chrome/browser/instant/instant_loader.cc (revision 158566) |
| +++ chrome/browser/instant/instant_loader.cc (working copy) |
| @@ -5,7 +5,6 @@ |
| #include "chrome/browser/instant/instant_loader.h" |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| -#include "chrome/browser/history/history_types.h" |
| #include "chrome/browser/instant/instant_loader_delegate.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| @@ -24,6 +23,21 @@ |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| +namespace { |
| + |
| +class InstantLoaderUserData : public base::SupportsUserData::Data { |
| + public: |
| + InstantLoaderUserData(InstantLoader* loader) : loader_(loader) {} |
|
sky
2012/09/25 22:23:19
explicit
jam
2012/09/25 22:42:39
Done.
|
| + virtual ~InstantLoaderUserData() {} |
| + |
| + InstantLoader* loader() const { return loader_; } |
| + |
| + private: |
| + InstantLoader* loader_; |
| +}; |
|
sky
2012/09/25 22:23:19
DISALLOW_...
jam
2012/09/25 22:42:39
Done.
|
| + |
| +} |
| + |
| // WebContentsDelegateImpl ----------------------------------------------------- |
| class InstantLoader::WebContentsDelegateImpl |
| @@ -59,9 +73,6 @@ |
| virtual void HandleGestureEnd() OVERRIDE; |
| virtual void DragEnded() OVERRIDE; |
| virtual bool OnGoToEntryOffset(int offset) OVERRIDE; |
| - virtual bool ShouldAddNavigationToHistory( |
| - const history::HistoryAddPageArgs& add_page_args, |
| - content::NavigationType navigation_type) OVERRIDE; |
| // content::WebContentsObserver: |
| virtual void DidFinishLoad( |
| @@ -169,13 +180,6 @@ |
| return false; |
| } |
| -bool InstantLoader::WebContentsDelegateImpl::ShouldAddNavigationToHistory( |
| - const history::HistoryAddPageArgs& add_page_args, |
| - content::NavigationType navigation_type) { |
| - loader_->last_navigation_ = add_page_args; |
| - return false; |
| -} |
| - |
| void InstantLoader::WebContentsDelegateImpl::DidFinishLoad( |
| int64 frame_id, |
| const GURL& validated_url, |
| @@ -281,6 +285,16 @@ |
| // InstantLoader --------------------------------------------------------------- |
| +int InstantLoader::kUserDataKey; |
| + |
| +// static |
| +InstantLoader* InstantLoader::FromWebContents( |
| + content::WebContents* web_contents) { |
| + InstantLoaderUserData* data = static_cast<InstantLoaderUserData*>( |
| + web_contents->GetUserData(&kUserDataKey)); |
| + return data ? data->loader() : NULL; |
| +} |
| + |
| InstantLoader::InstantLoader(InstantLoaderDelegate* delegate, |
| const std::string& instant_url, |
| const TabContents* tab_contents) |
| @@ -294,6 +308,8 @@ |
| GetSessionStorageNamespaceMap()))), |
| supports_instant_(false), |
| instant_url_(instant_url) { |
| + preview_contents_->web_contents()->SetUserData( |
| + &kUserDataKey, new InstantLoaderUserData(this)); |
|
sreeram
2012/09/25 22:22:29
Move this to inside SetupPreviewContents(), so tha
jam
2012/09/25 22:42:39
Done.
|
| } |
| InstantLoader::~InstantLoader() { |
| @@ -340,6 +356,11 @@ |
| count)); |
| } |
| +void InstantLoader::DidNavigate( |
| + const history::HistoryAddPageArgs& add_page_args) { |
| + last_navigation_ = add_page_args; |
| +} |
| + |
| TabContents* InstantLoader::ReleasePreviewContents(InstantCommitType type, |
| const string16& text) { |
| content::RenderViewHost* rvh = |
| @@ -349,6 +370,7 @@ |
| else |
| rvh->Send(new ChromeViewMsg_SearchBoxCancel(rvh->GetRoutingID(), text)); |
| CleanupPreviewContents(); |
| + preview_contents_->web_contents()->RemoveUserData(&kUserDataKey); |
| return preview_contents_.release(); |
| } |