This source file includes following definitions.
- GetUniqueIDInConstructor
- Create
- Create
- FromNavigationEntry
- frame_tree_node_id_
- frame_tree_node_id_
- GetUniqueID
- GetPageType
- SetURL
- GetURL
- SetBaseURLForDataURL
- GetBaseURLForDataURL
- SetReferrer
- GetReferrer
- SetVirtualURL
- GetVirtualURL
- SetTitle
- GetTitle
- SetPageState
- GetPageState
- SetPageID
- GetPageID
- set_site_instance
- SetBindings
- GetTitleForDisplay
- IsViewSourceMode
- SetTransitionType
- GetTransitionType
- GetUserTypedURL
- SetHasPostData
- GetHasPostData
- SetPostID
- GetPostID
- SetBrowserInitiatedPostData
- GetBrowserInitiatedPostData
- GetFavicon
- GetFavicon
- GetSSL
- GetSSL
- SetOriginalRequestURL
- GetOriginalRequestURL
- SetIsOverridingUserAgent
- GetIsOverridingUserAgent
- SetTimestamp
- GetTimestamp
- SetHttpStatusCode
- GetHttpStatusCode
- IsRestored
- SetCanLoadLocalResources
- GetCanLoadLocalResources
- SetFrameToNavigate
- GetFrameToNavigate
- SetExtraData
- GetExtraData
- ClearExtraData
- ResetForCommit
- SetScreenshotPNGData
#include "content/browser/frame_host/navigation_entry_impl.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
#include "net/base/net_util.h"
#include "ui/gfx/text_elider.h"
static int GetUniqueIDInConstructor() {
static int unique_id_counter = 0;
return ++unique_id_counter;
}
namespace content {
int NavigationEntryImpl::kInvalidBindings = -1;
NavigationEntry* NavigationEntry::Create() {
return new NavigationEntryImpl();
}
NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) {
return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy));
}
NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
NavigationEntry* entry) {
return static_cast<NavigationEntryImpl*>(entry);
}
NavigationEntryImpl::NavigationEntryImpl()
: unique_id_(GetUniqueIDInConstructor()),
site_instance_(NULL),
bindings_(kInvalidBindings),
page_type_(PAGE_TYPE_NORMAL),
update_virtual_url_with_url_(false),
page_id_(-1),
transition_type_(PAGE_TRANSITION_LINK),
has_post_data_(false),
post_id_(-1),
restore_type_(RESTORE_NONE),
is_overriding_user_agent_(false),
http_status_code_(0),
is_renderer_initiated_(false),
should_replace_entry_(false),
should_clear_history_list_(false),
can_load_local_resources_(false),
frame_tree_node_id_(-1) {
}
NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance,
int page_id,
const GURL& url,
const Referrer& referrer,
const base::string16& title,
PageTransition transition_type,
bool is_renderer_initiated)
: unique_id_(GetUniqueIDInConstructor()),
site_instance_(instance),
bindings_(kInvalidBindings),
page_type_(PAGE_TYPE_NORMAL),
url_(url),
referrer_(referrer),
update_virtual_url_with_url_(false),
title_(title),
page_id_(page_id),
transition_type_(transition_type),
has_post_data_(false),
post_id_(-1),
restore_type_(RESTORE_NONE),
is_overriding_user_agent_(false),
http_status_code_(0),
is_renderer_initiated_(is_renderer_initiated),
should_replace_entry_(false),
should_clear_history_list_(false),
can_load_local_resources_(false),
frame_tree_node_id_(-1) {
}
NavigationEntryImpl::~NavigationEntryImpl() {
}
int NavigationEntryImpl::GetUniqueID() const {
return unique_id_;
}
PageType NavigationEntryImpl::GetPageType() const {
return page_type_;
}
void NavigationEntryImpl::SetURL(const GURL& url) {
url_ = url;
cached_display_title_.clear();
}
const GURL& NavigationEntryImpl::GetURL() const {
return url_;
}
void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) {
base_url_for_data_url_ = url;
}
const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const {
return base_url_for_data_url_;
}
void NavigationEntryImpl::SetReferrer(const Referrer& referrer) {
referrer_ = referrer;
}
const Referrer& NavigationEntryImpl::GetReferrer() const {
return referrer_;
}
void NavigationEntryImpl::SetVirtualURL(const GURL& url) {
virtual_url_ = (url == url_) ? GURL() : url;
cached_display_title_.clear();
}
const GURL& NavigationEntryImpl::GetVirtualURL() const {
return virtual_url_.is_empty() ? url_ : virtual_url_;
}
void NavigationEntryImpl::SetTitle(const base::string16& title) {
title_ = title;
cached_display_title_.clear();
}
const base::string16& NavigationEntryImpl::GetTitle() const {
return title_;
}
void NavigationEntryImpl::SetPageState(const PageState& state) {
page_state_ = state;
}
const PageState& NavigationEntryImpl::GetPageState() const {
return page_state_;
}
void NavigationEntryImpl::SetPageID(int page_id) {
page_id_ = page_id;
}
int32 NavigationEntryImpl::GetPageID() const {
return page_id_;
}
void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) {
site_instance_ = site_instance;
}
void NavigationEntryImpl::SetBindings(int bindings) {
CHECK_NE(bindings, kInvalidBindings);
CHECK(bindings_ == kInvalidBindings || bindings_ == bindings);
bindings_ = bindings;
}
const base::string16& NavigationEntryImpl::GetTitleForDisplay(
const std::string& languages) const {
if (!title_.empty())
return title_;
if (!cached_display_title_.empty())
return cached_display_title_;
base::string16 title;
if (!virtual_url_.is_empty()) {
title = net::FormatUrl(virtual_url_, languages);
} else if (!url_.is_empty()) {
title = net::FormatUrl(url_, languages);
}
if (url_.SchemeIsFile()) {
base::string16::size_type slashpos = title.rfind('/');
if (slashpos != base::string16::npos)
title = title.substr(slashpos + 1);
}
gfx::ElideString(title, kMaxTitleChars, &cached_display_title_);
return cached_display_title_;
}
bool NavigationEntryImpl::IsViewSourceMode() const {
return virtual_url_.SchemeIs(kViewSourceScheme);
}
void NavigationEntryImpl::SetTransitionType(
PageTransition transition_type) {
transition_type_ = transition_type;
}
PageTransition NavigationEntryImpl::GetTransitionType() const {
return transition_type_;
}
const GURL& NavigationEntryImpl::GetUserTypedURL() const {
return user_typed_url_;
}
void NavigationEntryImpl::SetHasPostData(bool has_post_data) {
has_post_data_ = has_post_data;
}
bool NavigationEntryImpl::GetHasPostData() const {
return has_post_data_;
}
void NavigationEntryImpl::SetPostID(int64 post_id) {
post_id_ = post_id;
}
int64 NavigationEntryImpl::GetPostID() const {
return post_id_;
}
void NavigationEntryImpl::SetBrowserInitiatedPostData(
const base::RefCountedMemory* data) {
browser_initiated_post_data_ = data;
}
const base::RefCountedMemory*
NavigationEntryImpl::GetBrowserInitiatedPostData() const {
return browser_initiated_post_data_.get();
}
const FaviconStatus& NavigationEntryImpl::GetFavicon() const {
return favicon_;
}
FaviconStatus& NavigationEntryImpl::GetFavicon() {
return favicon_;
}
const SSLStatus& NavigationEntryImpl::GetSSL() const {
return ssl_;
}
SSLStatus& NavigationEntryImpl::GetSSL() {
return ssl_;
}
void NavigationEntryImpl::SetOriginalRequestURL(const GURL& original_url) {
original_request_url_ = original_url;
}
const GURL& NavigationEntryImpl::GetOriginalRequestURL() const {
return original_request_url_;
}
void NavigationEntryImpl::SetIsOverridingUserAgent(bool override) {
is_overriding_user_agent_ = override;
}
bool NavigationEntryImpl::GetIsOverridingUserAgent() const {
return is_overriding_user_agent_;
}
void NavigationEntryImpl::SetTimestamp(base::Time timestamp) {
timestamp_ = timestamp;
}
base::Time NavigationEntryImpl::GetTimestamp() const {
return timestamp_;
}
void NavigationEntryImpl::SetHttpStatusCode(int http_status_code) {
http_status_code_ = http_status_code;
}
int NavigationEntryImpl::GetHttpStatusCode() const {
return http_status_code_;
}
bool NavigationEntryImpl::IsRestored() const {
return restore_type_ != RESTORE_NONE;
}
void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) {
can_load_local_resources_ = allow;
}
bool NavigationEntryImpl::GetCanLoadLocalResources() const {
return can_load_local_resources_;
}
void NavigationEntryImpl::SetFrameToNavigate(const std::string& frame_name) {
frame_to_navigate_ = frame_name;
}
const std::string& NavigationEntryImpl::GetFrameToNavigate() const {
return frame_to_navigate_;
}
void NavigationEntryImpl::SetExtraData(const std::string& key,
const base::string16& data) {
extra_data_[key] = data;
}
bool NavigationEntryImpl::GetExtraData(const std::string& key,
base::string16* data) const {
std::map<std::string, base::string16>::const_iterator iter =
extra_data_.find(key);
if (iter == extra_data_.end())
return false;
*data = iter->second;
return true;
}
void NavigationEntryImpl::ClearExtraData(const std::string& key) {
extra_data_.erase(key);
}
void NavigationEntryImpl::ResetForCommit() {
SetBrowserInitiatedPostData(NULL);
set_is_renderer_initiated(false);
set_transferred_global_request_id(GlobalRequestID());
set_should_replace_entry(false);
redirect_chain_.clear();
set_should_clear_history_list(false);
set_frame_tree_node_id(-1);
}
void NavigationEntryImpl::SetScreenshotPNGData(
scoped_refptr<base::RefCountedBytes> png_data) {
screenshot_ = png_data;
if (screenshot_.get())
UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size());
}
}