| 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/dom_ui/options/about_page_handler.h" | 5 #include "chrome/browser/dom_ui/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; | 56 const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 // Returns a substring [start, end) from |text|. | 59 // Returns a substring [start, end) from |text|. |
| 60 std::string StringSubRange(const std::string& text, size_t start, | 60 std::string StringSubRange(const std::string& text, size_t start, |
| 61 size_t end) { | 61 size_t end) { |
| 62 DCHECK(end > start); | 62 DCHECK(end > start); |
| 63 return text.substr(start, end - start); | 63 return text.substr(start, end - start); |
| 64 } | 64 } |
| 65 | 65 |
| 66 struct LocalizeEntry { |
| 67 const char* identifier; |
| 68 int resource; |
| 69 }; |
| 70 |
| 71 const LocalizeEntry localize_table[] = { |
| 72 #if defined (OS_CHROMEOS) |
| 73 { "product", IDS_PRODUCT_OS_NAME }, |
| 74 { "os", IDS_PRODUCT_OS_NAME }, |
| 75 { "loading", IDS_ABOUT_PAGE_LOADING }, |
| 76 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW }, |
| 77 { "update_status", IDS_UPGRADE_CHECK_STARTED }, |
| 78 { "restart_now", IDS_RELAUNCH_AND_UPDATE }, |
| 79 #else |
| 80 { "product", IDS_PRODUCT_NAME }, |
| 81 { "check_now", IDS_ABOUT_CHROME_UPDATE_CHECK }, |
| 82 #endif |
| 83 { "browser", IDS_PRODUCT_NAME }, |
| 84 { "more_info", IDS_ABOUT_PAGE_MORE_INFO }, |
| 85 { "copyright", IDS_ABOUT_VERSION_COPYRIGHT }, |
| 86 { "channel", IDS_ABOUT_PAGE_CHANNEL }, |
| 87 { "release", IDS_ABOUT_PAGE_CHANNEL_RELEASE }, |
| 88 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, |
| 89 { "development", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, |
| 90 { "canary", IDS_ABOUT_PAGE_CHANNEL_CANARY }, |
| 91 { "channel_warning_header", IDS_ABOUT_PAGE_CHANNEL_WARNING_HEADER }, |
| 92 { "channel_warning_text", IDS_ABOUT_PAGE_CHANNEL_WARNING_TEXT }, |
| 93 { "user_agent", IDS_ABOUT_VERSION_USER_AGENT }, |
| 94 { "command_line", IDS_ABOUT_VERSION_COMMAND_LINE }, |
| 95 }; |
| 96 |
| 97 void LocalizedStrings(DictionaryValue* localized_strings) { |
| 98 for (size_t n = 0; n != arraysize(localize_table); ++n) { |
| 99 localized_strings->SetString(localize_table[n].identifier, |
| 100 l10n_util::GetStringUTF16(localize_table[n].resource)); |
| 101 } |
| 102 } |
| 103 |
| 66 } // namespace | 104 } // namespace |
| 67 | 105 |
| 68 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
| 69 | 107 |
| 70 class AboutPageHandler::UpdateObserver | 108 class AboutPageHandler::UpdateObserver |
| 71 : public chromeos::UpdateLibrary::Observer { | 109 : public chromeos::UpdateLibrary::Observer { |
| 72 public: | 110 public: |
| 73 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} | 111 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} |
| 74 virtual ~UpdateObserver() {} | 112 virtual ~UpdateObserver() {} |
| 75 | 113 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 98 if (update_observer_.get()) { | 136 if (update_observer_.get()) { |
| 99 chromeos::CrosLibrary::Get()->GetUpdateLibrary()-> | 137 chromeos::CrosLibrary::Get()->GetUpdateLibrary()-> |
| 100 RemoveObserver(update_observer_.get()); | 138 RemoveObserver(update_observer_.get()); |
| 101 } | 139 } |
| 102 #endif | 140 #endif |
| 103 } | 141 } |
| 104 | 142 |
| 105 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { | 143 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { |
| 106 DCHECK(localized_strings); | 144 DCHECK(localized_strings); |
| 107 | 145 |
| 108 static OptionsStringResource resources[] = { | 146 LocalizedStrings(localized_strings); |
| 109 #if defined (OS_CHROMEOS) | |
| 110 { "product", IDS_PRODUCT_OS_NAME }, | |
| 111 { "os", IDS_PRODUCT_OS_NAME }, | |
| 112 { "loading", IDS_ABOUT_PAGE_LOADING }, | |
| 113 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW }, | |
| 114 { "update_status", IDS_UPGRADE_CHECK_STARTED }, | |
| 115 { "restart_now", IDS_RELAUNCH_AND_UPDATE }, | |
| 116 #else | |
| 117 { "product", IDS_PRODUCT_NAME }, | |
| 118 { "check_now", IDS_ABOUT_CHROME_UPDATE_CHECK }, | |
| 119 #endif | |
| 120 { "browser", IDS_PRODUCT_NAME }, | |
| 121 { "more_info", IDS_ABOUT_PAGE_MORE_INFO }, | |
| 122 { "copyright", IDS_ABOUT_VERSION_COPYRIGHT }, | |
| 123 { "channel", IDS_ABOUT_PAGE_CHANNEL }, | |
| 124 { "release", IDS_ABOUT_PAGE_CHANNEL_RELEASE }, | |
| 125 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, | |
| 126 { "development", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, | |
| 127 { "canary", IDS_ABOUT_PAGE_CHANNEL_CANARY }, | |
| 128 { "channel_warning_header", IDS_ABOUT_PAGE_CHANNEL_WARNING_HEADER }, | |
| 129 { "channel_warning_text", IDS_ABOUT_PAGE_CHANNEL_WARNING_TEXT }, | |
| 130 { "user_agent", IDS_ABOUT_VERSION_USER_AGENT }, | |
| 131 { "command_line", IDS_ABOUT_VERSION_COMMAND_LINE }, | |
| 132 }; | |
| 133 | 147 |
| 134 RegisterStrings(localized_strings, resources, arraysize(resources)); | |
| 135 RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE); | 148 RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE); |
| 136 | 149 |
| 137 // browser version | 150 // browser version |
| 138 | 151 |
| 139 chrome::VersionInfo version_info; | 152 chrome::VersionInfo version_info; |
| 140 DCHECK(version_info.is_valid()); | 153 DCHECK(version_info.is_valid()); |
| 141 | 154 |
| 142 std::string browser_version = version_info.Version(); | 155 std::string browser_version = version_info.Version(); |
| 143 std::string version_modifier = platform_util::GetVersionStringModifier(); | 156 std::string version_modifier = platform_util::GetVersionStringModifier(); |
| 144 if (!version_modifier.empty()) | 157 if (!version_modifier.empty()) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 423 |
| 411 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, | 424 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, |
| 412 std::string version) { | 425 std::string version) { |
| 413 if (version.size()) { | 426 if (version.size()) { |
| 414 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); | 427 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); |
| 415 web_ui_->CallJavascriptFunction(L"AboutPage.updateOSVersionCallback", | 428 web_ui_->CallJavascriptFunction(L"AboutPage.updateOSVersionCallback", |
| 416 *version_string); | 429 *version_string); |
| 417 } | 430 } |
| 418 } | 431 } |
| 419 #endif | 432 #endif |
| OLD | NEW |