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

Side by Side Diff: content/browser/tab_contents/navigation_controller.cc

Issue 7791029: When the user navigates to the home page, make sure to set the RLZ string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 } 215 }
216 216
217 bool NavigationController::IsInitialNavigation() { 217 bool NavigationController::IsInitialNavigation() {
218 return last_document_loaded_.is_null(); 218 return last_document_loaded_.is_null();
219 } 219 }
220 220
221 // static 221 // static
222 NavigationEntry* NavigationController::CreateNavigationEntry( 222 NavigationEntry* NavigationController::CreateNavigationEntry(
223 const GURL& url, const GURL& referrer, PageTransition::Type transition, 223 const GURL& url, const GURL& referrer, PageTransition::Type transition,
224 const std::string& extra_headers,
224 content::BrowserContext* browser_context) { 225 content::BrowserContext* browser_context) {
225 // Allow the browser URL handler to rewrite the URL. This will, for example, 226 // Allow the browser URL handler to rewrite the URL. This will, for example,
226 // remove "view-source:" from the beginning of the URL to get the URL that 227 // remove "view-source:" from the beginning of the URL to get the URL that
227 // will actually be loaded. This real URL won't be shown to the user, just 228 // will actually be loaded. This real URL won't be shown to the user, just
228 // used internally. 229 // used internally.
229 GURL loaded_url(url); 230 GURL loaded_url(url);
230 bool reverse_on_redirect = false; 231 bool reverse_on_redirect = false;
231 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 232 BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
232 &loaded_url, browser_context, &reverse_on_redirect); 233 &loaded_url, browser_context, &reverse_on_redirect);
233 234
234 NavigationEntry* entry = new NavigationEntry( 235 NavigationEntry* entry = new NavigationEntry(
235 NULL, // The site instance for tabs is sent on navigation 236 NULL, // The site instance for tabs is sent on navigation
236 // (TabContents::GetSiteInstance). 237 // (TabContents::GetSiteInstance).
237 -1, 238 -1,
238 loaded_url, 239 loaded_url,
239 referrer, 240 referrer,
240 string16(), 241 string16(),
241 transition); 242 transition);
242 entry->set_virtual_url(url); 243 entry->set_virtual_url(url);
243 entry->set_user_typed_url(url); 244 entry->set_user_typed_url(url);
244 entry->set_update_virtual_url_with_url(reverse_on_redirect); 245 entry->set_update_virtual_url_with_url(reverse_on_redirect);
246 entry->set_extra_headers(extra_headers);
245 return entry; 247 return entry;
246 } 248 }
247 249
248 NavigationEntry* NavigationController::GetEntryWithPageID( 250 NavigationEntry* NavigationController::GetEntryWithPageID(
249 SiteInstance* instance, int32 page_id) const { 251 SiteInstance* instance, int32 page_id) const {
250 int index = GetEntryIndexWithPageID(instance, page_id); 252 int index = GetEntryIndexWithPageID(instance, page_id);
251 return (index != -1) ? entries_[index].get() : NULL; 253 return (index != -1) ? entries_[index].get() : NULL;
252 } 254 }
253 255
254 void NavigationController::LoadEntry(NavigationEntry* entry) { 256 void NavigationController::LoadEntry(NavigationEntry* entry) {
(...skipping 11 matching lines...) Expand all
266 } 268 }
267 269
268 // When navigating to a new page, we don't know for sure if we will actually 270 // When navigating to a new page, we don't know for sure if we will actually
269 // end up leaving the current page. The new page load could for example 271 // end up leaving the current page. The new page load could for example
270 // result in a download or a 'no content' response (e.g., a mailto: URL). 272 // result in a download or a 'no content' response (e.g., a mailto: URL).
271 DiscardNonCommittedEntriesInternal(); 273 DiscardNonCommittedEntriesInternal();
272 pending_entry_ = entry; 274 pending_entry_ = entry;
273 NotificationService::current()->Notify( 275 NotificationService::current()->Notify(
274 content::NOTIFICATION_NAV_ENTRY_PENDING, 276 content::NOTIFICATION_NAV_ENTRY_PENDING,
275 Source<NavigationController>(this), 277 Source<NavigationController>(this),
276 NotificationService::NoDetails()); 278 Details<NavigationEntry>(entry));
sky 2011/08/30 17:05:25 Update comments for NAV_ENTRY_PENDING indicating w
Roger Tawa OOO till Jul 10th 2011/08/30 18:58:32 Done.
277 NavigateToPendingEntry(NO_RELOAD); 279 NavigateToPendingEntry(NO_RELOAD);
278 } 280 }
279 281
280 NavigationEntry* NavigationController::GetActiveEntry() const { 282 NavigationEntry* NavigationController::GetActiveEntry() const {
281 if (transient_entry_index_ != -1) 283 if (transient_entry_index_ != -1)
282 return entries_[transient_entry_index_].get(); 284 return entries_[transient_entry_index_].get();
283 if (pending_entry_) 285 if (pending_entry_)
284 return pending_entry_; 286 return pending_entry_;
285 return GetLastCommittedEntry(); 287 return GetLastCommittedEntry();
286 } 288 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 if (last_committed_entry_index_ != -1) 469 if (last_committed_entry_index_ != -1)
468 index = last_committed_entry_index_ + 1; 470 index = last_committed_entry_index_ + 1;
469 DiscardTransientEntry(); 471 DiscardTransientEntry();
470 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); 472 entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry));
471 transient_entry_index_ = index; 473 transient_entry_index_ = index;
472 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); 474 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll);
473 } 475 }
474 476
475 void NavigationController::LoadURL(const GURL& url, const GURL& referrer, 477 void NavigationController::LoadURL(const GURL& url, const GURL& referrer,
476 PageTransition::Type transition) { 478 PageTransition::Type transition) {
479 LoadURLWithHeaders(url, referrer, transition, std::string());
480 }
481
482 void NavigationController::LoadURLWithHeaders(
483 const GURL& url,
484 const GURL& referrer,
485 PageTransition::Type transition,
486 const std::string& extra_headers) {
477 // The user initiated a load, we don't need to reload anymore. 487 // The user initiated a load, we don't need to reload anymore.
478 needs_reload_ = false; 488 needs_reload_ = false;
479 489
480 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, 490 NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition,
491 extra_headers,
481 browser_context_); 492 browser_context_);
482 493
483 LoadEntry(entry); 494 LoadEntry(entry);
484 } 495 }
485 496
486 void NavigationController::DocumentLoadedInFrame() { 497 void NavigationController::DocumentLoadedInFrame() {
487 last_document_loaded_ = base::TimeTicks::Now(); 498 last_document_loaded_ = base::TimeTicks::Now();
488 } 499 }
489 500
490 bool NavigationController::RendererDidNavigate( 501 bool NavigationController::RendererDidNavigate(
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 size_t insert_index = 0; 1201 size_t insert_index = 0;
1191 for (int i = 0; i < max_index; i++) { 1202 for (int i = 0; i < max_index; i++) {
1192 // When cloning a tab, copy all entries except interstitial pages 1203 // When cloning a tab, copy all entries except interstitial pages
1193 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { 1204 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) {
1194 entries_.insert(entries_.begin() + insert_index++, 1205 entries_.insert(entries_.begin() + insert_index++,
1195 linked_ptr<NavigationEntry>( 1206 linked_ptr<NavigationEntry>(
1196 new NavigationEntry(*source.entries_[i]))); 1207 new NavigationEntry(*source.entries_[i])));
1197 } 1208 }
1198 } 1209 }
1199 } 1210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698