Add CefBrowserSettings.history_disabled option to disable history back/forward navigation (issue #419).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@393 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
605753c3b8
commit
8c5b56cbf5
|
@ -190,6 +190,11 @@ typedef struct _cef_browser_settings_t
|
|||
///
|
||||
bool load_drops_disabled;
|
||||
|
||||
///
|
||||
// Disable history back/forward navigation.
|
||||
///
|
||||
bool history_disabled;
|
||||
|
||||
// The below values map to WebPreferences settings.
|
||||
|
||||
///
|
||||
|
|
|
@ -324,6 +324,7 @@ struct CefBrowserSettingsTraits {
|
|||
{
|
||||
target->drag_drop_disabled = src->drag_drop_disabled;
|
||||
target->load_drops_disabled = src->load_drops_disabled;
|
||||
target->history_disabled = src->history_disabled;
|
||||
|
||||
cef_string_set(src->standard_font_family.str,
|
||||
src->standard_font_family.length, &target->standard_font_family, copy);
|
||||
|
|
|
@ -43,11 +43,12 @@ void BrowserNavigationEntry::SetContentState(const std::string& state) {
|
|||
// ----------------------------------------------------------------------------
|
||||
// BrowserNavigationController
|
||||
|
||||
BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell)
|
||||
BrowserNavigationController::BrowserNavigationController(
|
||||
CefBrowserImpl* browser)
|
||||
: pending_entry_(NULL),
|
||||
last_committed_entry_index_(-1),
|
||||
pending_entry_index_(-1),
|
||||
browser_(shell),
|
||||
browser_(browser),
|
||||
max_page_id_(-1) {
|
||||
}
|
||||
|
||||
|
@ -60,6 +61,7 @@ void BrowserNavigationController::Reset() {
|
|||
DiscardPendingEntry();
|
||||
|
||||
last_committed_entry_index_ = -1;
|
||||
UpdateMaxPageID();
|
||||
}
|
||||
|
||||
void BrowserNavigationController::Reload(bool ignoreCache) {
|
||||
|
@ -198,12 +200,19 @@ void BrowserNavigationController::DiscardPendingEntry() {
|
|||
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
||||
DiscardPendingEntry();
|
||||
|
||||
// Prune any entry which are in front of the current entry
|
||||
int current_size = static_cast<int>(entries_.size());
|
||||
if (current_size > 0) {
|
||||
while (last_committed_entry_index_ < (current_size - 1)) {
|
||||
entries_.pop_back();
|
||||
current_size--;
|
||||
const CefBrowserSettings& settings = browser_->settings();
|
||||
if (settings.history_disabled) {
|
||||
// History is disabled. Remove any existing entries.
|
||||
if (entries_.size() > 0)
|
||||
entries_.clear();
|
||||
} else {
|
||||
// Prune any entry which are in front of the current entry.
|
||||
int current_size = static_cast<int>(entries_.size());
|
||||
if (current_size > 0) {
|
||||
while (last_committed_entry_index_ < (current_size - 1)) {
|
||||
entries_.pop_back();
|
||||
current_size--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ private:
|
|||
// version as possible.
|
||||
class BrowserNavigationController {
|
||||
public:
|
||||
BrowserNavigationController(CefBrowserImpl* shell);
|
||||
BrowserNavigationController(CefBrowserImpl* browser);
|
||||
~BrowserNavigationController();
|
||||
|
||||
void Reset();
|
||||
|
|
|
@ -197,6 +197,8 @@ void AppGetBrowserSettings(CefBrowserSettings& settings)
|
|||
g_command_line->HasSwitch(cefclient::kDragDropDisabled);
|
||||
settings.load_drops_disabled =
|
||||
g_command_line->HasSwitch(cefclient::kLoadDropsDisabled);
|
||||
settings.history_disabled =
|
||||
g_command_line->HasSwitch(cefclient::kHistoryDisabled);
|
||||
settings.remote_fonts_disabled =
|
||||
g_command_line->HasSwitch(cefclient::kRemoteFontsDisabled);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ const char kJavascriptFlags[] = "javascript-flags";
|
|||
// CefBrowserSettings attributes.
|
||||
const char kDragDropDisabled[] = "drag-drop-disabled";
|
||||
const char kLoadDropsDisabled[] = "load-drops-disabled";
|
||||
const char kHistoryDisabled[] = "history-disabled";
|
||||
const char kRemoteFontsDisabled[] = "remote-fonts-disabled";
|
||||
const char kDefaultEncoding[] = "default-encoding";
|
||||
const char kEncodingDetectorEnabled[] = "encoding-detector-enabled";
|
||||
|
|
|
@ -35,6 +35,7 @@ extern const char kJavascriptFlags[];
|
|||
// CefBrowserSettings attributes.
|
||||
extern const char kDragDropDisabled[];
|
||||
extern const char kLoadDropsDisabled[];
|
||||
extern const char kHistoryDisabled[];
|
||||
extern const char kRemoteFontsDisabled[];
|
||||
extern const char kDefaultEncoding[];
|
||||
extern const char kEncodingDetectorEnabled[];
|
||||
|
|
Loading…
Reference in New Issue