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 | |
104 } // namespace | 66 } // namespace |
105 | 67 |
106 #if defined(OS_CHROMEOS) | 68 #if defined(OS_CHROMEOS) |
107 | 69 |
108 class AboutPageHandler::UpdateObserver | 70 class AboutPageHandler::UpdateObserver |
109 : public chromeos::UpdateLibrary::Observer { | 71 : public chromeos::UpdateLibrary::Observer { |
110 public: | 72 public: |
111 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} | 73 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} |
112 virtual ~UpdateObserver() {} | 74 virtual ~UpdateObserver() {} |
113 | 75 |
(...skipping 22 matching lines...) Expand all Loading... |
136 if (update_observer_.get()) { | 98 if (update_observer_.get()) { |
137 chromeos::CrosLibrary::Get()->GetUpdateLibrary()-> | 99 chromeos::CrosLibrary::Get()->GetUpdateLibrary()-> |
138 RemoveObserver(update_observer_.get()); | 100 RemoveObserver(update_observer_.get()); |
139 } | 101 } |
140 #endif | 102 #endif |
141 } | 103 } |
142 | 104 |
143 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { | 105 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { |
144 DCHECK(localized_strings); | 106 DCHECK(localized_strings); |
145 | 107 |
146 LocalizedStrings(localized_strings); | 108 static OptionsStringResource resources[] = { |
| 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 }; |
147 | 133 |
| 134 RegisterStrings(localized_strings, resources, arraysize(resources)); |
148 RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE); | 135 RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE); |
149 | 136 |
150 // browser version | 137 // browser version |
151 | 138 |
152 chrome::VersionInfo version_info; | 139 chrome::VersionInfo version_info; |
153 DCHECK(version_info.is_valid()); | 140 DCHECK(version_info.is_valid()); |
154 | 141 |
155 std::string browser_version = version_info.Version(); | 142 std::string browser_version = version_info.Version(); |
156 std::string version_modifier = platform_util::GetVersionStringModifier(); | 143 std::string version_modifier = platform_util::GetVersionStringModifier(); |
157 if (!version_modifier.empty()) | 144 if (!version_modifier.empty()) |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 410 |
424 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, | 411 void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle, |
425 std::string version) { | 412 std::string version) { |
426 if (version.size()) { | 413 if (version.size()) { |
427 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); | 414 scoped_ptr<Value> version_string(Value::CreateStringValue(version)); |
428 web_ui_->CallJavascriptFunction(L"AboutPage.updateOSVersionCallback", | 415 web_ui_->CallJavascriptFunction(L"AboutPage.updateOSVersionCallback", |
429 *version_string); | 416 *version_string); |
430 } | 417 } |
431 } | 418 } |
432 #endif | 419 #endif |
OLD | NEW |