Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_win.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc |
| index a079db5ccba8b662bd8133b299e64dfebd680e44..c655060f20e0c1c09c15cc80c28b2e7f22ed0f93 100644 |
| --- a/content/browser/accessibility/browser_accessibility_win.cc |
| +++ b/content/browser/accessibility/browser_accessibility_win.cc |
| @@ -8,6 +8,7 @@ |
| #include <UIAutomationCoreApi.h> |
| #include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_split.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/win/enum_variant.h" |
| @@ -867,8 +868,13 @@ STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { |
| if (!app_name) |
| return E_INVALIDARG; |
| - std::string product_name = GetContentClient()->GetProduct(); |
| - *app_name = SysAllocString(UTF8ToUTF16(product_name).c_str()); |
| + // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| + // the part before the "/". |
| + std::vector<std::string> product_components; |
| + base::SplitString(GetContentClient()->GetProduct(), '/', &product_components); |
| + if (product_components.size() != 2) |
| + return E_FAIL; |
|
jam
2013/06/28 23:10:10
nit: perhaps dcheck? also below
dmazzoni
2013/06/28 23:34:51
Done.
|
| + *app_name = SysAllocString(UTF8ToUTF16(product_components[0]).c_str()); |
| DCHECK(*app_name); |
| return *app_name ? S_OK : E_FAIL; |
| } |
| @@ -880,8 +886,13 @@ STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { |
| if (!app_version) |
| return E_INVALIDARG; |
| - std::string user_agent = GetContentClient()->GetUserAgent(); |
| - *app_version = SysAllocString(UTF8ToUTF16(user_agent).c_str()); |
| + // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| + // the part after the "/". |
| + std::vector<std::string> product_components; |
| + base::SplitString(GetContentClient()->GetProduct(), '/', &product_components); |
| + if (product_components.size() != 2) |
| + return E_FAIL; |
| + *app_version = SysAllocString(UTF8ToUTF16(product_components[1]).c_str()); |
| DCHECK(*app_version); |
| return *app_version ? S_OK : E_FAIL; |
| } |