Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3659)

Unified Diff: chrome/browser/instant/instant_loader.cc

Issue 10978016: Remove two functions on WebContentsDelegate which didn't belong in content. They were only called f… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698