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

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 18055008: Expose "Chrome" as accessible product name. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Parse product name in b_a_win.cc instead Created 7 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
« no previous file with comments | « chrome/common/chrome_version_info.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/win/enum_variant.h" 14 #include "base/win/enum_variant.h"
14 #include "base/win/scoped_comptr.h" 15 #include "base/win/scoped_comptr.h"
15 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
16 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 17 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
17 #include "content/common/accessibility_messages.h" 18 #include "content/common/accessibility_messages.h"
18 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
19 #include "ui/base/accessibility/accessible_text_utils.h" 20 #include "ui/base/accessibility/accessible_text_utils.h"
20 #include "ui/base/win/accessibility_ids_win.h" 21 #include "ui/base/win/accessibility_ids_win.h"
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // IAccessibleApplication methods. 861 // IAccessibleApplication methods.
861 // 862 //
862 863
863 STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { 864 STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) {
864 // No need to check |instance_active_| because this interface is 865 // No need to check |instance_active_| because this interface is
865 // global, and doesn't depend on any local state. 866 // global, and doesn't depend on any local state.
866 867
867 if (!app_name) 868 if (!app_name)
868 return E_INVALIDARG; 869 return E_INVALIDARG;
869 870
870 std::string product_name = GetContentClient()->GetProduct(); 871 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
871 *app_name = SysAllocString(UTF8ToUTF16(product_name).c_str()); 872 // the part before the "/".
873 std::vector<std::string> product_components;
874 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components);
875 if (product_components.size() != 2)
876 return E_FAIL;
jam 2013/06/28 23:10:10 nit: perhaps dcheck? also below
dmazzoni 2013/06/28 23:34:51 Done.
877 *app_name = SysAllocString(UTF8ToUTF16(product_components[0]).c_str());
872 DCHECK(*app_name); 878 DCHECK(*app_name);
873 return *app_name ? S_OK : E_FAIL; 879 return *app_name ? S_OK : E_FAIL;
874 } 880 }
875 881
876 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { 882 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) {
877 // No need to check |instance_active_| because this interface is 883 // No need to check |instance_active_| because this interface is
878 // global, and doesn't depend on any local state. 884 // global, and doesn't depend on any local state.
879 885
880 if (!app_version) 886 if (!app_version)
881 return E_INVALIDARG; 887 return E_INVALIDARG;
882 888
883 std::string user_agent = GetContentClient()->GetUserAgent(); 889 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
884 *app_version = SysAllocString(UTF8ToUTF16(user_agent).c_str()); 890 // the part after the "/".
891 std::vector<std::string> product_components;
892 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components);
893 if (product_components.size() != 2)
894 return E_FAIL;
895 *app_version = SysAllocString(UTF8ToUTF16(product_components[1]).c_str());
885 DCHECK(*app_version); 896 DCHECK(*app_version);
886 return *app_version ? S_OK : E_FAIL; 897 return *app_version ? S_OK : E_FAIL;
887 } 898 }
888 899
889 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { 900 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) {
890 // No need to check |instance_active_| because this interface is 901 // No need to check |instance_active_| because this interface is
891 // global, and doesn't depend on any local state. 902 // global, and doesn't depend on any local state.
892 903
893 if (!toolkit_name) 904 if (!toolkit_name)
894 return E_INVALIDARG; 905 return E_INVALIDARG;
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after
3604 // The role should always be set. 3615 // The role should always be set.
3605 DCHECK(!role_name_.empty() || ia_role_); 3616 DCHECK(!role_name_.empty() || ia_role_);
3606 3617
3607 // If we didn't explicitly set the IAccessible2 role, make it the same 3618 // If we didn't explicitly set the IAccessible2 role, make it the same
3608 // as the MSAA role. 3619 // as the MSAA role.
3609 if (!ia2_role_) 3620 if (!ia2_role_)
3610 ia2_role_ = ia_role_; 3621 ia2_role_ = ia_role_;
3611 } 3622 }
3612 3623
3613 } // namespace content 3624 } // namespace content
OLDNEW
« no previous file with comments | « chrome/common/chrome_version_info.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698