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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 2206343002: Add metrics for YouTube Flash embed rewrite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layers
Patch Set: Created 4 years, 4 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/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 using blink::WebURLResponse; 178 using blink::WebURLResponse;
179 using blink::WebVector; 179 using blink::WebVector;
180 using content::PluginInstanceThrottler; 180 using content::PluginInstanceThrottler;
181 using content::RenderFrame; 181 using content::RenderFrame;
182 using content::RenderThread; 182 using content::RenderThread;
183 using content::WebPluginInfo; 183 using content::WebPluginInfo;
184 using extensions::Extension; 184 using extensions::Extension;
185 185
186 namespace { 186 namespace {
187 187
188 enum YouTubeRewriteStatus {
189 SUCCESS = 0,
190 SUCCESS_PARAMS_REWRITE = 1,
191 SUCCESS_ENABLEJSAPI = 2,
192 FAILURE_ENABLEJSAPI = 3,
193 NUM_PLUGIN_ERROR // should be kept last
194 };
195
196 const char kFlashYouTubeRewriteUMA[] = "Plugin.Flash.YouTubeRewrite";
197
198 void RecordYouTubeRewriteUMA(int status, int max) {
199 UMA_HISTOGRAM_ENUMERATION(kFlashYouTubeRewriteUMA, status, max);
200 }
201
188 // Whitelist PPAPI for Android Runtime for Chromium. (See crbug.com/383937) 202 // Whitelist PPAPI for Android Runtime for Chromium. (See crbug.com/383937)
189 #if defined(ENABLE_PLUGINS) 203 #if defined(ENABLE_PLUGINS)
190 const char* const kPredefinedAllowedCameraDeviceOrigins[] = { 204 const char* const kPredefinedAllowedCameraDeviceOrigins[] = {
191 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", 205 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
192 "4EB74897CB187C7633357C2FE832E0AD6A44883A" 206 "4EB74897CB187C7633357C2FE832E0AD6A44883A"
193 }; 207 };
194 208
195 const char* const kPredefinedAllowedCompositorOrigins[] = { 209 const char* const kPredefinedAllowedCompositorOrigins[] = {
196 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", 210 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",
197 "4EB74897CB187C7633357C2FE832E0AD6A44883A" 211 "4EB74897CB187C7633357C2FE832E0AD6A44883A"
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) { 1440 (pos = url_str.find("?", pos)) != std::string::npos; pos += 1) {
1427 url_str.replace(pos, 1, "&"); 1441 url_str.replace(pos, 1, "&");
1428 } 1442 }
1429 } 1443 }
1430 1444
1431 GURL corrected_url = GURL(url_str); 1445 GURL corrected_url = GURL(url_str);
1432 1446
1433 // We don't modify any URLs that contain the enablejsapi=1 parameter 1447 // We don't modify any URLs that contain the enablejsapi=1 parameter
1434 // since the page may be interacting with the YouTube Flash player in 1448 // since the page may be interacting with the YouTube Flash player in
1435 // Javascript and we don't want to break working content. 1449 // Javascript and we don't want to break working content.
1436 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) 1450 if (corrected_url.query().find("enablejsapi=1") != std::string::npos) {
1451 RecordYouTubeRewriteUMA(FAILURE_ENABLEJSAPI, NUM_PLUGIN_ERROR);
1437 return GURL(); 1452 return GURL();
1453 }
1438 1454
1439 // Change the path to use the YouTube HTML5 API 1455 // Change the path to use the YouTube HTML5 API
1440 std::string path = corrected_url.path(); 1456 std::string path = corrected_url.path();
1441 path.replace(path.find("/v/"), 3, "/embed/"); 1457 path.replace(path.find("/v/"), 3, "/embed/");
1442 1458
1443 url::Replacements<char> r; 1459 url::Replacements<char> r;
1444 r.SetPath(path.c_str(), url::Component(0, path.length())); 1460 r.SetPath(path.c_str(), url::Component(0, path.length()));
1445 1461
1462 RecordYouTubeRewriteUMA(invalid_url ? SUCCESS_PARAMS_REWRITE : SUCCESS,
1463 NUM_PLUGIN_ERROR);
1446 return corrected_url.ReplaceComponents(r); 1464 return corrected_url.ReplaceComponents(r);
1447 } 1465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698