| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ | 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "url/gurl.h" | |
| 18 | 17 |
| 19 namespace history { | 18 namespace history { |
| 20 class ShortcutsBackend; | 19 class ShortcutsBackend; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace net { | 22 namespace net { |
| 24 class URLFetcher; | 23 class URLFetcher; |
| 25 class URLRequestStatus; | 24 class URLRequestStatus; |
| 26 } | 25 } |
| 27 | 26 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 public: | 49 public: |
| 51 enum LoadState { | 50 enum LoadState { |
| 52 LOAD_NOT_SEEN, | 51 LOAD_NOT_SEEN, |
| 53 LOAD_PENDING, | 52 LOAD_PENDING, |
| 54 LOAD_COMMITTED, | 53 LOAD_COMMITTED, |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 OmniboxNavigationObserver(Profile* profile, | 56 OmniboxNavigationObserver(Profile* profile, |
| 58 const string16& text, | 57 const string16& text, |
| 59 const AutocompleteMatch& match, | 58 const AutocompleteMatch& match, |
| 60 const GURL& alternate_nav_url); | 59 const AutocompleteMatch& alternate_nav_match); |
| 61 virtual ~OmniboxNavigationObserver(); | 60 virtual ~OmniboxNavigationObserver(); |
| 62 | 61 |
| 63 LoadState load_state() const { return load_state_; } | 62 LoadState load_state() const { return load_state_; } |
| 64 | 63 |
| 65 // Called directly by OmniboxEditModel when an extension-related navigation | 64 // Called directly by OmniboxEditModel when an extension-related navigation |
| 66 // occurs. Such navigations don't trigger an immediate NAV_ENTRY_PENDING and | 65 // occurs. Such navigations don't trigger an immediate NAV_ENTRY_PENDING and |
| 67 // must be handled separately. | 66 // must be handled separately. |
| 68 void OnSuccessfulNavigation(); | 67 void OnSuccessfulNavigation(); |
| 69 | 68 |
| 70 private: | 69 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 90 | 89 |
| 91 // net::URLFetcherDelegate: | 90 // net::URLFetcherDelegate: |
| 92 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 91 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 93 | 92 |
| 94 // Once the load has committed and any URL fetch has completed, this displays | 93 // Once the load has committed and any URL fetch has completed, this displays |
| 95 // the alternate nav infobar if necessary, and deletes |this|. | 94 // the alternate nav infobar if necessary, and deletes |this|. |
| 96 void OnAllLoadingFinished(); | 95 void OnAllLoadingFinished(); |
| 97 | 96 |
| 98 const string16 text_; | 97 const string16 text_; |
| 99 const AutocompleteMatch match_; | 98 const AutocompleteMatch match_; |
| 100 const GURL alternate_nav_url_; | 99 const AutocompleteMatch alternate_nav_match_; |
| 101 scoped_refptr<history::ShortcutsBackend> shortcuts_backend_; // May be NULL | 100 scoped_refptr<history::ShortcutsBackend> shortcuts_backend_; // May be NULL |
| 102 // in incognito. | 101 // in incognito. |
| 103 scoped_ptr<net::URLFetcher> fetcher_; | 102 scoped_ptr<net::URLFetcher> fetcher_; |
| 104 LoadState load_state_; | 103 LoadState load_state_; |
| 105 FetchState fetch_state_; | 104 FetchState fetch_state_; |
| 106 | 105 |
| 107 content::NotificationRegistrar registrar_; | 106 content::NotificationRegistrar registrar_; |
| 108 | 107 |
| 109 DISALLOW_COPY_AND_ASSIGN(OmniboxNavigationObserver); | 108 DISALLOW_COPY_AND_ASSIGN(OmniboxNavigationObserver); |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ | 111 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |