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

Side by Side Diff: chrome/browser/google/google_url_tracker.cc

Issue 10392189: Fix unsafe attempt to blindly access owner() in GoogleURLTracker::Close(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/google/google_url_tracker.h" 5 #include "chrome/browser/google/google_url_tracker.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DCHECK_EQ(GetHost(new_google_url_), GetHost(new_google_url)); 96 DCHECK_EQ(GetHost(new_google_url_), GetHost(new_google_url));
97 new_google_url_ = new_google_url; 97 new_google_url_ = new_google_url;
98 } 98 }
99 99
100 void GoogleURLTrackerInfoBarDelegate::Show() { 100 void GoogleURLTrackerInfoBarDelegate::Show() {
101 showing_ = true; 101 showing_ = true;
102 owner()->AddInfoBar(this); // May delete |this| on failure! 102 owner()->AddInfoBar(this); // May delete |this| on failure!
103 } 103 }
104 104
105 void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) { 105 void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) {
106 if (redo_search) { 106 if (redo_search && owner()) {
107 // Re-do the user's search on the new domain. 107 // Re-do the user's search on the new domain.
108 url_canon::Replacements<char> replacements; 108 url_canon::Replacements<char> replacements;
109 const std::string& host(new_google_url_.host()); 109 const std::string& host(new_google_url_.host());
110 replacements.SetHost(host.data(), url_parse::Component(0, host.length())); 110 replacements.SetHost(host.data(), url_parse::Component(0, host.length()));
111 GURL new_search_url(search_url_.ReplaceComponents(replacements)); 111 GURL new_search_url(search_url_.ReplaceComponents(replacements));
112 if (new_search_url.is_valid()) { 112 if (new_search_url.is_valid()) {
113 content::OpenURLParams params(new_search_url, content::Referrer(), 113 content::OpenURLParams params(new_search_url, content::Referrer(),
114 CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false); 114 CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false);
115 owner()->web_contents()->OpenURL(params); 115 owner()->web_contents()->OpenURL(params);
116 } 116 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 511
512 void GoogleURLTracker::CloseAllInfoBars(bool redo_searches) { 512 void GoogleURLTracker::CloseAllInfoBars(bool redo_searches) {
513 // Close all infobars, whether they've been added to tabs or not. 513 // Close all infobars, whether they've been added to tabs or not.
514 while (!infobar_map_.empty()) 514 while (!infobar_map_.empty())
515 infobar_map_.begin()->second->Close(redo_searches); 515 infobar_map_.begin()->second->Close(redo_searches);
516 516
517 // Any registered listeners for NAV_ENTRY_COMMITTED and TAB_CLOSED are now 517 // Any registered listeners for NAV_ENTRY_COMMITTED and TAB_CLOSED are now
518 // irrelevant as the associated infobars are gone. 518 // irrelevant as the associated infobars are gone.
519 registrar_.RemoveAll(); 519 registrar_.RemoveAll();
520 } 520 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698