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

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

Issue 27238: Clean up some style and organization in the browser about handler. No code... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/browser/memory_details.cc ('k') | chrome/browser/tab_contents/navigation_entry.h » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/tab_contents/navigation_controller.h" 5 #include "chrome/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 "chrome/browser/browser_about_handler.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/dom_ui/dom_ui_host.h" 12 #include "chrome/browser/dom_ui/dom_ui_host.h"
12 #include "chrome/browser/sessions/session_types.h" 13 #include "chrome/browser/sessions/session_types.h"
13 #include "chrome/browser/tab_contents/navigation_entry.h" 14 #include "chrome/browser/tab_contents/navigation_entry.h"
14 #include "chrome/browser/tab_contents/repost_form_warning.h" 15 #include "chrome/browser/tab_contents/repost_form_warning.h"
15 #include "chrome/browser/tab_contents/site_instance.h" 16 #include "chrome/browser/tab_contents/site_instance.h"
16 #include "chrome/common/navigation_types.h" 17 #include "chrome/common/navigation_types.h"
17 #include "chrome/common/notification_service.h" 18 #include "chrome/common/notification_service.h"
18 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
19 #include "chrome/common/resource_bundle.h" 20 #include "chrome/common/resource_bundle.h"
(...skipping 28 matching lines...) Expand all
48 // 49 //
49 // An empty state is treated as a new navigation by WebKit, which would mean 50 // An empty state is treated as a new navigation by WebKit, which would mean
50 // losing the navigation entries and generating a new navigation entry after 51 // losing the navigation entries and generating a new navigation entry after
51 // this one. We don't want that. To avoid this we create a valid state which 52 // this one. We don't want that. To avoid this we create a valid state which
52 // WebKit will not treat as a new navigation. 53 // WebKit will not treat as a new navigation.
53 void SetContentStateIfEmpty(NavigationEntry* entry) { 54 void SetContentStateIfEmpty(NavigationEntry* entry) {
54 if (entry->content_state().empty() && 55 if (entry->content_state().empty() &&
55 (entry->tab_type() == TAB_CONTENTS_WEB || 56 (entry->tab_type() == TAB_CONTENTS_WEB ||
56 entry->tab_type() == TAB_CONTENTS_NEW_TAB_UI || 57 entry->tab_type() == TAB_CONTENTS_NEW_TAB_UI ||
57 entry->tab_type() == TAB_CONTENTS_DOM_UI || 58 entry->tab_type() == TAB_CONTENTS_DOM_UI ||
58 entry->tab_type() == TAB_CONTENTS_ABOUT_UI ||
59 entry->tab_type() == TAB_CONTENTS_HTML_DIALOG || 59 entry->tab_type() == TAB_CONTENTS_HTML_DIALOG ||
60 entry->IsViewSourceMode())) { 60 entry->IsViewSourceMode())) {
61 entry->set_content_state( 61 entry->set_content_state(
62 webkit_glue::CreateHistoryStateForURL(entry->url())); 62 webkit_glue::CreateHistoryStateForURL(entry->url()));
63 } 63 }
64 } 64 }
65 65
66 // Configure all the NavigationEntries in entries for restore. This resets 66 // Configure all the NavigationEntries in entries for restore. This resets
67 // the transition type to reload and makes sure the content state isn't empty. 67 // the transition type to reload and makes sure the content state isn't empty.
68 void ConfigureEntriesForRestore( 68 void ConfigureEntriesForRestore(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 } 241 }
242 242
243 NavigationEntry* NavigationController::GetEntryWithPageID( 243 NavigationEntry* NavigationController::GetEntryWithPageID(
244 TabContentsType type, SiteInstance* instance, int32 page_id) const { 244 TabContentsType type, SiteInstance* instance, int32 page_id) const {
245 int index = GetEntryIndexWithPageID(type, instance, page_id); 245 int index = GetEntryIndexWithPageID(type, instance, page_id);
246 return (index != -1) ? entries_[index].get() : NULL; 246 return (index != -1) ? entries_[index].get() : NULL;
247 } 247 }
248 248
249 void NavigationController::LoadEntry(NavigationEntry* entry) { 249 void NavigationController::LoadEntry(NavigationEntry* entry) {
250 // Handle non-navigational URLs that popup dialogs and such, these should not
251 // actually navigate.
252 if (HandleNonNavigationAboutURL(entry->url()))
253 return;
254
250 // When navigating to a new page, we don't know for sure if we will actually 255 // When navigating to a new page, we don't know for sure if we will actually
251 // end up leaving the current page. The new page load could for example 256 // end up leaving the current page. The new page load could for example
252 // result in a download or a 'no content' response (e.g., a mailto: URL). 257 // result in a download or a 'no content' response (e.g., a mailto: URL).
253 DiscardNonCommittedEntriesInternal(); 258 DiscardNonCommittedEntriesInternal();
254 pending_entry_ = entry; 259 pending_entry_ = entry;
255 NotificationService::current()->Notify( 260 NotificationService::current()->Notify(
256 NotificationType::NAV_ENTRY_PENDING, 261 NotificationType::NAV_ENTRY_PENDING,
257 Source<NavigationController>(this), 262 Source<NavigationController>(this),
258 NotificationService::NoDetails()); 263 NotificationService::NoDetails());
259 NavigateToPendingEntry(false); 264 NavigateToPendingEntry(false);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 delete this; 461 delete this;
457 } 462 }
458 463
459 NavigationEntry* NavigationController::CreateNavigationEntry( 464 NavigationEntry* NavigationController::CreateNavigationEntry(
460 const GURL& url, const GURL& referrer, PageTransition::Type transition) { 465 const GURL& url, const GURL& referrer, PageTransition::Type transition) {
461 GURL real_url = url; 466 GURL real_url = url;
462 TabContentsType type; 467 TabContentsType type;
463 468
464 // If the active contents supports |url|, use it. 469 // If the active contents supports |url|, use it.
465 // Note: in both cases, we give TabContents a chance to rewrite the URL. 470 // Note: in both cases, we give TabContents a chance to rewrite the URL.
471 //
472 // TODO(brettw): The BrowserURLHandler::HandleBrowserURL call should just be
473 // moved here from inside TypeForURL once the tab contents types are removed.
466 TabContents* active = active_contents(); 474 TabContents* active = active_contents();
467 if (active && active->SupportsURL(&real_url)) 475 if (active && active->SupportsURL(&real_url))
468 type = active->type(); 476 type = active->type();
469 else 477 else
470 type = TabContents::TypeForURL(&real_url); 478 type = TabContents::TypeForURL(&real_url);
471 479
472 if (url.SchemeIs(chrome::kViewSourceScheme)) {
473 // Load the inner URL instead, setting the original URL as the "display".
474 real_url = GURL(url.path());
475 }
476
477 NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url, 480 NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url,
478 referrer, 481 referrer,
479 string16(), transition); 482 string16(), transition);
480 entry->set_display_url(url); 483 entry->set_display_url(url);
481 entry->set_user_typed_url(url); 484 entry->set_user_typed_url(url);
482 if (url.SchemeIsFile()) { 485 if (url.SchemeIsFile()) {
483 entry->set_title(WideToUTF16Hack( 486 entry->set_title(WideToUTF16Hack(
484 file_util::GetFilenameFromPath(UTF8ToWide(url.host() + url.path())))); 487 file_util::GetFilenameFromPath(UTF8ToWide(url.host() + url.path()))));
485 } 488 }
486 return entry; 489 return entry;
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 return i; 1229 return i;
1227 } 1230 }
1228 return -1; 1231 return -1;
1229 } 1232 }
1230 1233
1231 NavigationEntry* NavigationController::GetTransientEntry() const { 1234 NavigationEntry* NavigationController::GetTransientEntry() const {
1232 if (transient_entry_index_ == -1) 1235 if (transient_entry_index_ == -1)
1233 return NULL; 1236 return NULL;
1234 return entries_[transient_entry_index_].get(); 1237 return entries_[transient_entry_index_].get();
1235 } 1238 }
OLDNEW
« no previous file with comments | « chrome/browser/memory_details.cc ('k') | chrome/browser/tab_contents/navigation_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698