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/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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (base::ReadFileToString(label_file_path, &contents)) | 138 if (base::ReadFileToString(label_file_path, &contents)) |
139 return contents; | 139 return contents; |
140 return std::string(); | 140 return std::string(); |
141 } | 141 } |
142 | 142 |
143 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
144 | 144 |
145 } // namespace | 145 } // namespace |
146 | 146 |
147 HelpHandler::HelpHandler() | 147 HelpHandler::HelpHandler() |
148 : version_updater_(VersionUpdater::Create(nullptr)), | 148 : weak_factory_(this) { |
149 weak_factory_(this) { | |
150 } | 149 } |
151 | 150 |
152 HelpHandler::~HelpHandler() { | 151 HelpHandler::~HelpHandler() { |
153 } | 152 } |
154 | 153 |
155 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) { | 154 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) { |
156 struct L10nResources { | 155 struct L10nResources { |
157 const char* name; | 156 const char* name; |
158 int ids; | 157 int ids; |
159 }; | 158 }; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 localized_strings->SetString("jsEngineVersion", v8::V8::GetVersion()); | 292 localized_strings->SetString("jsEngineVersion", v8::V8::GetVersion()); |
294 | 293 |
295 localized_strings->SetString("userAgentInfo", GetUserAgent()); | 294 localized_strings->SetString("userAgentInfo", GetUserAgent()); |
296 | 295 |
297 base::CommandLine::StringType command_line = | 296 base::CommandLine::StringType command_line = |
298 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); | 297 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); |
299 localized_strings->SetString("commandLineInfo", command_line); | 298 localized_strings->SetString("commandLineInfo", command_line); |
300 } | 299 } |
301 | 300 |
302 void HelpHandler::RegisterMessages() { | 301 void HelpHandler::RegisterMessages() { |
303 #if defined(OS_CHROMEOS) | 302 version_updater_.reset(VersionUpdater::Create(web_ui()->GetWebContents())); |
304 version_updater_.reset( | |
305 VersionUpdater::Create(web_ui()->GetWebContents()->GetBrowserContext())); | |
306 #endif | |
307 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 303 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
308 content::NotificationService::AllSources()); | 304 content::NotificationService::AllSources()); |
309 | 305 |
310 web_ui()->RegisterMessageCallback("onPageLoaded", | 306 web_ui()->RegisterMessageCallback("onPageLoaded", |
311 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); | 307 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); |
312 web_ui()->RegisterMessageCallback("relaunchNow", | 308 web_ui()->RegisterMessageCallback("relaunchNow", |
313 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); | 309 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); |
314 web_ui()->RegisterMessageCallback("openFeedbackDialog", | 310 web_ui()->RegisterMessageCallback("openFeedbackDialog", |
315 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); | 311 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); |
316 web_ui()->RegisterMessageCallback("openHelpPage", | 312 web_ui()->RegisterMessageCallback("openHelpPage", |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 607 } |
612 | 608 |
613 void HelpHandler::OnFCCLabelTextRead(const std::string& text) { | 609 void HelpHandler::OnFCCLabelTextRead(const std::string& text) { |
614 // Remove unnecessary whitespace. | 610 // Remove unnecessary whitespace. |
615 web_ui()->CallJavascriptFunction( | 611 web_ui()->CallJavascriptFunction( |
616 "help.HelpPage.setProductLabelText", | 612 "help.HelpPage.setProductLabelText", |
617 base::StringValue(base::CollapseWhitespaceASCII(text, true))); | 613 base::StringValue(base::CollapseWhitespaceASCII(text, true))); |
618 } | 614 } |
619 | 615 |
620 #endif // defined(OS_CHROMEOS) | 616 #endif // defined(OS_CHROMEOS) |
OLD | NEW |