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/intranet_redirect_detector.h" | 8 #include "chrome/browser/intranet_redirect_detector.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/tab_contents/navigation_controller.h" | 10 #include "chrome/browser/tab_contents/navigation_controller.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 void AlternateNavURLFetcher::OnURLFetchComplete( | 89 void AlternateNavURLFetcher::OnURLFetchComplete( |
90 const URLFetcher* source, | 90 const URLFetcher* source, |
91 const GURL& url, | 91 const GURL& url, |
92 const net::URLRequestStatus& status, | 92 const net::URLRequestStatus& status, |
93 int response_code, | 93 int response_code, |
94 const ResponseCookies& cookies, | 94 const ResponseCookies& cookies, |
95 const std::string& data) { | 95 const std::string& data) { |
96 DCHECK(fetcher_.get() == source); | 96 DCHECK_EQ(fetcher_.get(), source); |
97 SetStatusFromURLFetch(url, status, response_code); | 97 SetStatusFromURLFetch(url, status, response_code); |
98 ShowInfobarIfPossible(); | 98 ShowInfobarIfPossible(); |
99 } | 99 } |
100 | 100 |
101 SkBitmap* AlternateNavURLFetcher::GetIcon() const { | 101 SkBitmap* AlternateNavURLFetcher::GetIcon() const { |
102 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 102 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
103 IDR_INFOBAR_ALT_NAV_URL); | 103 IDR_INFOBAR_ALT_NAV_URL); |
104 } | 104 } |
105 | 105 |
106 InfoBarDelegate::Type AlternateNavURLFetcher::GetInfoBarType() const { | 106 InfoBarDelegate::Type AlternateNavURLFetcher::GetInfoBarType() const { |
107 return PAGE_ACTION_TYPE; | 107 return PAGE_ACTION_TYPE; |
108 } | 108 } |
109 | 109 |
110 string16 AlternateNavURLFetcher::GetMessageTextWithOffset( | 110 string16 AlternateNavURLFetcher::GetMessageTextWithOffset( |
111 size_t* link_offset) const { | 111 size_t* link_offset) const { |
112 const string16 label = l10n_util::GetStringFUTF16( | 112 const string16 label = l10n_util::GetStringFUTF16( |
113 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset); | 113 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset); |
114 DCHECK(*link_offset != string16::npos); | 114 DCHECK_NE(*link_offset, string16::npos); |
115 return label; | 115 return label; |
116 } | 116 } |
117 | 117 |
118 string16 AlternateNavURLFetcher::GetLinkText() const { | 118 string16 AlternateNavURLFetcher::GetLinkText() const { |
119 return UTF8ToUTF16(alternate_nav_url_.spec()); | 119 return UTF8ToUTF16(alternate_nav_url_.spec()); |
120 } | 120 } |
121 | 121 |
122 bool AlternateNavURLFetcher::LinkClicked(WindowOpenDisposition disposition) { | 122 bool AlternateNavURLFetcher::LinkClicked(WindowOpenDisposition disposition) { |
123 infobar_contents_->OpenURL( | 123 infobar_contents_->OpenURL( |
124 alternate_nav_url_, GURL(), disposition, | 124 alternate_nav_url_, GURL(), disposition, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (!navigated_to_entry_ || state_ != SUCCEEDED) { | 165 if (!navigated_to_entry_ || state_ != SUCCEEDED) { |
166 if (state_ == FAILED) | 166 if (state_ == FAILED) |
167 delete this; | 167 delete this; |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 infobar_contents_ = controller_->tab_contents(); | 171 infobar_contents_ = controller_->tab_contents(); |
172 StoreActiveEntryUniqueID(infobar_contents_); | 172 StoreActiveEntryUniqueID(infobar_contents_); |
173 infobar_contents_->AddInfoBar(this); | 173 infobar_contents_->AddInfoBar(this); |
174 } | 174 } |
OLD | NEW |