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

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

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