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

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

Issue 1233043003: 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 = base::EndsWith(host, "youtube.com", true) || 92 bool is_youtube =
93 base::EndsWith(host, "youtube-nocookie.com", true); 93 base::EndsWith(host, "youtube.com", base::CompareCase::SENSITIVE) ||
94 base::EndsWith(host, "youtube-nocookie.com",
95 base::CompareCase::SENSITIVE);
94 96
95 return is_youtube && IsValidYouTubeVideo(url.path()) && 97 return is_youtube && IsValidYouTubeVideo(url.path()) &&
96 base::LowerCaseEqualsASCII(mime_type, 98 base::LowerCaseEqualsASCII(mime_type,
97 content::kFlashPluginSwfMimeType); 99 content::kFlashPluginSwfMimeType);
98 } 100 }
99 101
100 void MobileYouTubePlugin::OpenYoutubeUrlCallback() { 102 void MobileYouTubePlugin::OpenYoutubeUrlCallback() {
101 std::string youtube("vnd.youtube:"); 103 std::string youtube("vnd.youtube:");
102 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams()))); 104 GURL url(youtube.append(GetYoutubeVideoId(GetPluginParams())));
103 WebURLRequest request; 105 WebURLRequest request;
104 request.initialize(); 106 request.initialize();
105 request.setURL(url); 107 request.setURL(url);
106 render_frame()->LoadURLExternally( 108 render_frame()->LoadURLExternally(
107 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab); 109 GetFrame(), request, blink::WebNavigationPolicyNewForegroundTab);
108 } 110 }
109 111
110 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) { 112 v8::Local<v8::Value> MobileYouTubePlugin::GetV8Handle(v8::Isolate* isolate) {
111 return gin::CreateHandle(isolate, this).ToV8(); 113 return gin::CreateHandle(isolate, this).ToV8();
112 } 114 }
113 115
114 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder( 116 gin::ObjectTemplateBuilder MobileYouTubePlugin::GetObjectTemplateBuilder(
115 v8::Isolate* isolate) { 117 v8::Isolate* isolate) {
116 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate) 118 return gin::Wrappable<MobileYouTubePlugin>::GetObjectTemplateBuilder(isolate)
117 .SetMethod("openYoutubeURL", 119 .SetMethod("openYoutubeURL",
118 &MobileYouTubePlugin::OpenYoutubeUrlCallback); 120 &MobileYouTubePlugin::OpenYoutubeUrlCallback);
119 } 121 }
120 122
121 } // namespace plugins 123 } // 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