| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/activex_shim/activex_plugin.h" | 5 #include "webkit/activex_shim/activex_plugin.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/fix_wp64.h" | 9 #include "base/fix_wp64.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (!ignore) | 86 if (!ignore) |
| 87 params_.push_back(param); | 87 params_.push_back(param); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 void ActiveXPlugin::ConvertForEmbeddedWmp() { | 91 void ActiveXPlugin::ConvertForEmbeddedWmp() { |
| 92 clsid_ = L"{6bf52a52-394a-11d3-b153-00c04f79faa6}"; | 92 clsid_ = L"{6bf52a52-394a-11d3-b153-00c04f79faa6}"; |
| 93 ControlParam* existing_url_param = NULL; | 93 ControlParam* existing_url_param = NULL; |
| 94 std::wstring src; | 94 std::wstring src; |
| 95 // Find the src parameter and use it to add a new url parameter. | 95 // Find the src parameter and use it to add a new url parameter. |
| 96 // Find the volume parameter and setup defaults which make sense in |
| 97 // the Activex media player world. |
| 96 for (unsigned int i = 0; i < params_.size(); i++) { | 98 for (unsigned int i = 0; i < params_.size(); i++) { |
| 97 if (LowerCaseEqualsASCII(params_[i].name, "src")) | 99 if (LowerCaseEqualsASCII(params_[i].name, "src")) { |
| 98 src = params_[i].value; | 100 src = params_[i].value; |
| 99 else if (LowerCaseEqualsASCII(params_[i].name, "url")) | 101 } else if (LowerCaseEqualsASCII(params_[i].name, "url")) { |
| 100 existing_url_param = ¶ms_[i]; | 102 existing_url_param = ¶ms_[i]; |
| 103 } else if (LowerCaseEqualsASCII(params_[i].name, "volume")) { |
| 104 // In the NPAPI media player world a volume value lesser than |
| 105 // -3000 turns off the volume. A volume value of 0 indicates |
| 106 // full volume. Translate these to their Activex counterparts. |
| 107 int specified_volume = 0; |
| 108 if (StringToInt(params_[i].value, &specified_volume)) { |
| 109 // Valid volume lies between 0 and -3000 |
| 110 specified_volume = std::min (0, std::max(-3000, specified_volume)); |
| 111 // Translate to a value between 0 and 100. |
| 112 int activex_volume = specified_volume / 30 + 100; |
| 113 params_[i].value = IntToWString(activex_volume); |
| 114 } |
| 115 } |
| 101 } | 116 } |
| 117 |
| 102 if (!src.empty()) { | 118 if (!src.empty()) { |
| 103 if (existing_url_param == NULL) | 119 if (existing_url_param == NULL) |
| 104 params_.push_back(ControlParam(L"url", src)); | 120 params_.push_back(ControlParam(L"url", src)); |
| 105 else | 121 else |
| 106 existing_url_param->value = src; | 122 existing_url_param->value = src; |
| 107 } | 123 } |
| 108 } | 124 } |
| 109 | 125 |
| 110 NPError ActiveXPlugin::NPP_New(NPMIMEType plugin_type, int16 argc, char* argn[], | 126 NPError ActiveXPlugin::NPP_New(NPMIMEType plugin_type, int16 argc, char* argn[], |
| 111 char* argv[], NPSavedData* saved) { | 127 char* argv[], NPSavedData* saved) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // TODO(ruijiang): consider the base element of document. | 472 // TODO(ruijiang): consider the base element of document. |
| 457 std::wstring doc_url = GetCurrentURL(); | 473 std::wstring doc_url = GetCurrentURL(); |
| 458 GURL base(doc_url); | 474 GURL base(doc_url); |
| 459 GURL ret = base.Resolve(url); | 475 GURL ret = base.Resolve(url); |
| 460 return UTF8ToWide(ret.spec()); | 476 return UTF8ToWide(ret.spec()); |
| 461 } | 477 } |
| 462 | 478 |
| 463 | 479 |
| 464 } // namespace activex_shim | 480 } // namespace activex_shim |
| 465 | 481 |
| OLD | NEW |