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

Side by Side Diff: chrome/browser/ui/webui/about_page/about_page_handler.cc

Issue 9124028: separate about page into its own page (included in chrome://chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change indent, move script includes to inside body Created 8 years, 11 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
OLDNEW
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/options2/chromeos/about_page_handler2.h" 5 #include "chrome/browser/ui/webui/about_page/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/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" 19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
20 #include "chrome/browser/chromeos/dbus/power_manager_client.h" 20 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
21 #include "chrome/browser/chromeos/dbus/update_engine_client.h" 21 #include "chrome/browser/chromeos/dbus/update_engine_client.h"
22 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
23 #include "chrome/browser/chromeos/login/wizard_controller.h" 23 #include "chrome/browser/chromeos/login/wizard_controller.h"
24 #include "chrome/browser/google/google_util.h" 24 #include "chrome/browser/google/google_util.h"
25 #include "chrome/common/chrome_version_info.h" 25 #include "chrome/common/chrome_version_info.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "content/browser/webui/web_ui.h"
27 #include "content/public/common/content_client.h" 28 #include "content/public/common/content_client.h"
28 #include "googleurl/src/gurl.h" 29 #include "googleurl/src/gurl.h"
29 #include "grit/chromium_strings.h" 30 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
31 #include "grit/locale_settings.h" 32 #include "grit/locale_settings.h"
32 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
33 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 #include "v8/include/v8.h" 36 #include "v8/include/v8.h"
36 #include "webkit/glue/user_agent.h" 37 #include "webkit/glue/user_agent.h"
(...skipping 15 matching lines...) Expand all
52 53
53 // Returns a substring [start, end) from |text|. 54 // Returns a substring [start, end) from |text|.
54 std::string StringSubRange(const std::string& text, size_t start, 55 std::string StringSubRange(const std::string& text, size_t start,
55 size_t end) { 56 size_t end) {
56 DCHECK(end > start); 57 DCHECK(end > start);
57 return text.substr(start, end - start); 58 return text.substr(start, end - start);
58 } 59 }
59 60
60 } // namespace 61 } // namespace
61 62
62 namespace chromeos { 63 using chromeos::DBusThreadManager;
63 namespace options2 { 64 using chromeos::UpdateEngineClient;
65 using chromeos::UserManager;
66 using chromeos::VersionLoader;
67 using chromeos::WizardController;
64 68
65 class AboutPageHandler::UpdateObserver 69 class AboutPageHandler::UpdateObserver
66 : public UpdateEngineClient::Observer { 70 : public UpdateEngineClient::Observer {
67 public: 71 public:
68 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {} 72 explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {}
69 virtual ~UpdateObserver() {} 73 virtual ~UpdateObserver() {}
70 74
71 AboutPageHandler* page_handler() const { return page_handler_; } 75 AboutPageHandler* page_handler() const { return page_handler_; }
72 76
73 private: 77 private:
74 virtual void UpdateStatusChanged( 78 virtual void UpdateStatusChanged(
75 const UpdateEngineClient::Status& status) OVERRIDE { 79 const UpdateEngineClient::Status& status) OVERRIDE {
76 page_handler_->UpdateStatus(status); 80 page_handler_->UpdateStatus(status);
77 } 81 }
78 82
79 AboutPageHandler* page_handler_; 83 AboutPageHandler* page_handler_;
80 84
81 DISALLOW_COPY_AND_ASSIGN(UpdateObserver); 85 DISALLOW_COPY_AND_ASSIGN(UpdateObserver);
82 }; 86 };
83 87
84 AboutPageHandler::AboutPageHandler() 88 AboutPageHandler::AboutPageHandler()
85 : progress_(-1), 89 : progress_(-1),
86 sticky_(false), 90 sticky_(false),
87 started_(false) 91 started_(false) {
88 {} 92 }
89 93
90 AboutPageHandler::~AboutPageHandler() { 94 AboutPageHandler::~AboutPageHandler() {
91 if (update_observer_.get()) { 95 if (update_observer_.get()) {
92 DBusThreadManager::Get()->GetUpdateEngineClient()-> 96 DBusThreadManager::Get()->GetUpdateEngineClient()->
93 RemoveObserver(update_observer_.get()); 97 RemoveObserver(update_observer_.get());
94 } 98 }
95 } 99 }
96 100
97 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { 101 void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
98 DCHECK(localized_strings); 102 DCHECK(localized_strings);
103 DCHECK(localized_strings->empty());
99 104
100 static OptionsStringResource resources[] = { 105 struct L10nResources {
106 const char* name;
107 int ids;
108 };
109
110 static L10nResources resources[] = {
111 { "pageTitle", IDS_ABOUT_TAB_TITLE },
101 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, 112 { "firmware", IDS_ABOUT_PAGE_FIRMWARE },
102 { "product", IDS_PRODUCT_OS_NAME }, 113 { "product", IDS_PRODUCT_OS_NAME },
103 { "os", IDS_PRODUCT_OS_NAME }, 114 { "os", IDS_PRODUCT_OS_NAME },
104 { "platform", IDS_PLATFORM_LABEL }, 115 { "platform", IDS_PLATFORM_LABEL },
105 { "loading", IDS_ABOUT_PAGE_LOADING }, 116 { "loading", IDS_ABOUT_PAGE_LOADING },
106 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW }, 117 { "check_now", IDS_ABOUT_PAGE_CHECK_NOW },
107 { "update_status", IDS_UPGRADE_CHECK_STARTED }, 118 { "update_status", IDS_UPGRADE_CHECK_STARTED },
108 { "restart_now", IDS_RELAUNCH_AND_UPDATE }, 119 { "restart_now", IDS_RELAUNCH_AND_UPDATE },
109 { "browser", IDS_PRODUCT_NAME }, 120 { "browser", IDS_PRODUCT_NAME },
110 { "more_info", IDS_ABOUT_PAGE_MORE_INFO }, 121 { "more_info", IDS_ABOUT_PAGE_MORE_INFO },
111 { "copyright", IDS_ABOUT_VERSION_COPYRIGHT }, 122 { "copyright", IDS_ABOUT_VERSION_COPYRIGHT },
112 { "channel", IDS_ABOUT_PAGE_CHANNEL }, 123 { "channel", IDS_ABOUT_PAGE_CHANNEL },
113 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, 124 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE },
114 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, 125 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA },
115 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, 126 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT },
116 { "canary", IDS_ABOUT_PAGE_CHANNEL_CANARY }, 127 { "canary", IDS_ABOUT_PAGE_CHANNEL_CANARY },
117 { "channel_warning_header", IDS_ABOUT_PAGE_CHANNEL_WARNING_HEADER }, 128 { "channel_warning_header", IDS_ABOUT_PAGE_CHANNEL_WARNING_HEADER },
118 { "channel_warning_text", IDS_ABOUT_PAGE_CHANNEL_WARNING_TEXT }, 129 { "channel_warning_text", IDS_ABOUT_PAGE_CHANNEL_WARNING_TEXT },
119 { "user_agent", IDS_ABOUT_VERSION_USER_AGENT }, 130 { "user_agent", IDS_ABOUT_VERSION_USER_AGENT },
120 { "command_line", IDS_ABOUT_VERSION_COMMAND_LINE }, 131 { "command_line", IDS_ABOUT_VERSION_COMMAND_LINE },
121 }; 132 };
122 133
123 RegisterStrings(localized_strings, resources, arraysize(resources)); 134 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
124 RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE); 135 localized_strings->SetString(resources[i].name,
136 l10n_util::GetStringUTF16(resources[i].ids));
137 }
125 138
126 // browser version 139 // browser version
127 140
128 chrome::VersionInfo version_info; 141 chrome::VersionInfo version_info;
129 DCHECK(version_info.is_valid()); 142 DCHECK(version_info.is_valid());
130 143
131 std::string browser_version = version_info.Version(); 144 std::string browser_version = version_info.Version();
132 std::string version_modifier = 145 std::string version_modifier =
133 chrome::VersionInfo::GetVersionStringModifier(); 146 chrome::VersionInfo::GetVersionStringModifier();
134 if (!version_modifier.empty()) 147 if (!version_modifier.empty())
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (DBusThreadManager::Get()->GetUpdateEngineClient() 422 if (DBusThreadManager::Get()->GetUpdateEngineClient()
410 ->HasObserver(observer)) { 423 ->HasObserver(observer)) {
411 // If UpdateEngineClient still has the observer, then the page handler 424 // If UpdateEngineClient still has the observer, then the page handler
412 // is valid. 425 // is valid.
413 AboutPageHandler* handler = observer->page_handler(); 426 AboutPageHandler* handler = observer->page_handler();
414 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); 427 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel));
415 handler->web_ui()->CallJavascriptFunction( 428 handler->web_ui()->CallJavascriptFunction(
416 "AboutPage.updateSelectedOptionCallback", *channel_string); 429 "AboutPage.updateSelectedOptionCallback", *channel_string);
417 } 430 }
418 } 431 }
419
420 } // namespace options2
421 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/about_page/about_page_handler.h ('k') | chrome/browser/ui/webui/about_page/about_page_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698