| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 explicit AlternateNavURLFetcher(const GURL& alternate_nav_url); | 41 explicit AlternateNavURLFetcher(const GURL& alternate_nav_url); |
| 42 virtual ~AlternateNavURLFetcher(); | 42 virtual ~AlternateNavURLFetcher(); |
| 43 | 43 |
| 44 State state() const { return state_; } | 44 State state() const { return state_; } |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // NotificationObserver | 47 // NotificationObserver |
| 48 virtual void Observe(NotificationType type, | 48 virtual void Observe(NotificationType type, |
| 49 const NotificationSource& source, | 49 const NotificationSource& source, |
| 50 const NotificationDetails& details); | 50 const NotificationDetails& details) OVERRIDE; |
| 51 | 51 |
| 52 // URLFetcher::Delegate | 52 // URLFetcher::Delegate |
| 53 virtual void OnURLFetchComplete(const URLFetcher* source, | 53 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 54 const GURL& url, | 54 const GURL& url, |
| 55 const net::URLRequestStatus& status, | 55 const net::URLRequestStatus& status, |
| 56 int response_code, | 56 int response_code, |
| 57 const ResponseCookies& cookies, | 57 const ResponseCookies& cookies, |
| 58 const std::string& data); | 58 const std::string& data) OVERRIDE; |
| 59 | 59 |
| 60 // LinkInfoBarDelegate | 60 // LinkInfoBarDelegate |
| 61 virtual gfx::Image* GetIcon() const; | 61 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 62 virtual Type GetInfoBarType() const; | 62 virtual Type GetInfoBarType() const OVERRIDE; |
| 63 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; | 63 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const OVERRIDE; |
| 64 virtual string16 GetLinkText() const; | 64 virtual string16 GetLinkText() const OVERRIDE; |
| 65 virtual bool LinkClicked(WindowOpenDisposition disposition); | 65 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 66 virtual void InfoBarClosed(); | |
| 67 | 66 |
| 68 // Sets |state_| to either SUCCEEDED or FAILED depending on the result of the | 67 // Sets |state_| to either SUCCEEDED or FAILED depending on the result of the |
| 69 // fetch. | 68 // fetch. |
| 70 void SetStatusFromURLFetch(const GURL& url, | 69 void SetStatusFromURLFetch(const GURL& url, |
| 71 const net::URLRequestStatus& status, | 70 const net::URLRequestStatus& status, |
| 72 int response_code); | 71 int response_code); |
| 73 | 72 |
| 74 // Displays the infobar if all conditions are met (the page has loaded and | 73 // Displays the infobar if all conditions are met (the page has loaded and |
| 75 // the fetch of the alternate URL succeeded). | 74 // the fetch of the alternate URL succeeded). |
| 76 void ShowInfobarIfPossible(); | 75 void ShowInfobarIfPossible(); |
| 77 | 76 |
| 78 GURL alternate_nav_url_; | 77 GURL alternate_nav_url_; |
| 79 scoped_ptr<URLFetcher> fetcher_; | 78 scoped_ptr<URLFetcher> fetcher_; |
| 80 NavigationController* controller_; | 79 NavigationController* controller_; |
| 81 State state_; | 80 State state_; |
| 82 bool navigated_to_entry_; | 81 bool navigated_to_entry_; |
| 83 | 82 |
| 84 // The TabContents the InfoBarDelegate was added to. | 83 // The TabContents the InfoBarDelegate was added to. |
| 85 TabContents* infobar_contents_; | 84 TabContents* infobar_contents_; |
| 86 | 85 |
| 87 NotificationRegistrar registrar_; | 86 NotificationRegistrar registrar_; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); | 88 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ | 91 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ |
| OLD | NEW |