Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Side by Side Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 931333004: Add FrameNavigationEntry class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits + git cl format Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/navigation_entry_impl.h" 5 #include "content/browser/frame_host/navigation_entry_impl.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/common/content_constants.h" 10 #include "content/public/common/content_constants.h"
(...skipping 30 matching lines...) Expand all
41 ui::PAGE_TRANSITION_LINK, false) { 41 ui::PAGE_TRANSITION_LINK, false) {
42 } 42 }
43 43
44 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, 44 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance,
45 int page_id, 45 int page_id,
46 const GURL& url, 46 const GURL& url,
47 const Referrer& referrer, 47 const Referrer& referrer,
48 const base::string16& title, 48 const base::string16& title,
49 ui::PageTransition transition_type, 49 ui::PageTransition transition_type,
50 bool is_renderer_initiated) 50 bool is_renderer_initiated)
51 : unique_id_(GetUniqueIDInConstructor()), 51 : frame_entry_(instance, url, referrer),
52 site_instance_(instance), 52 unique_id_(GetUniqueIDInConstructor()),
53 bindings_(kInvalidBindings), 53 bindings_(kInvalidBindings),
54 page_type_(PAGE_TYPE_NORMAL), 54 page_type_(PAGE_TYPE_NORMAL),
55 url_(url),
56 referrer_(referrer),
57 update_virtual_url_with_url_(false), 55 update_virtual_url_with_url_(false),
58 title_(title), 56 title_(title),
59 page_id_(page_id), 57 page_id_(page_id),
60 transition_type_(transition_type), 58 transition_type_(transition_type),
61 has_post_data_(false), 59 has_post_data_(false),
62 post_id_(-1), 60 post_id_(-1),
63 restore_type_(RESTORE_NONE), 61 restore_type_(RESTORE_NONE),
64 is_overriding_user_agent_(false), 62 is_overriding_user_agent_(false),
65 http_status_code_(0), 63 http_status_code_(0),
66 is_renderer_initiated_(is_renderer_initiated), 64 is_renderer_initiated_(is_renderer_initiated),
67 should_replace_entry_(false), 65 should_replace_entry_(false),
68 should_clear_history_list_(false), 66 should_clear_history_list_(false),
69 can_load_local_resources_(false), 67 can_load_local_resources_(false),
70 frame_tree_node_id_(-1) { 68 frame_tree_node_id_(-1) {
71 } 69 }
72 70
73 NavigationEntryImpl::~NavigationEntryImpl() { 71 NavigationEntryImpl::~NavigationEntryImpl() {
74 } 72 }
75 73
76 int NavigationEntryImpl::GetUniqueID() const { 74 int NavigationEntryImpl::GetUniqueID() const {
77 return unique_id_; 75 return unique_id_;
78 } 76 }
79 77
80 PageType NavigationEntryImpl::GetPageType() const { 78 PageType NavigationEntryImpl::GetPageType() const {
81 return page_type_; 79 return page_type_;
82 } 80 }
83 81
84 void NavigationEntryImpl::SetURL(const GURL& url) { 82 void NavigationEntryImpl::SetURL(const GURL& url) {
85 url_ = url; 83 frame_entry_.set_url(url);
86 cached_display_title_.clear(); 84 cached_display_title_.clear();
87 } 85 }
88 86
89 const GURL& NavigationEntryImpl::GetURL() const { 87 const GURL& NavigationEntryImpl::GetURL() const {
90 return url_; 88 return frame_entry_.url();
91 } 89 }
92 90
93 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) { 91 void NavigationEntryImpl::SetBaseURLForDataURL(const GURL& url) {
94 base_url_for_data_url_ = url; 92 base_url_for_data_url_ = url;
95 } 93 }
96 94
97 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const { 95 const GURL& NavigationEntryImpl::GetBaseURLForDataURL() const {
98 return base_url_for_data_url_; 96 return base_url_for_data_url_;
99 } 97 }
100 98
101 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) { 99 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) {
102 referrer_ = referrer; 100 frame_entry_.set_referrer(referrer);
103 } 101 }
104 102
105 const Referrer& NavigationEntryImpl::GetReferrer() const { 103 const Referrer& NavigationEntryImpl::GetReferrer() const {
106 return referrer_; 104 return frame_entry_.referrer();
107 } 105 }
108 106
109 void NavigationEntryImpl::SetVirtualURL(const GURL& url) { 107 void NavigationEntryImpl::SetVirtualURL(const GURL& url) {
110 virtual_url_ = (url == url_) ? GURL() : url; 108 virtual_url_ = (url == GetURL()) ? GURL() : url;
111 cached_display_title_.clear(); 109 cached_display_title_.clear();
112 } 110 }
113 111
114 const GURL& NavigationEntryImpl::GetVirtualURL() const { 112 const GURL& NavigationEntryImpl::GetVirtualURL() const {
115 return virtual_url_.is_empty() ? url_ : virtual_url_; 113 return virtual_url_.is_empty() ? GetURL() : virtual_url_;
116 } 114 }
117 115
118 void NavigationEntryImpl::SetTitle(const base::string16& title) { 116 void NavigationEntryImpl::SetTitle(const base::string16& title) {
119 title_ = title; 117 title_ = title;
120 cached_display_title_.clear(); 118 cached_display_title_.clear();
121 } 119 }
122 120
123 const base::string16& NavigationEntryImpl::GetTitle() const { 121 const base::string16& NavigationEntryImpl::GetTitle() const {
124 return title_; 122 return title_;
125 } 123 }
126 124
127 void NavigationEntryImpl::SetPageState(const PageState& state) { 125 void NavigationEntryImpl::SetPageState(const PageState& state) {
128 CHECK(state.ToEncodedData().empty() || state.IsValid()); 126 CHECK(state.ToEncodedData().empty() || state.IsValid());
129 page_state_ = state; 127 page_state_ = state;
130 } 128 }
131 129
132 const PageState& NavigationEntryImpl::GetPageState() const { 130 const PageState& NavigationEntryImpl::GetPageState() const {
133 return page_state_; 131 return page_state_;
134 } 132 }
135 133
136 void NavigationEntryImpl::SetPageID(int page_id) { 134 void NavigationEntryImpl::SetPageID(int page_id) {
137 page_id_ = page_id; 135 page_id_ = page_id;
138 } 136 }
139 137
140 int32 NavigationEntryImpl::GetPageID() const { 138 int32 NavigationEntryImpl::GetPageID() const {
141 return page_id_; 139 return page_id_;
142 } 140 }
143 141
144 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) { 142 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) {
145 site_instance_ = site_instance; 143 frame_entry_.set_site_instance(site_instance);
146 } 144 }
147 145
148 void NavigationEntryImpl::set_source_site_instance( 146 void NavigationEntryImpl::set_source_site_instance(
149 SiteInstanceImpl* source_site_instance) { 147 SiteInstanceImpl* source_site_instance) {
150 source_site_instance_ = source_site_instance; 148 source_site_instance_ = source_site_instance;
151 } 149 }
152 150
153 void NavigationEntryImpl::SetBindings(int bindings) { 151 void NavigationEntryImpl::SetBindings(int bindings) {
154 // Ensure this is set to a valid value, and that it stays the same once set. 152 // Ensure this is set to a valid value, and that it stays the same once set.
155 CHECK_NE(bindings, kInvalidBindings); 153 CHECK_NE(bindings, kInvalidBindings);
(...skipping 10 matching lines...) Expand all
166 164
167 // More complicated cases will use the URLs as the title. This result we will 165 // More complicated cases will use the URLs as the title. This result we will
168 // cache since it's more complicated to compute. 166 // cache since it's more complicated to compute.
169 if (!cached_display_title_.empty()) 167 if (!cached_display_title_.empty())
170 return cached_display_title_; 168 return cached_display_title_;
171 169
172 // Use the virtual URL first if any, and fall back on using the real URL. 170 // Use the virtual URL first if any, and fall back on using the real URL.
173 base::string16 title; 171 base::string16 title;
174 if (!virtual_url_.is_empty()) { 172 if (!virtual_url_.is_empty()) {
175 title = net::FormatUrl(virtual_url_, languages); 173 title = net::FormatUrl(virtual_url_, languages);
176 } else if (!url_.is_empty()) { 174 } else if (!GetURL().is_empty()) {
177 title = net::FormatUrl(url_, languages); 175 title = net::FormatUrl(GetURL(), languages);
178 } 176 }
179 177
180 // For file:// URLs use the filename as the title, not the full path. 178 // For file:// URLs use the filename as the title, not the full path.
181 if (url_.SchemeIsFile()) { 179 if (GetURL().SchemeIsFile()) {
182 base::string16::size_type slashpos = title.rfind('/'); 180 base::string16::size_type slashpos = title.rfind('/');
183 if (slashpos != base::string16::npos) 181 if (slashpos != base::string16::npos)
184 title = title.substr(slashpos + 1); 182 title = title.substr(slashpos + 1);
185 } 183 }
186 184
187 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_); 185 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_);
188 return cached_display_title_; 186 return cached_display_title_;
189 } 187 }
190 188
191 bool NavigationEntryImpl::IsViewSourceMode() const { 189 bool NavigationEntryImpl::IsViewSourceMode() const {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 346 }
349 347
350 void NavigationEntryImpl::SetScreenshotPNGData( 348 void NavigationEntryImpl::SetScreenshotPNGData(
351 scoped_refptr<base::RefCountedBytes> png_data) { 349 scoped_refptr<base::RefCountedBytes> png_data) {
352 screenshot_ = png_data; 350 screenshot_ = png_data;
353 if (screenshot_.get()) 351 if (screenshot_.get())
354 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); 352 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size());
355 } 353 }
356 354
357 } // namespace content 355 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698