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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/google/google_url_tracker_factory.h" 12 #include "chrome/browser/google/google_url_tracker_factory.h"
13 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" 13 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h"
14 #include "chrome/browser/google/google_url_tracker_navigation_helper.h" 14 #include "chrome/browser/google/google_url_tracker_navigation_helper.h"
15 #include "chrome/browser/google/google_util.h" 15 #include "chrome/browser/google/google_util.h"
16 #include "chrome/browser/infobars/infobar.h"
17 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
24 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
25 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
26 #include "net/url_request/url_fetcher.h" 25 #include "net/url_request/url_fetcher.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 const GURL& search_url) { 341 const GURL& search_url) {
343 EntryMap::iterator i(entry_map_.find(infobar_service)); 342 EntryMap::iterator i(entry_map_.find(infobar_service));
344 DCHECK(i != entry_map_.end()); 343 DCHECK(i != entry_map_.end());
345 GoogleURLTrackerMapEntry* map_entry = i->second; 344 GoogleURLTrackerMapEntry* map_entry = i->second;
346 DCHECK(search_url.is_valid()); 345 DCHECK(search_url.is_valid());
347 346
348 UnregisterForEntrySpecificNotifications(*map_entry, true); 347 UnregisterForEntrySpecificNotifications(*map_entry, true);
349 if (map_entry->has_infobar_delegate()) { 348 if (map_entry->has_infobar_delegate()) {
350 map_entry->infobar_delegate()->Update(search_url); 349 map_entry->infobar_delegate()->Update(search_url);
351 } else { 350 } else {
352 InfoBar* infobar = infobar_creator_.Run(infobar_service, this, search_url); 351 GoogleURLTrackerInfoBarDelegate* infobar =
353 if (infobar) { 352 infobar_creator_.Run(infobar_service, this, search_url);
354 map_entry->SetInfoBarDelegate( 353 if (infobar)
355 static_cast<GoogleURLTrackerInfoBarDelegate*>(infobar->delegate())); 354 map_entry->SetInfoBarDelegate(infobar);
356 } else { 355 else
357 map_entry->Close(false); 356 map_entry->Close(false);
358 }
359 } 357 }
360 } 358 }
361 359
362 void GoogleURLTracker::OnTabClosed( 360 void GoogleURLTracker::OnTabClosed(
363 content::NavigationController* navigation_controller) { 361 content::NavigationController* navigation_controller) {
364 // Because InfoBarService tears itself down on tab destruction, it's possible 362 // Because InfoBarService tears itself down on tab destruction, it's possible
365 // to get a non-NULL InfoBarService pointer here, depending on which order 363 // to get a non-NULL InfoBarService pointer here, depending on which order
366 // notifications fired in. Likewise, the pointer in |entry_map_| (and in its 364 // notifications fired in. Likewise, the pointer in |entry_map_| (and in its
367 // associated MapEntry) may point to deleted memory. Therefore, if we were to 365 // associated MapEntry) may point to deleted memory. Therefore, if we were to
368 // access the InfoBarService* we have for this tab, we'd need to ensure we 366 // access the InfoBarService* we have for this tab, we'd need to ensure we
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 i->second->navigation_controller())) { 416 i->second->navigation_controller())) {
419 DCHECK(nav_helper_->IsListeningForNavigationStart()); 417 DCHECK(nav_helper_->IsListeningForNavigationStart());
420 return; 418 return;
421 } 419 }
422 } 420 }
423 if (nav_helper_->IsListeningForNavigationStart()) { 421 if (nav_helper_->IsListeningForNavigationStart()) {
424 DCHECK(!search_committed_); 422 DCHECK(!search_committed_);
425 nav_helper_->SetListeningForNavigationStart(false); 423 nav_helper_->SetListeningForNavigationStart(false);
426 } 424 }
427 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698