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

Side by Side Diff: components/plugins/renderer/mobile_youtube_plugin.cc

Issue 1279123004: Replace ToLower calls to the new format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 "components/plugins/renderer/mobile_youtube_plugin.h" 5 #include "components/plugins/renderer/mobile_youtube_plugin.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return webui::GetI18nTemplateHtml(template_html, &values); 42 return webui::GetI18nTemplateHtml(template_html, &values);
43 } 43 }
44 44
45 bool IsValidYouTubeVideo(const std::string& path) { 45 bool IsValidYouTubeVideo(const std::string& path) {
46 unsigned len = strlen(kSlashVSlash); 46 unsigned len = strlen(kSlashVSlash);
47 47
48 // check for more than just /v/ or /e/. 48 // check for more than just /v/ or /e/.
49 if (path.length() <= len) 49 if (path.length() <= len)
50 return false; 50 return false;
51 51
52 std::string str = base::StringToLowerASCII(path);
53 // Youtube flash url can start with /v/ or /e/. 52 // Youtube flash url can start with /v/ or /e/.
54 if (strncmp(str.data(), kSlashVSlash, len) != 0 && 53 if (!base::StartsWith(path, kSlashVSlash,
55 strncmp(str.data(), kSlashESlash, len) != 0) 54 base::CompareCase::INSENSITIVE_ASCII) ||
55 !base::StartsWith(path, kSlashESlash,
56 base::CompareCase::INSENSITIVE_ASCII))
56 return false; 57 return false;
57 58
58 // Start after /v/ 59 // Start after /v/
59 for (unsigned i = len; i < path.length(); i++) { 60 for (unsigned i = len; i < path.length(); i++) {
60 char c = str[i]; 61 char c = path[i];
61 if (isalpha(c) || isdigit(c) || c == '_' || c == '-') 62 if (isalpha(c) || isdigit(c) || c == '_' || c == '-')
62 continue; 63 continue;
63 // The url can have more parameters such as &hl=en after the video id. 64 // The url can have more parameters such as &hl=en after the video id.
64 // Once we start seeing extra parameters we can return true. 65 // Once we start seeing extra parameters we can return true.
65 return c == '&' && i > len; 66 return c == '&' && i > len;
66 } 67 }
67 return true; 68 return true;
68 } 69 }
69 70
70 } // namespace 71 } // namespace
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 115 }
115 116
116 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( 117 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder(
117 v8::Isolate* isolate) { 118 v8::Isolate* isolate) {
118 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate) 119 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate)
119 .SetMethod("openYoutubeURL", 120 .SetMethod("openYoutubeURL",
120 &MobileYouTubePlugin::OpenYoutubeUrlCallback); 121 &MobileYouTubePlugin::OpenYoutubeUrlCallback);
121 } 122 }
122 123
123 } // namespace plugins 124 } // namespace plugins
OLDNEW
« no previous file with comments | « components/os_crypt/ie7_password_win.cc ('k') | components/policy/core/common/preg_parser_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698