mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-18 13:10:42 +01:00
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;
|
bool load_drops_disabled;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Disable history back/forward navigation.
|
||||||
|
///
|
||||||
|
bool history_disabled;
|
||||||
|
|
||||||
// The below values map to WebPreferences settings.
|
// The below values map to WebPreferences settings.
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -324,6 +324,7 @@ struct CefBrowserSettingsTraits {
|
|||||||
{
|
{
|
||||||
target->drag_drop_disabled = src->drag_drop_disabled;
|
target->drag_drop_disabled = src->drag_drop_disabled;
|
||||||
target->load_drops_disabled = src->load_drops_disabled;
|
target->load_drops_disabled = src->load_drops_disabled;
|
||||||
|
target->history_disabled = src->history_disabled;
|
||||||
|
|
||||||
cef_string_set(src->standard_font_family.str,
|
cef_string_set(src->standard_font_family.str,
|
||||||
src->standard_font_family.length, &target->standard_font_family, copy);
|
src->standard_font_family.length, &target->standard_font_family, copy);
|
||||||
|
@ -43,11 +43,12 @@ void BrowserNavigationEntry::SetContentState(const std::string& state) {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// BrowserNavigationController
|
// BrowserNavigationController
|
||||||
|
|
||||||
BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell)
|
BrowserNavigationController::BrowserNavigationController(
|
||||||
|
CefBrowserImpl* browser)
|
||||||
: pending_entry_(NULL),
|
: pending_entry_(NULL),
|
||||||
last_committed_entry_index_(-1),
|
last_committed_entry_index_(-1),
|
||||||
pending_entry_index_(-1),
|
pending_entry_index_(-1),
|
||||||
browser_(shell),
|
browser_(browser),
|
||||||
max_page_id_(-1) {
|
max_page_id_(-1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ void BrowserNavigationController::Reset() {
|
|||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
last_committed_entry_index_ = -1;
|
last_committed_entry_index_ = -1;
|
||||||
|
UpdateMaxPageID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserNavigationController::Reload(bool ignoreCache) {
|
void BrowserNavigationController::Reload(bool ignoreCache) {
|
||||||
@ -198,7 +200,13 @@ void BrowserNavigationController::DiscardPendingEntry() {
|
|||||||
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
||||||
DiscardPendingEntry();
|
DiscardPendingEntry();
|
||||||
|
|
||||||
// Prune any entry which are in front of the current entry
|
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());
|
int current_size = static_cast<int>(entries_.size());
|
||||||
if (current_size > 0) {
|
if (current_size > 0) {
|
||||||
while (last_committed_entry_index_ < (current_size - 1)) {
|
while (last_committed_entry_index_ < (current_size - 1)) {
|
||||||
@ -206,6 +214,7 @@ void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
|
|||||||
current_size--;
|
current_size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
|
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
|
||||||
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
|
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
|
||||||
|
@ -97,7 +97,7 @@ private:
|
|||||||
// version as possible.
|
// version as possible.
|
||||||
class BrowserNavigationController {
|
class BrowserNavigationController {
|
||||||
public:
|
public:
|
||||||
BrowserNavigationController(CefBrowserImpl* shell);
|
BrowserNavigationController(CefBrowserImpl* browser);
|
||||||
~BrowserNavigationController();
|
~BrowserNavigationController();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
@ -197,6 +197,8 @@ void AppGetBrowserSettings(CefBrowserSettings& settings)
|
|||||||
g_command_line->HasSwitch(cefclient::kDragDropDisabled);
|
g_command_line->HasSwitch(cefclient::kDragDropDisabled);
|
||||||
settings.load_drops_disabled =
|
settings.load_drops_disabled =
|
||||||
g_command_line->HasSwitch(cefclient::kLoadDropsDisabled);
|
g_command_line->HasSwitch(cefclient::kLoadDropsDisabled);
|
||||||
|
settings.history_disabled =
|
||||||
|
g_command_line->HasSwitch(cefclient::kHistoryDisabled);
|
||||||
settings.remote_fonts_disabled =
|
settings.remote_fonts_disabled =
|
||||||
g_command_line->HasSwitch(cefclient::kRemoteFontsDisabled);
|
g_command_line->HasSwitch(cefclient::kRemoteFontsDisabled);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ const char kJavascriptFlags[] = "javascript-flags";
|
|||||||
// CefBrowserSettings attributes.
|
// CefBrowserSettings attributes.
|
||||||
const char kDragDropDisabled[] = "drag-drop-disabled";
|
const char kDragDropDisabled[] = "drag-drop-disabled";
|
||||||
const char kLoadDropsDisabled[] = "load-drops-disabled";
|
const char kLoadDropsDisabled[] = "load-drops-disabled";
|
||||||
|
const char kHistoryDisabled[] = "history-disabled";
|
||||||
const char kRemoteFontsDisabled[] = "remote-fonts-disabled";
|
const char kRemoteFontsDisabled[] = "remote-fonts-disabled";
|
||||||
const char kDefaultEncoding[] = "default-encoding";
|
const char kDefaultEncoding[] = "default-encoding";
|
||||||
const char kEncodingDetectorEnabled[] = "encoding-detector-enabled";
|
const char kEncodingDetectorEnabled[] = "encoding-detector-enabled";
|
||||||
|
@ -35,6 +35,7 @@ extern const char kJavascriptFlags[];
|
|||||||
// CefBrowserSettings attributes.
|
// CefBrowserSettings attributes.
|
||||||
extern const char kDragDropDisabled[];
|
extern const char kDragDropDisabled[];
|
||||||
extern const char kLoadDropsDisabled[];
|
extern const char kLoadDropsDisabled[];
|
||||||
|
extern const char kHistoryDisabled[];
|
||||||
extern const char kRemoteFontsDisabled[];
|
extern const char kRemoteFontsDisabled[];
|
||||||
extern const char kDefaultEncoding[];
|
extern const char kDefaultEncoding[];
|
||||||
extern const char kEncodingDetectorEnabled[];
|
extern const char kEncodingDetectorEnabled[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user