diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 20:25:25 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-04 20:25:25 +0000 |
commit | 1ce666a29eac9d51a909d537df8f6f8c271377c5 (patch) | |
tree | 5d2dde12b56f1e76416c24df10ce8760a6234aad | |
parent | bf140b7c4d58524deab0350e5b34aa49a05d6743 (diff) | |
download | chromium_src-1ce666a29eac9d51a909d537df8f6f8c271377c5.zip chromium_src-1ce666a29eac9d51a909d537df8f6f8c271377c5.tar.gz chromium_src-1ce666a29eac9d51a909d537df8f6f8c271377c5.tar.bz2 |
Rename AlternateNavURLFetcher to OmniboxNavigationObserver in preparation for
expanding its scope.
BUG=151044
TEST=none
R=sky@chromium.org
Review URL: https://codereview.chromium.org/25963002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227074 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/intranet_redirect_detector.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_edit_model.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_navigation_observer.cc (renamed from chrome/browser/ui/omnibox/alternate_nav_url_fetcher.cc) | 16 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_navigation_observer.h (renamed from chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h) | 40 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 4 |
5 files changed, 36 insertions, 36 deletions
diff --git a/chrome/browser/intranet_redirect_detector.h b/chrome/browser/intranet_redirect_detector.h index 2a84791..a39b9e6 100644 --- a/chrome/browser/intranet_redirect_detector.h +++ b/chrome/browser/intranet_redirect_detector.h @@ -26,7 +26,7 @@ class PrefRegistrySimple; // 302 redirect to "http://isp.domain.com/search?q=query" in order to display // custom pages on typos, nonexistent sites, etc. // -// We use this information in the AlternateNavURLFetcher to avoid displaying +// We use this information in the OmniboxNavigationObserver to avoid displaying // infobars for these cases. Our infobars are designed to allow users to get at // intranet sites when they were erroneously taken to a search result page. In // these cases, however, users would be shown a confusing and useless infobar diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 8abd761..11c8540 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -42,9 +42,9 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" #include "chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.h" #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" +#include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" #include "chrome/browser/ui/omnibox/omnibox_view.h" @@ -769,16 +769,16 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, if (destination_url.is_valid()) { // The OmniboxNavigationObserver will listen for the pending navigation // notification that will be issued as a result of the "open URL." - scoped_ptr<AlternateNavURLFetcher> fetcher( - new AlternateNavURLFetcher(alternate_nav_url)); + scoped_ptr<OmniboxNavigationObserver> observer( + new OmniboxNavigationObserver(alternate_nav_url)); // This calls RevertAll again. base::AutoReset<bool> tmp(&in_revert_, true); controller_->OnAutocompleteAccept( destination_url, disposition, content::PageTransitionFromInt( match.transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); - if (fetcher->state() != AlternateNavURLFetcher::NOT_STARTED) - ignore_result(fetcher.release()); // The fetcher will delete itself. + if (observer->state() != OmniboxNavigationObserver::NOT_STARTED) + ignore_result(observer.release()); // The observer will delete itself. } } diff --git a/chrome/browser/ui/omnibox/alternate_nav_url_fetcher.cc b/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc index 01b2edf..e4bc6bb 100644 --- a/chrome/browser/ui/omnibox/alternate_nav_url_fetcher.cc +++ b/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" +#include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/infobars/infobar_service.h" @@ -21,7 +21,7 @@ using content::NavigationController; -AlternateNavURLFetcher::AlternateNavURLFetcher( +OmniboxNavigationObserver::OmniboxNavigationObserver( const GURL& alternate_nav_url) : alternate_nav_url_(alternate_nav_url), controller_(NULL), @@ -31,10 +31,10 @@ AlternateNavURLFetcher::AlternateNavURLFetcher( content::NotificationService::AllSources()); } -AlternateNavURLFetcher::~AlternateNavURLFetcher() { +OmniboxNavigationObserver::~OmniboxNavigationObserver() { } -void AlternateNavURLFetcher::Observe( +void OmniboxNavigationObserver::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -79,7 +79,7 @@ void AlternateNavURLFetcher::Observe( } } -void AlternateNavURLFetcher::OnURLFetchComplete( +void OmniboxNavigationObserver::OnURLFetchComplete( const net::URLFetcher* source) { DCHECK_EQ(fetcher_.get(), source); SetStatusFromURLFetch( @@ -88,7 +88,7 @@ void AlternateNavURLFetcher::OnURLFetchComplete( // WARNING: |this| may be deleted! } -void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { +void OmniboxNavigationObserver::StartFetch(NavigationController* controller) { controller_ = controller; content::WebContents* web_contents = controller_->GetWebContents(); registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, @@ -105,7 +105,7 @@ void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { fetcher_->Start(); } -void AlternateNavURLFetcher::SetStatusFromURLFetch( +void OmniboxNavigationObserver::SetStatusFromURLFetch( const GURL& url, const net::URLRequestStatus& status, int response_code) { @@ -132,7 +132,7 @@ void AlternateNavURLFetcher::SetStatusFromURLFetch( } } -void AlternateNavURLFetcher::ShowInfoBarIfPossible() { +void OmniboxNavigationObserver::ShowInfoBarIfPossible() { if (navigated_to_entry_ && (state_ == SUCCEEDED)) { AlternateNavInfoBarDelegate::Create( InfoBarService::FromWebContents(controller_->GetWebContents()), diff --git a/chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h b/chrome/browser/ui/omnibox/omnibox_navigation_observer.h index 1987213..555c7e9 100644 --- a/chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h +++ b/chrome/browser/ui/omnibox/omnibox_navigation_observer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_URL_FETCHER_H_ -#define CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_URL_FETCHER_H_ +#ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ +#define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ #include <string> @@ -22,24 +22,24 @@ class URLFetcher; class URLRequestStatus; } -// Attempts to get the HEAD of a host name and displays an info bar if the -// request was successful. This is used for single-word queries where we can't -// tell if the entry was a search or an intranet hostname. The autocomplete bar -// assumes it's a query and issues an AlternateNavURLFetcher to display a "did -// you mean" infobar suggesting a navigation. +// Monitors omnibox navigations in order to trigger behaviors that depend on +// successful navigations. // -// The memory management of this object is a bit tricky. The location bar view +// Currently two such behaviors exist: +// (1) For single-word queries where we can't tell if the entry was a search or +// an intranet hostname, the omnibox opens as a search by default, but this +// class attempts to open as a URL via an HTTP HEAD request. If successful, +// displays an infobar once the search result has also loaded. See +// AlternateNavInfoBarDelegate. +// (2) Omnibox navigations that complete successfully are added to the +// Shortcuts backend. TODO(pkasting): Not yet implemented. +// +// The memory management of this object is a bit tricky. The OmniboxEditModel // will create us and be responsible for us until we attach as an observer // after a pending load starts (it will delete us if this doesn't happen). // Once this pending load starts, we're responsible for deleting ourselves. -// We'll do this in the following cases: -// * The tab is navigated again once we start listening (so the fetch is no -// longer useful) -// * The tab is closed before we show an infobar -// * The intranet fetch fails -// * None of the above apply, so we successfully show an infobar -class AlternateNavURLFetcher : public content::NotificationObserver, - public net::URLFetcherDelegate { +class OmniboxNavigationObserver : public content::NotificationObserver, + public net::URLFetcherDelegate { public: enum State { NOT_STARTED, @@ -48,8 +48,8 @@ class AlternateNavURLFetcher : public content::NotificationObserver, FAILED, }; - explicit AlternateNavURLFetcher(const GURL& alternate_nav_url); - virtual ~AlternateNavURLFetcher(); + explicit OmniboxNavigationObserver(const GURL& alternate_nav_url); + virtual ~OmniboxNavigationObserver(); State state() const { return state_; } @@ -86,7 +86,7 @@ class AlternateNavURLFetcher : public content::NotificationObserver, content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); + DISALLOW_COPY_AND_ASSIGN(OmniboxNavigationObserver); }; -#endif // CHROME_BROWSER_UI_OMNIBOX_ALTERNATE_NAV_URL_FETCHER_H_ +#endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index cdfc402..87a6079 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1342,8 +1342,6 @@ 'browser/ui/ntp_background_util.h', 'browser/ui/omnibox/alternate_nav_infobar_delegate.cc', 'browser/ui/omnibox/alternate_nav_infobar_delegate.h', - 'browser/ui/omnibox/alternate_nav_url_fetcher.cc', - 'browser/ui/omnibox/alternate_nav_url_fetcher.h', 'browser/ui/omnibox/location_bar.h', 'browser/ui/omnibox/location_bar_util.cc', 'browser/ui/omnibox/location_bar_util.h', @@ -1355,6 +1353,8 @@ 'browser/ui/omnibox/omnibox_edit_controller.h', 'browser/ui/omnibox/omnibox_edit_model.cc', 'browser/ui/omnibox/omnibox_edit_model.h', + 'browser/ui/omnibox/omnibox_navigation_observer.cc', + 'browser/ui/omnibox/omnibox_navigation_observer.h', 'browser/ui/omnibox/omnibox_popup_model.cc', 'browser/ui/omnibox/omnibox_popup_model.h', 'browser/ui/omnibox/omnibox_popup_model_observer.h', |