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

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

Issue 1233453011: Revert of Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 params, 82 params,
83 HtmlData(params, template_html)) { 83 HtmlData(params, template_html)) {
84 } 84 }
85 85
86 MobileYouTubePlugin::~MobileYouTubePlugin() {} 86 MobileYouTubePlugin::~MobileYouTubePlugin() {}
87 87
88 // static 88 // static
89 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url, 89 bool MobileYouTubePlugin::IsYouTubeURL(const GURL& url,
90 const std::string& mime_type) { 90 const std::string& mime_type) {
91 std::string host = url.host(); 91 std::string host = url.host();
92 bool is_youtube = 92 bool is_youtube = base::EndsWith(host, "youtube.com", true) ||
93 base::EndsWith(host, "youtube.com", base::CompareCase::SENSITIVE) || 93 base::EndsWith(host, "youtube-nocookie.com", true);
94 base::EndsWith(host, "youtube-nocookie.com",
95 base::CompareCase::SENSITIVE);
96 94
97 return is_youtube && IsValidYouTubeVideo(url.path()) && 95 return is_youtube && IsValidYouTubeVideo(url.path()) &&
98 base::LowerCaseEqualsASCII(mime_type, 96 base::LowerCaseEqualsASCII(mime_type,
99 content::kFlashPluginSwfMimeType); 97 content::kFlashPluginSwfMimeType);
100 } 98 }
101 99
102 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { 100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() {
103 std::string youtube("vnd.youtube:"); 101 std::string youtube("vnd.youtube:");
104 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); 102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams())));
105 WebURLRequest request; 103 WebURLRequest request;
106 request.initialize(); 104 request.initialize();
107 request.setURL(url); 105 request.setURL(url);
108 render_frame()->LoadURLExternally( 106 render_frame()->LoadURLExternally(
109 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); 107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab);
110 } 108 }
111 109
112 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) { 110 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) {
113 return gin::CreateHandle(isolate, this).ToV8(); 111 return gin::CreateHandle(isolate, this).ToV8();
114 } 112 }
115 113
116 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( 114 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder(
117 v8::Isolate* isolate) { 115 v8::Isolate* isolate) {
118 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate) 116 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate)
119 .SetMethod("openYoutubeURL", 117 .SetMethod("openYoutubeURL",
120 &MobileYouTubePlugin::OpenYoutubeUrlCallback); 118 &MobileYouTubePlugin::OpenYoutubeUrlCallback);
121 } 119 }
122 120
123 } // namespace plugins 121 } // namespace plugins
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_manager.cc ('k') | components/plugins/renderer/plugin_placeholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698