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

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

Issue 12086109: Prevent bindings escalation on an existing NavigationEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Catch another case where pending WebUI was set. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/navigation_entry_impl.h" 5 #include "content/browser/web_contents/navigation_entry_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
11 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
12 #include "ui/base/text/text_elider.h" 12 #include "ui/base/text/text_elider.h"
13 13
14 // Use this to get a new unique ID for a NavigationEntry during construction. 14 // Use this to get a new unique ID for a NavigationEntry during construction.
15 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). 15 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator).
16 static int GetUniqueIDInConstructor() { 16 static int GetUniqueIDInConstructor() {
17 static int unique_id_counter = 0; 17 static int unique_id_counter = 0;
18 return ++unique_id_counter; 18 return ++unique_id_counter;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 22
23 int NavigationEntryImpl::kInvalidBindings = -1;
24
23 NavigationEntry* NavigationEntry::Create() { 25 NavigationEntry* NavigationEntry::Create() {
24 return new NavigationEntryImpl(); 26 return new NavigationEntryImpl();
25 } 27 }
26 28
27 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) { 29 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) {
28 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy)); 30 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy));
29 } 31 }
30 32
31 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( 33 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
32 NavigationEntry* entry) { 34 NavigationEntry* entry) {
33 return static_cast<NavigationEntryImpl*>(entry); 35 return static_cast<NavigationEntryImpl*>(entry);
34 } 36 }
35 37
36 NavigationEntryImpl::NavigationEntryImpl() 38 NavigationEntryImpl::NavigationEntryImpl()
37 : unique_id_(GetUniqueIDInConstructor()), 39 : unique_id_(GetUniqueIDInConstructor()),
38 site_instance_(NULL), 40 site_instance_(NULL),
41 bindings_(kInvalidBindings),
39 page_type_(PAGE_TYPE_NORMAL), 42 page_type_(PAGE_TYPE_NORMAL),
40 update_virtual_url_with_url_(false), 43 update_virtual_url_with_url_(false),
41 page_id_(-1), 44 page_id_(-1),
42 transition_type_(PAGE_TRANSITION_LINK), 45 transition_type_(PAGE_TRANSITION_LINK),
43 has_post_data_(false), 46 has_post_data_(false),
44 post_id_(-1), 47 post_id_(-1),
45 restore_type_(RESTORE_NONE), 48 restore_type_(RESTORE_NONE),
46 is_overriding_user_agent_(false), 49 is_overriding_user_agent_(false),
47 is_renderer_initiated_(false), 50 is_renderer_initiated_(false),
48 should_replace_entry_(false), 51 should_replace_entry_(false),
49 can_load_local_resources_(false) { 52 can_load_local_resources_(false) {
50 } 53 }
51 54
52 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, 55 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance,
53 int page_id, 56 int page_id,
54 const GURL& url, 57 const GURL& url,
55 const Referrer& referrer, 58 const Referrer& referrer,
56 const string16& title, 59 const string16& title,
57 PageTransition transition_type, 60 PageTransition transition_type,
58 bool is_renderer_initiated) 61 bool is_renderer_initiated)
59 : unique_id_(GetUniqueIDInConstructor()), 62 : unique_id_(GetUniqueIDInConstructor()),
60 site_instance_(instance), 63 site_instance_(instance),
64 bindings_(kInvalidBindings),
61 page_type_(PAGE_TYPE_NORMAL), 65 page_type_(PAGE_TYPE_NORMAL),
62 url_(url), 66 url_(url),
63 referrer_(referrer), 67 referrer_(referrer),
64 update_virtual_url_with_url_(false), 68 update_virtual_url_with_url_(false),
65 title_(title), 69 title_(title),
66 page_id_(page_id), 70 page_id_(page_id),
67 transition_type_(transition_type), 71 transition_type_(transition_type),
68 has_post_data_(false), 72 has_post_data_(false),
69 post_id_(-1), 73 post_id_(-1),
70 restore_type_(RESTORE_NONE), 74 restore_type_(RESTORE_NONE),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 145 }
142 146
143 int32 NavigationEntryImpl::GetPageID() const { 147 int32 NavigationEntryImpl::GetPageID() const {
144 return page_id_; 148 return page_id_;
145 } 149 }
146 150
147 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) { 151 void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) {
148 site_instance_ = site_instance; 152 site_instance_ = site_instance;
149 } 153 }
150 154
155 void NavigationEntryImpl::SetBindings(int bindings) {
156 // Ensure this is set to a valid value, and that it stays the same once set.
157 CHECK_NE(bindings, kInvalidBindings);
158 CHECK(bindings_ == kInvalidBindings || bindings_ == bindings);
159 bindings_ = bindings;
160 }
161
151 const string16& NavigationEntryImpl::GetTitleForDisplay( 162 const string16& NavigationEntryImpl::GetTitleForDisplay(
152 const std::string& languages) const { 163 const std::string& languages) const {
153 // Most pages have real titles. Don't even bother caching anything if this is 164 // Most pages have real titles. Don't even bother caching anything if this is
154 // the case. 165 // the case.
155 if (!title_.empty()) 166 if (!title_.empty())
156 return title_; 167 return title_;
157 168
158 // More complicated cases will use the URLs as the title. This result we will 169 // More complicated cases will use the URLs as the title. This result we will
159 // cache since it's more complicated to compute. 170 // cache since it's more complicated to compute.
160 if (!cached_display_title_.empty()) 171 if (!cached_display_title_.empty())
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 const std::string& NavigationEntryImpl::GetFrameToNavigate() const { 289 const std::string& NavigationEntryImpl::GetFrameToNavigate() const {
279 return frame_to_navigate_; 290 return frame_to_navigate_;
280 } 291 }
281 292
282 void NavigationEntryImpl::SetScreenshotPNGData( 293 void NavigationEntryImpl::SetScreenshotPNGData(
283 const std::vector<unsigned char>& png_data) { 294 const std::vector<unsigned char>& png_data) {
284 screenshot_ = png_data.empty() ? NULL : new base::RefCountedBytes(png_data); 295 screenshot_ = png_data.empty() ? NULL : new base::RefCountedBytes(png_data);
285 } 296 }
286 297
287 } // namespace content 298 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/navigation_entry_impl.h ('k') | content/browser/web_contents/render_view_host_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698