Add CefBrowser::ReloadIgnoreCache() method and MENU_ID_NAV_RELOAD_NOCACHE menu support. (issue #118).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@107 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
de51597b22
commit
4fd793f802
|
@ -361,6 +361,9 @@ public:
|
||||||
// Reload the current page.
|
// Reload the current page.
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void Reload() =0;
|
virtual void Reload() =0;
|
||||||
|
// Reload the current page ignoring any cached data.
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void ReloadIgnoreCache() =0;
|
||||||
// Stop loading the page.
|
// Stop loading the page.
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void StopLoad() =0;
|
virtual void StopLoad() =0;
|
||||||
|
|
|
@ -210,6 +210,9 @@ typedef struct _cef_browser_t
|
||||||
// Reload the current page.
|
// Reload the current page.
|
||||||
void (CEF_CALLBACK *reload)(struct _cef_browser_t* self);
|
void (CEF_CALLBACK *reload)(struct _cef_browser_t* self);
|
||||||
|
|
||||||
|
// Reload the current page ignoring any cached data.
|
||||||
|
void (CEF_CALLBACK *reload_ignore_cache)(struct _cef_browser_t* self);
|
||||||
|
|
||||||
// Stop loading the page.
|
// Stop loading the page.
|
||||||
void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self);
|
void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* self);
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,8 @@ enum cef_handler_menuid_t
|
||||||
MENU_ID_NAV_BACK = 10,
|
MENU_ID_NAV_BACK = 10,
|
||||||
MENU_ID_NAV_FORWARD = 11,
|
MENU_ID_NAV_FORWARD = 11,
|
||||||
MENU_ID_NAV_RELOAD = 12,
|
MENU_ID_NAV_RELOAD = 12,
|
||||||
MENU_ID_NAV_STOP = 13,
|
MENU_ID_NAV_RELOAD_NOCACHE = 13,
|
||||||
|
MENU_ID_NAV_STOP = 14,
|
||||||
MENU_ID_UNDO = 20,
|
MENU_ID_UNDO = 20,
|
||||||
MENU_ID_REDO = 21,
|
MENU_ID_REDO = 21,
|
||||||
MENU_ID_CUT = 22,
|
MENU_ID_CUT = 22,
|
||||||
|
|
|
@ -136,6 +136,12 @@ void CefBrowserImpl::Reload()
|
||||||
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_RELOAD));
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_RELOAD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserImpl::ReloadIgnoreCache()
|
||||||
|
{
|
||||||
|
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||||
|
&CefBrowserImpl::UIT_HandleActionView, MENU_ID_NAV_RELOAD_NOCACHE));
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::StopLoad()
|
void CefBrowserImpl::StopLoad()
|
||||||
{
|
{
|
||||||
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this,
|
||||||
|
@ -669,14 +675,15 @@ void CefBrowserImpl::UIT_GoBackOrForward(int offset)
|
||||||
nav_controller_->GoToOffset(offset);
|
nav_controller_->GoToOffset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::UIT_Reload()
|
void CefBrowserImpl::UIT_Reload(bool ignoreCache)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
nav_controller_->Reload();
|
nav_controller_->Reload(ignoreCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||||
bool reload)
|
bool reload,
|
||||||
|
bool ignoreCache)
|
||||||
{
|
{
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
|
|
||||||
|
@ -704,7 +711,7 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||||
// If we are reloading, then WebKit will use the state of the current page.
|
// If we are reloading, then WebKit will use the state of the current page.
|
||||||
// Otherwise, we give it the state to navigate to.
|
// Otherwise, we give it the state to navigate to.
|
||||||
if (reload) {
|
if (reload) {
|
||||||
frame->reload();
|
frame->reload(ignoreCache);
|
||||||
} else if (!entry.GetContentState().empty()) {
|
} else if (!entry.GetContentState().empty()) {
|
||||||
DCHECK(entry.GetPageID() != -1);
|
DCHECK(entry.GetPageID() != -1);
|
||||||
frame->loadHistoryItem(
|
frame->loadHistoryItem(
|
||||||
|
@ -813,7 +820,10 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId,
|
||||||
UIT_GoBackOrForward(1);
|
UIT_GoBackOrForward(1);
|
||||||
break;
|
break;
|
||||||
case MENU_ID_NAV_RELOAD:
|
case MENU_ID_NAV_RELOAD:
|
||||||
UIT_Reload();
|
UIT_Reload(false);
|
||||||
|
break;
|
||||||
|
case MENU_ID_NAV_RELOAD_NOCACHE:
|
||||||
|
UIT_Reload(true);
|
||||||
break;
|
break;
|
||||||
case MENU_ID_NAV_STOP:
|
case MENU_ID_NAV_STOP:
|
||||||
if (GetWebView())
|
if (GetWebView())
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
virtual bool CanGoForward();
|
virtual bool CanGoForward();
|
||||||
virtual void GoForward();
|
virtual void GoForward();
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
|
virtual void ReloadIgnoreCache();
|
||||||
virtual void StopLoad();
|
virtual void StopLoad();
|
||||||
virtual void SetFocus(bool enable);
|
virtual void SetFocus(bool enable);
|
||||||
virtual CefWindowHandle GetWindowHandle();
|
virtual CefWindowHandle GetWindowHandle();
|
||||||
|
@ -183,8 +184,10 @@ public:
|
||||||
const std::wstring& script_url,
|
const std::wstring& script_url,
|
||||||
int start_line);
|
int start_line);
|
||||||
void UIT_GoBackOrForward(int offset);
|
void UIT_GoBackOrForward(int offset);
|
||||||
void UIT_Reload();
|
void UIT_Reload(bool ignoreCache);
|
||||||
bool UIT_Navigate(const BrowserNavigationEntry& entry, bool reload);
|
bool UIT_Navigate(const BrowserNavigationEntry& entry,
|
||||||
|
bool reload,
|
||||||
|
bool ignoreCahce);
|
||||||
void UIT_SetFocus(WebWidgetHost* host, bool enable);
|
void UIT_SetFocus(WebWidgetHost* host, bool enable);
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url);
|
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url);
|
||||||
|
|
|
@ -62,7 +62,7 @@ void BrowserNavigationController::Reset() {
|
||||||
last_committed_entry_index_ = -1;
|
last_committed_entry_index_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::Reload() {
|
void BrowserNavigationController::Reload(bool ignoreCache) {
|
||||||
// Base the navigation on where we are now...
|
// Base the navigation on where we are now...
|
||||||
int current_index = GetCurrentEntryIndex();
|
int current_index = GetCurrentEntryIndex();
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void BrowserNavigationController::Reload() {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
pending_entry_index_ = current_index;
|
pending_entry_index_ = current_index;
|
||||||
NavigateToPendingEntry(true);
|
NavigateToPendingEntry(true, ignoreCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::GoToOffset(int offset) {
|
void BrowserNavigationController::GoToOffset(int offset) {
|
||||||
|
@ -92,7 +92,7 @@ void BrowserNavigationController::GoToIndex(int index) {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
pending_entry_index_ = index;
|
pending_entry_index_ = index;
|
||||||
NavigateToPendingEntry(false);
|
NavigateToPendingEntry(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
|
void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
|
||||||
|
@ -101,7 +101,7 @@ void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
|
||||||
// result in a download or a 'no content' response (e.g., a mailto: URL).
|
// result in a download or a 'no content' response (e.g., a mailto: URL).
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
pending_entry_ = entry;
|
pending_entry_ = entry;
|
||||||
NavigateToPendingEntry(false);
|
NavigateToPendingEntry(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,14 +218,14 @@ int BrowserNavigationController::GetEntryIndexWithPageID(int32 page_id) const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::NavigateToPendingEntry(bool reload) {
|
void BrowserNavigationController::NavigateToPendingEntry(bool reload, bool ignoreCache) {
|
||||||
// For session history navigations only the pending_entry_index_ is set.
|
// For session history navigations only the pending_entry_index_ is set.
|
||||||
if (!pending_entry_) {
|
if (!pending_entry_) {
|
||||||
DCHECK(pending_entry_index_ != -1);
|
DCHECK(pending_entry_index_ != -1);
|
||||||
pending_entry_ = entries_[pending_entry_index_].get();
|
pending_entry_ = entries_[pending_entry_index_].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser_->UIT_Navigate(*pending_entry_, reload)) {
|
if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) {
|
||||||
// Note: this is redundant if navigation completed synchronously because
|
// Note: this is redundant if navigation completed synchronously because
|
||||||
// DidNavigateToEntry call this as well.
|
// DidNavigateToEntry call this as well.
|
||||||
UpdateMaxPageID();
|
UpdateMaxPageID();
|
||||||
|
|
|
@ -103,7 +103,7 @@ class BrowserNavigationController {
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
// Causes the controller to reload the current (or pending) entry.
|
// Causes the controller to reload the current (or pending) entry.
|
||||||
void Reload();
|
void Reload(bool ignoreCache);
|
||||||
|
|
||||||
// Causes the controller to go to the specified offset from current. Does
|
// Causes the controller to go to the specified offset from current. Does
|
||||||
// nothing if out of bounds.
|
// nothing if out of bounds.
|
||||||
|
@ -176,7 +176,7 @@ class BrowserNavigationController {
|
||||||
void InsertEntry(BrowserNavigationEntry* entry);
|
void InsertEntry(BrowserNavigationEntry* entry);
|
||||||
|
|
||||||
int GetMaxPageID() const { return max_page_id_; }
|
int GetMaxPageID() const { return max_page_id_; }
|
||||||
void NavigateToPendingEntry(bool reload);
|
void NavigateToPendingEntry(bool reload, bool ignoreCache);
|
||||||
|
|
||||||
// Return the index of the entry with the corresponding type and page_id,
|
// Return the index of the entry with the corresponding type and page_id,
|
||||||
// or -1 if not found.
|
// or -1 if not found.
|
||||||
|
|
|
@ -103,6 +103,15 @@ void CEF_CALLBACK browser_reload(struct _cef_browser_t* self)
|
||||||
CefBrowserCppToC::Get(self)->Reload();
|
CefBrowserCppToC::Get(self)->Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t* self)
|
||||||
|
{
|
||||||
|
DCHECK(self);
|
||||||
|
if(!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CefBrowserCppToC::Get(self)->ReloadIgnoreCache();
|
||||||
|
}
|
||||||
|
|
||||||
void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self)
|
void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self)
|
||||||
{
|
{
|
||||||
DCHECK(self);
|
DCHECK(self);
|
||||||
|
@ -255,6 +264,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
||||||
struct_.struct_.can_go_forward = browser_can_go_forward;
|
struct_.struct_.can_go_forward = browser_can_go_forward;
|
||||||
struct_.struct_.go_forward = browser_go_forward;
|
struct_.struct_.go_forward = browser_go_forward;
|
||||||
struct_.struct_.reload = browser_reload;
|
struct_.struct_.reload = browser_reload;
|
||||||
|
struct_.struct_.reload_ignore_cache = browser_reload_ignore_cache;
|
||||||
struct_.struct_.stop_load = browser_stop_load;
|
struct_.struct_.stop_load = browser_stop_load;
|
||||||
struct_.struct_.set_focus = browser_set_focus;
|
struct_.struct_.set_focus = browser_set_focus;
|
||||||
struct_.struct_.get_window_handle = browser_get_window_handle;
|
struct_.struct_.get_window_handle = browser_get_window_handle;
|
||||||
|
|
|
@ -77,6 +77,14 @@ void CefBrowserCToCpp::Reload()
|
||||||
struct_->reload(struct_);
|
struct_->reload(struct_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserCToCpp::ReloadIgnoreCache()
|
||||||
|
{
|
||||||
|
if(CEF_MEMBER_MISSING(struct_, reload))
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct_->reload_ignore_cache(struct_);
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserCToCpp::StopLoad()
|
void CefBrowserCToCpp::StopLoad()
|
||||||
{
|
{
|
||||||
if(CEF_MEMBER_MISSING(struct_, stop_load))
|
if(CEF_MEMBER_MISSING(struct_, stop_load))
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
virtual bool CanGoForward();
|
virtual bool CanGoForward();
|
||||||
virtual void GoForward();
|
virtual void GoForward();
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
|
virtual void ReloadIgnoreCache();
|
||||||
virtual void StopLoad();
|
virtual void StopLoad();
|
||||||
virtual void SetFocus(bool enable);
|
virtual void SetFocus(bool enable);
|
||||||
virtual CefWindowHandle GetWindowHandle();
|
virtual CefWindowHandle GetWindowHandle();
|
||||||
|
|
Loading…
Reference in New Issue