summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/webui/about_ui.cc76
-rw-r--r--chrome/common/url_constants.cc3
-rw-r--r--chrome/common/url_constants.h2
3 files changed, 76 insertions, 5 deletions
diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc
index a283ff8..88073ef 100644
--- a/chrome/browser/ui/webui/about_ui.cc
+++ b/chrome/browser/ui/webui/about_ui.cc
@@ -328,6 +328,75 @@ class ChromeOSTermsHandler
DISALLOW_COPY_AND_ASSIGN(ChromeOSTermsHandler);
};
+class ChromeOSCreditsHandler
+ : public base::RefCountedThreadSafe<ChromeOSCreditsHandler> {
+ public:
+ static void Start(const std::string& path,
+ const content::URLDataSource::GotDataCallback& callback) {
+ scoped_refptr<ChromeOSCreditsHandler> handler(
+ new ChromeOSCreditsHandler(path, callback));
+ handler->StartOnUIThread();
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<ChromeOSCreditsHandler>;
+
+ ChromeOSCreditsHandler(
+ const std::string& path,
+ const content::URLDataSource::GotDataCallback& callback)
+ : path_(path), callback_(callback) {}
+
+ virtual ~ChromeOSCreditsHandler() {}
+
+ void StartOnUIThread() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (path_ == kKeyboardUtilsPath) {
+ contents_ = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_KEYBOARD_UTILS_JS)
+ .as_string();
+ ResponseOnUIThread();
+ return;
+ }
+ // Load local Chrome OS credits from the disk.
+ BrowserThread::PostBlockingPoolTaskAndReply(
+ FROM_HERE,
+ base::Bind(&ChromeOSCreditsHandler::LoadCreditsFileOnBlockingPool,
+ this),
+ base::Bind(&ChromeOSCreditsHandler::ResponseOnUIThread, this));
+ }
+
+ void LoadCreditsFileOnBlockingPool() {
+ DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ base::FilePath credits_file_path(chrome::kChromeOSCreditsPath);
+ if (!base::ReadFileToString(credits_file_path, &contents_)) {
+ // File with credits not found, ResponseOnUIThread will load credits
+ // from resources if contents_ is empty.
+ contents_.clear();
+ }
+ }
+
+ void ResponseOnUIThread() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ // If we fail to load Chrome OS credits from disk, load it from resources.
+ if (contents_.empty() && path_ != kKeyboardUtilsPath) {
+ contents_ = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_OS_CREDITS_HTML)
+ .as_string();
+ }
+ callback_.Run(base::RefCountedString::TakeString(&contents_));
+ }
+
+ // Path in the URL.
+ const std::string path_;
+
+ // Callback to run with the response.
+ content::URLDataSource::GotDataCallback callback_;
+
+ // Chrome OS credits contents that was loaded from file.
+ std::string contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeOSCreditsHandler);
+};
#endif
} // namespace
@@ -1029,11 +1098,8 @@ void AboutUIHTMLSource::StartDataRequest(
return;
#if defined(OS_CHROMEOS)
} else if (source_name_ == chrome::kChromeUIOSCreditsHost) {
- int idr = IDR_OS_CREDITS_HTML;
- if (path == kKeyboardUtilsPath)
- idr = IDR_KEYBOARD_UTILS_JS;
- response = ResourceBundle::GetSharedInstance().GetRawDataResource(
- idr).as_string();
+ ChromeOSCreditsHandler::Start(path, callback);
+ return;
#endif
#if defined(OS_LINUX) || defined(OS_OPENBSD)
} else if (source_name_ == chrome::kChromeUISandboxHost) {
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 0c41609..851a14a 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -306,6 +306,9 @@ const char kEULAPathFormat[] = "/usr/share/chromeos-assets/eula/%s/eula.html";
const char kOemEulaURLPath[] = "oem";
const char kOnlineEulaURLPath[] =
"https://www.google.com/intl/%s/chrome/eula_text.html";
+
+const char kChromeOSCreditsPath[] =
+ "/opt/google/chrome/resources/about_os_credits.html";
#endif
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA)
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index 0c130f88..0f15bad 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -296,6 +296,8 @@ extern const char kChromeUIWrenchMenu[];
extern const char kEULAPathFormat[];
extern const char kOemEulaURLPath[];
extern const char kOnlineEulaURLPath[];
+
+extern const char kChromeOSCreditsPath[];
#endif
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA)