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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 enum LoadState { | 49 enum LoadState { |
50 LOAD_NOT_SEEN, | 50 LOAD_NOT_SEEN, |
51 LOAD_PENDING, | 51 LOAD_PENDING, |
52 LOAD_COMMITTED, | 52 LOAD_COMMITTED, |
53 }; | 53 }; |
54 | 54 |
55 OmniboxNavigationObserver(Profile* profile, | 55 OmniboxNavigationObserver(Profile* profile, |
56 const base::string16& text, | 56 const base::string16& text, |
57 const AutocompleteMatch& match, | 57 const AutocompleteMatch& match, |
58 const AutocompleteMatch& alternate_nav_match); | 58 const AutocompleteMatch& alternate_nav_match); |
59 virtual ~OmniboxNavigationObserver(); | 59 ~OmniboxNavigationObserver() override; |
60 | 60 |
61 LoadState load_state() const { return load_state_; } | 61 LoadState load_state() const { return load_state_; } |
62 | 62 |
63 // Called directly by OmniboxEditModel when an extension-related navigation | 63 // Called directly by OmniboxEditModel when an extension-related navigation |
64 // occurs. Such navigations don't trigger an immediate NAV_ENTRY_PENDING and | 64 // occurs. Such navigations don't trigger an immediate NAV_ENTRY_PENDING and |
65 // must be handled separately. | 65 // must be handled separately. |
66 void OnSuccessfulNavigation(); | 66 void OnSuccessfulNavigation(); |
67 | 67 |
68 private: | 68 private: |
69 enum FetchState { | 69 enum FetchState { |
70 FETCH_NOT_COMPLETE, | 70 FETCH_NOT_COMPLETE, |
71 FETCH_SUCCEEDED, | 71 FETCH_SUCCEEDED, |
72 FETCH_FAILED, | 72 FETCH_FAILED, |
73 }; | 73 }; |
74 | 74 |
75 // content::NotificationObserver: | 75 // content::NotificationObserver: |
76 virtual void Observe(int type, | 76 void Observe(int type, |
77 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
78 const content::NotificationDetails& details) override; | 78 const content::NotificationDetails& details) override; |
79 | 79 |
80 // content::WebContentsObserver: | 80 // content::WebContentsObserver: |
81 virtual void DidStartNavigationToPendingEntry( | 81 void DidStartNavigationToPendingEntry( |
82 const GURL& url, | 82 const GURL& url, |
83 content::NavigationController::ReloadType reload_type) override; | 83 content::NavigationController::ReloadType reload_type) override; |
84 virtual void NavigationEntryCommitted( | 84 void NavigationEntryCommitted( |
85 const content::LoadCommittedDetails& load_details) override; | 85 const content::LoadCommittedDetails& load_details) override; |
86 virtual void WebContentsDestroyed() override; | 86 void WebContentsDestroyed() override; |
87 | 87 |
88 // net::URLFetcherDelegate: | 88 // net::URLFetcherDelegate: |
89 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 89 void OnURLFetchComplete(const net::URLFetcher* source) override; |
90 | 90 |
91 // Once the load has committed and any URL fetch has completed, this displays | 91 // Once the load has committed and any URL fetch has completed, this displays |
92 // the alternate nav infobar if necessary, and deletes |this|. | 92 // the alternate nav infobar if necessary, and deletes |this|. |
93 void OnAllLoadingFinished(); | 93 void OnAllLoadingFinished(); |
94 | 94 |
95 const base::string16 text_; | 95 const base::string16 text_; |
96 const AutocompleteMatch match_; | 96 const AutocompleteMatch match_; |
97 const AutocompleteMatch alternate_nav_match_; | 97 const AutocompleteMatch alternate_nav_match_; |
98 scoped_refptr<ShortcutsBackend> shortcuts_backend_; // NULL in incognito. | 98 scoped_refptr<ShortcutsBackend> shortcuts_backend_; // NULL in incognito. |
99 scoped_ptr<net::URLFetcher> fetcher_; | 99 scoped_ptr<net::URLFetcher> fetcher_; |
100 LoadState load_state_; | 100 LoadState load_state_; |
101 FetchState fetch_state_; | 101 FetchState fetch_state_; |
102 | 102 |
103 content::NotificationRegistrar registrar_; | 103 content::NotificationRegistrar registrar_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(OmniboxNavigationObserver); | 105 DISALLOW_COPY_AND_ASSIGN(OmniboxNavigationObserver); |
106 }; | 106 }; |
107 | 107 |
108 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ | 108 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_NAVIGATION_OBSERVER_H_ |
OLD | NEW |