| OLD | NEW |
| 1 // Copyright (c) 2010 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 |
| 11 #include "chrome/browser/tab_contents/infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 State state() const { return state_; } | 44 State state() const { return state_; } |
| 45 | 45 |
| 46 // NotificationObserver | 46 // NotificationObserver |
| 47 virtual void Observe(NotificationType type, | 47 virtual void Observe(NotificationType type, |
| 48 const NotificationSource& source, | 48 const NotificationSource& source, |
| 49 const NotificationDetails& details); | 49 const NotificationDetails& details); |
| 50 | 50 |
| 51 // URLFetcher::Delegate | 51 // URLFetcher::Delegate |
| 52 virtual void OnURLFetchComplete(const URLFetcher* source, | 52 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 53 const GURL& url, | 53 const GURL& url, |
| 54 const URLRequestStatus& status, | 54 const net::URLRequestStatus& status, |
| 55 int response_code, | 55 int response_code, |
| 56 const ResponseCookies& cookies, | 56 const ResponseCookies& cookies, |
| 57 const std::string& data); | 57 const std::string& data); |
| 58 | 58 |
| 59 // LinkInfoBarDelegate | 59 // LinkInfoBarDelegate |
| 60 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; | 60 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; |
| 61 virtual string16 GetLinkText() const; | 61 virtual string16 GetLinkText() const; |
| 62 virtual SkBitmap* GetIcon() const; | 62 virtual SkBitmap* GetIcon() const; |
| 63 virtual bool LinkClicked(WindowOpenDisposition disposition); | 63 virtual bool LinkClicked(WindowOpenDisposition disposition); |
| 64 virtual void InfoBarClosed(); | 64 virtual void InfoBarClosed(); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // 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 |
| 68 // fetch. | 68 // fetch. |
| 69 void SetStatusFromURLFetch(const GURL& url, | 69 void SetStatusFromURLFetch(const GURL& url, |
| 70 const URLRequestStatus& status, | 70 const net::URLRequestStatus& status, |
| 71 int response_code); | 71 int response_code); |
| 72 | 72 |
| 73 // 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 |
| 74 // the fetch of the alternate URL succeeded). | 74 // the fetch of the alternate URL succeeded). |
| 75 void ShowInfobarIfPossible(); | 75 void ShowInfobarIfPossible(); |
| 76 | 76 |
| 77 GURL alternate_nav_url_; | 77 GURL alternate_nav_url_; |
| 78 scoped_ptr<URLFetcher> fetcher_; | 78 scoped_ptr<URLFetcher> fetcher_; |
| 79 NavigationController* controller_; | 79 NavigationController* controller_; |
| 80 State state_; | 80 State state_; |
| 81 bool navigated_to_entry_; | 81 bool navigated_to_entry_; |
| 82 | 82 |
| 83 // The TabContents the InfoBarDelegate was added to. | 83 // The TabContents the InfoBarDelegate was added to. |
| 84 TabContents* infobar_contents_; | 84 TabContents* infobar_contents_; |
| 85 | 85 |
| 86 NotificationRegistrar registrar_; | 86 NotificationRegistrar registrar_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); | 88 DISALLOW_COPY_AND_ASSIGN(AlternateNavURLFetcher); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ | 91 #endif // CHROME_BROWSER_ALTERNATE_NAV_URL_FETCHER_H_ |
| OLD | NEW |