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

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

Issue 9169065: Reloading page after installing app should bring it into correct process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/tab_contents/navigation_controller_impl.h" 5 #include "content/browser/tab_contents/navigation_controller_impl.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_number_conversions.h" // Temporary 9 #include "base/string_number_conversions.h" // Temporary
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 content::NOTIFICATION_REPOST_WARNING_SHOWN, 258 content::NOTIFICATION_REPOST_WARNING_SHOWN,
259 content::Source<NavigationController>(this), 259 content::Source<NavigationController>(this),
260 content::NotificationService::NoDetails()); 260 content::NotificationService::NoDetails());
261 261
262 pending_reload_ = reload_type; 262 pending_reload_ = reload_type;
263 tab_contents_->Activate(); 263 tab_contents_->Activate();
264 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); 264 tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_);
265 } else { 265 } else {
266 DiscardNonCommittedEntriesInternal(); 266 DiscardNonCommittedEntriesInternal();
267 267
268 pending_entry_index_ = current_index; 268 NavigationEntryImpl* entry = entries_[current_index].get();
Charlie Reis 2012/01/26 01:20:23 GetEntryAtIndex
nasko 2012/01/26 20:25:57 I've used direct access to the collection, since I
Charlie Reis 2012/01/26 21:49:45 Ah. Yes, that's fine then. I've emailed John abo
269 entries_[pending_entry_index_]->SetTransitionType( 269 SiteInstance* site_instance = entry->site_instance();
270 content::PAGE_TRANSITION_RELOAD); 270
271 // If we are reloading an entry that no longer belongs to the current
272 // site instance (for example, refreshing a page for just installed app),
273 // the reload must happen in a new process and behave as new navigation
Charlie Reis 2012/01/26 01:20:23 Nit: let's split out the "behave as new navigation
nasko 2012/01/26 20:25:57 Done.
274 // when it comes to history.
275 if (site_instance != NULL &&
Charlie Reis 2012/01/26 01:20:23 More common to drop the != NULL. And actually, sh
nasko 2012/01/26 20:25:57 Done.
276 site_instance->HasWrongProcessForURL(entry->GetURL())) {
277 // Create a navigation entry that resembles the current one
Charlie Reis 2012/01/26 01:20:23 Nit: perhaps mention which things must not be copi
nasko 2012/01/26 20:25:57 Done.
278 NavigationEntryImpl* nav_entry = NavigationEntryImpl::FromNavigationEntry(
279 CreateNavigationEntry(
280 entry->GetURL(), entry->GetReferrer(), entry->GetTransitionType(),
281 false, entry->extra_headers(), browser_context_));
282
283 nav_entry->set_is_cross_site_reload(true);
284 pending_entry_ = nav_entry;
285 } else {
286 pending_entry_index_ = current_index;
287 entries_[pending_entry_index_]->SetTransitionType(
288 content::PAGE_TRANSITION_RELOAD);
289 }
290
271 NavigateToPendingEntry(reload_type); 291 NavigateToPendingEntry(reload_type);
272 } 292 }
273 } 293 }
274 294
275 void NavigationControllerImpl::CancelPendingReload() { 295 void NavigationControllerImpl::CancelPendingReload() {
276 DCHECK(pending_reload_ != NO_RELOAD); 296 DCHECK(pending_reload_ != NO_RELOAD);
277 pending_reload_ = NO_RELOAD; 297 pending_reload_ = NO_RELOAD;
278 } 298 }
279 299
280 void NavigationControllerImpl::ContinuePendingReload() { 300 void NavigationControllerImpl::ContinuePendingReload() {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } else { 595 } else {
576 details->previous_url = GURL(); 596 details->previous_url = GURL();
577 details->previous_entry_index = -1; 597 details->previous_entry_index = -1;
578 } 598 }
579 599
580 // If we have a pending entry at this point, it should have a SiteInstance. 600 // If we have a pending entry at this point, it should have a SiteInstance.
581 // Restored entries start out with a null SiteInstance, but we should have 601 // Restored entries start out with a null SiteInstance, but we should have
582 // assigned one in NavigateToPendingEntry. 602 // assigned one in NavigateToPendingEntry.
583 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); 603 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance());
584 604
605 // If we are doing a cross-site reload, we need to replace the existing
606 // navigation entry, not add another entry to the history. This has the side
607 // effect of removing forward browsing history, if such existed.
608 if (pending_entry_ != NULL) {
609 details->did_replace_entry = pending_entry_->is_cross_site_reload();
Charlie Reis 2012/01/26 01:20:23 Nit: extra space.
610 }
611
585 // is_in_page must be computed before the entry gets committed. 612 // is_in_page must be computed before the entry gets committed.
586 details->is_in_page = IsURLInPageNavigation(params.url); 613 details->is_in_page = IsURLInPageNavigation(params.url);
587 614
588 // Do navigation-type specific actions. These will make and commit an entry. 615 // Do navigation-type specific actions. These will make and commit an entry.
589 details->type = ClassifyNavigation(params); 616 details->type = ClassifyNavigation(params);
590 617
591 switch (details->type) { 618 switch (details->type) {
592 case content::NAVIGATION_TYPE_NEW_PAGE: 619 case content::NAVIGATION_TYPE_NEW_PAGE:
593 RendererDidNavigateToNewPage(params, &(details->did_replace_entry)); 620 RendererDidNavigateToNewPage(params, &(details->did_replace_entry));
594 break; 621 break;
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 for (int i = 0; i < max_index; i++) { 1388 for (int i = 0; i < max_index; i++) {
1362 // When cloning a tab, copy all entries except interstitial pages 1389 // When cloning a tab, copy all entries except interstitial pages
1363 if (source.entries_[i].get()->GetPageType() != 1390 if (source.entries_[i].get()->GetPageType() !=
1364 content::PAGE_TYPE_INTERSTITIAL) { 1391 content::PAGE_TYPE_INTERSTITIAL) {
1365 entries_.insert(entries_.begin() + insert_index++, 1392 entries_.insert(entries_.begin() + insert_index++,
1366 linked_ptr<NavigationEntryImpl>( 1393 linked_ptr<NavigationEntryImpl>(
1367 new NavigationEntryImpl(*source.entries_[i]))); 1394 new NavigationEntryImpl(*source.entries_[i])));
1368 } 1395 }
1369 } 1396 }
1370 } 1397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698