Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: chrome/browser/alternate_nav_url_fetcher.cc

Issue 10079023: Move notifications used only in chrome/ out of content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: six! Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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 #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"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: 155 case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
156 // The page was navigated, we can show the infobar now if necessary. 156 // The page was navigated, we can show the infobar now if necessary.
157 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 157 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
158 content::Source<NavigationController>(controller_)); 158 content::Source<NavigationController>(controller_));
159 navigated_to_entry_ = true; 159 navigated_to_entry_ = true;
160 ShowInfobarIfPossible(); 160 ShowInfobarIfPossible();
161 // WARNING: |this| may be deleted! 161 // WARNING: |this| may be deleted!
162 break; 162 break;
163 163
164 case content::NOTIFICATION_TAB_CLOSED: 164 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
165 // We have been closed. In order to prevent the URLFetcher from trying to 165 // We have been closed. In order to prevent the URLFetcher from trying to
166 // access the controller that will be invalid, we delete ourselves. 166 // access the controller that will be invalid, we delete ourselves.
167 // This deletes the URLFetcher and insures its callback won't be called. 167 // This deletes the URLFetcher and insures its callback won't be called.
168 delete this; 168 delete this;
169 break; 169 break;
170 170
171 default: 171 default:
172 NOTREACHED(); 172 NOTREACHED();
173 } 173 }
174 } 174 }
175 175
176 void AlternateNavURLFetcher::OnURLFetchComplete( 176 void AlternateNavURLFetcher::OnURLFetchComplete(
177 const content::URLFetcher* source) { 177 const content::URLFetcher* source) {
178 DCHECK_EQ(fetcher_.get(), source); 178 DCHECK_EQ(fetcher_.get(), source);
179 SetStatusFromURLFetch( 179 SetStatusFromURLFetch(
180 source->GetURL(), source->GetStatus(), source->GetResponseCode()); 180 source->GetURL(), source->GetStatus(), source->GetResponseCode());
181 ShowInfobarIfPossible(); 181 ShowInfobarIfPossible();
182 // WARNING: |this| may be deleted! 182 // WARNING: |this| may be deleted!
183 } 183 }
184 184
185 void AlternateNavURLFetcher::StartFetch(NavigationController* controller) { 185 void AlternateNavURLFetcher::StartFetch(NavigationController* controller) {
186 controller_ = controller; 186 controller_ = controller;
187 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, 187 registrar_.Add(
188 content::Source<NavigationController>(controller_)); 188 this,
189 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
190 content::Source<content::WebContents>(controller_->GetWebContents()));
189 191
190 DCHECK_EQ(NOT_STARTED, state_); 192 DCHECK_EQ(NOT_STARTED, state_);
191 state_ = IN_PROGRESS; 193 state_ = IN_PROGRESS;
192 fetcher_.reset(content::URLFetcher::Create( 194 fetcher_.reset(content::URLFetcher::Create(
193 GURL(alternate_nav_url_), content::URLFetcher::HEAD, this)); 195 GURL(alternate_nav_url_), content::URLFetcher::HEAD, this));
194 fetcher_->SetRequestContext( 196 fetcher_->SetRequestContext(
195 controller_->GetBrowserContext()->GetRequestContext()); 197 controller_->GetBrowserContext()->GetRequestContext());
196 198
197 content::WebContents* web_contents = controller_->GetWebContents(); 199 content::WebContents* web_contents = controller_->GetWebContents();
198 fetcher_->AssociateWithRenderView( 200 fetcher_->AssociateWithRenderView(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return; 236 return;
235 } 237 }
236 238
237 InfoBarTabHelper* infobar_helper = 239 InfoBarTabHelper* infobar_helper =
238 TabContentsWrapper::GetCurrentWrapperForContents( 240 TabContentsWrapper::GetCurrentWrapperForContents(
239 controller_->GetWebContents())->infobar_tab_helper(); 241 controller_->GetWebContents())->infobar_tab_helper();
240 infobar_helper->AddInfoBar( 242 infobar_helper->AddInfoBar(
241 new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); 243 new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_));
242 delete this; 244 delete this;
243 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698