diff options
-rw-r--r-- | chrome/browser/chromeos/dom_ui/system_info_ui.cc | 165 | ||||
-rw-r--r-- | chrome/browser/chromeos/dom_ui/system_info_ui.h | 19 | ||||
-rw-r--r-- | chrome/browser/dom_ui/bug_report_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_factory.cc | 3 | ||||
-rw-r--r-- | chrome/browser/resources/bug_report.css | 8 | ||||
-rw-r--r-- | chrome/browser/resources/bug_report.html | 197 | ||||
-rw-r--r-- | chrome/browser/resources/bug_report.js | 4 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 3 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 3 |
10 files changed, 315 insertions, 91 deletions
diff --git a/chrome/browser/chromeos/dom_ui/system_info_ui.cc b/chrome/browser/chromeos/dom_ui/system_info_ui.cc new file mode 100644 index 0000000..01172833 --- /dev/null +++ b/chrome/browser/chromeos/dom_ui/system_info_ui.cc @@ -0,0 +1,165 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/dom_ui/system_info_ui.h" + +#include "app/l10n_util.h" +#include "app/resource_bundle.h" +#include "base/callback.h" +#include "base/message_loop.h" +#include "base/path_service.h" +#include "base/string_piece.h" +#include "base/string_util.h" +#include "base/thread.h" +#include "base/time.h" +#include "base/utf_string_conversions.h" +#include "base/values.h" +#include "base/weak_ptr.h" +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/syslogs_library.h" +#include "chrome/browser/dom_ui/chrome_url_data_manager.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/jstemplate_builder.h" +#include "chrome/common/url_constants.h" +#include "net/base/escape.h" +#include "net/base/directory_lister.h" +#include "grit/browser_resources.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "grit/locale_settings.h" + +class SystemInfoUIHTMLSource : public ChromeURLDataManager::DataSource { + public: + SystemInfoUIHTMLSource(); + + // Called when the network layer has requested a resource underneath + // the path we registered. + virtual void StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "text/html"; + } + + private: + ~SystemInfoUIHTMLSource() {} + + DISALLOW_COPY_AND_ASSIGN(SystemInfoUIHTMLSource); +}; + +// The handler for Javascript messages related to the "system" view. +class SystemInfoHandler : public DOMMessageHandler, + public base::SupportsWeakPtr<SystemInfoHandler> { + public: + SystemInfoHandler(); + virtual ~SystemInfoHandler(); + + // DOMMessageHandler implementation. + virtual DOMMessageHandler* Attach(DOMUI* dom_ui); + virtual void RegisterMessages(); + + private: + DISALLOW_COPY_AND_ASSIGN(SystemInfoHandler); +}; + +//////////////////////////////////////////////////////////////////////////////// +// +// SystemInfoUIHTMLSource +// +//////////////////////////////////////////////////////////////////////////////// + +SystemInfoUIHTMLSource::SystemInfoUIHTMLSource() + : DataSource(chrome::kChromeUISystemInfoHost, MessageLoop::current()) { +} + +void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id) { + DictionaryValue strings; + strings.SetString("title", l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TITLE)); + strings.SetString("description", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_DESC)); + strings.SetString("table_title", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_TABLE_TITLE)); + strings.SetString("expand_all_btn", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND_ALL)); + strings.SetString("collapse_all_btn", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE_ALL)); + strings.SetString("expand_btn", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND)); + strings.SetString("collapse_btn", + l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE)); + SetFontAndTextDirection(&strings); + + chromeos::SyslogsLibrary* syslogs_lib = + chromeos::CrosLibrary::Get()->GetSyslogsLibrary(); + scoped_ptr<chromeos::LogDictionaryType> sys_info; + if (syslogs_lib) + sys_info.reset(syslogs_lib->GetSyslogs(new FilePath())); + if (sys_info.get()) { + ListValue* details = new ListValue(); + strings.Set("details", details); + chromeos::LogDictionaryType::iterator it; + for (it = sys_info.get()->begin(); it != sys_info.get()->end(); ++it) { + DictionaryValue* val = new DictionaryValue; + val->SetString("stat_name", it->first); + val->SetString("stat_value", it->second); + details->Append(val); + } + strings.SetString("anchor", path); + } + + static const base::StringPiece systeminfo_html( + ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_ABOUT_SYS_HTML)); + const std::string full_html = jstemplate_builder::GetTemplatesHtml( + systeminfo_html, &strings, "t" /* template root node id */); + + scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); + html_bytes->data.resize(full_html.size()); + std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); + + SendResponse(request_id, html_bytes); +} + +//////////////////////////////////////////////////////////////////////////////// +// +// SystemInfoHandler +// +//////////////////////////////////////////////////////////////////////////////// +SystemInfoHandler::SystemInfoHandler() { +} + +SystemInfoHandler::~SystemInfoHandler() { +} + +DOMMessageHandler* SystemInfoHandler::Attach(DOMUI* dom_ui) { + // TODO(stevenjb): customize handler attach if needed... + return DOMMessageHandler::Attach(dom_ui); +} + +void SystemInfoHandler::RegisterMessages() { + // TODO(stevenjb): add message registration, callbacks... +} + +//////////////////////////////////////////////////////////////////////////////// +// +// SystemInfoUI +// +//////////////////////////////////////////////////////////////////////////////// + +SystemInfoUI::SystemInfoUI(TabContents* contents) : DOMUI(contents) { + SystemInfoHandler* handler = new SystemInfoHandler(); + AddMessageHandler((handler)->Attach(this)); + SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); + + // Set up the chrome://system/ source. + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod( + Singleton<ChromeURLDataManager>::get(), + &ChromeURLDataManager::AddDataSource, + make_scoped_refptr(html_source))); +} diff --git a/chrome/browser/chromeos/dom_ui/system_info_ui.h b/chrome/browser/chromeos/dom_ui/system_info_ui.h new file mode 100644 index 0000000..945ca24 --- /dev/null +++ b/chrome/browser/chromeos/dom_ui/system_info_ui.h @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_SYSTEM_INFO_UI_H_ +#define CHROME_BROWSER_CHROMEOS_DOM_UI_SYSTEM_INFO_UI_H_ +#pragma once + +#include "chrome/browser/dom_ui/dom_ui.h" + +class SystemInfoUI : public DOMUI { + public: + explicit SystemInfoUI(TabContents* contents); + + private: + DISALLOW_COPY_AND_ASSIGN(SystemInfoUI); +}; + +#endif // CHROME_BROWSER_CHROMEOS_DOM_UI_SYSTEM_INFO_UI_H_ diff --git a/chrome/browser/dom_ui/bug_report_ui.cc b/chrome/browser/dom_ui/bug_report_ui.cc index 021ff9e..6fb0706 100644 --- a/chrome/browser/dom_ui/bug_report_ui.cc +++ b/chrome/browser/dom_ui/bug_report_ui.cc @@ -478,7 +478,7 @@ void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { #if defined(OS_CHROMEOS) // 1: user e-mail sys_info_ = GetSystemInformation(); - dialog_defaults.Append(new StringValue(chrome::kAboutSystemURL)); + dialog_defaults.Append(new StringValue(chrome::kChromeUISystemInfoURL)); // 2: user e-mail dialog_defaults.Append(new StringValue(GetUserEmail())); diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 2e86f77..d649e45 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -37,6 +37,7 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/dom_ui/imageburner_ui.h" +#include "chrome/browser/chromeos/dom_ui/system_info_ui.h" #include "chrome/browser/dom_ui/filebrowse_ui.h" #include "chrome/browser/dom_ui/mediaplayer_ui.h" #include "chrome/browser/dom_ui/register_page_ui.h" @@ -154,6 +155,8 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile, return &NewDOMUI<SlideshowUI>; if (url.host() == chrome::kChromeUIOptionsHost) return &NewDOMUI<OptionsUI>; + if (url.host() == chrome::kChromeUISystemInfoHost) + return &NewDOMUI<SystemInfoUI>; #else if (url.host() == chrome::kChromeUIOptionsHost) { if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/chrome/browser/resources/bug_report.css b/chrome/browser/resources/bug_report.css index 09230c1..6366a51 100644 --- a/chrome/browser/resources/bug_report.css +++ b/chrome/browser/resources/bug_report.css @@ -94,6 +94,14 @@ th { color: #233478; } +#main-panel { + display: -webkit-box; +} + +.formpane { + margin-right: 20px; +} + body { -webkit-user-select: none; } diff --git a/chrome/browser/resources/bug_report.html b/chrome/browser/resources/bug_report.html index d643010..8cf0b75 100644 --- a/chrome/browser/resources/bug_report.html +++ b/chrome/browser/resources/bug_report.html @@ -19,6 +19,17 @@ function load() { // textContent on description-text textarea seems to default // to several spaces, this resets it to empty. $('description-text').textContent = ''; + $('send-report-button').disabled = true; + + $('issue-with-combo').addEventListener('change', function(e) { + $('send-report-button').disabled = + this.selectedIndex <= 0 || $('description-text').value.length == 0; + }); + + $('description-text').addEventListener('keyup', function(e) { + $('send-report-button').disabled = + $('issue-with-combo').selectedIndex <= 0 || this.value.length == 0; + }); $('current-screenshot').nextSibling.textContent = localStrings.getString('currentscreenshots'); @@ -78,6 +89,10 @@ function setupScreenshots(screenshots) { addScreenshot('current-screenshots', currentScreenshot); savedScreenshots = screenshots[1]; + if (savedScreenshots.length == 0) { + $('saved-screenshots').disabled = true; + return; + } for (i = 0; i < savedScreenshots.length; ++i) addScreenshot('saved-screenshots', savedScreenshots[i]); } @@ -88,7 +103,6 @@ function setupDialogDefaults(defaults) { $('page-url-text').value = defaults[0]; if (defaults.length > 2) { // We're in Chromium OS. - $('sysinfo-url').href = defaults[1]; $('user-email-text').value = defaults[2]; } } @@ -98,96 +112,103 @@ window.addEventListener('DOMContentLoaded', load); </script> </head> <body> -<table> - <!-- Issue type dropdown --> - <tr> - <th id="issue-with" class="bug-report-label" i18n-content="issue-with"> - </th> - </tr> - <tr> - <td> - <select id="issue-with-combo" class="bug-report-text"> - </select> - </td> - </tr> - <!-- Page URL text box --> - <tr> - <th colspan="2" id="page-url" class="bug-report-label" - i18n-content="page-url"> - </th> - </tr> - <tr> - <td colspan="2"> - <input id='page-url-text' maxlength=200 class="bug-report-text"> - </td> - </tr> - <!-- Description --> - <tr> - <th id="description" colspan="2" class="bug-report-label" - i18n-content="description"> - </th> - </tr> - <tr> - <td colspan="2"> - <textarea id='description-text' rows="10" class="bug-report-text"> - </textarea> - </td> - </tr> +<div> + <div id="main-panel"> + <div class="formpane"> + <table> + <!-- Issue type dropdown --> + <tr> + <th id="issue-with" class="bug-report-label" i18n-content="issue-with"> + </th> + </tr> + <tr> + <td> + <select id="issue-with-combo" class="bug-report-text"> + </select> + </td> + </tr> + <!-- Page URL text box --> + <tr> + <th colspan="2" id="page-url" class="bug-report-label" + i18n-content="page-url"> + </th> + </tr> + <tr> + <td colspan="2"> + <input id='page-url-text' maxlength=200 class="bug-report-text"> + </td> + </tr> + <!-- Description --> + <tr> + <th id="description" colspan="2" class="bug-report-label" + i18n-content="description"> + </th> + </tr> + <tr> + <td colspan="2"> + <textarea id='description-text' rows="10" class="bug-report-text"> + </textarea> + </td> + </tr> + </table> + </div> + <div class="formpane"> + <table> <if expr="pp_ifdef('chromeos')"> - <!-- System Information checkbox --> - <tr> - <td> - <input id="sys-info-checkbox" type="checkbox" value="sysinfo" checked> - <span id="sysinfo-label"></span> <a href='about:blank' id="sysinfo-url" - target="_blank" i18n-content="sysinfo">></a> - </td> - </tr> - <!-- Page URL text box --> - <tr> - <th id="user-email" class="bug-report-label" i18n-content="user-email"> - </th> - </tr> - <tr> - <td> - <input id='user-email-text' maxlength=200 class="bug-report-text"> - </td> - </tr> + <!-- Page URL text box --> + <tr> + <th id="user-email" class="bug-report-label" i18n-content="user-email"> + </th> + </tr> + <tr> + <td> + <input id='user-email-text' maxlength=200 class="bug-report-text"> + </td> + </tr> + <!-- System Information checkbox --> + <tr> + <td> + <input id="sys-info-checkbox" type="checkbox" value="sysinfo" checked> + <span id="sysinfo-label"></span> <a href='chrome://system/' + id="sysinfo-url"><span i18n-content="sysinfo"></span></a> + </td> + </tr> </if> - <!-- Screenshot radio buttons --> - <tr> - <th id="screenshot" class="bug-report-label" i18n-content="screenshot"> - </th> - </tr> - <tr> - <td> - <input id="no-screenshot" type="radio" name="screenshot-group" - value="none" onclick="noneSelected()"> - <br> + <!-- Screenshot radio buttons --> + <tr> + <th id="screenshot" class="bug-report-label" i18n-content="screenshot"> + </th> + </tr> + <tr> + <td> + <input id="no-screenshot" type="radio" name="screenshot-group" + value="none" onclick="noneSelected()"> + <br> <if expr="pp_ifdef('chromeos')"> - <input id="saved-screenshot" type="radio" name="screenshot-group" - value="saved" onclick="savedSelected()"> - <br> - <div id="saved-screenshots" style="display: none;" - class="thumbnail-list"> - </div> + <input id="saved-screenshot" type="radio" name="screenshot-group" + value="saved" onclick="savedSelected()"> + <br> + <div id="saved-screenshots" style="display: none;" + class="thumbnail-list"> + </div> </if> - <input id="current-screenshot" type="radio" name="screenshot-group" - value="current" checked onclick="currentSelected()"> - <br> - <div id="current-screenshots" class="thumbnail-list"> - </div> - </td> - </tr> - <!-- Buttons --> - <tr> - <td> - <hr> - <input id='send-report-button' type="submit" class="bug-report-button" - i18n-values="value:send-report" onclick="sendReport()"> - <input id='cancel-button' type="submit" class="bug-report-button" - i18n-values="value:cancel" onclick="cancel()"> - </td> - </tr> -</table> + <input id="current-screenshot" type="radio" name="screenshot-group" + value="current" checked onclick="currentSelected()"> + <br> + <div id="current-screenshots" class="thumbnail-list"> + </div> + </td> + </tr> + </table> + </div> + </div> +</div> +<div id="buttons"> + <!-- Buttons --> + <input id='send-report-button' type="submit" class="bug-report-button" + i18n-values="value:send-report" onclick="sendReport()"> + <input id='cancel-button' type="submit" class="bug-report-button" + i18n-values="value:cancel" onclick="cancel()"> +</div> </body> </html> diff --git a/chrome/browser/resources/bug_report.js b/chrome/browser/resources/bug_report.js index 26476b4..c9af14f 100644 --- a/chrome/browser/resources/bug_report.js +++ b/chrome/browser/resources/bug_report.js @@ -22,6 +22,10 @@ var localStrings = new LocalStrings(); function selectImage(divId, thumbnailId) { var thumbnailDivs = $(divId).children; selectedThumbnailDivId = divId; + if (thumbnailDivs.length == 0) { + $(divId).style.display = 'none'; + return; + } for (var i = 0; i < thumbnailDivs.length; i++) { // If the the current div matches the thumbnail id provided, // or there is no thumbnail id given, and we're at the first thumbnail. diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b24481f..5abeb8a 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -449,6 +449,8 @@ 'browser/chromeos/dom_ui/language_pinyin_options_handler.h', 'browser/chromeos/dom_ui/proxy_handler.cc', 'browser/chromeos/dom_ui/proxy_handler.h', + 'browser/chromeos/dom_ui/system_info_ui.cc', + 'browser/chromeos/dom_ui/system_info_ui.h', 'browser/chromeos/dom_ui/system_options_handler.cc', 'browser/chromeos/dom_ui/system_options_handler.h', 'browser/chromeos/dom_ui/system_settings_provider.cc', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 46c4cb0..273057f 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -57,7 +57,6 @@ const char kAboutMemoryURL[] = "about:memory"; const char kAboutNetInternalsURL[] = "about:net-internals"; const char kAboutPluginsURL[] = "about:plugins"; const char kAboutShorthangURL[] = "about:shorthang"; -const char kAboutSystemURL[] = "about:system"; const char kAboutTermsURL[] = "about:terms"; const char kAboutVaporwareURL[] = "about:vaporware"; const char kAboutVersionURL[] = "about:version"; @@ -88,6 +87,7 @@ const char kChromeUIPluginsURL[] = "chrome://plugins/"; const char kChromeUIPrintURL[] = "chrome://print/"; const char kChromeUIRegisterPageURL[] = "chrome://register/"; const char kChromeUISlideshowURL[] = "chrome://slideshow/"; +const char kChromeUISystemInfoURL[] = "chrome://system/"; const char kChromeUIBookmarksHost[] = "bookmarks"; const char kChromeUIBugReportHost[] = "bugreport"; @@ -114,6 +114,7 @@ const char kChromeUIRemotingHost[] = "remoting"; const char kChromeUIResourcesHost[] = "resources"; const char kChromeUISlideshowHost[] = "slideshow"; const char kChromeUISyncResourcesHost[] = "syncresources"; +const char kChromeUISystemInfoHost[] = "system"; const char kChromeUIRemotingResourcesHost[] = "remotingresources"; const char kChromeUIThemePath[] = "theme"; const char kChromeUIScreenshotPath[] = "screenshots"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 986d23c..cf276b4 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -52,7 +52,6 @@ extern const char kAboutMemoryURL[]; extern const char kAboutNetInternalsURL[]; extern const char kAboutPluginsURL[]; extern const char kAboutShorthangURL[]; -extern const char kAboutSystemURL[]; extern const char kAboutTermsURL[]; extern const char kAboutVaporwareURL[]; extern const char kAboutVersionURL[]; @@ -81,6 +80,7 @@ extern const char kChromeUIPluginsURL[]; extern const char kChromeUIPrintURL[]; extern const char kChromeUIRegisterPageURL[]; extern const char kChromeUISlideshowURL[]; +extern const char kChromeUISystemInfoURL[]; // chrome components of URLs. Should be kept in sync with the full URLs // above. @@ -111,6 +111,7 @@ extern const char kChromeUIResourcesHost[]; extern const char kChromeUIScreenshotPath[]; extern const char kChromeUISlideshowHost[]; extern const char kChromeUISyncResourcesHost[]; +extern const char kChromeUISystemInfoHost[]; extern const char kChromeUIThemePath[]; extern const char kChromeUIThumbnailPath[]; |