| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/about_page_handler.h" | 5 #include "chrome/browser/ui/webui/options/about_page_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 RemoveObserver(update_observer_.get()); | 101 RemoveObserver(update_observer_.get()); |
| 102 } | 102 } |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| 105 | 105 |
| 106 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { | 106 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { |
| 107 DCHECK(localized_strings); | 107 DCHECK(localized_strings); |
| 108 | 108 |
| 109 static OptionsStringResource resources[] = { | 109 static OptionsStringResource resources[] = { |
| 110 #if defined (OS_CHROMEOS) | 110 #if defined (OS_CHROMEOS) |
| 111 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, |
| 111 { "product", IDS_PRODUCT_OS_NAME }, | 112 { "product", IDS_PRODUCT_OS_NAME }, |
| 112 { "os", IDS_PRODUCT_OS_NAME }, | 113 { "os", IDS_PRODUCT_OS_NAME }, |
| 113 { "loading", IDS_ABOUT_PAGE_LOADING }, | 114 { "loading", IDS_ABOUT_PAGE_LOADING }, |
| 114 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW }, | 115 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW }, |
| 115 { "update_status", IDS_UPGRADE_CHECK_STARTED }, | 116 { "update_status", IDS_UPGRADE_CHECK_STARTED }, |
| 116 { "restart_now", IDS_RELAUNCH_AND_UPDATE }, | 117 { "restart_now", IDS_RELAUNCH_AND_UPDATE }, |
| 117 #else | 118 #else |
| 118 { "product", IDS_PRODUCT_NAME }, | 119 { "product", IDS_PRODUCT_NAME }, |
| 119 { "check_now", IDS_ABOUT_CHROME_UPDATE_CHECK }, | 120 { "check_now", IDS_ABOUT_CHROME_UPDATE_CHECK }, |
| 120 #endif | 121 #endif |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 NewCallback(this, &AboutPageHandler::RestartNow)); | 269 NewCallback(this, &AboutPageHandler::RestartNow)); |
| 269 #endif | 270 #endif |
| 270 } | 271 } |
| 271 | 272 |
| 272 void AboutPageHandler::PageReady(const ListValue* args) { | 273 void AboutPageHandler::PageReady(const ListValue* args) { |
| 273 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
| 274 // Version information is loaded from a callback | 275 // Version information is loaded from a callback |
| 275 loader_.GetVersion(&consumer_, | 276 loader_.GetVersion(&consumer_, |
| 276 NewCallback(this, &AboutPageHandler::OnOSVersion), | 277 NewCallback(this, &AboutPageHandler::OnOSVersion), |
| 277 chromeos::VersionLoader::VERSION_FULL); | 278 chromeos::VersionLoader::VERSION_FULL); |
| 279 loader_.GetFirmware(&consumer_, |
| 280 NewCallback(this, &AboutPageHandler::OnOSFirmware)); |
| 278 | 281 |
| 279 chromeos::UpdateLibrary* update_library = | 282 chromeos::UpdateLibrary* update_library = |
| 280 chromeos::CrosLibrary::Get()->GetUpdateLibrary(); | 283 chromeos::CrosLibrary::Get()->GetUpdateLibrary(); |
| 281 | 284 |
| 282 update_observer_.reset(new UpdateObserver(this)); | 285 update_observer_.reset(new UpdateObserver(this)); |
| 283 update_library->AddObserver(update_observer_.get()); | 286 update_library->AddObserver(update_observer_.get()); |
| 284 | 287 |
| 285 // Update the WebUI page with the current status. See comments below. | 288 // Update the WebUI page with the current status. See comments below. |
| 286 UpdateStatus(update_library->status()); | 289 UpdateStatus(update_library->status()); |
| 287 | 290 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 415 |
| 413 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, | 416 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, |
| 414 std::string version) { | 417 std::string version) { |
| 415 if (version.size()) { | 418 if (version.size()) { |
| 416 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); | 419 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); |
| 417 web_ui_->CallJavascriptFunction("AboutPage.updateOSVersionCallback", | 420 web_ui_->CallJavascriptFunction("AboutPage.updateOSVersionCallback", |
| 418 *version_string); | 421 *version_string); |
| 419 } | 422 } |
| 420 } | 423 } |
| 421 | 424 |
| 425 void AboutPageHandler::OnOSFirmware(chromeos::VersionLoader::Handle handle, |
| 426 std::string firmware) { |
| 427 if (firmware.size()) { |
| 428 scoped_ptr<Value> firmware_string(Value::CreateStringValue(firmware)); |
| 429 web_ui_->CallJavascriptFunction("AboutPage.updateOSFirmwareCallback", |
| 430 *firmware_string); |
| 431 } |
| 432 } |
| 433 |
| 422 // Callback from UpdateEngine with channel information. | 434 // Callback from UpdateEngine with channel information. |
| 423 // static | 435 // static |
| 424 void AboutPageHandler::UpdateSelectedChannel(void* user_data, | 436 void AboutPageHandler::UpdateSelectedChannel(void* user_data, |
| 425 const char* channel) { | 437 const char* channel) { |
| 426 if (!user_data || !channel) { | 438 if (!user_data || !channel) { |
| 427 LOG(WARNING) << "UpdateSelectedChannel returned NULL."; | 439 LOG(WARNING) << "UpdateSelectedChannel returned NULL."; |
| 428 return; | 440 return; |
| 429 } | 441 } |
| 430 UpdateObserver* observer = static_cast<UpdateObserver*>(user_data); | 442 UpdateObserver* observer = static_cast<UpdateObserver*>(user_data); |
| 431 if (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->HasObserver(observer)) { | 443 if (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->HasObserver(observer)) { |
| 432 // If UpdateLibrary still has the observer, then the page handler is valid. | 444 // If UpdateLibrary still has the observer, then the page handler is valid. |
| 433 AboutPageHandler* handler = observer->page_handler(); | 445 AboutPageHandler* handler = observer->page_handler(); |
| 434 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 446 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
| 435 handler->web_ui_->CallJavascriptFunction( | 447 handler->web_ui_->CallJavascriptFunction( |
| 436 "AboutPage.updateSelectedOptionCallback", *channel_string); | 448 "AboutPage.updateSelectedOptionCallback", *channel_string); |
| 437 } | 449 } |
| 438 } | 450 } |
| 439 | 451 |
| 440 #endif // defined(OS_CHROMEOS) | 452 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |