| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/storage/durable_storage_permission_infobar_delegate.h" | 5 #include "chrome/browser/storage/durable_storage_permission_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| 11 #include "components/url_formatter/url_formatter.h" | 11 #include "components/url_formatter/url_formatter.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 infobars::InfoBar* DurableStoragePermissionInfoBarDelegate::Create( | 17 infobars::InfoBar* DurableStoragePermissionInfoBarDelegate::Create( |
| 18 InfoBarService* infobar_service, | 18 InfoBarService* infobar_service, |
| 19 PermissionQueueController* controller, | |
| 20 const PermissionRequestID& id, | 19 const PermissionRequestID& id, |
| 21 const GURL& requesting_frame, | 20 const GURL& requesting_frame, |
| 22 const std::string& display_languages, | 21 const std::string& display_languages, |
| 23 ContentSettingsType type) { | 22 ContentSettingsType type, |
| 23 const base::Callback<void(bool, bool)>& callback) { |
| 24 return infobar_service->AddInfoBar( | 24 return infobar_service->AddInfoBar( |
| 25 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 25 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
| 26 new DurableStoragePermissionInfoBarDelegate( | 26 new DurableStoragePermissionInfoBarDelegate( |
| 27 controller, id, requesting_frame, display_languages, type)))); | 27 id, requesting_frame, display_languages, type, callback)))); |
| 28 } | 28 } |
| 29 | 29 |
| 30 DurableStoragePermissionInfoBarDelegate:: | 30 DurableStoragePermissionInfoBarDelegate:: |
| 31 DurableStoragePermissionInfoBarDelegate( | 31 DurableStoragePermissionInfoBarDelegate( |
| 32 PermissionQueueController* controller, | |
| 33 const PermissionRequestID& id, | 32 const PermissionRequestID& id, |
| 34 const GURL& requesting_frame, | 33 const GURL& requesting_frame, |
| 35 const std::string& display_languages, | 34 const std::string& display_languages, |
| 36 ContentSettingsType type) | 35 ContentSettingsType type, |
| 37 : PermissionInfobarDelegate(controller, id, requesting_frame, type), | 36 const base::Callback<void(bool, bool)>& callback) |
| 37 : PermissionInfobarDelegate(id, requesting_frame, type, callback), |
| 38 requesting_frame_(requesting_frame), | 38 requesting_frame_(requesting_frame), |
| 39 display_languages_(display_languages) { | 39 display_languages_(display_languages) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 base::string16 DurableStoragePermissionInfoBarDelegate::GetMessageText() const { | 42 base::string16 DurableStoragePermissionInfoBarDelegate::GetMessageText() const { |
| 43 return l10n_util::GetStringFUTF16( | 43 return l10n_util::GetStringFUTF16( |
| 44 IDS_DURABLE_STORAGE_INFOBAR_QUESTION, | 44 IDS_DURABLE_STORAGE_INFOBAR_QUESTION, |
| 45 url_formatter::FormatUrl( | 45 url_formatter::FormatUrl( |
| 46 requesting_frame_.GetOrigin(), display_languages_, | 46 requesting_frame_.GetOrigin(), display_languages_, |
| 47 url_formatter::kFormatUrlOmitUsernamePassword | | 47 url_formatter::kFormatUrlOmitUsernamePassword | |
| 48 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, | 48 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 49 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 49 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
| 50 } | 50 } |
| OLD | NEW |