diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 10:51:16 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 10:51:16 +0000 |
commit | 1ccb3568d81cf47adf6f062067c186fdf43dd56d (patch) | |
tree | b8200bd953cbc88db64a09cc8fb6f7eca7237088 /chrome/browser/tab_contents | |
parent | 0f0acb414b3e4ad3febc85bc3e6364a8b206ab76 (diff) | |
download | chromium_src-1ccb3568d81cf47adf6f062067c186fdf43dd56d.zip chromium_src-1ccb3568d81cf47adf6f062067c186fdf43dd56d.tar.gz chromium_src-1ccb3568d81cf47adf6f062067c186fdf43dd56d.tar.bz2 |
linux: plumb shift-reload down into new shift-reload API
Currently Linux-only, but the Mac/Win bits should now be trivial.
While I was add it, I tweaked a NavigationController function
that took a bare boolean into an enum to make the call sites more
explicit about what they're doing.
(In most places I added new functions that call into a shared
backing function; this is so I don't need to change every single
caller of e.g. Reload() to pass through an extra flag that will
be the same for almost every caller.)
BUG=1906
TEST=visit astronomy picture of the day; hit reload, picture pops
up quickly; hit shift-reload, picture loads slowly
Review URL: http://codereview.chromium.org/594063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/navigation_controller.cc | 26 | ||||
-rw-r--r-- | chrome/browser/tab_contents/navigation_controller.h | 13 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 26 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 3 |
4 files changed, 49 insertions, 19 deletions
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index 58d4123..3edb1ce 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -173,6 +173,14 @@ void NavigationController::RestoreFromState( } void NavigationController::Reload(bool check_for_repost) { + ReloadInternal(check_for_repost, RELOAD); +} +void NavigationController::ReloadIgnoringCache(bool check_for_repost) { + ReloadInternal(check_for_repost, RELOAD_IGNORING_CACHE); +} + +void NavigationController::ReloadInternal(bool check_for_repost, + ReloadType reload_type) { // Reloading a transient entry does nothing. if (transient_entry_index_ != -1) return; @@ -199,7 +207,7 @@ void NavigationController::Reload(bool check_for_repost) { pending_entry_index_ = current_index; entries_[pending_entry_index_]->set_transition_type(PageTransition::RELOAD); - NavigateToPendingEntry(true); + NavigateToPendingEntry(reload_type); } } @@ -224,7 +232,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) { NotificationType::NAV_ENTRY_PENDING, Source<NavigationController>(this), NotificationService::NoDetails()); - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } NavigationEntry* NavigationController::GetActiveEntry() const { @@ -288,7 +296,7 @@ void NavigationController::GoBack() { DiscardNonCommittedEntries(); pending_entry_index_ = current_index - 1; - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } void NavigationController::GoForward() { @@ -310,7 +318,7 @@ void NavigationController::GoForward() { if (!transient) pending_entry_index_++; - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } void NavigationController::GoToIndex(int index) { @@ -333,7 +341,7 @@ void NavigationController::GoToIndex(int index) { DiscardNonCommittedEntries(); pending_entry_index_ = index; - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } void NavigationController::GoToOffset(int offset) { @@ -360,7 +368,7 @@ void NavigationController::RemoveEntryAtIndex(int index, // We removed the currently shown entry, so we have to load something else. if (last_committed_entry_index_ != -1) { pending_entry_index_ = last_committed_entry_index_; - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } else { // If there is nothing to show, show a default page. LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, @@ -940,7 +948,7 @@ void NavigationController::SetWindowID(const SessionID& id) { NotificationService::NoDetails()); } -void NavigationController::NavigateToPendingEntry(bool reload) { +void NavigationController::NavigateToPendingEntry(ReloadType reload_type) { needs_reload_ = false; // For session history navigations only the pending_entry_index_ is set. @@ -949,7 +957,7 @@ void NavigationController::NavigateToPendingEntry(bool reload) { pending_entry_ = entries_[pending_entry_index_].get(); } - if (!tab_contents_->NavigateToPendingEntry(reload)) + if (!tab_contents_->NavigateToPendingEntry(reload_type)) DiscardNonCommittedEntries(); } @@ -995,7 +1003,7 @@ void NavigationController::LoadIfNecessary() { // Explicitly use NavigateToPendingEntry so that the renderer uses the // cached state. pending_entry_index_ = last_committed_entry_index_; - NavigateToPendingEntry(false); + NavigateToPendingEntry(NO_RELOAD); } void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index 2aba4fe..810f8b9 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -133,6 +133,12 @@ class NavigationController { int count; }; + enum ReloadType { + NO_RELOAD, // Normal load. + RELOAD, // Normal (cache-validating) reload. + RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. + }; + // --------------------------------------------------------------------------- NavigationController(TabContents* tab_contents, Profile* profile); @@ -286,6 +292,8 @@ class NavigationController { // entry has POST data the user is prompted to see if they really want to // reload the page. In nearly all cases pass in true. void Reload(bool check_for_repost); + // Like Reload(), but don't use caches (aka "shift-reload"). + void ReloadIgnoringCache(bool check_for_repost); // Removing of entries ------------------------------------------------------- @@ -431,8 +439,11 @@ class NavigationController { bool RendererDidNavigateAutoSubframe( const ViewHostMsg_FrameNavigate_Params& params); + // Helper function for code shared between Reload() and ReloadAll(). + void ReloadInternal(bool check_for_repost, ReloadType reload_type); + // Actually issues the navigation held in pending_entry. - void NavigateToPendingEntry(bool reload); + void NavigateToPendingEntry(ReloadType reload_type); // Allows the derived class to issue notifications that a load has been // committed. This will fill in the active entry to the details structure. diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index f050c93..82ec6f0 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -186,9 +186,16 @@ BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { #endif ViewMsg_Navigate_Params::NavigationType GetNavigationType( - Profile* profile, const NavigationEntry& entry, bool reload) { - if (reload) - return ViewMsg_Navigate_Params::RELOAD; + Profile* profile, const NavigationEntry& entry, + NavigationController::ReloadType reload_type) { + switch (reload_type) { + case NavigationController::RELOAD: + return ViewMsg_Navigate_Params::RELOAD; + case NavigationController::RELOAD_IGNORING_CACHE: + return ViewMsg_Navigate_Params::RELOAD_IGNORING_CACHE; + case NavigationController::NO_RELOAD: + break; // Fall through to rest of function. + } if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && profile->DidLastSessionExitCleanly()) @@ -198,13 +205,14 @@ ViewMsg_Navigate_Params::NavigationType GetNavigationType( } void MakeNavigateParams(Profile* profile, const NavigationEntry& entry, - bool reload, ViewMsg_Navigate_Params* params) { + NavigationController::ReloadType reload_type, + ViewMsg_Navigate_Params* params) { params->page_id = entry.page_id(); params->url = entry.url(); params->referrer = entry.referrer(); params->transition = entry.transition_type(); params->state = entry.content_state(); - params->navigation_type = GetNavigationType(profile, entry, reload); + params->navigation_type = GetNavigationType(profile, entry, reload_type); params->request_time = base::Time::Now(); } @@ -703,7 +711,8 @@ void TabContents::OpenURL(const GURL& url, const GURL& referrer, delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); } -bool TabContents::NavigateToPendingEntry(bool reload) { +bool TabContents::NavigateToPendingEntry( + NavigationController::ReloadType reload_type) { const NavigationEntry& entry = *controller_.pending_entry(); RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); @@ -724,7 +733,7 @@ bool TabContents::NavigateToPendingEntry(bool reload) { // Navigate in the desired RenderViewHost. ViewMsg_Navigate_Params navigate_params; - MakeNavigateParams(profile(), entry, reload, &navigate_params); + MakeNavigateParams(profile(), entry, reload_type, &navigate_params); dest_render_view_host->Navigate(navigate_params); if (entry.page_id() == -1) { @@ -742,7 +751,8 @@ bool TabContents::NavigateToPendingEntry(bool reload) { // loading. GetPasswordManager()->ClearProvisionalSave(); - if (reload && !profile()->IsOffTheRecord()) { + if (reload_type != NavigationController::NO_RELOAD && + !profile()->IsOffTheRecord()) { FaviconService* favicon_service = profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); if (favicon_service) diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 4d11745..1553032 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -321,7 +321,8 @@ class TabContents : public PageNavigator, // // If this method returns false, then the navigation is discarded (equivalent // to calling DiscardPendingEntry on the NavigationController). - virtual bool NavigateToPendingEntry(bool reload); + virtual bool NavigateToPendingEntry( + NavigationController::ReloadType reload_type); // Stop any pending navigation. virtual void Stop(); |