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

Side by Side Diff: chrome/browser/ui/android/content_settings/popup_blocked_infobar_delegate.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
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/ui/android/content_settings/popup_blocked_infobar_deleg ate.h" 5 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg ate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
(...skipping 11 matching lines...) Expand all
22 22
23 23
24 // static 24 // static
25 void PopupBlockedInfoBarDelegate::Create(content::WebContents* web_contents, 25 void PopupBlockedInfoBarDelegate::Create(content::WebContents* web_contents,
26 int num_popups) { 26 int num_popups) {
27 const GURL& url = web_contents->GetURL(); 27 const GURL& url = web_contents->GetURL();
28 Profile* profile = 28 Profile* profile =
29 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 29 Profile::FromBrowserContext(web_contents->GetBrowserContext());
30 InfoBarService* infobar_service = 30 InfoBarService* infobar_service =
31 InfoBarService::FromWebContents(web_contents); 31 InfoBarService::FromWebContents(web_contents);
32 scoped_ptr<infobars::InfoBar> infobar(infobar_service->CreateConfirmInfoBar( 32 std::unique_ptr<infobars::InfoBar> infobar(
33 scoped_ptr<ConfirmInfoBarDelegate>(new PopupBlockedInfoBarDelegate( 33 infobar_service->CreateConfirmInfoBar(
34 num_popups, 34 std::unique_ptr<ConfirmInfoBarDelegate>(
35 url, 35 new PopupBlockedInfoBarDelegate(
36 HostContentSettingsMapFactory::GetForProfile(profile))))); 36 num_popups, url,
37 HostContentSettingsMapFactory::GetForProfile(profile)))));
37 38
38 // See if there is an existing popup infobar already. 39 // See if there is an existing popup infobar already.
39 // TODO(dfalcantara) When triggering more than one popup the infobar 40 // TODO(dfalcantara) When triggering more than one popup the infobar
40 // will be shown once, then hide then be shown again. 41 // will be shown once, then hide then be shown again.
41 // This will be fixed once we have an in place replace infobar mechanism. 42 // This will be fixed once we have an in place replace infobar mechanism.
42 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { 43 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
43 infobars::InfoBar* existing_infobar = infobar_service->infobar_at(i); 44 infobars::InfoBar* existing_infobar = infobar_service->infobar_at(i);
44 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) { 45 if (existing_infobar->delegate()->AsPopupBlockedInfoBarDelegate()) {
45 infobar_service->ReplaceInfoBar(existing_infobar, std::move(infobar)); 46 infobar_service->ReplaceInfoBar(existing_infobar, std::move(infobar));
46 return; 47 return;
(...skipping 19 matching lines...) Expand all
66 PopupBlockedInfoBarDelegate::AsPopupBlockedInfoBarDelegate() { 67 PopupBlockedInfoBarDelegate::AsPopupBlockedInfoBarDelegate() {
67 return this; 68 return this;
68 } 69 }
69 70
70 PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate( 71 PopupBlockedInfoBarDelegate::PopupBlockedInfoBarDelegate(
71 int num_popups, 72 int num_popups,
72 const GURL& url, 73 const GURL& url,
73 HostContentSettingsMap* map) 74 HostContentSettingsMap* map)
74 : ConfirmInfoBarDelegate(), num_popups_(num_popups), url_(url), map_(map) { 75 : ConfirmInfoBarDelegate(), num_popups_(num_popups), url_(url), map_(map) {
75 content_settings::SettingInfo setting_info; 76 content_settings::SettingInfo setting_info;
76 scoped_ptr<base::Value> setting = map->GetWebsiteSetting( 77 std::unique_ptr<base::Value> setting = map->GetWebsiteSetting(
77 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &setting_info); 78 url, url, CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &setting_info);
78 can_show_popups_ = 79 can_show_popups_ =
79 setting_info.source != content_settings::SETTING_SOURCE_POLICY; 80 setting_info.source != content_settings::SETTING_SOURCE_POLICY;
80 } 81 }
81 82
82 base::string16 PopupBlockedInfoBarDelegate::GetMessageText() const { 83 base::string16 PopupBlockedInfoBarDelegate::GetMessageText() const {
83 return l10n_util::GetStringFUTF16Int(IDS_POPUPS_BLOCKED_INFOBAR_TEXT, 84 return l10n_util::GetStringFUTF16Int(IDS_POPUPS_BLOCKED_INFOBAR_TEXT,
84 num_popups_); 85 num_popups_);
85 } 86 }
86 87
(...skipping 23 matching lines...) Expand all
110 PopupBlockerTabHelper::FromWebContents(web_contents); 111 PopupBlockerTabHelper::FromWebContents(web_contents);
111 DCHECK(popup_blocker_helper); 112 DCHECK(popup_blocker_helper);
112 PopupBlockerTabHelper::PopupIdMap blocked_popups = 113 PopupBlockerTabHelper::PopupIdMap blocked_popups =
113 popup_blocker_helper->GetBlockedPopupRequests(); 114 popup_blocker_helper->GetBlockedPopupRequests();
114 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin(); 115 for (PopupBlockerTabHelper::PopupIdMap::iterator it = blocked_popups.begin();
115 it != blocked_popups.end(); ++it) 116 it != blocked_popups.end(); ++it)
116 popup_blocker_helper->ShowBlockedPopup(it->first); 117 popup_blocker_helper->ShowBlockedPopup(it->first);
117 118
118 return true; 119 return true;
119 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/connection_info_popup_android.h ('k') | chrome/browser/ui/android/context_menu_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698