| OLD | NEW |
| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 const content::NotificationDetails& details) { | 320 const content::NotificationDetails& details) { |
| 321 switch (type) { | 321 switch (type) { |
| 322 case content::NOTIFICATION_NAV_ENTRY_PENDING: { | 322 case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
| 323 NavigationController* controller = | 323 NavigationController* controller = |
| 324 content::Source<NavigationController>(source).ptr(); | 324 content::Source<NavigationController>(source).ptr(); |
| 325 OnNavigationPending(source, controller->GetPendingEntry()->GetURL()); | 325 OnNavigationPending(source, controller->GetPendingEntry()->GetURL()); |
| 326 break; | 326 break; |
| 327 } | 327 } |
| 328 | 328 |
| 329 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: | 329 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: |
| 330 case content::NOTIFICATION_TAB_CLOSED: | |
| 331 OnNavigationCommittedOrTabClosed( | 330 OnNavigationCommittedOrTabClosed( |
| 332 content::Source<NavigationController>(source).ptr()-> | 331 content::Source<NavigationController>(source).ptr()-> |
| 333 GetWebContents(), type); | 332 GetWebContents(), type); |
| 334 break; | 333 break; |
| 335 | 334 |
| 335 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
| 336 OnNavigationCommittedOrTabClosed( |
| 337 content::Source<content::WebContents>(source).ptr(), type); |
| 338 break; |
| 339 |
| 336 default: | 340 default: |
| 337 NOTREACHED() << "Unknown notification received:" << type; | 341 NOTREACHED() << "Unknown notification received:" << type; |
| 338 } | 342 } |
| 339 } | 343 } |
| 340 | 344 |
| 341 void GoogleURLTracker::OnIPAddressChanged() { | 345 void GoogleURLTracker::OnIPAddressChanged() { |
| 342 already_fetched_ = false; | 346 already_fetched_ = false; |
| 343 StartFetchIfDesirable(); | 347 StartFetchIfDesirable(); |
| 344 } | 348 } |
| 345 | 349 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 356 const content::NotificationSource& source, | 360 const content::NotificationSource& source, |
| 357 const GURL& pending_url) { | 361 const GURL& pending_url) { |
| 358 controller_ = content::Source<NavigationController>(source).ptr(); | 362 controller_ = content::Source<NavigationController>(source).ptr(); |
| 359 search_url_ = pending_url; | 363 search_url_ = pending_url; |
| 360 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 364 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 361 content::NotificationService::AllBrowserContextsAndSources()); | 365 content::NotificationService::AllBrowserContextsAndSources()); |
| 362 // Start listening for the commit notification. We also need to listen for the | 366 // Start listening for the commit notification. We also need to listen for the |
| 363 // tab close command since that means the load will never commit. | 367 // tab close command since that means the load will never commit. |
| 364 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 368 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 365 content::Source<NavigationController>(controller_)); | 369 content::Source<NavigationController>(controller_)); |
| 366 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, | 370 registrar_.Add( |
| 367 content::Source<NavigationController>(controller_)); | 371 this, |
| 372 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 373 content::Source<content::WebContents>(controller_->GetWebContents())); |
| 368 } | 374 } |
| 369 | 375 |
| 370 void GoogleURLTracker::OnNavigationCommittedOrTabClosed( | 376 void GoogleURLTracker::OnNavigationCommittedOrTabClosed( |
| 371 WebContents* web_contents, | 377 WebContents* web_contents, |
| 372 int type) { | 378 int type) { |
| 373 registrar_.RemoveAll(); | 379 registrar_.RemoveAll(); |
| 374 | 380 |
| 375 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 381 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
| 376 ShowGoogleURLInfoBarIfNecessary(web_contents); | 382 ShowGoogleURLInfoBarIfNecessary(web_contents); |
| 377 } else { | 383 } else { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 388 | 394 |
| 389 // |tab_contents| can be NULL during tests. | 395 // |tab_contents| can be NULL during tests. |
| 390 InfoBarTabHelper* infobar_helper = NULL; | 396 InfoBarTabHelper* infobar_helper = NULL; |
| 391 if (web_contents) { | 397 if (web_contents) { |
| 392 TabContentsWrapper* wrapper = | 398 TabContentsWrapper* wrapper = |
| 393 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 399 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
| 394 infobar_helper = wrapper->infobar_tab_helper(); | 400 infobar_helper = wrapper->infobar_tab_helper(); |
| 395 } | 401 } |
| 396 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); | 402 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); |
| 397 } | 403 } |
| OLD | NEW |