summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-10 02:58:06 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-10 02:58:06 +0000
commitc02f1e100676e3e586291d9b546aa9c7bf64205b (patch)
tree1eea7e4170b16ec46e475d4d913ea487e1fb99e0
parentddd8d5e5cf7f916268e9429ebe3cf5be65268630 (diff)
downloadchromium_src-c02f1e100676e3e586291d9b546aa9c7bf64205b.zip
chromium_src-c02f1e100676e3e586291d9b546aa9c7bf64205b.tar.gz
chromium_src-c02f1e100676e3e586291d9b546aa9c7bf64205b.tar.bz2
Make a JavaScript hook to open a new window to about:terms from chrome://plugins/.
We need it for Flash, and we can't link directly. BUG=none TEST=later Review URL: http://codereview.chromium.org/1642001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44180 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/plugins_ui.cc33
-rw-r--r--chrome/browser/resources/plugins.html7
2 files changed, 36 insertions, 4 deletions
diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc
index 8a9de5c..90905ee 100644
--- a/chrome/browser/dom_ui/plugins_ui.cc
+++ b/chrome/browser/dom_ui/plugins_ui.cc
@@ -8,6 +8,8 @@
#include "app/resource_bundle.h"
#include "base/singleton.h"
#include "base/values.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/pref_service.h"
@@ -121,6 +123,11 @@ class PluginsDOMHandler : public DOMMessageHandler {
// Callback for the "enablePlugin" message.
void HandleEnablePluginMessage(const Value* value);
+ // Callback for the "showTermsOfService" message. This really just opens a new
+ // window with about:terms. Flash can't link directly to about:terms due to
+ // the security model.
+ void HandleShowTermsOfServiceMessage(const Value* value);
+
private:
// Creates a dictionary containing all the information about the given plugin;
// this is put into the list to "return" for the "requestPluginsData" message.
@@ -142,6 +149,8 @@ void PluginsDOMHandler::RegisterMessages() {
NewCallback(this, &PluginsDOMHandler::HandleRequestPluginsData));
dom_ui_->RegisterMessageCallback("enablePlugin",
NewCallback(this, &PluginsDOMHandler::HandleEnablePluginMessage));
+ dom_ui_->RegisterMessageCallback("showTermsOfService",
+ NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage));
}
void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) {
@@ -164,13 +173,21 @@ void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) {
}
void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) {
- CHECK(value->IsType(Value::TYPE_LIST));
+ // Be robust in accepting badness since plug-ins display HTML (hence
+ // JavaScript).
+ if (!value->IsType(Value::TYPE_LIST))
+ return;
+
const ListValue* list = static_cast<const ListValue*>(value);
- CHECK(list->GetSize() == 2);
+ if (list->GetSize() != 2)
+ return;
+
FilePath::StringType plugin_path;
std::string enable_str;
- CHECK(list->GetString(0, &plugin_path));
- CHECK(list->GetString(1, &enable_str));
+ if (!list->GetString(0, &plugin_path) ||
+ !list->GetString(1, &enable_str))
+ return;
+
if (enable_str == "true")
NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(plugin_path));
else
@@ -184,6 +201,14 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) {
UpdatePreferences();
}
+void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) {
+ // Show it in a new browser window....
+ Browser* browser = Browser::Create(dom_ui_->GetProfile());
+ browser->OpenURL(GURL(chrome::kAboutTermsURL),
+ GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
+ browser->window()->Show();
+}
+
DictionaryValue* PluginsDOMHandler::CreatePluginDetailValue(
const WebPluginInfo& plugin) {
DictionaryValue* plugin_data = new DictionaryValue();
diff --git a/chrome/browser/resources/plugins.html b/chrome/browser/resources/plugins.html
index e621ef5..ba0a4a2 100644
--- a/chrome/browser/resources/plugins.html
+++ b/chrome/browser/resources/plugins.html
@@ -322,6 +322,13 @@ function requestPluginsData() {
}
/**
+ * Asks the C++ PluginsDOMHandler to show the terms of service (about:terms).
+ */
+function showTermsOfService() {
+ chrome.send('showTermsOfService', []);
+}
+
+/**
* Called by the dom_ui_ to re-populate the page with data representing the
* current state of installed plugins.
*/