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

Side by Side Diff: chrome/browser/plugins/plugin_infobar_delegates.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 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 (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/plugins/plugin_infobar_delegates.h" 5 #include "chrome/browser/plugins/plugin_infobar_delegates.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/user_metrics.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "chrome/app/vector_icons/vector_icons.h" 14 #include "chrome/app/vector_icons/vector_icons.h"
14 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 16 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 17 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
17 #include "chrome/browser/plugins/plugin_installer.h" 18 #include "chrome/browser/plugins/plugin_installer.h"
18 #include "chrome/browser/plugins/plugin_metadata.h" 19 #include "chrome/browser/plugins/plugin_metadata.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/shell_integration.h" 21 #include "chrome/browser/shell_integration.h"
21 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/common/features.h" 23 #include "chrome/common/features.h"
23 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
24 #include "chrome/grit/chromium_strings.h" 25 #include "chrome/grit/chromium_strings.h"
25 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
26 #include "chrome/grit/locale_settings.h" 27 #include "chrome/grit/locale_settings.h"
27 #include "chrome/grit/theme_resources.h" 28 #include "chrome/grit/theme_resources.h"
28 #include "components/google/core/browser/google_util.h" 29 #include "components/google/core/browser/google_util.h"
29 #include "components/infobars/core/infobar.h" 30 #include "components/infobars/core/infobar.h"
30 #include "components/strings/grit/components_strings.h" 31 #include "components/strings/grit/components_strings.h"
31 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/user_metrics.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 36
37 #if defined(OS_WIN) 37 #if defined(OS_WIN)
38 #include <shellapi.h> 38 #include <shellapi.h>
39 #include "ui/base/win/shell.h" 39 #include "ui/base/win/shell.h"
40 #endif 40 #endif
41 41
42 using base::UserMetricsAction; 42 using base::UserMetricsAction;
43 43
(...skipping 14 matching lines...) Expand all
58 58
59 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( 59 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate(
60 PluginInstaller* installer, 60 PluginInstaller* installer,
61 std::unique_ptr<PluginMetadata> plugin_metadata, 61 std::unique_ptr<PluginMetadata> plugin_metadata,
62 const base::string16& message) 62 const base::string16& message)
63 : ConfirmInfoBarDelegate(), 63 : ConfirmInfoBarDelegate(),
64 WeakPluginInstallerObserver(installer), 64 WeakPluginInstallerObserver(installer),
65 identifier_(plugin_metadata->identifier()), 65 identifier_(plugin_metadata->identifier()),
66 plugin_metadata_(std::move(plugin_metadata)), 66 plugin_metadata_(std::move(plugin_metadata)),
67 message_(message) { 67 message_(message) {
68 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); 68 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown"));
69 std::string name = base::UTF16ToUTF8(plugin_metadata_->name()); 69 std::string name = base::UTF16ToUTF8(plugin_metadata_->name());
70 if (name == PluginMetadata::kJavaGroupName) { 70 if (name == PluginMetadata::kJavaGroupName) {
71 content::RecordAction( 71 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown.Java"));
72 UserMetricsAction("OutdatedPluginInfobar.Shown.Java"));
73 } else if (name == PluginMetadata::kQuickTimeGroupName) { 72 } else if (name == PluginMetadata::kQuickTimeGroupName) {
74 content::RecordAction( 73 base::RecordAction(
75 UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime")); 74 UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime"));
76 } else if (name == PluginMetadata::kShockwaveGroupName) { 75 } else if (name == PluginMetadata::kShockwaveGroupName) {
77 content::RecordAction( 76 base::RecordAction(
78 UserMetricsAction("OutdatedPluginInfobar.Shown.Shockwave")); 77 UserMetricsAction("OutdatedPluginInfobar.Shown.Shockwave"));
79 } else if (name == PluginMetadata::kRealPlayerGroupName) { 78 } else if (name == PluginMetadata::kRealPlayerGroupName) {
80 content::RecordAction( 79 base::RecordAction(
81 UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer")); 80 UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer"));
82 } else if (name == PluginMetadata::kSilverlightGroupName) { 81 } else if (name == PluginMetadata::kSilverlightGroupName) {
83 content::RecordAction( 82 base::RecordAction(
84 UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight")); 83 UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight"));
85 } else if (name == PluginMetadata::kAdobeReaderGroupName) { 84 } else if (name == PluginMetadata::kAdobeReaderGroupName) {
86 content::RecordAction( 85 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown.Reader"));
87 UserMetricsAction("OutdatedPluginInfobar.Shown.Reader"));
88 } 86 }
89 } 87 }
90 88
91 OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() { 89 OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() {
92 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed")); 90 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed"));
93 } 91 }
94 92
95 infobars::InfoBarDelegate::InfoBarIdentifier 93 infobars::InfoBarDelegate::InfoBarIdentifier
96 OutdatedPluginInfoBarDelegate::GetIdentifier() const { 94 OutdatedPluginInfoBarDelegate::GetIdentifier() const {
97 return OUTDATED_PLUGIN_INFOBAR_DELEGATE; 95 return OUTDATED_PLUGIN_INFOBAR_DELEGATE;
98 } 96 }
99 97
100 void OutdatedPluginInfoBarDelegate::InfoBarDismissed() { 98 void OutdatedPluginInfoBarDelegate::InfoBarDismissed() {
101 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Dismissed")); 99 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Dismissed"));
102 } 100 }
103 101
104 const gfx::VectorIcon& OutdatedPluginInfoBarDelegate::GetVectorIcon() const { 102 const gfx::VectorIcon& OutdatedPluginInfoBarDelegate::GetVectorIcon() const {
105 return kExtensionIcon; 103 return kExtensionIcon;
106 } 104 }
107 105
108 base::string16 OutdatedPluginInfoBarDelegate::GetMessageText() const { 106 base::string16 OutdatedPluginInfoBarDelegate::GetMessageText() const {
109 return message_; 107 return message_;
110 } 108 }
111 109
112 base::string16 OutdatedPluginInfoBarDelegate::GetButtonLabel( 110 base::string16 OutdatedPluginInfoBarDelegate::GetButtonLabel(
113 InfoBarButton button) const { 111 InfoBarButton button) const {
114 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 112 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
115 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); 113 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY);
116 } 114 }
117 115
118 bool OutdatedPluginInfoBarDelegate::Accept() { 116 bool OutdatedPluginInfoBarDelegate::Accept() {
119 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); 117 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update"));
120 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will 118 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will
121 // result in deleting ourselves. Accordingly, we make sure to 119 // result in deleting ourselves. Accordingly, we make sure to
122 // not pass a reference to an object that can go away. 120 // not pass a reference to an object that can go away.
123 GURL plugin_url(plugin_metadata_->plugin_url()); 121 GURL plugin_url(plugin_metadata_->plugin_url());
124 content::WebContents* web_contents = 122 content::WebContents* web_contents =
125 InfoBarService::WebContentsFromInfoBar(infobar()); 123 InfoBarService::WebContentsFromInfoBar(infobar());
126 if (web_contents) { 124 if (web_contents) {
127 DCHECK(plugin_metadata_->url_for_display()); 125 DCHECK(plugin_metadata_->url_for_display());
128 installer()->OpenDownloadURL(plugin_url, web_contents); 126 installer()->OpenDownloadURL(plugin_url, web_contents);
129 } 127 }
130 return false; 128 return false;
131 } 129 }
132 130
133 bool OutdatedPluginInfoBarDelegate::Cancel() { 131 bool OutdatedPluginInfoBarDelegate::Cancel() {
134 content::RecordAction( 132 base::RecordAction(UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
135 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
136 133
137 content::WebContents* web_contents = 134 content::WebContents* web_contents =
138 InfoBarService::WebContentsFromInfoBar(infobar()); 135 InfoBarService::WebContentsFromInfoBar(infobar());
139 if (web_contents) { 136 if (web_contents) {
140 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( 137 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
141 web_contents, true, identifier_); 138 web_contents, true, identifier_);
142 } 139 }
143 140
144 return true; 141 return true;
145 } 142 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 std::unique_ptr<PluginMetadata> plugin_metadata, 175 std::unique_ptr<PluginMetadata> plugin_metadata,
179 const base::string16& message) { 176 const base::string16& message) {
180 DCHECK(infobar->owner()); 177 DCHECK(infobar->owner());
181 infobar->owner()->ReplaceInfoBar( 178 infobar->owner()->ReplaceInfoBar(
182 infobar, infobar->owner()->CreateConfirmInfoBar( 179 infobar, infobar->owner()->CreateConfirmInfoBar(
183 std::unique_ptr<ConfirmInfoBarDelegate>( 180 std::unique_ptr<ConfirmInfoBarDelegate>(
184 new OutdatedPluginInfoBarDelegate( 181 new OutdatedPluginInfoBarDelegate(
185 installer, std::move(plugin_metadata), message)))); 182 installer, std::move(plugin_metadata), message))));
186 } 183 }
187 184
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_request_manager.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698