summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authordpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 11:44:36 +0000
committerdpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 11:44:36 +0000
commit5272851e482e081b58055d8f8470fef014704b09 (patch)
tree219f6d52c6dea64a243e999099ddd59d7fab2470 /chrome/browser/dom_ui
parentb47fc93828d237045e1c62236be80e94d1913b28 (diff)
downloadchromium_src-5272851e482e081b58055d8f8470fef014704b09.zip
chromium_src-5272851e482e081b58055d8f8470fef014704b09.tar.gz
chromium_src-5272851e482e081b58055d8f8470fef014704b09.tar.bz2
Revert 57635: Implement about:labs
Original CL: http://codereview.chromium.org/3152055 Implement about:labs Tabpose is currently the only lab on mac, tabs-on-left the only lab on windows. Nothing for linux yet. BUG=53399 TEST=Go to about:labs. Should have one feature on windows and osx each, none on linux yet. about:labs should not be visible on the stable channel. Labs that were enabled on the dev channel should not be enabled on the stable channel. about:labs in chromeos should still work (they use a different implementation) TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/3256001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc7
-rw-r--r--chrome/browser/dom_ui/labs_ui.cc196
-rw-r--r--chrome/browser/dom_ui/labs_ui.h25
-rw-r--r--chrome/browser/dom_ui/plugins_ui.cc22
4 files changed, 19 insertions, 231 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index 251f646..0737acf 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/dom_ui/history_ui.h"
#include "chrome/browser/dom_ui/history2_ui.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
-#include "chrome/browser/dom_ui/labs_ui.h"
#include "chrome/browser/dom_ui/net_internals_ui.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/dom_ui/options_ui.h"
@@ -23,7 +22,6 @@
#include "chrome/browser/extensions/extension_dom_ui.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/extensions_ui.h"
-#include "chrome/browser/labs.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -118,8 +116,6 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) {
return &NewDOMUI<HistoryUI>;
if (url.host() == chrome::kChromeUIHistory2Host)
return &NewDOMUI<HistoryUI2>;
- if (about_labs::IsEnabled() && url.host() == chrome::kChromeUILabsHost)
- return &NewDOMUI<LabsUI>;
if (url.host() == chrome::kChromeUINetInternalsHost)
return &NewDOMUI<NetInternalsUI>;
if (url.host() == chrome::kChromeUIPluginsHost)
@@ -233,9 +229,6 @@ RefCountedMemory* DOMUIFactory::GetFaviconResourceBytes(Profile* profile,
if (page_url.host() == chrome::kChromeUIHistory2Host)
return HistoryUI2::GetFaviconResourceBytes();
- if (about_labs::IsEnabled() && page_url.host() == chrome::kChromeUILabsHost)
- return LabsUI::GetFaviconResourceBytes();
-
if (page_url.host() == chrome::kChromeUIOptionsHost)
return OptionsUI::GetFaviconResourceBytes();
diff --git a/chrome/browser/dom_ui/labs_ui.cc b/chrome/browser/dom_ui/labs_ui.cc
deleted file mode 100644
index 3e02112..0000000
--- a/chrome/browser/dom_ui/labs_ui.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// 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/dom_ui/labs_ui.h"
-
-#include <string>
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/singleton.h"
-#include "base/values.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
-#include "chrome/browser/labs.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/common/jstemplate_builder.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "grit/browser_resources.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-
-namespace {
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// LabsUIHTMLSource
-//
-///////////////////////////////////////////////////////////////////////////////
-
-class LabsUIHTMLSource : public ChromeURLDataManager::DataSource {
- public:
- LabsUIHTMLSource()
- : DataSource(chrome::kChromeUILabsHost, MessageLoop::current()) {}
-
- // 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:
- ~LabsUIHTMLSource() {}
-
- DISALLOW_COPY_AND_ASSIGN(LabsUIHTMLSource);
-};
-
-void LabsUIHTMLSource::StartDataRequest(const std::string& path,
- bool is_off_the_record,
- int request_id) {
- // Strings used in the JsTemplate file.
- DictionaryValue localized_strings;
- localized_strings.SetString("labsTitle",
- l10n_util::GetStringUTF16(IDS_LABS_TITLE));
- localized_strings.SetString("labsLongTitle",
- l10n_util::GetStringUTF16(IDS_LABS_LONG_TITLE));
- localized_strings.SetString("labsTableTitle",
- l10n_util::GetStringUTF16(IDS_LABS_TABLE_TITLE));
- localized_strings.SetString("labsNoExperimentsAvailable",
- l10n_util::GetStringUTF16(IDS_LABS_NO_EXPERIMENTS_AVAILABLE));
- localized_strings.SetString("labsBlurb", l10n_util::GetStringFUTF16(
- IDS_LABS_BLURB,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- localized_strings.SetString("labsRestartNotice", l10n_util::GetStringFUTF16(
- IDS_LABS_RESTART_NOTICE,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- localized_strings.SetString("labsRestartButton",
- l10n_util::GetStringUTF16(IDS_LABS_RESTART_BUTTON));
- localized_strings.SetString("disable",
- l10n_util::GetStringUTF16(IDS_LABS_DISABLE));
- localized_strings.SetString("enable",
- l10n_util::GetStringUTF16(IDS_LABS_ENABLE));
-
- ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings);
-
- static const base::StringPiece labs_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_LABS_HTML));
- std::string full_html(labs_html.data(), labs_html.size());
- jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
- jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
- jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
- jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
-
- 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);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// LabsDOMHandler
-//
-////////////////////////////////////////////////////////////////////////////////
-
-// The handler for Javascript messages for the chrome://labs/ page.
-class LabsDOMHandler : public DOMMessageHandler {
- public:
- LabsDOMHandler() {}
- virtual ~LabsDOMHandler() {}
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
- // Callback for the "requestLabsExperiments" message.
- void HandleRequestLabsExperiments(const ListValue* args);
-
- // Callback for the "enableLabsExperiment" message.
- void HandleEnableLabsExperimentMessage(const ListValue* args);
-
- // Callback for the "restartBrowser" message. Restores all tabs on restart.
- void HandleRestartBrowser(const ListValue* args);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LabsDOMHandler);
-};
-
-void LabsDOMHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("requestLabsExperiments",
- NewCallback(this, &LabsDOMHandler::HandleRequestLabsExperiments));
- dom_ui_->RegisterMessageCallback("enableLabsExperiment",
- NewCallback(this, &LabsDOMHandler::HandleEnableLabsExperimentMessage));
- dom_ui_->RegisterMessageCallback("restartBrowser",
- NewCallback(this, &LabsDOMHandler::HandleRestartBrowser));
-}
-
-void LabsDOMHandler::HandleRequestLabsExperiments(const ListValue* args) {
- DictionaryValue results;
- results.Set("labsExperiments",
- about_labs::GetLabsExperimentsData(dom_ui_->GetProfile()));
- results.SetBoolean("needsRestart",
- about_labs::IsRestartNeededToCommitChanges());
- dom_ui_->CallJavascriptFunction(L"returnLabsExperiments", results);
-}
-
-void LabsDOMHandler::HandleEnableLabsExperimentMessage(const ListValue* args) {
- DCHECK_EQ(2u, args->GetSize());
- if (args->GetSize() != 2)
- return;
-
- std::string experiment_internal_name;
- std::string enable_str;
- if (!args->GetString(0, &experiment_internal_name) ||
- !args->GetString(1, &enable_str))
- return;
-
- about_labs::SetExperimentEnabled(
- dom_ui_->GetProfile(), experiment_internal_name, enable_str == "true");
-}
-
-void LabsDOMHandler::HandleRestartBrowser(const ListValue* args) {
- // Set the flag to restore state after the restart.
- PrefService* pref_service = g_browser_process->local_state();
- pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true);
- BrowserList::CloseAllBrowsersAndExit();
-}
-
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// LabsUI
-//
-///////////////////////////////////////////////////////////////////////////////
-
-LabsUI::LabsUI(TabContents* contents) : DOMUI(contents) {
- AddMessageHandler((new LabsDOMHandler())->Attach(this));
-
- LabsUIHTMLSource* html_source = new LabsUIHTMLSource();
-
- // Set up the chrome://labs/ source.
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(Singleton<ChromeURLDataManager>::get(),
- &ChromeURLDataManager::AddDataSource,
- make_scoped_refptr(html_source)));
-}
-
-// static
-RefCountedMemory* LabsUI::GetFaviconResourceBytes() {
- return ResourceBundle::GetSharedInstance().
- LoadDataResourceBytes(IDR_LABS);
-}
-
-// static
-void LabsUI::RegisterUserPrefs(PrefService* prefs) {
- prefs->RegisterListPref(prefs::kEnabledLabsExperiments);
-}
diff --git a/chrome/browser/dom_ui/labs_ui.h b/chrome/browser/dom_ui/labs_ui.h
deleted file mode 100644
index 0919030..0000000
--- a/chrome/browser/dom_ui/labs_ui.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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_DOM_UI_LABS_UI_H_
-#define CHROME_BROWSER_DOM_UI_LABS_UI_H_
-#pragma once
-
-#include "chrome/browser/dom_ui/dom_ui.h"
-
-class PrefService;
-class RefCountedMemory;
-
-class LabsUI : public DOMUI {
- public:
- explicit LabsUI(TabContents* contents);
-
- static RefCountedMemory* GetFaviconResourceBytes();
- static void RegisterUserPrefs(PrefService* prefs);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LabsUI);
-};
-
-#endif // CHROME_BROWSER_DOM_UI_LABS_UI_H_
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc
index a52fc88..e529a68 100644
--- a/chrome/browser/dom_ui/plugins_ui.cc
+++ b/chrome/browser/dom_ui/plugins_ui.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/dom_ui/plugins_ui.h"
#include <algorithm>
+#include <set>
#include <string>
#include <vector>
@@ -147,6 +148,20 @@ class PluginsDOMHandler : public DOMMessageHandler {
void HandleShowTermsOfServiceMessage(const ListValue* args);
private:
+ // Creates a dictionary containing all the information about the given plugin;
+ // this is put into the list to "return" for the "requestPluginsData" message.
+ DictionaryValue* CreatePluginDetailValue(
+ const WebPluginInfo& plugin,
+ const std::set<string16>& plugin_blacklist_set);
+
+ // Creates a dictionary containing the important parts of the information
+ // about the given plugin; this is put into a list and saved in prefs.
+ DictionaryValue* CreatePluginSummaryValue(const WebPluginInfo& plugin);
+
+ // Update the user preferences to reflect the current (user-selected) state of
+ // plugins.
+ void UpdatePreferences();
+
DISALLOW_COPY_AND_ASSIGN(PluginsDOMHandler);
};
@@ -160,9 +175,10 @@ void PluginsDOMHandler::RegisterMessages() {
}
void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) {
- DictionaryValue results;
- results.Set("plugins", plugin_updater::GetPluginGroupsData());
- dom_ui_->CallJavascriptFunction(L"returnPluginsData", results);
+ DictionaryValue* results = new DictionaryValue();
+ results->Set("plugins", plugin_updater::GetPluginGroupsData());
+
+ dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results);
}
void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) {