summaryrefslogtreecommitdiffstats
path: root/chrome/browser/external_tab_container.cc
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 19:03:50 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 19:03:50 +0000
commit6c908bb20ff6d3f85e9ed08c864a59702c3bc09a (patch)
tree7162961137a8ad25658b47d2bd5b4a03e35f5c6d /chrome/browser/external_tab_container.cc
parent20dcfd549f122b8a15b76447c14c5c3539c88242 (diff)
downloadchromium_src-6c908bb20ff6d3f85e9ed08c864a59702c3bc09a.zip
chromium_src-6c908bb20ff6d3f85e9ed08c864a59702c3bc09a.tar.gz
chromium_src-6c908bb20ff6d3f85e9ed08c864a59702c3bc09a.tar.bz2
InitNavigationInfo only if there's a valid entry
Automation can send information about an entry only if it exists. Handle the case that during early loading there's no navigation entry and we can avoid sending navigation information. BUG=none TEST=none Review URL: http://codereview.chromium.org/174225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_tab_container.cc')
-rw-r--r--chrome/browser/external_tab_container.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 5cf341b..59c8a34 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -205,10 +205,9 @@ void ExternalTabContainer::NavigationStateChanged(const TabContents* source,
unsigned changed_flags) {
if (automation_) {
IPC::NavigationInfo nav_info;
- InitNavigationInfo(&nav_info, NavigationType::NAV_IGNORE, 0);
- automation_->Send(new AutomationMsg_NavigationStateChanged(0, tab_handle_,
- changed_flags,
- nav_info));
+ if (InitNavigationInfo(&nav_info, NavigationType::NAV_IGNORE, 0))
+ automation_->Send(new AutomationMsg_NavigationStateChanged(
+ 0, tab_handle_, changed_flags, nav_info));
}
}
@@ -408,11 +407,11 @@ void ExternalTabContainer::Observe(NotificationType type,
// When the previous entry index is invalid, it will be -1, which
// will still make the computation come out right (navigating to the
// 0th entry will be +1).
- InitNavigationInfo(&navigation_info, commit->type,
- commit->previous_entry_index -
- tab_contents_->controller().last_committed_entry_index());
- automation_->Send(new AutomationMsg_DidNavigate(0, tab_handle_,
- navigation_info));
+ if (InitNavigationInfo(&navigation_info, commit->type,
+ commit->previous_entry_index -
+ tab_contents_->controller().last_committed_entry_index()))
+ automation_->Send(new AutomationMsg_DidNavigate(0, tab_handle_,
+ navigation_info));
}
break;
}
@@ -517,12 +516,14 @@ bool ExternalTabContainer::ProcessUnhandledKeyStroke(HWND window,
return false;
}
-void ExternalTabContainer::InitNavigationInfo(IPC::NavigationInfo* nav_info,
+bool ExternalTabContainer::InitNavigationInfo(IPC::NavigationInfo* nav_info,
NavigationType::Type nav_type,
int relative_offset) {
- NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
DCHECK(nav_info);
- DCHECK(entry);
+ NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
+ // If this is very early in the game then we may not have an entry.
+ if (!entry)
+ return false;
nav_info->navigation_type = nav_type;
nav_info->relative_offset = relative_offset;
@@ -530,5 +531,6 @@ void ExternalTabContainer::InitNavigationInfo(IPC::NavigationInfo* nav_info,
tab_contents_->controller().GetCurrentEntryIndex();
nav_info->title = UTF16ToWideHack(entry->title());
nav_info->url = entry->url();
+ return true;
}