| 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/ui/omnibox/omnibox_navigation_observer.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autocomplete/shortcuts_backend.h" | 7 #include "chrome/browser/autocomplete/shortcuts_backend.h" |
| 8 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 8 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/intranet_redirect_detector.h" | 10 #include "chrome/browser/intranet_redirect_detector.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // We need to start by listening to AllSources, since we don't know which tab | 70 // We need to start by listening to AllSources, since we don't know which tab |
| 71 // the navigation might occur in. | 71 // the navigation might occur in. |
| 72 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 72 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 73 content::NotificationService::AllSources()); | 73 content::NotificationService::AllSources()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 OmniboxNavigationObserver::~OmniboxNavigationObserver() { | 76 OmniboxNavigationObserver::~OmniboxNavigationObserver() { |
| 77 } | 77 } |
| 78 | 78 |
| 79 void OmniboxNavigationObserver::OnSuccessfulNavigation() { | 79 void OmniboxNavigationObserver::OnSuccessfulNavigation() { |
| 80 if (shortcuts_backend_) | 80 if (shortcuts_backend_.get()) |
| 81 shortcuts_backend_->AddOrUpdateShortcut(text_, match_); | 81 shortcuts_backend_->AddOrUpdateShortcut(text_, match_); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void OmniboxNavigationObserver::Observe( | 84 void OmniboxNavigationObserver::Observe( |
| 85 int type, | 85 int type, |
| 86 const content::NotificationSource& source, | 86 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) { | 87 const content::NotificationDetails& details) { |
| 88 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); | 88 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); |
| 89 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 89 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 90 content::NotificationService::AllSources()); | 90 content::NotificationService::AllSources()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 OnAllLoadingFinished(); // deletes |this|! | 140 OnAllLoadingFinished(); // deletes |this|! |
| 141 } | 141 } |
| 142 | 142 |
| 143 void OmniboxNavigationObserver::OnAllLoadingFinished() { | 143 void OmniboxNavigationObserver::OnAllLoadingFinished() { |
| 144 if (fetch_state_ == FETCH_SUCCEEDED) { | 144 if (fetch_state_ == FETCH_SUCCEEDED) { |
| 145 AlternateNavInfoBarDelegate::Create( | 145 AlternateNavInfoBarDelegate::Create( |
| 146 web_contents(), text_, alternate_nav_match_, match_.destination_url); | 146 web_contents(), text_, alternate_nav_match_, match_.destination_url); |
| 147 } | 147 } |
| 148 delete this; | 148 delete this; |
| 149 } | 149 } |
| OLD | NEW |