OLD | NEW |
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/pepper_broker_infobar_delegate.h" | 5 #include "chrome/browser/pepper_broker_infobar_delegate.h" |
6 | 6 |
| 7 #include "base/metrics/user_metrics.h" |
7 #include "chrome/app/vector_icons/vector_icons.h" | 8 #include "chrome/app/vector_icons/vector_icons.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/plugins/plugin_finder.h" | 12 #include "chrome/browser/plugins/plugin_finder.h" |
12 #include "chrome/browser/plugins/plugin_metadata.h" | 13 #include "chrome/browser/plugins/plugin_metadata.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
15 #include "components/content_settings/core/browser/host_content_settings_map.h" | 16 #include "components/content_settings/core/browser/host_content_settings_map.h" |
16 #include "components/infobars/core/infobar.h" | 17 #include "components/infobars/core/infobar.h" |
17 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
18 #include "components/url_formatter/elide_url.h" | 19 #include "components/url_formatter/elide_url.h" |
19 #include "content/public/browser/page_navigator.h" | 20 #include "content/public/browser/page_navigator.h" |
20 #include "content/public/browser/plugin_service.h" | 21 #include "content/public/browser/plugin_service.h" |
21 #include "content/public/browser/user_metrics.h" | |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/referrer.h" | 23 #include "content/public/common/referrer.h" |
24 #include "content/public/common/webplugininfo.h" | 24 #include "content/public/common/webplugininfo.h" |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
26 | 26 |
27 // static | 27 // static |
28 void PepperBrokerInfoBarDelegate::Create( | 28 void PepperBrokerInfoBarDelegate::Create( |
29 content::WebContents* web_contents, | 29 content::WebContents* web_contents, |
30 const GURL& url, | 30 const GURL& url, |
31 const base::FilePath& plugin_path, | 31 const base::FilePath& plugin_path, |
(...skipping 10 matching lines...) Expand all Loading... |
42 TabSpecificContentSettings::FromWebContents(web_contents); | 42 TabSpecificContentSettings::FromWebContents(web_contents); |
43 | 43 |
44 HostContentSettingsMap* content_settings = | 44 HostContentSettingsMap* content_settings = |
45 HostContentSettingsMapFactory::GetForProfile(profile); | 45 HostContentSettingsMapFactory::GetForProfile(profile); |
46 ContentSetting setting = | 46 ContentSetting setting = |
47 content_settings->GetContentSetting(url, url, | 47 content_settings->GetContentSetting(url, url, |
48 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 48 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
49 std::string()); | 49 std::string()); |
50 | 50 |
51 if (setting == CONTENT_SETTING_ASK) { | 51 if (setting == CONTENT_SETTING_ASK) { |
52 content::RecordAction( | 52 base::RecordAction(base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
53 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | |
54 InfoBarService* infobar_service = | 53 InfoBarService* infobar_service = |
55 InfoBarService::FromWebContents(web_contents); | 54 InfoBarService::FromWebContents(web_contents); |
56 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 55 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
57 std::unique_ptr<ConfirmInfoBarDelegate>( | 56 std::unique_ptr<ConfirmInfoBarDelegate>( |
58 new PepperBrokerInfoBarDelegate(url, plugin_path, content_settings, | 57 new PepperBrokerInfoBarDelegate(url, plugin_path, content_settings, |
59 tab_content_settings, callback)))); | 58 tab_content_settings, callback)))); |
60 return; | 59 return; |
61 } | 60 } |
62 | 61 |
63 bool allowed = (setting == CONTENT_SETTING_ALLOW); | 62 bool allowed = (setting == CONTENT_SETTING_ALLOW); |
64 content::RecordAction(allowed ? | 63 base::RecordAction(allowed |
65 base::UserMetricsAction("PPAPI.BrokerSettingAllow") : | 64 ? base::UserMetricsAction("PPAPI.BrokerSettingAllow") |
66 base::UserMetricsAction("PPAPI.BrokerSettingDeny")); | 65 : base::UserMetricsAction("PPAPI.BrokerSettingDeny")); |
67 tab_content_settings->SetPepperBrokerAllowed(allowed); | 66 tab_content_settings->SetPepperBrokerAllowed(allowed); |
68 callback.Run(allowed); | 67 callback.Run(allowed); |
69 } | 68 } |
70 | 69 |
71 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( | 70 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( |
72 const GURL& url, | 71 const GURL& url, |
73 const base::FilePath& plugin_path, | 72 const base::FilePath& plugin_path, |
74 HostContentSettingsMap* content_settings, | 73 HostContentSettingsMap* content_settings, |
75 TabSpecificContentSettings* tab_content_settings, | 74 TabSpecificContentSettings* tab_content_settings, |
76 const base::Callback<void(bool)>& callback) | 75 const base::Callback<void(bool)>& callback) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 126 |
128 base::string16 PepperBrokerInfoBarDelegate::GetLinkText() const { | 127 base::string16 PepperBrokerInfoBarDelegate::GetLinkText() const { |
129 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 128 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
130 } | 129 } |
131 | 130 |
132 GURL PepperBrokerInfoBarDelegate::GetLinkURL() const { | 131 GURL PepperBrokerInfoBarDelegate::GetLinkURL() const { |
133 return GURL("https://support.google.com/chrome/?p=ib_pepper_broker"); | 132 return GURL("https://support.google.com/chrome/?p=ib_pepper_broker"); |
134 } | 133 } |
135 | 134 |
136 void PepperBrokerInfoBarDelegate::DispatchCallback(bool result) { | 135 void PepperBrokerInfoBarDelegate::DispatchCallback(bool result) { |
137 content::RecordAction(result ? | 136 base::RecordAction( |
138 base::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") : | 137 result ? base::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") |
139 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 138 : base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
140 callback_.Run(result); | 139 callback_.Run(result); |
141 callback_ = base::Callback<void(bool)>(); | 140 callback_ = base::Callback<void(bool)>(); |
142 content_settings_->SetContentSettingDefaultScope( | 141 content_settings_->SetContentSettingDefaultScope( |
143 url_, GURL(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string(), | 142 url_, GURL(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string(), |
144 result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 143 result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
145 tab_content_settings_->SetPepperBrokerAllowed(result); | 144 tab_content_settings_->SetPepperBrokerAllowed(result); |
146 } | 145 } |
OLD | NEW |