Commit 3ac64f2c authored by mpearson@chromium.org's avatar mpearson@chromium.org

Omnibox: Possibly Fix Rare OpenMatch Crash

The associated bug seems to imply a crash on this line
ClassifyPage(controller_->GetWebContents()->GetURL())
in OmniboxEditModel::OpenMatch().

This change corrects the part of the test that may fail
(if there's no active tab for some reason).
I think controller_ is always valid (the rest of the edit
model code use it without testing it for non-NULL).
But I see at least two places in OmniboxEditModel that
test for the non-NULLness of controller_->GetWebContents().
Hence, I think it might be able to be NULL, so this
change adds a test for it here too.

TEST=new code compiles
BUG=142931


Review URL: https://chromiumcodereview.appspot.com/12250014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182244 0039d316-1c4b-4281-b951-d872f2087c98
parent a3eeccb9
...@@ -573,6 +573,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, ...@@ -573,6 +573,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match,
// open). // open).
if (popup_->IsOpen()) { if (popup_->IsOpen()) {
const base::TimeTicks& now(base::TimeTicks::Now()); const base::TimeTicks& now(base::TimeTicks::Now());
const content::WebContents* web_contents = controller_->GetWebContents();
// TODO(sreeram): Handle is_temporary_text_set_by_instant_ correctly. // TODO(sreeram): Handle is_temporary_text_set_by_instant_ correctly.
AutocompleteLog log( AutocompleteLog log(
autocomplete_controller_->input().text(), autocomplete_controller_->input().text(),
...@@ -580,7 +581,8 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, ...@@ -580,7 +581,8 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match,
autocomplete_controller_->input().type(), autocomplete_controller_->input().type(),
popup_->selected_line(), popup_->selected_line(),
-1, // don't yet know tab ID; set later if appropriate -1, // don't yet know tab ID; set later if appropriate
ClassifyPage(controller_->GetWebContents()->GetURL()), web_contents ? ClassifyPage(web_contents->GetURL()) :
metrics::OmniboxEventProto_PageClassification_OTHER,
now - time_user_first_modified_omnibox_, now - time_user_first_modified_omnibox_,
string16::npos, // completed_length; possibly set later string16::npos, // completed_length; possibly set later
now - autocomplete_controller_->last_time_default_match_changed(), now - autocomplete_controller_->last_time_default_match_changed(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment