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

Side by Side Diff: chrome/browser/ui/webui/help/help_handler.cc

Issue 9413028: Help: Show the platform version and firmware on CrOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/help/help_handler.h ('k') | no next file » | 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 "chrome/browser/ui/webui/help/help_handler.h" 5 #include "chrome/browser/ui/webui/help/help_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 { "productCopyright", IDS_ABOUT_VERSION_COPYRIGHT }, 71 { "productCopyright", IDS_ABOUT_VERSION_COPYRIGHT },
72 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED }, 72 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED },
73 { "upToDate", IDS_UPGRADE_UP_TO_DATE }, 73 { "upToDate", IDS_UPGRADE_UP_TO_DATE },
74 { "updating", IDS_UPGRADE_UPDATING }, 74 { "updating", IDS_UPGRADE_UPDATING },
75 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, 75 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH },
76 // TODO(jhawkins): Verify the following UI is only in the official build. 76 // TODO(jhawkins): Verify the following UI is only in the official build.
77 #if defined(OFFICIAL_BUILD) 77 #if defined(OFFICIAL_BUILD)
78 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, 78 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME },
79 { "reportAProblem", IDS_REPORT_A_PROBLEM }, 79 { "reportAProblem", IDS_REPORT_A_PROBLEM },
80 #endif 80 #endif
81 #if defined(OS_CHROMEOS)
82 { "platform", IDS_PLATFORM_LABEL },
83 { "firmware", IDS_ABOUT_PAGE_FIRMWARE },
84 #endif
81 }; 85 };
82 86
83 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { 87 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
84 localized_strings->SetString(resources[i].name, 88 localized_strings->SetString(resources[i].name,
85 l10n_util::GetStringUTF16(resources[i].ids)); 89 l10n_util::GetStringUTF16(resources[i].ids));
86 } 90 }
87 91
88 localized_strings->SetString( 92 localized_strings->SetString(
89 "browserVersion", 93 "browserVersion",
90 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, 94 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION,
91 BuildBrowserVersionString())); 95 BuildBrowserVersionString()));
92 96
93 string16 license = l10n_util::GetStringFUTF16( 97 string16 license = l10n_util::GetStringFUTF16(
94 IDS_ABOUT_VERSION_LICENSE, 98 IDS_ABOUT_VERSION_LICENSE,
95 #if !defined(OS_CHROMEOS) 99 #if !defined(OS_CHROMEOS)
96 UTF8ToUTF16(google_util::StringAppendGoogleLocaleParam( 100 UTF8ToUTF16(google_util::StringAppendGoogleLocaleParam(
97 chrome::kChromiumProjectURL)), 101 chrome::kChromiumProjectURL)),
98 #endif 102 #endif
99 ASCIIToUTF16(chrome::kChromeUICreditsURL)); 103 ASCIIToUTF16(chrome::kChromeUICreditsURL));
100 localized_strings->SetString("productLicense", license); 104 localized_strings->SetString("productLicense", license);
101 105
102 string16 tos = l10n_util::GetStringFUTF16( 106 string16 tos = l10n_util::GetStringFUTF16(
103 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL)); 107 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL));
104 localized_strings->SetString("productTOS", tos); 108 localized_strings->SetString("productTOS", tos);
105 } 109 }
106 110
107 void HelpHandler::RegisterMessages() { 111 void HelpHandler::RegisterMessages() {
108 web_ui()->RegisterMessageCallback("checkForUpdate", 112 web_ui()->RegisterMessageCallback("onPageLoaded",
109 base::Bind(&HelpHandler::CheckForUpdate, base::Unretained(this))); 113 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this)));
110 web_ui()->RegisterMessageCallback("relaunchNow", 114 web_ui()->RegisterMessageCallback("relaunchNow",
111 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); 115 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this)));
112 } 116 }
113 117
114 void HelpHandler::CheckForUpdate(const ListValue* args) { 118 void HelpHandler::OnPageLoaded(const ListValue* args) {
119 #if defined(OS_CHROMEOS)
120 // Version information is loaded from a callback
121 loader_.GetVersion(&consumer_, base::Bind(&HelpHandler::OnOSVersion,
122 base::Unretained(this)),
123 chromeos::VersionLoader::VERSION_FULL);
124 loader_.GetFirmware(&consumer_, base::Bind(&HelpHandler::OnOSFirmware,
125 base::Unretained(this)));
126 #endif // defined(OS_CHROMEOS)
127
115 version_updater_->CheckForUpdate( 128 version_updater_->CheckForUpdate(
116 base::Bind(&HelpHandler::UpdateStatus, base::Unretained(this))); 129 base::Bind(&HelpHandler::UpdateStatus, base::Unretained(this)));
117 } 130 }
118 131
119 void HelpHandler::RelaunchNow(const ListValue* args) { 132 void HelpHandler::RelaunchNow(const ListValue* args) {
120 version_updater_->RelaunchBrowser(); 133 version_updater_->RelaunchBrowser();
121 } 134 }
122 135
123 void HelpHandler::UpdateStatus(VersionUpdater::Status status, int progress) { 136 void HelpHandler::UpdateStatus(VersionUpdater::Status status, int progress) {
124 // Only UPDATING state should have progress set. 137 // Only UPDATING state should have progress set.
(...skipping 16 matching lines...) Expand all
141 } 154 }
142 155
143 scoped_ptr<Value> status_value(Value::CreateStringValue(status_str)); 156 scoped_ptr<Value> status_value(Value::CreateStringValue(status_str));
144 web_ui()->CallJavascriptFunction("HelpPage.setUpdateStatus", *status_value); 157 web_ui()->CallJavascriptFunction("HelpPage.setUpdateStatus", *status_value);
145 158
146 if (status == VersionUpdater::UPDATING) { 159 if (status == VersionUpdater::UPDATING) {
147 scoped_ptr<Value> progress_value(Value::CreateIntegerValue(progress)); 160 scoped_ptr<Value> progress_value(Value::CreateIntegerValue(progress));
148 web_ui()->CallJavascriptFunction("HelpPage.setProgress", *progress_value); 161 web_ui()->CallJavascriptFunction("HelpPage.setProgress", *progress_value);
149 } 162 }
150 } 163 }
164
165 #if defined(OS_CHROMEOS)
166
167 void HelpHandler::OnOSVersion(chromeos::VersionLoader::Handle handle,
168 std::string version) {
169 if (version.size()) {
170 scoped_ptr<Value> version_string(Value::CreateStringValue(version));
171 web_ui()->CallJavascriptFunction("HelpPage.setOSVersion", *version_string);
172 }
173 }
174
175 void HelpHandler::OnOSFirmware(chromeos::VersionLoader::Handle handle,
176 std::string firmware) {
177 if (firmware.size()) {
178 scoped_ptr<Value> firmware_string(Value::CreateStringValue(firmware));
179 web_ui()->CallJavascriptFunction("HelpPage.setOSFirmware",
180 *firmware_string);
181 }
182 }
183
184 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/help_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698