OLD | NEW |
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 "chrome/browser/ui/webui/version_handler.h" | 5 #include "chrome/browser/ui/webui/version_handler.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/plugins/plugin_prefs.h" | 12 #include "chrome/browser/plugins/plugin_prefs.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "components/variations/active_field_trials.h" | 15 #include "components/variations/active_field_trials.h" |
| 16 #include "components/version_ui/version_handler_helper.h" |
16 #include "components/version_ui/version_ui_constants.h" | 17 #include "components/version_ui/version_ui_constants.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/plugin_service.h" | 19 #include "content/public/browser/plugin_service.h" |
19 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
20 #include "content/public/common/content_constants.h" | 21 #include "content/public/common/content_constants.h" |
21 #include "grit/components_strings.h" | 22 #include "grit/components_strings.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace { | 26 namespace { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 content::BrowserThread::FILE, FROM_HERE, | 78 content::BrowserThread::FILE, FROM_HERE, |
78 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(), | 79 base::Bind(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(), |
79 base::Unretained(exec_path_buffer), | 80 base::Unretained(exec_path_buffer), |
80 base::Unretained(profile_path_buffer)), | 81 base::Unretained(profile_path_buffer)), |
81 base::Bind(&VersionHandler::OnGotFilePaths, | 82 base::Bind(&VersionHandler::OnGotFilePaths, |
82 weak_ptr_factory_.GetWeakPtr(), | 83 weak_ptr_factory_.GetWeakPtr(), |
83 base::Owned(exec_path_buffer), | 84 base::Owned(exec_path_buffer), |
84 base::Owned(profile_path_buffer))); | 85 base::Owned(profile_path_buffer))); |
85 | 86 |
86 // Respond with the variations info immediately. | 87 // Respond with the variations info immediately. |
87 std::vector<std::string> variations; | |
88 #if !defined(NDEBUG) | |
89 base::FieldTrial::ActiveGroups active_groups; | |
90 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); | |
91 | |
92 const unsigned char kNonBreakingHyphenUTF8[] = { 0xE2, 0x80, 0x91, '\0' }; | |
93 const std::string kNonBreakingHyphenUTF8String( | |
94 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8)); | |
95 for (size_t i = 0; i < active_groups.size(); ++i) { | |
96 std::string line = active_groups[i].trial_name + ":" + | |
97 active_groups[i].group_name; | |
98 base::ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line); | |
99 variations.push_back(line); | |
100 } | |
101 #else | |
102 // In release mode, display the hashes only. | |
103 variations::GetFieldTrialActiveGroupIdsAsStrings(&variations); | |
104 #endif | |
105 | |
106 base::ListValue variations_list; | |
107 for (std::vector<std::string>::const_iterator it = variations.begin(); | |
108 it != variations.end(); ++it) { | |
109 variations_list.Append(new base::StringValue(*it)); | |
110 } | |
111 | |
112 // In release mode, this will return an empty list to clear the section. | |
113 web_ui()->CallJavascriptFunction(version_ui::kReturnVariationInfo, | 88 web_ui()->CallJavascriptFunction(version_ui::kReturnVariationInfo, |
114 variations_list); | 89 *version_ui::GetVariationsList()); |
115 } | 90 } |
116 | 91 |
117 void VersionHandler::OnGotFilePaths(base::string16* executable_path_data, | 92 void VersionHandler::OnGotFilePaths(base::string16* executable_path_data, |
118 base::string16* profile_path_data) { | 93 base::string16* profile_path_data) { |
119 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
120 | 95 |
121 base::StringValue exec_path(*executable_path_data); | 96 base::StringValue exec_path(*executable_path_data); |
122 base::StringValue profile_path(*profile_path_data); | 97 base::StringValue profile_path(*profile_path_data); |
123 web_ui()->CallJavascriptFunction(version_ui::kReturnFilePaths, exec_path, | 98 web_ui()->CallJavascriptFunction(version_ui::kReturnFilePaths, exec_path, |
124 profile_path); | 99 profile_path); |
(...skipping 16 matching lines...) Expand all Loading... |
141 flash_version = info_array[i].version; | 116 flash_version = info_array[i].version; |
142 break; | 117 break; |
143 } | 118 } |
144 } | 119 } |
145 } | 120 } |
146 | 121 |
147 base::StringValue arg(flash_version); | 122 base::StringValue arg(flash_version); |
148 web_ui()->CallJavascriptFunction(version_ui::kReturnFlashVersion, arg); | 123 web_ui()->CallJavascriptFunction(version_ui::kReturnFlashVersion, arg); |
149 } | 124 } |
150 #endif // defined(ENABLE_PLUGINS) | 125 #endif // defined(ENABLE_PLUGINS) |
OLD | NEW |