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

Side by Side Diff: chrome/browser/views/find_bar_win.cc

Issue 27173: Fix 8030: Crash in EndFindSession (automation_ui_test) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/find_bar_win.h" 5 #include "chrome/browser/views/find_bar_win.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/view_ids.h" 10 #include "chrome/browser/view_ids.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 bool FindBarWin::IsAnimating() { 191 bool FindBarWin::IsAnimating() {
192 return animation_->IsAnimating(); 192 return animation_->IsAnimating();
193 } 193 }
194 194
195 void FindBarWin::EndFindSession() { 195 void FindBarWin::EndFindSession() {
196 animation_->Reset(1.0); 196 animation_->Reset(1.0);
197 animation_->Hide(); 197 animation_->Hide();
198 198
199 // When we hide the window, we need to notify the renderer that we are done 199 // |web_contents_| can be NULL for a number of reasons, for example when the
200 // for now, so that we can abort the scoping effort and clear all the 200 // tab is closing. We must guard against that case. See issue 8030.
201 // tickmarks and highlighting. 201 if (web_contents_) {
202 web_contents_->StopFinding(false); // false = don't clear selection on 202 // When we hide the window, we need to notify the renderer that we are done
203 // page. 203 // for now, so that we can abort the scoping effort and clear all the
204 view_->UpdateForResult(web_contents_->find_result(), std::wstring()); 204 // tickmarks and highlighting.
205 web_contents_->StopFinding(false); // false = don't clear selection on
206 // page.
207 view_->UpdateForResult(web_contents_->find_result(), std::wstring());
205 208
206 // When we get dismissed we restore the focus to where it belongs. 209 // When we get dismissed we restore the focus to where it belongs.
207 RestoreSavedFocus(); 210 RestoreSavedFocus();
211 }
208 } 212 }
209 213
210 void FindBarWin::ChangeWebContents(WebContents* contents) { 214 void FindBarWin::ChangeWebContents(WebContents* contents) {
211 if (web_contents_) { 215 if (web_contents_) {
212 NotificationService::current()->RemoveObserver( 216 NotificationService::current()->RemoveObserver(
213 this, NotificationType::FIND_RESULT_AVAILABLE, 217 this, NotificationType::FIND_RESULT_AVAILABLE,
214 Source<TabContents>(web_contents_)); 218 Source<TabContents>(web_contents_));
215 NotificationService::current()->RemoveObserver( 219 NotificationService::current()->RemoveObserver(
216 this, NotificationType::NAV_ENTRY_COMMITTED, 220 this, NotificationType::NAV_ENTRY_COMMITTED,
217 Source<NavigationController>(web_contents_->controller())); 221 Source<NavigationController>(web_contents_->controller()));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 view_->SchedulePaint(); 277 view_->SchedulePaint();
274 } 278 }
275 279
276 //////////////////////////////////////////////////////////////////////////////// 280 ////////////////////////////////////////////////////////////////////////////////
277 // FindBarWin, NotificationObserver implementation: 281 // FindBarWin, NotificationObserver implementation:
278 282
279 void FindBarWin::Observe(NotificationType type, 283 void FindBarWin::Observe(NotificationType type,
280 const NotificationSource& source, 284 const NotificationSource& source,
281 const NotificationDetails& details) { 285 const NotificationDetails& details) {
282 if (type == NotificationType::FIND_RESULT_AVAILABLE) { 286 if (type == NotificationType::FIND_RESULT_AVAILABLE) {
283 // Don't update for notifications from TabContentses other than the one we a re 287 // Don't update for notifications from TabContentses other than the one we
284 // actively tracking. 288 // are actively tracking.
285 if (Source<TabContents>(source).ptr() == web_contents_) { 289 if (Source<TabContents>(source).ptr() == web_contents_) {
286 UpdateUIForFindResult(web_contents_->find_result(), 290 UpdateUIForFindResult(web_contents_->find_result(),
287 web_contents_->find_text()); 291 web_contents_->find_text());
288 FindNotificationDetails details = web_contents_->find_result(); 292 FindNotificationDetails details = web_contents_->find_result();
289 } 293 }
290 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { 294 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) {
291 NavigationController* source_controller = 295 NavigationController* source_controller =
292 Source<NavigationController>(source).ptr(); 296 Source<NavigationController>(source).ptr();
293 if (source_controller == web_contents_->controller()) { 297 if (source_controller == web_contents_->controller()) {
294 NavigationController::LoadCommittedDetails* commit_details = 298 NavigationController::LoadCommittedDetails* commit_details =
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 555
552 // We now need to check if the window is obscuring the search results. 556 // We now need to check if the window is obscuring the search results.
553 if (!result.selection_rect().IsEmpty()) 557 if (!result.selection_rect().IsEmpty())
554 MoveWindowIfNecessary(result.selection_rect(), false); 558 MoveWindowIfNecessary(result.selection_rect(), false);
555 559
556 // Once we find a match we no longer want to keep track of what had 560 // Once we find a match we no longer want to keep track of what had
557 // focus. EndFindSession will then set the focus to the page content. 561 // focus. EndFindSession will then set the focus to the page content.
558 if (result.number_of_matches() > 0) 562 if (result.number_of_matches() > 0)
559 focus_tracker_.reset(NULL); 563 focus_tracker_.reset(NULL);
560 } 564 }
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