OLD | NEW |
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ |
6 #define CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ | 6 #define CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/common/url_fetcher_delegate.h" | |
13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "content/public/common/url_fetcher_delegate.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class NavigationController; | 18 class NavigationController; |
19 } | 19 } |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 class URLRequestStatus; | 22 class URLRequestStatus; |
23 } | 23 } |
24 | 24 |
(...skipping 28 matching lines...) Expand all Loading... |
53 | 53 |
54 State state() const { return state_; } | 54 State state() const { return state_; } |
55 | 55 |
56 private: | 56 private: |
57 // content::NotificationObserver | 57 // content::NotificationObserver |
58 virtual void Observe(int type, | 58 virtual void Observe(int type, |
59 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
60 const content::NotificationDetails& details) OVERRIDE; | 60 const content::NotificationDetails& details) OVERRIDE; |
61 | 61 |
62 // content::URLFetcherDelegate | 62 // content::URLFetcherDelegate |
63 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 63 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
64 | 64 |
65 // Sets |controller_| to the supplied pointer and begins fetching | 65 // Sets |controller_| to the supplied pointer and begins fetching |
66 // |alternate_nav_url_|. | 66 // |alternate_nav_url_|. |
67 void StartFetch(content::NavigationController* controller); | 67 void StartFetch(content::NavigationController* controller); |
68 | 68 |
69 // Sets |state_| to either SUCCEEDED or FAILED depending on the result of the | 69 // Sets |state_| to either SUCCEEDED or FAILED depending on the result of the |
70 // fetch. | 70 // fetch. |
71 void SetStatusFromURLFetch(const GURL& url, | 71 void SetStatusFromURLFetch(const GURL& url, |
72 const net::URLRequestStatus& status, | 72 const net::URLRequestStatus& status, |
73 int response_code); | 73 int response_code); |
74 | 74 |
75 // Displays the infobar if all conditions are met (the page has loaded and | 75 // Displays the infobar if all conditions are met (the page has loaded and |
76 // the fetch of the alternate URL succeeded). Unless we're still waiting on | 76 // the fetch of the alternate URL succeeded). Unless we're still waiting on |
77 // one of the above conditions to finish, this will also delete us, as whether | 77 // one of the above conditions to finish, this will also delete us, as whether |
78 // or not we show an infobar, there is no reason to live further. | 78 // or not we show an infobar, there is no reason to live further. |
79 void ShowInfobarIfPossible(); | 79 void ShowInfobarIfPossible(); |
80 | 80 |
81 GURL alternate_nav_url_; | 81 GURL alternate_nav_url_; |
82 scoped_ptr<content::URLFetcher> fetcher_; | 82 scoped_ptr<content::URLFetcher> fetcher_; |
83 content::NavigationController* controller_; | 83 content::NavigationController* controller_; |
84 State state_; | 84 State state_; |
85 bool navigated_to_entry_; | 85 bool navigated_to_entry_; |
86 | 86 |
87 content::NotificationRegistrar registrar_; | 87 content::NotificationRegistrar registrar_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); | 89 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); |
90 }; | 90 }; |
91 | 91 |
92 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ | 92 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ |
OLD | NEW |