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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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/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/bind.h" 9 #include "base/bind.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 12 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
13 #include "chrome/browser/infobars/infobar.h"
14 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tab_contents/tab_util.h" 15 #include "chrome/browser/tab_contents/tab_util.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/navigation_details.h" 18 #include "content/public/browser/navigation_details.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
22 #include "grit/locale_settings.h" 21 #include "grit/locale_settings.h"
23 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
24 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
25 #include "url/gurl.h" 24 #include "url/gurl.h"
26 #include "webkit/common/quota/quota_types.h" 25 #include "webkit/common/quota/quota_types.h"
27 26
28 27
29 28
30 // RequestQuotaInfoBarDelegate ------------------------------------------------ 29 // RequestQuotaInfoBarDelegate ------------------------------------------------
31 30
32 namespace { 31 namespace {
33 32
34 class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate { 33 class RequestQuotaInfoBarDelegate : public ConfirmInfoBarDelegate {
35 public: 34 public:
36 // Creates a request quota infobar and delegate and adds the infobar to 35 // Creates a request quota infobar delegate and adds it to |infobar_service|.
37 // |infobar_service|.
38 static void Create( 36 static void Create(
39 InfoBarService* infobar_service, 37 InfoBarService* infobar_service,
40 ChromeQuotaPermissionContext* context, 38 ChromeQuotaPermissionContext* context,
41 const GURL& origin_url, 39 const GURL& origin_url,
42 int64 requested_quota, 40 int64 requested_quota,
43 const std::string& display_languages, 41 const std::string& display_languages,
44 const content::QuotaPermissionContext::PermissionCallback& callback); 42 const content::QuotaPermissionContext::PermissionCallback& callback);
45 43
46 private: 44 private:
47 RequestQuotaInfoBarDelegate( 45 RequestQuotaInfoBarDelegate(
46 InfoBarService* infobar_service,
48 ChromeQuotaPermissionContext* context, 47 ChromeQuotaPermissionContext* context,
49 const GURL& origin_url, 48 const GURL& origin_url,
50 int64 requested_quota, 49 int64 requested_quota,
51 const std::string& display_languages, 50 const std::string& display_languages,
52 const content::QuotaPermissionContext::PermissionCallback& callback); 51 const content::QuotaPermissionContext::PermissionCallback& callback);
53 virtual ~RequestQuotaInfoBarDelegate(); 52 virtual ~RequestQuotaInfoBarDelegate();
54 53
55 // ConfirmInfoBarDelegate: 54 // ConfirmInfoBarDelegate:
56 virtual bool ShouldExpireInternal( 55 virtual bool ShouldExpireInternal(
57 const content::LoadCommittedDetails& details) const OVERRIDE; 56 const content::LoadCommittedDetails& details) const OVERRIDE;
(...skipping 11 matching lines...) Expand all
69 }; 68 };
70 69
71 // static 70 // static
72 void RequestQuotaInfoBarDelegate::Create( 71 void RequestQuotaInfoBarDelegate::Create(
73 InfoBarService* infobar_service, 72 InfoBarService* infobar_service,
74 ChromeQuotaPermissionContext* context, 73 ChromeQuotaPermissionContext* context,
75 const GURL& origin_url, 74 const GURL& origin_url,
76 int64 requested_quota, 75 int64 requested_quota,
77 const std::string& display_languages, 76 const std::string& display_languages,
78 const content::QuotaPermissionContext::PermissionCallback& callback) { 77 const content::QuotaPermissionContext::PermissionCallback& callback) {
79 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 78 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
80 scoped_ptr<ConfirmInfoBarDelegate>(new RequestQuotaInfoBarDelegate( 79 new RequestQuotaInfoBarDelegate(infobar_service, context, origin_url,
81 context, origin_url, requested_quota, display_languages, callback)))); 80 requested_quota, display_languages,
81 callback)));
82 } 82 }
83 83
84 RequestQuotaInfoBarDelegate::RequestQuotaInfoBarDelegate( 84 RequestQuotaInfoBarDelegate::RequestQuotaInfoBarDelegate(
85 InfoBarService* infobar_service,
85 ChromeQuotaPermissionContext* context, 86 ChromeQuotaPermissionContext* context,
86 const GURL& origin_url, 87 const GURL& origin_url,
87 int64 requested_quota, 88 int64 requested_quota,
88 const std::string& display_languages, 89 const std::string& display_languages,
89 const content::QuotaPermissionContext::PermissionCallback& callback) 90 const content::QuotaPermissionContext::PermissionCallback& callback)
90 : ConfirmInfoBarDelegate(), 91 : ConfirmInfoBarDelegate(infobar_service),
91 context_(context), 92 context_(context),
92 origin_url_(origin_url), 93 origin_url_(origin_url),
93 display_languages_(display_languages), 94 display_languages_(display_languages),
94 requested_quota_(requested_quota), 95 requested_quota_(requested_quota),
95 callback_(callback) { 96 callback_(callback) {
96 } 97 }
97 98
98 RequestQuotaInfoBarDelegate::~RequestQuotaInfoBarDelegate() { 99 RequestQuotaInfoBarDelegate::~RequestQuotaInfoBarDelegate() {
99 if (!callback_.is_null()) { 100 if (!callback_.is_null()) {
100 context_->DispatchCallbackOnIOThread( 101 context_->DispatchCallbackOnIOThread(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 content::BrowserThread::IO, FROM_HERE, 201 content::BrowserThread::IO, FROM_HERE,
201 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, 202 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread,
202 this, callback, response)); 203 this, callback, response));
203 return; 204 return;
204 } 205 }
205 206
206 callback.Run(response); 207 callback.Run(response);
207 } 208 }
208 209
209 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} 210 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698