diff options
Diffstat (limited to 'chrome')
31 files changed, 491 insertions, 425 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index dd21d10..fef750e 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -76,7 +76,7 @@ void AlternateNavURLFetcher::OnURLFetchComplete(const URLFetcher* source, void AlternateNavURLFetcher::ShowInfobar() { const NavigationEntry* const entry = controller_->GetActiveEntry(); DCHECK(entry); - if (entry->GetType() != TAB_CONTENTS_WEB) + if (entry->tab_type() != TAB_CONTENTS_WEB) return; TabContents* tab_contents = controller_->GetTabContents(TAB_CONTENTS_WEB); diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 2112e27..09a243e 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1408,7 +1408,7 @@ void AutomationProvider::GetTabTitle(const IPC::Message& message, int handle) { std::wstring title; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - title = tab->GetActiveEntry()->GetTitle(); + title = tab->GetActiveEntry()->title(); title_string_size = static_cast<int>(title.size()); } @@ -1503,7 +1503,7 @@ void AutomationProvider::GetTabURL(const IPC::Message& message, int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); // Return what the user would see in the location bar. - url = tab->GetActiveEntry()->GetDisplayURL(); + url = tab->GetActiveEntry()->display_url(); success = true; } @@ -2004,7 +2004,7 @@ void AutomationProvider::GetPageType(const IPC::Message& message, int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); - NavigationEntry::PageType page_type = entry->GetPageType(); + NavigationEntry::PageType page_type = entry->page_type(); // In order to return the proper result when an interstitial is shown and // no navigation entry were created for it we need to ask the WebContents. if (page_type == NavigationEntry::NORMAL_PAGE && @@ -2025,7 +2025,7 @@ void AutomationProvider::ActionOnSSLBlockingPage(const IPC::Message& message, if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); - if (entry->GetPageType() == NavigationEntry::INTERSTITIAL_PAGE) { + if (entry->page_type() == NavigationEntry::INTERSTITIAL_PAGE) { TabContents* tab_contents = tab->GetTabContents(TAB_CONTENTS_WEB); SSLBlockingPage* ssl_blocking_page = SSLBlockingPage::GetSSLBlockingPage(tab_contents); diff --git a/chrome/browser/back_forward_menu_model.cc b/chrome/browser/back_forward_menu_model.cc index dfe3edd..22651c1 100644 --- a/chrome/browser/back_forward_menu_model.cc +++ b/chrome/browser/back_forward_menu_model.cc @@ -154,7 +154,7 @@ std::wstring BackForwardMenuModel::GetLabel(int menu_id) const { return L""; NavigationEntry* entry = GetNavigationEntry(menu_id); - return entry->GetTitle(); + return entry->title(); } const SkBitmap& BackForwardMenuModel::GetIcon(int menu_id) const { @@ -163,7 +163,7 @@ const SkBitmap& BackForwardMenuModel::GetIcon(int menu_id) const { return GetEmptyIcon(); NavigationEntry* entry = GetNavigationEntry(menu_id); - return entry->GetFavIcon(); + return entry->favicon().bitmap(); } bool BackForwardMenuModel::IsItemSeparator(int menu_id) const { @@ -273,14 +273,14 @@ int BackForwardMenuModel::GetIndexOfNextChapterStop(int start_from, } NavigationEntry* start_entry = controller->GetEntryAtIndex(start_from); - GURL url = start_entry->GetURL(); + const GURL& url = start_entry->url(); if (!forward) { // When going backwards we return the first entry we find that has a // different domain. for (int i = start_from - 1; i >= 0; --i) { if (!net::RegistryControlledDomainService::SameDomainOrHost(url, - controller->GetEntryAtIndex(i)->GetURL())) + controller->GetEntryAtIndex(i)->url())) return i; } // We have reached the beginning without finding a chapter stop. @@ -290,7 +290,7 @@ int BackForwardMenuModel::GetIndexOfNextChapterStop(int start_from, // different domain. for (int i = start_from + 1; i < max_count; ++i) { if (!net::RegistryControlledDomainService::SameDomainOrHost(url, - controller->GetEntryAtIndex(i)->GetURL())) + controller->GetEntryAtIndex(i)->url())) return i - 1; } // Last entry is always considered a chapter stop. diff --git a/chrome/browser/back_forward_menu_model_unittest.cc b/chrome/browser/back_forward_menu_model_unittest.cc index d13e12d..934fb1a 100644 --- a/chrome/browser/back_forward_menu_model_unittest.cc +++ b/chrome/browser/back_forward_menu_model_unittest.cc @@ -31,8 +31,8 @@ class BackFwdMenuModelTestTabContents : public TabContents { bool Navigate(const NavigationEntry& entry, bool reload) { NavigationEntry* pending_entry = new NavigationEntry(entry); - if (pending_entry->GetPageID() == -1) { - pending_entry->SetPageID(g_page_id_++); + if (pending_entry->page_id() == -1) { + pending_entry->set_page_id(g_page_id_++); } DidNavigateToEntry(pending_entry); return true; @@ -41,7 +41,7 @@ class BackFwdMenuModelTestTabContents : public TabContents { void UpdateState(const std::wstring& title) { NavigationEntry* entry = controller()->GetEntryWithPageID(type(), NULL, g_page_id_ - 1); - entry->SetTitle(title); + entry->set_title(title); } private: diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index 86ac345..052187d 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -449,7 +449,7 @@ void Browser::ExecuteCommand(int id) { NavigationEntry* entry = current_tab->controller()->GetLastCommittedEntry(); if (entry) { - GURL url("view-source:" + entry->GetURL().spec()); + GURL url("view-source:" + entry->url().spec()); AddTabWithURL(url, PageTransition::LINK, true, NULL); } break; @@ -750,7 +750,7 @@ void Browser::GoBack() { // recreated. // - we have not yet visited that navigation entry (typically session // restore), in which case the page is not already available. - if (prev_nav_entry->GetType() == TAB_CONTENTS_WEB && + if (prev_nav_entry->tab_type() == TAB_CONTENTS_WEB && !prev_nav_entry->restored()) { // It is the job of the code that shows the interstitial to listen for // notifications of the interstitial getting hidden and appropriately @@ -786,7 +786,7 @@ void Browser::Reload() { if (web_contents && web_contents->showing_interstitial_page()) { NavigationEntry* entry = current_tab->controller()->GetActiveEntry(); DCHECK(entry); // Should exist if interstitial is showing. - OpenURL(entry->GetURL(), CURRENT_TAB, PageTransition::RELOAD); + OpenURL(entry->url(), CURRENT_TAB, PageTransition::RELOAD); return; } } @@ -817,7 +817,7 @@ void Browser::StarCurrentTabContents() { NavigationEntry* entry = rvh->controller()->GetActiveEntry(); if (!entry) return; // Can't star if there is no URL. - const GURL& url = entry->GetDisplayURL(); + const GURL& url = entry->display_url(); if (url.is_empty() || !url.is_valid()) return; @@ -825,7 +825,7 @@ void Browser::StarCurrentTabContents() { if (!window_->GetStarButton()->is_bubble_showing()) { const bool newly_bookmarked = (model->GetNodeByURL(url) == NULL); if (newly_bookmarked) { - model->SetURLStarred(url, entry->GetTitle(), true); + model->SetURLStarred(url, entry->title(), true); if (!model->GetNodeByURL(url)) { // Starring failed. This shouldn't happen. NOTREACHED(); @@ -900,7 +900,7 @@ void Browser::OpenBugReportDialog() { if (current_tab->type() == TAB_CONTENTS_WEB) { // URL for the current page bug_report_view->SetUrl( - current_tab->controller()->GetActiveEntry()->GetURL()); + current_tab->controller()->GetActiveEntry()->url()); } } diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index cf73d42..5a764b4 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -803,7 +803,7 @@ bool NewTabUIContents::Navigate(const NavigationEntry& entry, bool reload) { // also the pending entry. NavigationEntry* pending_entry = controller()->GetPendingEntry(); DCHECK(pending_entry && pending_entry == &entry); - pending_entry->SetTitle(forced_title_); + pending_entry->set_title(forced_title_); return result; } diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc index c9f3566..f77b05c 100644 --- a/chrome/browser/fav_icon_helper.cc +++ b/chrome/browser/fav_icon_helper.cc @@ -47,13 +47,13 @@ void FavIconHelper::SetFavIconURL(const GURL& icon_url) { if (!GetHistoryService()) return; - if (!fav_icon_expired_ && entry->IsValidFavIcon() && - entry->GetFavIconURL() == icon_url) { + if (!fav_icon_expired_ && entry->favicon().is_valid() && + entry->favicon().url() == icon_url) { // We already have the icon, no need to proceed. return; } - entry->SetFavIconURL(icon_url); + entry->favicon().set_url(icon_url); if (got_fav_icon_from_history_) DownloadFavIconOrAskHistory(entry); @@ -119,12 +119,12 @@ void FavIconHelper::UpdateFavIcon(NavigationEntry* entry, void FavIconHelper::UpdateFavIcon(NavigationEntry* entry, const SkBitmap& image) { // No matter what happens, we need to mark the favicon as being set. - entry->SetValidFavIcon(true); + entry->favicon().set_is_valid(true); if (image.empty()) return; - entry->SetFavIcon(image); + entry->favicon().set_bitmap(image); if (web_contents_->delegate()) { web_contents_->delegate()->NavigationStateChanged( web_contents_, TabContents::INVALIDATE_FAVICON); @@ -133,8 +133,8 @@ void FavIconHelper::UpdateFavIcon(NavigationEntry* entry, NavigationEntry* FavIconHelper::GetEntry() { NavigationEntry* entry = web_contents_->controller()->GetActiveEntry(); - if (entry && entry->GetURL() == url_ && - web_contents_->IsActiveEntry(entry->GetPageID())) { + if (entry && entry->url() == url_ && + web_contents_->IsActiveEntry(entry->page_id())) { return entry; } // If the URL has changed out from under us (as will happen with redirects) @@ -156,20 +156,20 @@ void FavIconHelper::OnFavIconDataForInitialURL( fav_icon_expired_ = (know_favicon && expired); - if (know_favicon && !entry->IsValidFavIcon() && - (!got_fav_icon_url_ || entry->GetFavIconURL() == icon_url)) { + if (know_favicon && !entry->favicon().is_valid() && + (!got_fav_icon_url_ || entry->favicon().url() == icon_url)) { // The db knows the favicon (although it may be out of date) and the entry // doesn't have an icon. Set the favicon now, and if the favicon turns out // to be expired (or the wrong url) we'll fetch later on. This way the // user doesn't see a flash of the default favicon. - entry->SetFavIconURL(icon_url); + entry->favicon().set_url(icon_url); if (data && !data->data.empty()) UpdateFavIcon(entry, data->data); - entry->SetValidFavIcon(true); + entry->favicon().set_is_valid(true); } if (know_favicon && !expired) { - if (got_fav_icon_url_ && entry->GetFavIconURL() != icon_url) { + if (got_fav_icon_url_ && entry->favicon().url() != icon_url) { // Mapping in the database is wrong. DownloadFavIconOrAskHistory will // update the mapping for this url and download the favicon if we don't // already have it. @@ -195,7 +195,7 @@ void FavIconHelper::DownloadFavIconOrAskHistory(NavigationEntry* entry) { // favicon given the favicon URL. if (profile()->IsOffTheRecord()) { GetHistoryService()->GetFavIcon( - entry->GetFavIconURL(), + entry->favicon().url(), &cancelable_consumer_, NewCallback(this, &FavIconHelper::OnFavIconData)); } else { @@ -206,8 +206,8 @@ void FavIconHelper::DownloadFavIconOrAskHistory(NavigationEntry* entry) { // This is asynchronous. The history service will call back when done. // Issue the request and associate the current page ID with it. GetHistoryService()->UpdateFavIconMappingAndFetch( - entry->GetURL(), - entry->GetFavIconURL(), &cancelable_consumer_, + entry->url(), + entry->favicon().url(), &cancelable_consumer_, NewCallback(this, &FavIconHelper::OnFavIconData)); } } @@ -241,7 +241,7 @@ void FavIconHelper::OnFavIconData( void FavIconHelper::ScheduleDownload(NavigationEntry* entry) { const int download_id = web_contents_->render_view_host()->DownloadImage( - entry->GetFavIconURL(), kFavIconSize); + entry->favicon().url(), kFavIconSize); if (!download_id) { // Download request failed. return; @@ -249,7 +249,7 @@ void FavIconHelper::ScheduleDownload(NavigationEntry* entry) { // Download ids should be unique. DCHECK(download_requests_.find(download_id) == download_requests_.end()); download_requests_[download_id] = - DownloadRequest(entry->GetURL(), entry->GetFavIconURL()); + DownloadRequest(entry->url(), entry->favicon().url()); } SkBitmap FavIconHelper::ConvertToFavIconSize(const SkBitmap& image) { diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index ef0c719..2046ba0 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -216,9 +216,9 @@ void NativeUIContents::SetPageState(PageState* page_state) { DCHECK(ne); std::string rep; state_->GetByteRepresentation(&rep); - ne->SetContentState(rep); + ne->set_content_state(rep); // This is not a WebContents, so we use a NULL SiteInstance. - ctrl->NotifyEntryChangedByPageID(type(), NULL, ne->GetPageID()); + ctrl->NotifyEntryChangedByPageID(type(), NULL, ne->page_id()); } } } @@ -234,7 +234,7 @@ bool NativeUIContents::Navigate(const NavigationEntry& entry, bool reload) { current_view_ = NULL; } - NativeUI* new_ui = GetNativeUIForURL(entry.GetURL()); + NativeUI* new_ui = GetNativeUIForURL(entry.url()); if (new_ui) { current_ui_ = new_ui; is_visible_ = true; @@ -242,9 +242,9 @@ bool NativeUIContents::Navigate(const NavigationEntry& entry, bool reload) { current_view_ = new_ui->GetView(); root_view->AddChildView(current_view_); - std::string s = entry.GetContentState(); + std::string s = entry.content_state(); if (s.empty()) - state_->InitWithURL(entry.GetURL()); + state_->InitWithURL(entry.url()); else state_->InitWithBytes(s); @@ -253,22 +253,22 @@ bool NativeUIContents::Navigate(const NavigationEntry& entry, bool reload) { } NavigationEntry* new_entry = new NavigationEntry(entry); - if (new_entry->GetPageID() == -1) - new_entry->SetPageID(++g_next_page_id); - new_entry->SetTitle(GetDefaultTitle()); - new_entry->SetFavIcon(GetFavIcon()); - new_entry->SetValidFavIcon(true); + if (new_entry->page_id() == -1) + new_entry->set_page_id(++g_next_page_id); + new_entry->set_title(GetDefaultTitle()); + new_entry->favicon().set_bitmap(GetFavIcon()); + new_entry->favicon().set_is_valid(true); if (new_ui) { // Strip out the query params, they should have moved to state. // TODO(sky): use GURL methods for replacements once bug is fixed. size_t scheme_end, host_end; - GetSchemeAndHostEnd(entry.GetURL(), &scheme_end, &host_end); - new_entry->SetURL(GURL(entry.GetURL().spec().substr(0, host_end))); + GetSchemeAndHostEnd(entry.url(), &scheme_end, &host_end); + new_entry->set_url(GURL(entry.url().spec().substr(0, host_end))); } std::string content_state; state_->GetByteRepresentation(&content_state); - new_entry->SetContentState(content_state); - const int32 page_id = new_entry->GetPageID(); + new_entry->set_content_state(content_state); + const int32 page_id = new_entry->page_id(); DidNavigateToEntry(new_entry); // This is not a WebContents, so we use a NULL SiteInstance. controller()->NotifyEntryChangedByPageID(type(), NULL, page_id); diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc index 93ddc9b..514e400 100644 --- a/chrome/browser/navigation_controller.cc +++ b/chrome/browser/navigation_controller.cc @@ -93,9 +93,10 @@ static void CreateNavigationEntriesFromTabNavigations( // Use a transition type of reload so that we don't incorrectly // increase the typed count. PageTransition::RELOAD); - entry->SetDisplayURL(navigation.url); - entry->SetContentState(navigation.state); - entry->SetHasPostData(navigation.type_mask & TabNavigation::HAS_POST_DATA); + entry->set_display_url(navigation.url); + entry->set_content_state(navigation.state); + entry->set_has_post_data( + navigation.type_mask & TabNavigation::HAS_POST_DATA); entries->push_back(linked_ptr<NavigationEntry>(entry)); } } @@ -107,7 +108,7 @@ static void ConfigureEntriesForRestore( for (size_t i = 0, count = entries->size(); i < count; ++i) { // Use a transition type of reload so that we don't incorrectly increase // the typed count. - (*entries)[i]->SetTransitionType(PageTransition::RELOAD); + (*entries)[i]->set_transition_type(PageTransition::RELOAD); (*entries)[i]->set_restored(true); // NOTE(darin): This code is only needed for backwards compat. NavigationController::SetContentStateIfEmpty((*entries)[i].get()); @@ -185,7 +186,7 @@ void NavigationController::Reload() { DiscardPendingEntryInternal(); int current_index = GetCurrentEntryIndex(); if (check_for_repost_ && current_index != -1 && - GetEntryAtIndex(current_index)->HasPostData() && + GetEntryAtIndex(current_index)->has_post_data() && active_contents_->AsWebContents() && !active_contents_->AsWebContents()->showing_repost_interstitial()) { // The user is asking to reload a page with POST data and we're not showing @@ -207,7 +208,7 @@ void NavigationController::Reload() { DiscardPendingEntryInternal(); pending_entry_index_ = current_index; - entries_[pending_entry_index_]->SetTransitionType(PageTransition::RELOAD); + entries_[pending_entry_index_]->set_transition_type(PageTransition::RELOAD); NavigateToPendingEntry(true); } } @@ -236,18 +237,18 @@ void NavigationController::LoadEntry(NavigationEntry* entry) { /* static */ void NavigationController::SetContentStateIfEmpty( NavigationEntry* entry) { - if (entry->GetContentState().empty() && - (entry->GetType() == TAB_CONTENTS_WEB || - entry->GetType() == TAB_CONTENTS_NEW_TAB_UI || - entry->GetType() == TAB_CONTENTS_ABOUT_UI || - entry->GetType() == TAB_CONTENTS_HTML_DIALOG)) { + if (entry->content_state().empty() && + (entry->tab_type() == TAB_CONTENTS_WEB || + entry->tab_type() == TAB_CONTENTS_NEW_TAB_UI || + entry->tab_type() == TAB_CONTENTS_ABOUT_UI || + entry->tab_type() == TAB_CONTENTS_HTML_DIALOG)) { // The state is empty and the url will be rendered by WebKit. An empty // state is treated as a new navigation by WebKit, which would mean // losing the navigation entries and generating a new navigation // entry after this one. We don't want that. To avoid this we create // a valid state which WebKit will not treat as a new navigation. - entry->SetContentState( - webkit_glue::CreateHistoryStateForURL(entry->GetURL())); + entry->set_content_state( + webkit_glue::CreateHistoryStateForURL(entry->url())); } } @@ -430,11 +431,11 @@ NavigationEntry* NavigationController::CreateNavigationEntry( NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url, std::wstring(), transition); - entry->SetDisplayURL(url); - entry->SetUserTypedURL(url); + entry->set_display_url(url); + entry->set_user_typed_url(url); if (url.SchemeIsFile()) { - entry->SetTitle(file_util::GetFilenameFromPath(UTF8ToWide(url.host() + - url.path()))); + entry->set_title(file_util::GetFilenameFromPath(UTF8ToWide(url.host() + + url.path()))); } return entry; } @@ -454,9 +455,9 @@ void NavigationController::LoadURLLazily(const GURL& url, const std::wstring& title, SkBitmap* icon) { NavigationEntry* entry = CreateNavigationEntry(url, type); - entry->SetTitle(title); + entry->set_title(title); if (icon) - entry->SetFavIcon(*icon); + entry->favicon().set_bitmap(*icon); // TODO(pkasting): http://b/1113085 Should this use DiscardPendingEntry()? DiscardPendingEntryInternal(); @@ -470,14 +471,14 @@ bool NavigationController::LoadingURLLazily() { const std::wstring& NavigationController::GetLazyTitle() const { if (pending_entry_) - return pending_entry_->GetTitle(); + return pending_entry_->title(); else return EmptyWString(); } const SkBitmap& NavigationController::GetLazyFavIcon() const { if (pending_entry_) { - return pending_entry_->GetFavIcon(); + return pending_entry_->favicon().bitmap(); } else { ResourceBundle &rb = ResourceBundle::GetSharedInstance(); return *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); @@ -494,7 +495,7 @@ void NavigationController::SetAlternateNavURLFetcher( void NavigationController::DidNavigateToEntry(NavigationEntry* entry) { DCHECK(active_contents_); - DCHECK(entry->GetType() == active_contents_->type()); + DCHECK(entry->tab_type() == active_contents_->type()); SetContentStateIfEmpty(entry); @@ -504,8 +505,8 @@ void NavigationController::DidNavigateToEntry(NavigationEntry* entry) { // seen before, then consider it a new navigation. Note that if the entry // has a SiteInstance, it should be the same as the SiteInstance of the // active WebContents, because we have just navigated to it. - DCHECK(entry->GetPageID() >= 0) << "Page ID must be set before calling us."; - if (entry->GetPageID() > GetMaxPageID()) { + DCHECK(entry->page_id() >= 0) << "Page ID must be set before calling us."; + if (entry->page_id() > GetMaxPageID()) { InsertEntry(entry); NotifyNavigationEntryCommitted(); return; @@ -516,17 +517,17 @@ void NavigationController::DidNavigateToEntry(NavigationEntry* entry) { // must update the current entry index accordingly. When navigating to the // same URL, a new PageID is not created. - int existing_entry_index = GetEntryIndexWithPageID(entry->GetType(), + int existing_entry_index = GetEntryIndexWithPageID(entry->tab_type(), entry->site_instance(), - entry->GetPageID()); + entry->page_id()); NavigationEntry* existing_entry = (existing_entry_index != -1) ? entries_[existing_entry_index].get() : NULL; if (!existing_entry) { // No existing entry, then simply ignore this navigation! - DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); + DLOG(WARNING) << "ignoring navigation for page: " << entry->page_id(); } else if ((existing_entry != pending_entry_) && pending_entry_ && - (pending_entry_->GetPageID() == -1) && - (pending_entry_->GetURL() == existing_entry->GetURL())) { + (pending_entry_->page_id() == -1) && + (pending_entry_->url() == existing_entry->url())) { // Not a new navigation. existing_entry->set_unique_id(pending_entry_->unique_id()); DiscardPendingEntry(); @@ -536,12 +537,10 @@ void NavigationController::DidNavigateToEntry(NavigationEntry* entry) { // page in session history could have resulted in a new client redirect. // The given entry might also provide a new title (typically an empty title // to overwrite the existing title). - existing_entry->SetURL(entry->GetURL()); - existing_entry->SetTitle(entry->GetTitle()); - existing_entry->SetFavIconURL(entry->GetFavIconURL()); - existing_entry->SetFavIcon(entry->GetFavIcon()); - existing_entry->SetValidFavIcon(entry->IsValidFavIcon()); - existing_entry->SetContentState(entry->GetContentState()); + existing_entry->set_url(entry->url()); + existing_entry->set_title(entry->title()); + existing_entry->favicon() = entry->favicon(); + existing_entry->set_content_state(entry->content_state()); // TODO(brettw) why only copy the security style and no other SSL stuff? existing_entry->ssl().set_security_style(entry->ssl().security_style()); @@ -579,7 +578,7 @@ void NavigationController::DidNavigateToEntry(NavigationEntry* entry) { if (index < 0 || GetPendingEntryIndex() != -1) return; - TabContentsType active_type = GetEntryAtIndex(index)->GetType(); + TabContentsType active_type = GetEntryAtIndex(index)->tab_type(); for (TabContentsMap::iterator i = tab_contents_map_.begin(); i != tab_contents_map_.end(); ++i) { if (i->first != active_type) @@ -619,12 +618,12 @@ void NavigationController::DiscardPendingEntry() { // Synchronize the active_contents_ to the last committed entry. NavigationEntry* last_entry = GetLastCommittedEntry(); - if (last_entry && last_entry->GetType() != active_contents_->type()) { + if (last_entry && last_entry->tab_type() != active_contents_->type()) { TabContents* from_contents = active_contents_; from_contents->SetActive(false); // Switch back to the previous tab contents. - active_contents_ = GetTabContents(last_entry->GetType()); + active_contents_ = GetTabContents(last_entry->tab_type()); DCHECK(active_contents_); active_contents_->SetActive(true); @@ -648,7 +647,7 @@ void NavigationController::DiscardPendingEntry() { } void NavigationController::InsertEntry(NavigationEntry* entry) { - DCHECK(entry->GetTransitionType() != PageTransition::AUTO_SUBFRAME); + DCHECK(entry->transition_type() != PageTransition::AUTO_SUBFRAME); // Copy the pending entry's unique ID to the committed entry. // I don't know if pending_entry_index_ can be other than -1 here. @@ -702,7 +701,7 @@ void NavigationController::NavigateToPendingEntry(bool reload) { // last visited that page. pending_entry_->ssl() = NavigationEntry::SSLStatus(); - if (from_contents && from_contents->type() != pending_entry_->GetType()) + if (from_contents && from_contents->type() != pending_entry_->tab_type()) from_contents->SetActive(false); HWND parent = @@ -767,9 +766,9 @@ void NavigationController::IndexOfActiveEntryChanged( TabContents* NavigationController::GetTabContentsCreateIfNecessary( HWND parent, const NavigationEntry& entry) { - TabContents* contents = GetTabContents(entry.GetType()); + TabContents* contents = GetTabContents(entry.tab_type()); if (!contents) { - contents = TabContents::CreateWithType(entry.GetType(), parent, profile_, + contents = TabContents::CreateWithType(entry.tab_type(), parent, profile_, entry.site_instance()); if (!contents->AsWebContents()) { // Update the max page id, otherwise the newly created TabContents may @@ -780,8 +779,8 @@ TabContents* NavigationController::GetTabContentsCreateIfNecessary( // max_page_id is updated to reflect the restored range of page ids. int32 max_page_id = contents->GetMaxPageID(); for (size_t i = 0; i < entries_.size(); ++i) { - if (entries_[i]->GetType() == entry.GetType()) - max_page_id = std::max(max_page_id, entries_[i]->GetPageID()); + if (entries_[i]->tab_type() == entry.tab_type()) + max_page_id = std::max(max_page_id, entries_[i]->page_id()); } contents->UpdateMaxPageID(max_page_id); } @@ -973,9 +972,9 @@ int NavigationController::GetEntryIndexWithPageID( DCHECK(instance == NULL); for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) { - if ((entries_[i]->GetType() == type) && + if ((entries_[i]->tab_type() == type) && (entries_[i]->site_instance() == instance) && - (entries_[i]->GetPageID() == page_id)) + (entries_[i]->page_id() == page_id)) return i; } return -1; diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index fa5e3e4..c90f4ff 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -51,7 +51,7 @@ class TestContents : public TabContents { void CompleteNavigation(int page_id) { DCHECK(pending_entry_.get()); - pending_entry_->SetPageID(page_id); + pending_entry_->set_page_id(page_id); DidNavigateToEntry(pending_entry_.get()); controller()->NotifyEntryChangedByPageID(type(), NULL, page_id); pending_entry_.release(); @@ -448,9 +448,9 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) { // Do a new navigation without making a pending one. const GURL kNewURL("test1:see"); NavigationEntry* entry = new NavigationEntry(kTestContentsType1); - entry->SetPageID(2); - entry->SetURL(kNewURL); - entry->SetTitle(L"Hello, world"); + entry->set_page_id(2); + entry->set_url(kNewURL); + entry->set_title(L"Hello, world"); contents->controller()->DidNavigateToEntry(entry); // There should no longer be any pending entry, and the third navigation we @@ -458,7 +458,7 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) { EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); EXPECT_EQ(1, contents->controller()->GetLastCommittedEntryIndex()); - EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->GetURL()); + EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->url()); } // Tests navigating to a new URL when there is a new pending navigation that is @@ -484,9 +484,9 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { // Before that commits, do a new navigation. const GURL kNewURL("test1:see"); NavigationEntry* entry = new NavigationEntry(kTestContentsType1); - entry->SetPageID(3); - entry->SetURL(kNewURL); - entry->SetTitle(L"Hello, world"); + entry->set_page_id(3); + entry->set_url(kNewURL); + entry->set_title(L"Hello, world"); contents->controller()->DidNavigateToEntry(entry); // There should no longer be any pending entry, and the third navigation we @@ -497,7 +497,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); EXPECT_EQ(1, contents->controller()->GetLastCommittedEntryIndex()); - EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->GetURL()); + EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->url()); } // Tests navigating to a new URL when there is a pending back/forward @@ -530,9 +530,9 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { // Before that commits, do a new navigation. const GURL kNewURL("test1:see"); NavigationEntry* entry = new NavigationEntry(kTestContentsType1); - entry->SetPageID(3); - entry->SetURL(kNewURL); - entry->SetTitle(L"Hello, world"); + entry->set_page_id(3); + entry->set_url(kNewURL); + entry->set_title(L"Hello, world"); contents->controller()->DidNavigateToEntry(entry); // There should no longer be any pending entry, and the third navigation we @@ -540,7 +540,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); EXPECT_EQ(2, contents->controller()->GetLastCommittedEntryIndex()); - EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->GetURL()); + EXPECT_EQ(kNewURL, contents->controller()->GetActiveEntry()->url()); } TEST_F(NavigationControllerTest, Reload) { @@ -597,8 +597,8 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { contents->controller()->Reload(); EXPECT_EQ(0, notifications.size()); - contents->pending_entry()->SetURL(url2); - contents->pending_entry()->SetTransitionType(PageTransition::LINK); + contents->pending_entry()->set_url(url2); + contents->pending_entry()->set_transition_type(PageTransition::LINK); contents->CompleteNavigation(1); EXPECT_TRUE(notifications.Check2AndReset(NOTIFY_NAV_ENTRY_COMMITTED, NOTIFY_NAV_ENTRY_CHANGED)); @@ -688,8 +688,8 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { EXPECT_FALSE(contents->controller()->CanGoBack()); EXPECT_TRUE(contents->controller()->CanGoForward()); - contents->pending_entry()->SetURL(url3); - contents->pending_entry()->SetTransitionType(PageTransition::LINK); + contents->pending_entry()->set_url(url3); + contents->pending_entry()->set_transition_type(PageTransition::LINK); contents->CompleteNavigation(2); EXPECT_TRUE(notifications.Check2AndReset(NOTIFY_NAV_ENTRY_COMMITTED, NOTIFY_NAV_ENTRY_CHANGED)); @@ -728,13 +728,13 @@ TEST_F(NavigationControllerTest, Back_NewPending) { // Now start a new pending navigation and go back before it commits. contents->controller()->LoadURL(kUrl3, PageTransition::TYPED); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); - EXPECT_EQ(kUrl3, contents->controller()->GetPendingEntry()->GetURL()); + EXPECT_EQ(kUrl3, contents->controller()->GetPendingEntry()->url()); contents->controller()->GoBack(); // The pending navigation should now be the "back" item and the new one // should be gone. EXPECT_EQ(0, contents->controller()->GetPendingEntryIndex()); - EXPECT_EQ(kUrl1, contents->controller()->GetPendingEntry()->GetURL()); + EXPECT_EQ(kUrl1, contents->controller()->GetPendingEntry()->url()); } // Receives a back message when there is a different renavigation already @@ -755,15 +755,15 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // With nothing pending, say we get a navigation to the second entry. const std::wstring kNewTitle1(L"Hello, world"); NavigationEntry* entry = new NavigationEntry(kTestContentsType1); - entry->SetPageID(1); - entry->SetURL(kUrl2); - entry->SetTitle(kNewTitle1); + entry->set_page_id(1); + entry->set_url(kUrl2); + entry->set_title(kNewTitle1); contents->controller()->DidNavigateToEntry(entry); // That second URL should be the last committed and it should have gotten the // new title. EXPECT_EQ(kNewTitle1, contents->controller()->GetEntryWithPageID( - kTestContentsType1, NULL, 1)->GetTitle()); + kTestContentsType1, NULL, 1)->title()); EXPECT_EQ(1, contents->controller()->GetLastCommittedEntryIndex()); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); @@ -780,9 +780,9 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // match the pending one. const std::wstring kNewTitle2(L"Hello, world"); entry = new NavigationEntry(kTestContentsType1); - entry->SetPageID(0); - entry->SetURL(kUrl1); - entry->SetTitle(kNewTitle2); + entry->set_page_id(0); + entry->set_url(kUrl1); + entry->set_title(kNewTitle2); contents->controller()->DidNavigateToEntry(entry); // The navigation should not have affected the pending entry. @@ -791,7 +791,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // But the navigated entry should be updated to the new title, and should be // the last committed. EXPECT_EQ(kNewTitle2, contents->controller()->GetEntryWithPageID( - kTestContentsType1, NULL, 0)->GetTitle()); + kTestContentsType1, NULL, 0)->title()); EXPECT_EQ(0, contents->controller()->GetLastCommittedEntryIndex()); } @@ -879,8 +879,8 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) { EXPECT_TRUE(contents->controller()->CanGoBack()); EXPECT_FALSE(contents->controller()->CanGoForward()); - contents->pending_entry()->SetURL(url3); - contents->pending_entry()->SetTransitionType(PageTransition::LINK); + contents->pending_entry()->set_url(url3); + contents->pending_entry()->set_transition_type(PageTransition::LINK); contents->CompleteNavigation(2); EXPECT_TRUE(notifications.Check3AndReset(NOTIFY_NAV_LIST_PRUNED, NOTIFY_NAV_ENTRY_COMMITTED, @@ -1076,7 +1076,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { // We expect http://www.a.com/0 to be gone. EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount); - EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->GetURL(), + EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(), GURL("test1://www.a.com/1")); // More navigations. @@ -1087,7 +1087,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { url_index++; } EXPECT_EQ(contents->controller()->GetEntryCount(), kMaxEntryCount); - EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->GetURL(), + EXPECT_EQ(contents->controller()->GetEntryAtIndex(0)->url(), GURL("test1://www.a.com/4")); } diff --git a/chrome/browser/navigation_entry.cc b/chrome/browser/navigation_entry.cc index 8a1170c..2cb98f2 100644 --- a/chrome/browser/navigation_entry.cc +++ b/chrome/browser/navigation_entry.cc @@ -6,7 +6,12 @@ #include "chrome/common/resource_bundle.h" -int NavigationEntry::unique_id_counter_ = 0; +// Use this to get a new unique ID for a NavigationEntry during construction. +// The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). +static int GetUniqueID() { + static int unique_id_counter = 0; + return ++unique_id_counter; +} NavigationEntry::SSLStatus::SSLStatus() : security_style_(SECURITY_STYLE_UNKNOWN), @@ -16,18 +21,20 @@ NavigationEntry::SSLStatus::SSLStatus() content_status_(NORMAL_CONTENT) { } +NavigationEntry::FaviconStatus::FaviconStatus() : valid_(false) { + ResourceBundle &rb = ResourceBundle::GetSharedInstance(); + bitmap_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); +} + NavigationEntry::NavigationEntry(TabContentsType type) - : type_(type), - unique_id_(GetUniqueID()), + : unique_id_(GetUniqueID()), + tab_type_(type), site_instance_(NULL), + page_type_(NORMAL_PAGE), page_id_(-1), transition_type_(PageTransition::LINK), - page_type_(NORMAL_PAGE), - valid_fav_icon_(false), has_post_data_(false), restored_(false) { - ResourceBundle &rb = ResourceBundle::GetSharedInstance(); - favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); } NavigationEntry::NavigationEntry(TabContentsType type, @@ -36,45 +43,14 @@ NavigationEntry::NavigationEntry(TabContentsType type, const GURL& url, const std::wstring& title, PageTransition::Type transition_type) - : type_(type), - unique_id_(GetUniqueID()), + : unique_id_(GetUniqueID()), + tab_type_(type), site_instance_(instance), - page_id_(page_id), + page_type_(NORMAL_PAGE), url_(url), title_(title), + page_id_(page_id), transition_type_(transition_type), - page_type_(NORMAL_PAGE), - valid_fav_icon_(false), has_post_data_(false), restored_(false) { - ResourceBundle &rb = ResourceBundle::GetSharedInstance(); - favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); -} - - -void NavigationEntry::SetSiteInstance(SiteInstance* site_instance) { - // Note that the SiteInstance should usually not be changed after it is set, - // but this may happen if the NavigationEntry was cloned and needs to use a - // different SiteInstance. - - if (site_instance_ == site_instance) { - // No change necessary. - return; - } - - // The ref counting is handled automatically, since these are scoped_refptrs. - site_instance_ = site_instance; } - -void NavigationEntry::SetContentState(const std::string& state) { - state_ = state; -} - -int NavigationEntry::GetUniqueID() { - // Never return 0, as that is the "no ID" value. - do { - ++unique_id_counter_; - } while (!unique_id_counter_); - return unique_id_counter_; -} - diff --git a/chrome/browser/navigation_entry.h b/chrome/browser/navigation_entry.h index 0b5073f..f7aa143 100644 --- a/chrome/browser/navigation_entry.h +++ b/chrome/browser/navigation_entry.h @@ -27,6 +27,8 @@ //////////////////////////////////////////////////////////////////////////////// class NavigationEntry { public: + // SSL ----------------------------------------------------------------------- + // Collects the SSL information for this NavigationEntry. class SSLStatus { public: @@ -85,9 +87,10 @@ class NavigationEntry { return (content_status_ & UNSAFE_CONTENT) != 0; } - // Raw accessors for all the content status flags. This is used by the UI - // tests for checking and for certain copying. Use the per-status functions - // for normal usage. + // Raw accessors for all the content status flags. This contains a + // combination of any of the ContentStatusFlags defined above. It is used + // by the UI tests for checking and for certain copying. Use the per-status + // functions for normal usage. void set_content_status(int content_status) { content_status_ = content_status; } @@ -96,11 +99,12 @@ class NavigationEntry { } private: + // See the accessors above for descriptions. SecurityStyle security_style_; int cert_id_; int cert_status_; int security_bits_; - int content_status_; // A combination of any of the ContentStatusFlags. + int content_status_; // Copy and assignment is explicitly allowed for this class. }; @@ -112,10 +116,52 @@ class NavigationEntry { INTERSTITIAL_PAGE }; - // Use this to get a new unique ID during construction. - static int GetUniqueID(); + // Favicon ------------------------------------------------------------------- + + // Collects the favicon related information for a NavigationEntry. + class FaviconStatus { + public: + FaviconStatus(); + + // Indicates whether we've gotten an official favicon for the page, or are + // just using the default favicon. + void set_is_valid(bool is_valid) { + valid_ = is_valid; + } + bool is_valid() const { + return valid_; + } + + // The URL of the favicon which was used to load it off the web. + void set_url(const GURL& favicon_url) { + url_ = favicon_url; + } + const GURL& url() const { + return url_; + } + + // The favicon bitmap for the page. If the favicon has not been explicitly + // set or it empty, it will return the default favicon. Note that this is + // loaded asynchronously, so even if the favicon URL is valid we may return + // the default favicon if we haven't gotten the data yet. + void set_bitmap(const SkBitmap& bitmap) { + bitmap_ = bitmap; + } + const SkBitmap& bitmap() const { + return bitmap_; + } + + private: + // See the accessors above for descriptions. + bool valid_; + GURL url_; + SkBitmap bitmap_; + + // Copy and assignment is explicitly allowed for this class. + }; + + // --------------------------------------------------------------------------- - // Create a new NavigationEntry. explicit NavigationEntry(TabContentsType type); NavigationEntry(TabContentsType type, SiteInstance* instance, @@ -123,107 +169,180 @@ class NavigationEntry { const GURL& url, const std::wstring& title, PageTransition::Type transition_type); - ~NavigationEntry() { } - // Return the TabContents type required to display this entry. Immutable - // because a tab can never change its type. - TabContentsType GetType() const { return type_; } + // Page-related stuff -------------------------------------------------------- - // Accessors for the unique ID of this entry. A unique ID is preserved across - // commits and redirects, which means that sometimes a NavigationEntry's - // unique ID needs to be set (e.g. when creating a committed entry to - // correspond to a to-be-deleted pending entry, the pending entry's ID must be - // copied). - int unique_id() const { return unique_id_; } - void set_unique_id(int unique_id) { unique_id_ = unique_id; } + // A unique ID is preserved across commits and redirects, which means that + // sometimes a NavigationEntry's unique ID needs to be set (e.g. when + // creating a committed entry to correspond to a to-be-deleted pending entry, + // the pending entry's ID must be copied). + void set_unique_id(int unique_id) { + unique_id_ = unique_id; + } + int unique_id() const { + return unique_id_; + } - void SetSiteInstance(SiteInstance* site_instance); - SiteInstance* site_instance() const { return site_instance_; } + // Return the TabContents type required to display this entry. Immutable + // because a tab can never change its type. + TabContentsType tab_type() const { + return tab_type_; + } - void SetURL(const GURL& url) { url_ = url; } - const GURL& GetURL() const { return url_; } + // The SiteInstance tells us how to share sub-processes when the tab type is + // TAB_CONTENTS_WEB. This will be NULL otherwise. This is a reference counted + // pointer to a shared site instance. + // + // Note that the SiteInstance should usually not be changed after it is set, + // but this may happen if the NavigationEntry was cloned and needs to use a + // different SiteInstance. + void set_site_instance(SiteInstance* site_instance) { + site_instance_ = site_instance; + } + SiteInstance* site_instance() const { + return site_instance_; + } - // All the SSL flags. - const SSLStatus& ssl() const { - return ssl_; + // The page type tells us if this entry is for an interstitial or error page. + // See the PageType enum above. + void set_page_type(PageType page_type) { + page_type_ = page_type; } - SSLStatus& ssl() { - return ssl_; + PageType page_type() const { + return page_type_; } - // Set / Get the page type. - void SetPageType(PageType page_type) { page_type_ = page_type; } - PageType GetPageType() const { return page_type_; } + // The actual URL of the page. For some about pages, this may be a scary + // data: URL or something like that. Use display_url() below for showing to + // the user. + void set_url(const GURL& url) { + url_ = url; + } + const GURL& url() const { + return url_; + } - void SetDisplayURL(const GURL& url) { + // The display URL, when nonempty, will override the actual URL of the page + // when we display it to the user. This allows us to have nice and friendly + // URLs that the user sees for things like about: URLs, but actually feed + // the renderer a data URL that results in the content loading. + // + // display_url() will return the URL to display to the user in all cases, so + // if there is no overridden display URL, it will return the actual one. + void set_display_url(const GURL& url) { display_url_ = (url == url_) ? GURL() : url; } - bool HasDisplayURL() const { return !display_url_.is_empty(); } - const GURL& GetDisplayURL() const { + bool has_display_url() const { + return !display_url_.is_empty(); + } + const GURL& display_url() const { return display_url_.is_empty() ? url_ : display_url_; } - void SetTitle(const std::wstring& title) { title_ = title; } - const std::wstring& GetTitle() const { return title_; } + // The title as set by the page. This will be empty if there is no title set. + // The caller is responsible for detecting when there is no title and + // displaying the appropriate "Untitled" label if this is being displayed to + // the user. + void set_title(const std::wstring& title) { + title_ = title; + } + const std::wstring& title() const { + return title_; + } + + // The favicon data and tracking information. See FaviconStatus above. + const FaviconStatus& favicon() const { + return favicon_; + } + FaviconStatus& favicon() { + return favicon_; + } - // WARNING: This state is saved to the database and used to restore previous + // Content state is an opaque blob created by WebKit that represents the + // state of the page. This includes form entries and scroll position for each + // frame. We store it so that we can supply it back to WebKit to restore form + // state properly when the user goes back and forward. + // + // WARNING: This state is saved to the file and used to restore previous // states. If you write a custom TabContents and provide your own state make // sure you have the ability to modify the format in the future while being // able to deal with older versions. - void SetContentState(const std::string& state); - const std::string& GetContentState() const { return state_; } - - void SetPageID(int page_id) { page_id_ = page_id; } - int32 GetPageID() const { return page_id_; } - - void SetTransitionType(PageTransition::Type transition_type) { - transition_type_ = transition_type; + void set_content_state(const std::string& state) { + content_state_ = state; + } + const std::string& content_state() const { + return content_state_; } - PageTransition::Type GetTransitionType() const { return transition_type_; } - - // Sets the URL of the favicon. - void SetFavIconURL(const GURL& favicon_url) { favicon_url_ = favicon_url; } - // Returns the URL of the favicon. This may be empty if we don't know the - // favicon, or didn't succesfully load it before navigating to another page. - const GURL& GetFavIconURL() const { return favicon_url_; } + // Describes the current page that the tab represents. For web pages + // (TAB_CONTENTS_WEB) this is the ID that the renderer generated for the page + // and is how we can tell new versus renavigations. + void set_page_id(int page_id) { + page_id_ = page_id; + } + int32 page_id() const { + return page_id_; + } - // Sets the favicon for the page. - void SetFavIcon(const SkBitmap& favicon) { favicon_ = favicon; } + // All the SSL flags and state. See SSLStatus above. + const SSLStatus& ssl() const { + return ssl_; + } + SSLStatus& ssl() { + return ssl_; + } - // Returns the favicon for the page. If the icon has not been explicitly set, - // or is empty, this returns the default favicon. - // As loading the favicon happens asynchronously, it is possible for this to - // return the default favicon even though the page has a favicon other than - // the default. - const SkBitmap& GetFavIcon() const { return favicon_; } + // Tracking stuff ------------------------------------------------------------ - // Whether the favicon is valid. The favicon is valid if it represents the - // true favicon of the site. - void SetValidFavIcon(bool valid_fav_icon) { - valid_fav_icon_ = valid_fav_icon; + // The transition type indicates what the user did to move to this page from + // the previous page. + void set_transition_type(PageTransition::Type transition_type) { + transition_type_ = transition_type; + } + PageTransition::Type transition_type() const { + return transition_type_; } - bool IsValidFavIcon() const { return valid_fav_icon_; } - void SetUserTypedURL(const GURL& user_typed_url) { + // The user typed URL was the URL that the user initiated the navigation + // with, regardless of any redirects. This is used to generate keywords, for + // example, based on "what the user thinks the site is called" rather than + // what it's actually called. For example, if the user types "foo.com", that + // may redirect somewhere arbitrary like "bar.com/foo", and we want to use + // the name that the user things of the site as having. + // + // This URL will be is_empty() if the URL was navigated to some other way. + // Callers should fall back on using the regular or display URL in this case. + void set_user_typed_url(const GURL& user_typed_url) { user_typed_url_ = user_typed_url; } - const GURL& GetUserTypedURL() const { return user_typed_url_; } - - // If the user typed url is valid it is returned, otherwise url is returned. - const GURL& GetUserTypedURLOrURL() const { - return user_typed_url_.is_valid() ? user_typed_url_ : url_; + const GURL& user_typed_url() const { + return user_typed_url_; } - bool HasPostData() const { return has_post_data_; } - - void SetHasPostData(bool has_post_data) { has_post_data_ = has_post_data; } + // Post data is form data that was posted to get to this page. The data will + // have to be reposted to reload the page properly. This flag indicates + // whether the page had post data. + // + // The actual post data is stored in the content_state and is extracted by + // WebKit to actually make the request. + void set_has_post_data(bool has_post_data) { + has_post_data_ = has_post_data; + } + bool has_post_data() const { + return has_post_data_; + } - // See comment above field. - void set_restored(bool restored) { restored_ = restored; } - bool restored() const { return restored_; } + // Was this entry created from session/tab restore? If so this is true and + // gets set to false once we navigate to it. + // (See NavigationController::DidNavigateToEntry). + void set_restored(bool restored) { + restored_ = restored; + } + bool restored() const { + return restored_; + } private: // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING @@ -232,56 +351,24 @@ class NavigationEntry { // update SessionService/TabRestoreService appropriately. // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - // Unique IDs only really need to distinguish the various existing entries - // from each other, rather than be unique over all time; so it doesn't matter - // if this eventually wraps. - static int unique_id_counter_; - - TabContentsType type_; - + // See the accessors above for descriptions. int unique_id_; - - // If this entry is a TAB_CONTENTS_WEB, then keep a pointer to the - // SiteInstance that it belongs to. This allows us to reuse the same - // process if the user goes Back across site boundaries. If the process is - // gone by the time the user clicks Back, a new process will be created. - // This is NULL if this entry's type is not TAB_CONTENT_WEB. + TabContentsType tab_type_; scoped_refptr<SiteInstance> site_instance_; - - // Describes the current page that the tab represents. This is not relevant - // for all tab contents types. - int32 page_id_; - + PageType page_type_; GURL url_; - // The URL the user typed in. May be invalid. - GURL user_typed_url_; - std::wstring title_; - GURL favicon_url_; GURL display_url_; - - std::string state_; - - // The favorite icon for this entry. - SkBitmap favicon_; - - PageType page_type_; - + std::wstring title_; + FaviconStatus favicon_; + std::string content_state_; + int32 page_id_; SSLStatus ssl_; - - bool valid_fav_icon_; - - // True if this navigation needs to send post data in order to be displayed - // properly. - bool has_post_data_; - - // The transition type indicates what the user did to move to this page from - // the previous page. PageTransition::Type transition_type_; - - // Was this entry created from session/tab restore? If so this is true and - // gets set to false once we navigate to it - // (NavigationControllerBase::DidNavigateToEntry). + GURL user_typed_url_; + bool has_post_data_; bool restored_; + + // Copy and assignment is explicitly allowed for this class. }; -#endif // CHROME_BROWSER_NAVIGATION_ENTRY_H_ +#endif // CHROME_BROWSER_NAVIGATION_ENTRY_H_ diff --git a/chrome/browser/page_info_window.cc b/chrome/browser/page_info_window.cc index 1902efc..f136b65 100644 --- a/chrome/browser/page_info_window.cc +++ b/chrome/browser/page_info_window.cc @@ -233,14 +233,14 @@ SecurityTabView::SecurityTabView(Profile* profile, const NavigationEntry::SSLStatus& ssl = navigation_entry->ssl(); // Identity section. - std::wstring subject_name(UTF8ToWide(navigation_entry->GetURL().host())); + std::wstring subject_name(UTF8ToWide(navigation_entry->url().host())); bool empty_subject_name = false; if (subject_name.empty()) { subject_name.assign( l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); empty_subject_name = true; } - if (navigation_entry->GetPageType() == NavigationEntry::NORMAL_PAGE && + if (navigation_entry->page_type() == NavigationEntry::NORMAL_PAGE && ssl.cert_id() && CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) && !net::IsCertStatusError(ssl.cert_status())) { @@ -250,7 +250,7 @@ SecurityTabView::SecurityTabView(Profile* profile, identity_title = l10n_util::GetStringF(IDS_PAGE_INFO_EV_IDENTITY_TITLE, UTF8ToWide(cert->subject().organization_names[0]), - UTF8ToWide(navigation_entry->GetURL().host())); + UTF8ToWide(navigation_entry->url().host())); // An EV Cert is required to have a city (localityName) and country but // state is "if any". DCHECK(!cert->subject().locality_name.empty()); @@ -349,7 +349,7 @@ SecurityTabView::SecurityTabView(Profile* profile, Profile::EXPLICIT_ACCESS); if (history) { history->GetVisitCountToHost( - navigation_entry->GetURL(), + navigation_entry->url(), &request_consumer_, NewCallback(this, &SecurityTabView::OnGotVisitCountToHost)); } diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 6c86a68..39e3bda 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -170,7 +170,7 @@ std::wstring PrintViewManager::RenderSourceName() { GURL PrintViewManager::RenderSourceUrl() { NavigationEntry* entry = owner_.controller()->GetActiveEntry(); if (entry) - return entry->GetDisplayURL(); + return entry->display_url(); else return GURL(); } diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc index 8d692e3..d84834b 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -406,14 +406,14 @@ bool RenderViewContextMenuController::IsDevCommandEnabled(int id) const { return false; // Don't inspect inspector, new tab UI, etc. - if (active_entry->GetURL().SchemeIs("chrome-resource")) + if (active_entry->url().SchemeIs("chrome-resource")) return false; // Don't inspect about:network, about:memory, etc. // However, we do want to inspect about:blank, which is often // used by ordinary web pages. - if (active_entry->GetDisplayURL().SchemeIs("about") && - !LowerCaseEqualsASCII(active_entry->GetDisplayURL().path(), "blank")) + if (active_entry->display_url().SchemeIs("about") && + !LowerCaseEqualsASCII(active_entry->display_url().path(), "blank")) return false; // Don't enable the web inspector if JavaScript is disabled diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 0579a47..e2edfde 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -561,10 +561,10 @@ void RenderViewHost::SetDOMUIProperty(const std::string& name, void RenderViewHost::MakeNavigateParams(const NavigationEntry& entry, bool reload, ViewMsg_Navigate_Params* params) { - params->page_id = entry.GetPageID(); - params->url = entry.GetURL(); - params->transition = entry.GetTransitionType(); - params->state = entry.GetContentState(); + params->page_id = entry.page_id(); + params->url = entry.url(); + params->transition = entry.transition_type(); + params->state = entry.content_state(); params->reload = reload; } diff --git a/chrome/browser/render_view_host_manager.cc b/chrome/browser/render_view_host_manager.cc index 125750b..7a57d8c 100644 --- a/chrome/browser/render_view_host_manager.cc +++ b/chrome/browser/render_view_host_manager.cc @@ -617,10 +617,10 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( // RenderViews in response to a link click. // if (CommandLine().HasSwitch(switches::kProcessPerSite) && - entry.GetTransitionType() == PageTransition::GENERATED) + entry.transition_type() == PageTransition::GENERATED) return curr_instance; - const GURL& dest_url = entry.GetURL(); + const GURL& dest_url = entry.url(); // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it // for this entry. We won't commit the SiteInstance to this site until the @@ -671,7 +671,7 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( // to open a new tab to an interstitial-inducing URL, and then navigates // the page to a different same-site URL. (This seems very unlikely in // practice.) - const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : + const GURL& current_url = (curr_entry) ? curr_entry->url() : curr_instance->site(); if (SiteInstance::IsSameWebSite(current_url, dest_url)) { @@ -689,8 +689,8 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) { NavigationEntry* curr_entry = delegate_->GetControllerForRenderManager()->GetLastCommittedEntry(); - if (curr_entry && curr_entry->GetType() == TAB_CONTENTS_WEB) { - DCHECK(!curr_entry->GetContentState().empty()); + if (curr_entry && curr_entry->tab_type() == TAB_CONTENTS_WEB) { + DCHECK(!curr_entry->content_state().empty()); // TODO(creis): Should send a message to the RenderView to let it know // we're about to switch away, so that it sends an UpdateState message. diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index eacbf86..c495952 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -173,9 +173,9 @@ void SafeBrowsingBlockingPage::DisplayBlockingPage() { // this dummy entry a new one. Because we'll remove the entry when the // interstitial is going away, it will not conflict with any future // navigations. - nav_entry->SetPageID(tab_->GetMaxPageID() + 1); - nav_entry->SetPageType(NavigationEntry::INTERSTITIAL_PAGE); - nav_entry->SetURL(url_); + nav_entry->set_page_id(tab_->GetMaxPageID() + 1); + nav_entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE); + nav_entry->set_url(url_); tab_->controller()->DidNavigateToEntry(nav_entry); created_temporary_entry_ = true; } @@ -213,7 +213,7 @@ bool SafeBrowsingBlockingPage::GoBack() { // interstitial to hide which will trigger "this" to be deleted. tab_->controller()->LoadURL(GURL("about:blank"), PageTransition::AUTO_BOOKMARK); - } else if (prev_entry->GetType() != TAB_CONTENTS_WEB || + } else if (prev_entry->tab_type() != TAB_CONTENTS_WEB || prev_entry->restored() || !is_main_frame_) { // We do navigate back if any of these is true: diff --git a/chrome/browser/session_service.cc b/chrome/browser/session_service.cc index 39a6034..fe582d1 100644 --- a/chrome/browser/session_service.cc +++ b/chrome/browser/session_service.cc @@ -290,7 +290,7 @@ void SessionService::UpdateTabNavigation(const SessionID& window_id, const SessionID& tab_id, int index, const NavigationEntry& entry) { - if (!entry.GetDisplayURL().is_valid() || + if (!entry.display_url().is_valid() || !ShouldTrackChangesToWindow(window_id)) return; @@ -537,17 +537,16 @@ SessionCommand* SessionService::CreateUpdateTabNavigationCommand( Pickle pickle; pickle.WriteInt(tab_id.id()); pickle.WriteInt(index); - const GURL& url = entry.GetDisplayURL(); - const std::wstring& title = entry.GetTitle(); - const std::string& state = entry.GetContentState(); static const SessionCommand::size_type max_state_size = std::numeric_limits<SessionCommand::size_type>::max() - 1024; - if (url.spec().size() + title.size() + state.size() >= max_state_size) { + if (entry.display_url().spec().size() + + entry.title().size() + + entry.content_state().size() >= max_state_size) { // We only allow navigations up to 63k (which should be completely // reasonable). On the off chance we get one that is too big, try to // keep the url. - if (url.spec().size() < max_state_size) { - pickle.WriteString(url.spec()); + if (entry.display_url().spec().size() < max_state_size) { + pickle.WriteString(entry.display_url().spec()); pickle.WriteWString(std::wstring()); pickle.WriteString(std::string()); } else { @@ -556,12 +555,12 @@ SessionCommand* SessionService::CreateUpdateTabNavigationCommand( pickle.WriteString(std::string()); } } else { - pickle.WriteString(url.spec()); - pickle.WriteWString(title); - pickle.WriteString(state); + pickle.WriteString(entry.display_url().spec()); + pickle.WriteWString(entry.title()); + pickle.WriteString(entry.content_state()); } - pickle.WriteInt(entry.GetTransitionType()); - int type_mask = entry.HasPostData() ? TabNavigation::HAS_POST_DATA : 0; + pickle.WriteInt(entry.transition_type()); + int type_mask = entry.has_post_data() ? TabNavigation::HAS_POST_DATA : 0; pickle.WriteInt(type_mask); // Adding more data? Be sure and update TabRestoreService too. return new SessionCommand(kCommandUpdateTabNavigation, pickle); diff --git a/chrome/browser/session_service_unittest.cc b/chrome/browser/session_service_unittest.cc index 02c8191..d24ec11 100644 --- a/chrome/browser/session_service_unittest.cc +++ b/chrome/browser/session_service_unittest.cc @@ -45,11 +45,12 @@ class SessionServiceTest : public testing::Test { const TabNavigation& navigation, bool select) { NavigationEntry entry(TAB_CONTENTS_UNKNOWN_TYPE); - entry.SetURL(navigation.url); - entry.SetTitle(navigation.title); - entry.SetContentState(navigation.state); - entry.SetTransitionType(navigation.transition); - entry.SetHasPostData(navigation.type_mask & TabNavigation::HAS_POST_DATA); + entry.set_url(navigation.url); + entry.set_title(navigation.title); + entry.set_content_state(navigation.state); + entry.set_transition_type(navigation.transition); + entry.set_has_post_data( + navigation.type_mask & TabNavigation::HAS_POST_DATA); service()->UpdateTabNavigation(window_id, tab_id, navigation.index, entry); if (select) service()->SetSelectedNavigationIndex(window_id, tab_id, diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 4059fb4..bd93416 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -79,7 +79,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { PageTransition::LINK); // Redundantly setting e1's SiteInstance shouldn't affect the ref count. - e1->SetSiteInstance(instance); + e1->set_site_instance(instance); EXPECT_EQ(0, siteDeleteCounter); // Add a second reference @@ -142,7 +142,7 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) { NavigationEntry* e2 = new NavigationEntry(*e1); // Should be able to change the SiteInstance of the cloned entry. - e2->SetSiteInstance(instance2); + e2->set_site_instance(instance2); // The first SiteInstance should go away after deleting e1, since e2 should // no longer be referencing it. diff --git a/chrome/browser/ssl_blocking_page.cc b/chrome/browser/ssl_blocking_page.cc index 2971753..db0f684 100644 --- a/chrome/browser/ssl_blocking_page.cc +++ b/chrome/browser/ssl_blocking_page.cc @@ -140,20 +140,19 @@ void SSLBlockingPage::Show() { // interstitial is going away, it will not conflict with any future // navigations. created_nav_entry_ = true; - nav_entry->SetPageID(tab_->GetMaxPageID() + 1); - nav_entry->SetURL(error_->request_url()); + nav_entry->set_page_id(tab_->GetMaxPageID() + 1); + nav_entry->set_url(error_->request_url()); } else { // Make sure to update the current entry ssl state to reflect the error. *nav_entry = *(tab_->controller()->GetPendingEntry()); } - nav_entry->SetPageType(NavigationEntry::INTERSTITIAL_PAGE); + nav_entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE); nav_entry->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN); nav_entry->ssl().set_cert_id(cert_id); nav_entry->ssl().set_cert_status(ssl_info.cert_status); nav_entry->ssl().set_security_bits(ssl_info.security_bits); // The controller will own the entry. - int page_id = nav_entry->GetPageID(); tab_->controller()->DidNavigateToEntry(nav_entry); tab->ShowInterstitialPage(html_text, NULL); } @@ -223,7 +222,7 @@ void SSLBlockingPage::DontProceed() { // interstitial to hide which will trigger "this" to be deleted. tab_->controller()->LoadURL(GURL("about:blank"), PageTransition::AUTO_BOOKMARK); - } else if (entry->GetType() != TAB_CONTENTS_WEB) { + } else if (entry->tab_type() != TAB_CONTENTS_WEB) { // Not a WebContent, reload it so to recreate the TabContents for it. tab_->controller()->Reload(); } else { diff --git a/chrome/browser/ssl_manager.cc b/chrome/browser/ssl_manager.cc index c5dd953..9089585 100644 --- a/chrome/browser/ssl_manager.cc +++ b/chrome/browser/ssl_manager.cc @@ -531,13 +531,13 @@ void SSLManager::OnMixedContentRequest(ResourceDispatcherHost* rdh, void SSLManager::OnCertError(CertError* error) { // Ask our delegate to deal with the error. NavigationEntry* entry = controller_->GetActiveEntry(); - delegate()->OnCertError(entry->GetURL(), error); + delegate()->OnCertError(entry->url(), error); } void SSLManager::OnMixedContent(MixedContentHandler* mixed_content) { // Ask our delegate to deal with the mixed content. NavigationEntry* entry = controller_->GetActiveEntry(); - delegate()->OnMixedContent(controller_, entry->GetURL(), mixed_content); + delegate()->OnMixedContent(controller_, entry->url(), mixed_content); } void SSLManager::Observe(NotificationType type, @@ -578,7 +578,7 @@ void SSLManager::InitializeEntryIfNeeded(NavigationEntry* entry) { // fresh entry and should get the default style. if (entry->ssl().security_style() == SECURITY_STYLE_UNKNOWN) { entry->ssl().set_security_style( - delegate()->GetDefaultStyle(entry->GetURL())); + delegate()->GetDefaultStyle(entry->url())); } } diff --git a/chrome/browser/ssl_policy.cc b/chrome/browser/ssl_policy.cc index 680844f..22d1bd7 100644 --- a/chrome/browser/ssl_policy.cc +++ b/chrome/browser/ssl_policy.cc @@ -102,7 +102,8 @@ static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) { true, error->request_url(), security_info); - tab->controller()->GetActiveEntry()->SetPageType(NavigationEntry::ERROR_PAGE); + tab->controller()->GetActiveEntry()->set_page_type( + NavigationEntry::ERROR_PAGE); } static void ShowBlockingPage(SSLPolicy* policy, SSLManager::CertError* error) { @@ -384,7 +385,7 @@ void SSLPolicy::OnRequestStarted(SSLManager* manager, const GURL& url, } NavigationEntry::SSLStatus& ssl = entry->ssl(); - if (!entry->GetURL().SchemeIsSecure() || // Current page is not secure. + if (!entry->url().SchemeIsSecure() || // Current page is not secure. resource_type == ResourceType::MAIN_FRAME || // Main frame load. net::IsCertStatusError(ssl.cert_status())) { // There is already // an error for the main page, don't report sub-resources as unsafe @@ -417,11 +418,11 @@ void SSLPolicy::OnRequestStarted(SSLManager* manager, const GURL& url, // state will be reset. // Now check for mixed content. - if (entry->GetURL().SchemeIsSecure() && !url.SchemeIsSecure()) { + if (entry->url().SchemeIsSecure() && !url.SchemeIsSecure()) { ssl.set_has_mixed_content(); const std::wstring& msg = l10n_util::GetStringF( IDS_MIXED_CONTENT_LOG_MESSAGE, - UTF8ToWide(entry->GetURL().spec()), + UTF8ToWide(entry->url().spec()), UTF8ToWide(url.spec())); manager->AddMessageToConsole(msg, MESSAGE_LEVEL_WARNING); } diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc index 3eda18f..27d7a0a 100644 --- a/chrome/browser/tab_contents.cc +++ b/chrome/browser/tab_contents.cc @@ -93,7 +93,7 @@ const GURL& TabContents::GetURL() const { // We may not have a navigation entry yet NavigationEntry* entry = controller_->GetActiveEntry(); - return entry ? entry->GetDisplayURL() : kEmptyURL; + return entry ? entry->display_url() : kEmptyURL; } const std::wstring& TabContents::GetTitle() const { @@ -105,7 +105,7 @@ const std::wstring& TabContents::GetTitle() const { // get a new title. NavigationEntry* entry = controller_->GetLastCommittedEntry(); if (entry) - return entry->GetTitle(); + return entry->title(); else if (controller_->LoadingURLLazily()) return controller_->GetLazyTitle(); return EmptyWString(); @@ -118,7 +118,7 @@ SkBitmap TabContents::GetFavIcon() const { // entry rather than a pending navigation entry. NavigationEntry* entry = controller_->GetLastCommittedEntry(); if (entry) - return entry->GetFavIcon(); + return entry->favicon().bitmap(); else if (controller_->LoadingURLLazily()) return controller_->GetLazyFavIcon(); return SkBitmap(); @@ -258,7 +258,7 @@ void TabContents::SetIsLoading(bool is_loading, void TabContents::DidNavigateToEntry(NavigationEntry* entry) { // The entry may be deleted by DidNavigateToEntry... - int new_page_id = entry->GetPageID(); + int new_page_id = entry->page_id(); controller_->DidNavigateToEntry(entry); @@ -269,11 +269,11 @@ void TabContents::DidNavigateToEntry(NavigationEntry* entry) { bool TabContents::Navigate(const NavigationEntry& entry, bool reload) { NavigationEntry* new_entry = new NavigationEntry(entry); - if (new_entry->GetPageID() == -1) { + if (new_entry->page_id() == -1) { // This is a new navigation. Our behavior is to always navigate to the // same page (page 0) in response to a navigation. - new_entry->SetPageID(0); - new_entry->SetTitle(GetDefaultTitle()); + new_entry->set_page_id(0); + new_entry->set_title(GetDefaultTitle()); } DidNavigateToEntry(new_entry); return true; diff --git a/chrome/browser/tab_restore_service.cc b/chrome/browser/tab_restore_service.cc index 06408f2..ef7a973 100644 --- a/chrome/browser/tab_restore_service.cc +++ b/chrome/browser/tab_restore_service.cc @@ -157,11 +157,12 @@ void TabRestoreService::PopulateTabFromController( controller->GetPendingEntry() : controller->GetEntryAtIndex(i); TabNavigation& tab_nav = tab->navigations[i]; tab_nav.index = i; - tab_nav.url = entry->GetDisplayURL(); - tab_nav.title = entry->GetTitle(); - tab_nav.state = entry->GetContentState(); - tab_nav.transition = entry->GetTransitionType(); - tab_nav.type_mask = entry->HasPostData() ? TabNavigation::HAS_POST_DATA : 0; + tab_nav.url = entry->display_url(); + tab_nav.title = entry->title(); + tab_nav.state = entry->content_state(); + tab_nav.transition = entry->transition_type(); + tab_nav.type_mask = entry->has_post_data() ? + TabNavigation::HAS_POST_DATA : 0; } tab->current_navigation_index = controller->GetCurrentEntryIndex(); if (tab->current_navigation_index == -1 && entry_count > 0) diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index ca64a92..6d9cc14 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -34,8 +34,8 @@ class TabStripModelTestTabContents : public TabContents { bool Navigate(const NavigationEntry& entry, bool reload) { NavigationEntry* pending_entry = new NavigationEntry(entry); - if (pending_entry->GetPageID() == -1) { - pending_entry->SetPageID(g_page_id_++); + if (pending_entry->page_id() == -1) { + pending_entry->set_page_id(g_page_id_++); } DidNavigateToEntry(pending_entry); diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index 59689c2..9f83ed2 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -39,7 +39,7 @@ std::wstring ToolbarModel::GetText() { // Explicitly hide the URL for this tab. url = GURL(); } else if (entry) { - url = entry->GetDisplayURL(); + url = entry->display_url(); } } return gfx::ElideUrl(url, ChromeFont(), 0, languages); @@ -133,10 +133,9 @@ void ToolbarModel::GetIconHoverText(std::wstring* text, SkColor* text_color) { text->assign(error_info.short_description()); *text_color = kBrokenHttpsInfoBubbleTextColor; } else { - const GURL& url = entry->GetURL(); - DCHECK(url.has_host()); + DCHECK(entry->url().has_host()); text->assign(l10n_util::GetStringF(IDS_SECURE_CONNECTION, - UTF8ToWide(url.host()))); + UTF8ToWide(entry->url().host()))); *text_color = kOKHttpsInfoBubbleTextColor; } break; @@ -196,7 +195,7 @@ void ToolbarModel::CreateErrorText(NavigationEntry* entry, std::wstring* text) { std::vector<SSLErrorInfo> errors; SSLErrorInfo::GetErrorsForCertStatus(ssl.cert_id(), ssl.cert_status(), - entry->GetURL(), + entry->url(), &errors); if (ssl.has_mixed_content()) { errors.push_back(SSLErrorInfo::CreateError(SSLErrorInfo::MIXED_CONTENTS, diff --git a/chrome/browser/views/info_bar_view.cc b/chrome/browser/views/info_bar_view.cc index 96ab036..c10dfa9 100644 --- a/chrome/browser/views/info_bar_view.cc +++ b/chrome/browser/views/info_bar_view.cc @@ -117,7 +117,7 @@ void InfoBarView::DidNavigate(NavigationEntry* entry) { for (std::map<View*,int>::iterator i = expire_map_.begin(); i != expire_map_.end(); ++i) { if ((pending_entry && - pending_entry->GetTransitionType() == PageTransition::RELOAD) || + pending_entry->transition_type() == PageTransition::RELOAD) || i->second != active_id) to_remove.push_back(i->first); } diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index cb22b7e..85c8619 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -579,13 +579,13 @@ bool WebContents::Navigate(const NavigationEntry& entry, bool reload) { // Navigate in the desired RenderViewHost dest_render_view_host->NavigateToEntry(entry, reload); - if (entry.GetPageID() == -1) { + if (entry.page_id() == -1) { // HACK!! This code suppresses javascript: URLs from being added to // session history, which is what we want to do for javascript: URLs that // do not generate content. What we really need is a message from the // renderer telling us that a new page was not created. The same message // could be used for mailto: URLs and the like. - if (entry.GetURL().SchemeIs("javascript")) + if (entry.url().SchemeIs("javascript")) return false; } @@ -593,7 +593,7 @@ bool WebContents::Navigate(const NavigationEntry& entry, bool reload) { HistoryService* history = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); if (history) - history->SetFavIconOutOfDateForPage(entry.GetURL()); + history->SetFavIconOutOfDateForPage(entry.url()); } return true; @@ -940,7 +940,7 @@ void WebContents::CreateShortcut() { // We only allow one pending install request. By resetting the page id we // effectively cancel the pending install request. - pending_install_.page_id = entry->GetPageID(); + pending_install_.page_id = entry->page_id(); pending_install_.icon = GetFavIcon(); pending_install_.title = GetTitle(); pending_install_.url = GetURL(); @@ -1001,7 +1001,7 @@ bool WebContents::IsActiveEntry(int32 page_id) { NavigationEntry* active_entry = controller()->GetActiveEntry(); return (active_entry != NULL && active_entry->site_instance() == site_instance() && - active_entry->GetPageID() == page_id); + active_entry->page_id() == page_id); } /////////////////////////////////////////////////////////////////////////////// @@ -1214,15 +1214,15 @@ NavigationEntry* WebContents::CreateNavigationEntryForCommit( // don't set the URL. This will happen in the DidNavigateMainFrame/SubFrame // because the entry's URL should represent the toplevel frame only. NavigationEntry* entry = new NavigationEntry(type()); - entry->SetPageID(params.page_id); - entry->SetTransitionType(params.transition); - entry->SetSiteInstance(site_instance()); + entry->set_page_id(params.page_id); + entry->set_transition_type(params.transition); + entry->set_site_instance(site_instance()); // Now that we've assigned a SiteInstance to this entry, we need to // assign it to the NavigationController's pending entry as well. This // allows us to find it via GetEntryWithPageID, etc. if (controller()->GetPendingEntry()) - controller()->GetPendingEntry()->SetSiteInstance(entry->site_instance()); + controller()->GetPendingEntry()->set_site_instance(entry->site_instance()); // Update the site of the SiteInstance if it doesn't have one yet, unless we // are showing an interstitial page. If we are, we should wait until the @@ -1246,13 +1246,10 @@ NavigationEntry* WebContents::CreateNavigationEntryForCommit( // without an URL (via window.open), we may not have a committed entry yet! NavigationEntry* old_entry = controller()->GetLastCommittedEntry(); if (old_entry) { - entry->SetTitle(old_entry->GetTitle()); - entry->SetFavIcon(old_entry->GetFavIcon()); - entry->SetFavIconURL(old_entry->GetFavIconURL()); - if (in_page_nav) { - entry->SetValidFavIcon(old_entry->IsValidFavIcon()); + entry->set_title(old_entry->title()); + entry->favicon() = old_entry->favicon(); + if (in_page_nav) entry->ssl() = old_entry->ssl(); - } } } @@ -1265,18 +1262,18 @@ void WebContents::DidNavigateMainFramePreCommit( // Update contents MIME type of the main webframe. contents_mime_type_ = params.contents_mime_type; - entry->SetURL(params.url); + entry->set_url(params.url); NavigationEntry* pending = controller()->GetPendingEntry(); if (pending) { // Copy fields from the pending NavigationEntry into the actual // NavigationEntry that we're committing to. - entry->SetUserTypedURL(pending->GetUserTypedURL()); - if (pending->HasDisplayURL()) - entry->SetDisplayURL(pending->GetDisplayURL()); - if (pending->GetURL().SchemeIsFile()) - entry->SetTitle(pending->GetTitle()); - entry->SetContentState(pending->GetContentState()); + entry->set_user_typed_url(pending->user_typed_url()); + if (pending->has_display_url()) + entry->set_display_url(pending->display_url()); + if (pending->url().SchemeIsFile()) + entry->set_title(pending->title()); + entry->set_content_state(pending->content_state()); } // We no longer know the title after this navigation. @@ -1306,7 +1303,7 @@ void WebContents::DidNavigateMainFramePreCommit( // destination of a redirect, we don't want to treat it as a redirect // even though that's what its transition will be) http://b/1117048. bool user_initiated_big_change = true; - if ((PageTransition::IsRedirect(entry->GetTransitionType()) && + if ((PageTransition::IsRedirect(entry->transition_type()) && !controller()->GetPendingEntry()) || (params.gesture == NavigationGestureAuto) || IsInPageNavigation(params.url)) { @@ -1346,7 +1343,7 @@ void WebContents::DidNavigateMainFramePreCommit( MaybeCloseChildWindows(params); // Get the favicon, either from history or request it from the net. - fav_icon_helper_.FetchFavIcon(entry->GetURL()); + fav_icon_helper_.FetchFavIcon(entry->url()); // We hide the FindInPage window when the user navigates away, except on // reload. @@ -1354,7 +1351,7 @@ void WebContents::DidNavigateMainFramePreCommit( PageTransition::RELOAD) SetFindInPageVisible(false); - entry->SetHasPostData(params.is_post); + entry->set_has_post_data(params.is_post); } void WebContents::DidNavigateSubFramePreCommit( @@ -1369,10 +1366,10 @@ void WebContents::DidNavigateSubFramePreCommit( // Reset entry state to match that of the pending entry. entry->set_unique_id(last_committed->unique_id()); - entry->SetURL(last_committed->GetURL()); - entry->SetTransitionType(last_committed->GetTransitionType()); - entry->SetUserTypedURL(last_committed->GetUserTypedURL()); - entry->SetContentState(last_committed->GetContentState()); + entry->set_url(last_committed->url()); + entry->set_transition_type(last_committed->transition_type()); + entry->set_user_typed_url(last_committed->user_typed_url()); + entry->set_content_state(last_committed->content_state()); // TODO(jcampan): when navigating to an insecure/unsafe inner frame, the // main entry is the one that gets notified of the mixed/unsafe contents @@ -1401,7 +1398,7 @@ void WebContents::DidNavigateAnyFramePreCommit( // download_manager can be NULL in unit test context. if (download_manager && download_manager ->in_progress_count() == 0 && current_entry && !net::RegistryControlledDomainService::SameDomainOrHost( - current_entry->GetURL(), entry->GetURL())) { + current_entry->url(), entry->url())) { TimeDelta time_delta( TimeTicks::Now() - last_download_shelf_show_); if (time_delta > @@ -1425,7 +1422,7 @@ void WebContents::DidNavigateAnyFramePreCommit( // Most of the time, the displayURL matches the loaded URL, but for about: // URLs, we use a data: URL as the real value. We actually want to save // the about: URL to the history db and keep the data: URL hidden. - UpdateHistoryForNavigation(entry->GetDisplayURL(), params); + UpdateHistoryForNavigation(entry->display_url(), params); } } @@ -1542,11 +1539,11 @@ void WebContents::UpdateState(RenderViewHost* rvh, unsigned changed_flags = 0; // Update the URL. - if (url != entry->GetURL()) { + if (url != entry->url()) { changed_flags |= INVALIDATE_URL; if (entry == controller()->GetActiveEntry()) fav_icon_helper_.FetchFavIcon(url); - entry->SetURL(url); + entry->set_url(url); } // For file URLs without a title, use the pathname instead. @@ -1556,16 +1553,16 @@ void WebContents::UpdateState(RenderViewHost* rvh, } else { TrimWhitespace(title, TRIM_ALL, &final_title); } - if (final_title != entry->GetTitle()) { + if (final_title != entry->title()) { changed_flags |= INVALIDATE_TITLE; - entry->SetTitle(final_title); + entry->set_title(final_title); // Update the history system for this page. if (!profile()->IsOffTheRecord()) { HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); if (hs) - hs->SetPageTitle(entry->GetDisplayURL(), final_title); + hs->SetPageTitle(entry->display_url(), final_title); } } if (GetHWND()) { @@ -1575,9 +1572,9 @@ void WebContents::UpdateState(RenderViewHost* rvh, } // Update the state (forms, etc.). - if (state != entry->GetContentState()) { + if (state != entry->content_state()) { changed_flags |= INVALIDATE_STATE; - entry->SetContentState(state); + entry->set_content_state(state); } // Notify everybody of the changes (only when the current page changed). @@ -1612,10 +1609,10 @@ void WebContents::UpdateTitle(RenderViewHost* rvh, std::wstring trimmed_title; TrimWhitespace(title, TRIM_ALL, &trimmed_title); - if (title == entry->GetTitle()) + if (title == entry->title()) return; // Title did not change, do nothing. - entry->SetTitle(trimmed_title); + entry->set_title(trimmed_title); // Broadcast notifications when the UI should be updated. if (entry == controller()->GetEntryAtOffset(0)) @@ -1627,7 +1624,7 @@ void WebContents::UpdateTitle(RenderViewHost* rvh, HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); if (hs && !has_page_title_ && !trimmed_title.empty()) { - hs->SetPageTitle(entry->GetDisplayURL(), trimmed_title); + hs->SetPageTitle(entry->display_url(), trimmed_title); has_page_title_ = true; } } @@ -1692,8 +1689,8 @@ void WebContents::DidStopLoading(RenderViewHost* rvh, int32 page_id) { TimeDelta elapsed = TimeTicks::Now() - current_load_start_; details.reset(new LoadNotificationDetails( - entry->GetDisplayURL(), - entry->GetTransitionType(), + entry->display_url(), + entry->transition_type(), elapsed, controller(), controller()->GetCurrentEntryIndex())); @@ -1735,9 +1732,9 @@ void WebContents::DidRedirectProvisionalLoad(int32 page_id, entry = controller()->GetPendingEntry(); else entry = controller()->GetEntryWithPageID(type(), site_instance(), page_id); - if (!entry || entry->GetType() != type() || entry->GetURL() != source_url) + if (!entry || entry->tab_type() != type() || entry->url() != source_url) return; - entry->SetURL(target_url); + entry->set_url(target_url); } void WebContents::DidLoadResourceFromMemoryCache( @@ -1774,7 +1771,7 @@ void WebContents::DidFailProvisionalLoadWithError( // pending entry if the URLs match, otherwise the user initiated a navigate // before the page loaded so that the discard would discard the wrong entry. NavigationEntry* pending_entry = controller()->GetPendingEntry(); - if (pending_entry && pending_entry->GetURL() == url) + if (pending_entry && pending_entry->url() == url) controller()->DiscardPendingEntry(); render_manager_.RendererAbortedProvisionalLoad(render_view_host); @@ -2120,7 +2117,7 @@ void WebContents::OnJSOutOfMemory() { // Returns true if the entry's transition type is FORM_SUBMIT. static bool IsFormSubmit(const NavigationEntry* entry) { DCHECK(entry); - return (PageTransition::StripQualifier(entry->GetTransitionType()) == + return (PageTransition::StripQualifier(entry->transition_type()) == PageTransition::FORM_SUBMIT); } @@ -2159,11 +2156,17 @@ void WebContents::PageHasOSDD(RenderViewHost* render_view_host, else base_entry = NULL; } - if (!base_entry || !base_entry->GetUserTypedURLOrURL().is_valid()) + + // We want to use the user typed URL if available since that represents what + // the user typed to get here, and fall back on the regular URL if not. + if (!base_entry) return; - std::wstring keyword = - TemplateURLModel::GenerateKeyword(base_entry->GetUserTypedURLOrURL(), - autodetected); + GURL keyword_url = base_entry->user_typed_url().is_valid() ? + base_entry->user_typed_url() : base_entry->url(); + if (!keyword_url.is_valid()) + return; + std::wstring keyword = TemplateURLModel::GenerateKeyword(keyword_url, + autodetected); if (keyword.empty()) return; const TemplateURL* template_url = @@ -2180,7 +2183,7 @@ void WebContents::PageHasOSDD(RenderViewHost* render_view_host, profile()->GetTemplateURLFetcher()->ScheduleDownload( keyword, url, - base_entry->GetFavIconURL(), + base_entry->favicon().url(), GetAncestor(GetHWND(), GA_ROOT), autodetected); } @@ -2203,7 +2206,7 @@ void WebContents::OnGearsCreateShortcutDone( const GearsShortcutData& shortcut_data, bool success) { NavigationEntry* current_entry = controller()->GetLastCommittedEntry(); bool same_page = - current_entry && pending_install_.page_id == current_entry->GetPageID(); + current_entry && pending_install_.page_id == current_entry->page_id(); if (success && same_page) { // Only switch to app mode if the user chose to create a shortcut and @@ -2340,9 +2343,10 @@ void WebContents::GenerateKeywordIfNecessary( return; } + GURL keyword_url = previous_entry->user_typed_url().is_valid() ? + previous_entry->user_typed_url() : previous_entry->url(); std::wstring keyword = - TemplateURLModel::GenerateKeyword(previous_entry->GetUserTypedURLOrURL(), - true); // autodetected + TemplateURLModel::GenerateKeyword(keyword_url, true); // autodetected if (keyword.empty()) return; @@ -2375,7 +2379,7 @@ void WebContents::GenerateKeywordIfNecessary( new_url->add_input_encoding(params.searchable_form_encoding); DCHECK(controller()->GetLastCommittedEntry()); const GURL& favicon_url = - controller()->GetLastCommittedEntry()->GetFavIconURL(); + controller()->GetLastCommittedEntry()->favicon().url(); if (favicon_url.is_valid()) { new_url->SetFavIconURL(favicon_url); } else { @@ -2493,8 +2497,8 @@ bool WebContents::IsInPageNavigation(const GURL& url) const { // entry URL is the same as |url|. NavigationEntry* entry = controller()->GetLastCommittedEntry(); return (entry && url.has_ref() && - (url != entry->GetURL()) && // Test for reload of a URL with a ref. - GURLWithoutRef(entry->GetURL()) == GURLWithoutRef(url)); + (url != entry->url()) && // Test for reload of a URL with a ref. + GURLWithoutRef(entry->url()) == GURLWithoutRef(url)); } SkBitmap WebContents::GetFavIcon() { diff --git a/chrome/browser/web_contents_unittest.cc b/chrome/browser/web_contents_unittest.cc index 032e8eb..26024da 100644 --- a/chrome/browser/web_contents_unittest.cc +++ b/chrome/browser/web_contents_unittest.cc @@ -1152,26 +1152,26 @@ TEST_F(WebContentsTest, NavigationEntryContentState) { InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); entry = contents->controller()->GetLastCommittedEntry(); - EXPECT_FALSE(entry->GetContentState().empty()); + EXPECT_FALSE(entry->content_state().empty()); // Navigate to same site. const GURL url2("http://images.google.com"); contents->controller()->LoadURL(url2, PageTransition::TYPED); entry = contents->controller()->GetLastCommittedEntry(); - EXPECT_FALSE(entry->GetContentState().empty()); + EXPECT_FALSE(entry->content_state().empty()); // Committed entry should have content state after DidNavigate. ViewHostMsg_FrameNavigate_Params params2; InitNavigateParams(¶ms2, 2, url2); contents->TestDidNavigate(orig_rvh, params2); entry = contents->controller()->GetLastCommittedEntry(); - EXPECT_FALSE(entry->GetContentState().empty()); + EXPECT_FALSE(entry->content_state().empty()); // Now go back. Committed entry should still have content state. contents->controller()->GoBack(); contents->TestDidNavigate(orig_rvh, params1); entry = contents->controller()->GetLastCommittedEntry(); - EXPECT_FALSE(entry->GetContentState().empty()); + EXPECT_FALSE(entry->content_state().empty()); } // Test that NavigationEntries have the correct content state after opening @@ -1189,7 +1189,7 @@ TEST_F(WebContentsTest, NavigationEntryContentStateNewWindow) { // Should have a content state here. NavigationEntry* entry = contents->controller()->GetLastCommittedEntry(); - EXPECT_FALSE(entry->GetContentState().empty()); + EXPECT_FALSE(entry->content_state().empty()); } // Tests that IsInPageNavigation returns appropriate results. Prevents |