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

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

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 3 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) 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/chrome_quota_permission_context.h" 5 #include "chrome/browser/chrome_quota_permission_context.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 14 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
17 #include "content/browser/tab_contents/navigation_details.h" 18 #include "content/browser/tab_contents/navigation_details.h"
18 #include "content/browser/tab_contents/tab_contents.h" 19 #include "content/browser/tab_contents/tab_contents.h"
19 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (!tab_contents) { 137 if (!tab_contents) {
137 // The tab may have gone away or the request may not be from a tab. 138 // The tab may have gone away or the request may not be from a tab.
138 LOG(WARNING) << "Attempt to request quota tabless renderer: " 139 LOG(WARNING) << "Attempt to request quota tabless renderer: "
139 << render_process_id << "," << render_view_id; 140 << render_process_id << "," << render_view_id;
140 DispatchCallbackOnIOThread(callback.release(), kResponseCancelled); 141 DispatchCallbackOnIOThread(callback.release(), kResponseCancelled);
141 return; 142 return;
142 } 143 }
143 144
144 TabContentsWrapper* wrapper = 145 TabContentsWrapper* wrapper =
145 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); 146 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
146 wrapper->AddInfoBar(new RequestQuotaInfoBarDelegate( 147 wrapper->infobar_tab_helper()->AddInfoBar(new RequestQuotaInfoBarDelegate(
147 tab_contents, this, 148 tab_contents, this,
148 origin_url, requested_quota, 149 origin_url, requested_quota,
149 wrapper->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), 150 wrapper->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages),
150 callback.release())); 151 callback.release()));
151 } 152 }
152 153
153 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( 154 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread(
154 PermissionCallback* callback_ptr, 155 PermissionCallback* callback_ptr,
155 Response response) { 156 Response response) {
156 DCHECK(callback_ptr); 157 DCHECK(callback_ptr);
157 scoped_ptr<PermissionCallback> callback(callback_ptr); 158 scoped_ptr<PermissionCallback> callback(callback_ptr);
158 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 159 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
159 BrowserThread::PostTask( 160 BrowserThread::PostTask(
160 BrowserThread::IO, FROM_HERE, 161 BrowserThread::IO, FROM_HERE,
161 NewRunnableMethod( 162 NewRunnableMethod(
162 this, &ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, 163 this, &ChromeQuotaPermissionContext::DispatchCallbackOnIOThread,
163 callback.release(), response)); 164 callback.release(), response));
164 return; 165 return;
165 } 166 }
166 callback->Run(response); 167 callback->Run(response);
167 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698