| 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 #include "chrome/browser/alternate_nav_url_fetcher.h" | 5 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/infobar_tab_helper.h" | 8 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 9 #include "chrome/browser/intranet_redirect_detector.h" | 9 #include "chrome/browser/intranet_redirect_detector.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/tab_contents/link_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/link_infobar_delegate.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "content/browser/tab_contents/navigation_controller.h" | 14 #include "content/browser/tab_contents/navigation_controller.h" |
| 15 #include "content/browser/tab_contents/navigation_entry.h" | 15 #include "content/browser/tab_contents/navigation_entry.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/common/net/url_fetcher.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 #include "grit/theme_resources_standard.h" | 19 #include "grit/theme_resources_standard.h" |
| 19 #include "net/base/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domain.h" |
| 20 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 23 | 24 |
| 24 // AlternateNavInfoBarDelegate ------------------------------------------------ | 25 // AlternateNavInfoBarDelegate ------------------------------------------------ |
| 25 | 26 |
| 26 class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { | 27 class AlternateNavInfoBarDelegate : public LinkInfoBarDelegate { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // access the controller that will be invalid, we delete ourselves. | 155 // access the controller that will be invalid, we delete ourselves. |
| 155 // This deletes the URLFetcher and insures its callback won't be called. | 156 // This deletes the URLFetcher and insures its callback won't be called. |
| 156 delete this; | 157 delete this; |
| 157 break; | 158 break; |
| 158 | 159 |
| 159 default: | 160 default: |
| 160 NOTREACHED(); | 161 NOTREACHED(); |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 164 void AlternateNavURLFetcher::OnURLFetchComplete( | 165 void AlternateNavURLFetcher::OnURLFetchComplete(const URLFetcher* source) { |
| 165 const URLFetcher* source, | |
| 166 const GURL& url, | |
| 167 const net::URLRequestStatus& status, | |
| 168 int response_code, | |
| 169 const net::ResponseCookies& cookies, | |
| 170 const std::string& data) { | |
| 171 DCHECK_EQ(fetcher_.get(), source); | 166 DCHECK_EQ(fetcher_.get(), source); |
| 172 SetStatusFromURLFetch(url, status, response_code); | 167 SetStatusFromURLFetch( |
| 168 source->url(), source->status(), source->response_code()); |
| 173 ShowInfobarIfPossible(); | 169 ShowInfobarIfPossible(); |
| 174 // WARNING: |this| may be deleted! | 170 // WARNING: |this| may be deleted! |
| 175 } | 171 } |
| 176 | 172 |
| 177 void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { | 173 void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { |
| 178 controller_ = controller; | 174 controller_ = controller; |
| 179 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, | 175 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, |
| 180 content::Source<NavigationController>(controller_)); | 176 content::Source<NavigationController>(controller_)); |
| 181 | 177 |
| 182 DCHECK_EQ(NOT_STARTED, state_); | 178 DCHECK_EQ(NOT_STARTED, state_); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return; | 216 return; |
| 221 } | 217 } |
| 222 | 218 |
| 223 InfoBarTabHelper* infobar_helper = | 219 InfoBarTabHelper* infobar_helper = |
| 224 TabContentsWrapper::GetCurrentWrapperForContents( | 220 TabContentsWrapper::GetCurrentWrapperForContents( |
| 225 controller_->tab_contents())->infobar_tab_helper(); | 221 controller_->tab_contents())->infobar_tab_helper(); |
| 226 infobar_helper->AddInfoBar( | 222 infobar_helper->AddInfoBar( |
| 227 new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); | 223 new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); |
| 228 delete this; | 224 delete this; |
| 229 } | 225 } |
| OLD | NEW |