summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 15:45:31 +0000
committerkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 15:45:31 +0000
commite24be072268be5ca69f68b9fffdc872e3444c320 (patch)
treeb66f6364cb8604d99b6ea0c4746910e2d65ac1d8 /chrome
parentf95f89147dbc66f2b3c54f6e8179c9400607338c (diff)
downloadchromium_src-e24be072268be5ca69f68b9fffdc872e3444c320.zip
chromium_src-e24be072268be5ca69f68b9fffdc872e3444c320.tar.gz
chromium_src-e24be072268be5ca69f68b9fffdc872e3444c320.tar.bz2
Makes it so that when a user clicks "No" in the infobar that asks if they want to register a protocol handler, it adds the protocol to the ignored list for that user, which means it won't show up in their right-click menu for links with that protocol, and appears in an ignored list in the settings at chrome://settings/handlers
TEST=Manual testing Review URL: http://codereview.chromium.org/7358012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd7
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.cc6
-rw-r--r--chrome/browser/custom_handlers/protocol_handler_registry.h3
-rw-r--r--chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc4
-rw-r--r--chrome/browser/resources/options/content_settings.js4
-rw-r--r--chrome/browser/resources/options/handler_options.css4
-rw-r--r--chrome/browser/resources/options/handler_options.html14
-rw-r--r--chrome/browser/resources/options/handler_options.js12
-rw-r--r--chrome/browser/resources/options/handler_options_list.js89
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc3
-rw-r--r--chrome/browser/ui/webui/options/handler_options_handler.cc59
-rw-r--r--chrome/browser/ui/webui/options/handler_options_handler.h10
12 files changed, 188 insertions, 27 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index b6431db..d8728ad 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5529,6 +5529,9 @@ ls' lab.">
<message name="IDS_HANDLERS_NONE_HANDLER" desc="Text in the dropdown for handlers for a given protocol that indicates that the protocol shouldn't be handled.">
(none)
</message>
+ <message name="IDS_HANDLERS_IGNORED_HEADING" desc="Header for the section of the handlers settings page that lists handlers that are ignored.">
+ Ignored protocol handlers
+ </message>
<message name="IDS_HANDLER_OPTIONS_WINDOW_TITLE" desc="The title of the window that lets a user change what handlers they have registered for various protocols / mimetypes.">
Protocol Handlers
@@ -12916,6 +12919,10 @@ ls' lab.">
No
</message>
+ <message name="IDS_REGISTER_PROTOCOL_HANDLER_NEVER" desc="Text to show for the never button for the register protocol handler request infobar.">
+ Never
+ </message>
+
<message name="IDS_REGISTER_PROTOCOL_HANDLER_ALREADY_REGISTERED" desc="Text to show when the user tries to register a protocol handler that they have already registered.">
<ph name="HANDLER_TITLE">$1<ex>Google Search</ex></ph> is already being used to handle <ph name="PROTOCOL">$2<ex>search</ex></ph>: links.
</message>
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc
index 0418a4fa..745e2af 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc
@@ -74,6 +74,11 @@ ProtocolHandlerRegistry::GetHandlersFor(
return p->second;
}
+ProtocolHandlerRegistry::ProtocolHandlerList
+ProtocolHandlerRegistry::GetIgnoredHandlers() {
+ return ignored_protocol_handlers_;
+}
+
void ProtocolHandlerRegistry::RegisterProtocolHandler(
const ProtocolHandler& handler) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -416,6 +421,7 @@ void ProtocolHandlerRegistry::OnIgnoreRegisterProtocolHandler(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
IgnoreProtocolHandler(handler);
Save();
+ NotifyChanged();
}
// static
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h
index 776078d..445751d 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -112,6 +112,9 @@ class ProtocolHandlerRegistry
// Get the list of protocol handlers for the given scheme.
ProtocolHandlerList GetHandlersFor(const std::string& scheme) const;
+ // Get the list of ignored protocol handlers.
+ ProtocolHandlerList GetIgnoredHandlers();
+
// Yields a list of the protocols that have handlers registered in this
// registry.
void GetRegisteredProtocols(std::vector<std::string>* output) const;
diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
index d78e159..d614e43 100644
--- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
+++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
@@ -30,7 +30,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire(
}
InfoBarDelegate::Type
- RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const {
+RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const {
return PAGE_ACTION_TYPE;
}
@@ -68,7 +68,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
}
bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
- registry_->OnDenyRegisterProtocolHandler(handler_);
+ registry_->OnIgnoreRegisterProtocolHandler(handler_);
return true;
}
diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js
index 34a75b5..c85d3ad 100644
--- a/chrome/browser/resources/options/content_settings.js
+++ b/chrome/browser/resources/options/content_settings.js
@@ -107,6 +107,10 @@ cr.define('options', function() {
$('handlers-list').setHandlers(list);
};
+ ContentSettings.setIgnoredHandlers = function(list) {
+ $('ignored-handlers-list').setHandlers(list);
+ };
+
ContentSettings.setOTRExceptions = function(type, list) {
var exceptionsList =
document.querySelector('div[contentType=' + type + ']' +
diff --git a/chrome/browser/resources/options/handler_options.css b/chrome/browser/resources/options/handler_options.css
index 22d1670..77b2313 100644
--- a/chrome/browser/resources/options/handler_options.css
+++ b/chrome/browser/resources/options/handler_options.css
@@ -4,7 +4,7 @@
* found in the LICENSE file.
*/
-#handlers-column-headers {
+.handlers-column-headers {
display: -webkit-box;
}
@@ -48,7 +48,7 @@ div:not(.none):hover > .handlers-remove-column {
min-height: 250px;
}
-#handlers-list {
+#handler-options list {
border-radius: 2px;
border: solid 1px #D9D9D9;
margin-bottom: 10px;
diff --git a/chrome/browser/resources/options/handler_options.html b/chrome/browser/resources/options/handler_options.html
index de4ea17..b8ba813 100644
--- a/chrome/browser/resources/options/handler_options.html
+++ b/chrome/browser/resources/options/handler_options.html
@@ -1,6 +1,6 @@
<div id="handler-options" class="page" hidden>
<h1 i18n-content="handlersPage"></h1>
- <div id="handlers-column-headers">
+ <div class="handlers-column-headers">
<div class="handlers-type-column">
<h3 i18n-content="handlers_type_column_header"></h3>
</div>
@@ -10,4 +10,16 @@
<div class="handlers-remove-column"></div>
</div>
<list id="handlers-list"></list>
+
+ <h3 i18n-content="handlers_ignored_heading"></h3>
+ <div class="handlers-column-headers">
+ <div class="handlers-type-column">
+ <h3 i18n-content="handlers_type_column_header"></h3>
+ </div>
+ <div class="handlers-site-column">
+ <h3 i18n-content="handlers_site_column_header"></h3>
+ </div>
+ <div class="handlers-remove-column"></div>
+ </div>
+ <list id="ignored-handlers-list"></list>
</div>
diff --git a/chrome/browser/resources/options/handler_options.js b/chrome/browser/resources/options/handler_options.js
index e31a0d6..ad740f5 100644
--- a/chrome/browser/resources/options/handler_options.js
+++ b/chrome/browser/resources/options/handler_options.js
@@ -47,6 +47,10 @@ cr.define('options', function() {
this.handlersList_ = $('handlers-list');
options.HandlersList.decorate(this.handlersList_);
this.handlersList_.autoExpands = true;
+
+ this.ignoredHandlersList_ = $('ignored-handlers-list');
+ options.IgnoredHandlersList.decorate(this.ignoredHandlersList_);
+ this.ignoredHandlersList_.autoExpands = true;
},
};
@@ -58,6 +62,14 @@ cr.define('options', function() {
$('handlers-list').setHandlers(handlers);
};
+ /**
+ * Sets the list of ignored handlers shown by the view.
+ * @param handlers to be shown in the view.
+ */
+ HandlerOptions.setIgnoredHandlers = function(handlers) {
+ $('ignored-handlers-list').setHandlers(handlers);
+ };
+
return {
HandlerOptions: HandlerOptions
};
diff --git a/chrome/browser/resources/options/handler_options_list.js b/chrome/browser/resources/options/handler_options_list.js
index 658cef8..661956c 100644
--- a/chrome/browser/resources/options/handler_options_list.js
+++ b/chrome/browser/resources/options/handler_options_list.js
@@ -7,16 +7,93 @@ cr.define('options', function() {
const List = cr.ui.List;
const ListItem = cr.ui.ListItem;
const HandlerOptions = options.HandlerOptions;
+ const DeletableItem = options.DeletableItem;
+ const DeletableItemList = options.DeletableItemList;
const localStrings = new LocalStrings();
/**
+ * Creates a new ignored protocol / content handler list item.
+ *
+ * Accepts values in the form
+ * ['mailto', 'http://www.thesite.com/%s', 'The title of the protocol'],
+ * @param {Object} entry A dictionary describing the handlers for a given
+ * protocol.
+ * @constructor
+ * @extends {cr.ui.DeletableItemList}
+ */
+ function IgnoredHandlersListItem(entry) {
+ var el = cr.doc.createElement('div');
+ el.dataItem = entry;
+ el.__proto__ = IgnoredHandlersListItem.prototype;
+ el.decorate();
+ return el;
+ }
+
+ IgnoredHandlersListItem.prototype = {
+ __proto__: DeletableItem.prototype,
+
+ /** @inheritDoc */
+ decorate: function() {
+ DeletableItem.prototype.decorate.call(this);
+
+ // Protocol.
+ var protocolElement = document.createElement('div');
+ protocolElement.textContent = this.dataItem[0];
+ protocolElement.className = 'handlers-type-column';
+ this.contentElement_.appendChild(protocolElement);
+
+ // Site title.
+ var titleElement = document.createElement('div');
+ titleElement.textContent = this.dataItem[2];
+ titleElement.className = 'handlers-site-column';
+ titleElement.title = this.dataItem[1];
+ this.contentElement_.appendChild(titleElement);
+ },
+ };
+
+
+ var IgnoredHandlersList = cr.ui.define('list');
+
+ IgnoredHandlersList.prototype = {
+ __proto__: DeletableItemList.prototype,
+
+ createItem: function(entry) {
+ return new IgnoredHandlersListItem(entry);
+ },
+
+ deleteItemAtIndex: function(index) {
+ chrome.send('removeIgnoredHandler', [this.dataModel.item(index)]);
+ },
+
+ /**
+ * The length of the list.
+ */
+ get length() {
+ return this.dataModel.length;
+ },
+
+ /**
+ * Set the protocol handlers displayed by this list. See
+ * IgnoredHandlersListItem for an example of the format the list should
+ * take.
+ *
+ * @param {Object} list A list of ignored protocol handlers.
+ */
+ setHandlers: function(list) {
+ this.dataModel = new ArrayDataModel(list);
+ },
+ };
+
+
+
+ /**
* Creates a new protocol / content handler list item.
*
* Accepts values in the form
* { protocol: 'mailto',
* handlers: [
- * ['http://www.thesite.com/%s', 'The title of the protocol'],
+ * ['mailto', 'http://www.thesite.com/%s', 'The title of the protocol'],
* ...,
* ],
* }
@@ -30,7 +107,6 @@ cr.define('options', function() {
el.dataItem = entry;
el.__proto__ = HandlerListItem.prototype;
el.decorate();
-
return el;
}
@@ -57,7 +133,7 @@ cr.define('options', function() {
for (var i = 0; i < data.handlers.length; ++i) {
var optionElement = document.createElement('option');
optionElement.selected = i == data.default_handler;
- optionElement.textContent = data.handlers[i][1];
+ optionElement.textContent = data.handlers[i][2];
optionElement.value = i;
selectElement.appendChild(optionElement);
}
@@ -69,7 +145,7 @@ cr.define('options', function() {
delegate.clearDefault(data.protocol);
} else {
handlerElement.classList.remove('none');
- delegate.setDefault([data.protocol].concat(data.handlers[index]));
+ delegate.setDefault(data.handlers[index]);
}
});
handlerElement.appendChild(selectElement);
@@ -84,8 +160,7 @@ cr.define('options', function() {
localStrings.getString('handlers_remove_link');
removeElement.addEventListener('click', function (e) {
var value = selectElement ? selectElement.value : 0;
- delegate.removeHandler(value,
- [data.protocol].concat(data.handlers[value]));
+ delegate.removeHandler(value, data.handlers[value]);
});
removeElement.className = 'handlers-remove-column handlers-remove-link';
this.appendChild(removeElement);
@@ -146,6 +221,8 @@ cr.define('options', function() {
};
return {
+ IgnoredHandlersListItem: IgnoredHandlersListItem,
+ IgnoredHandlersList: IgnoredHandlersList,
HandlerListItem: HandlerListItem,
HandlersList: HandlersList,
};
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index 0487089..3f05b60 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -558,7 +558,8 @@ void TabContentsWrapper::OnRegisterProtocolHandler(const std::string& protocol,
ProtocolHandler::CreateProtocolHandler(protocol, url, title);
ProtocolHandlerRegistry* registry = profile()->GetProtocolHandlerRegistry();
- if (!registry->enabled() || registry->IsRegistered(handler))
+ if (!registry->enabled() || registry->IsRegistered(handler) ||
+ registry->IsIgnored(handler))
return;
if (!handler.IsEmpty() &&
diff --git a/chrome/browser/ui/webui/options/handler_options_handler.cc b/chrome/browser/ui/webui/options/handler_options_handler.cc
index 04c44cb..ff2f4e1 100644
--- a/chrome/browser/ui/webui/options/handler_options_handler.cc
+++ b/chrome/browser/ui/webui/options/handler_options_handler.cc
@@ -33,6 +33,7 @@ void HandlerOptionsHandler::GetLocalizedValues(
{ "handlers_site_column_header", IDS_HANDLERS_SITE_COLUMN_HEADER },
{ "handlers_remove_link", IDS_HANDLERS_REMOVE_HANDLER_LINK },
{ "handlers_none_handler", IDS_HANDLERS_NONE_HANDLER },
+ { "handlers_ignored_heading", IDS_HANDLERS_IGNORED_HEADING },
};
RegisterTitle(localized_strings, "handlersPage",
IDS_HANDLER_OPTIONS_WINDOW_TITLE);
@@ -56,6 +57,8 @@ void HandlerOptionsHandler::RegisterMessages() {
NewCallback(this, &HandlerOptionsHandler::SetHandlersEnabled));
web_ui_->RegisterMessageCallback("setDefault",
NewCallback(this, &HandlerOptionsHandler::SetDefault));
+ web_ui_->RegisterMessageCallback("removeIgnoredHandler",
+ NewCallback(this, &HandlerOptionsHandler::RemoveIgnoredHandler));
}
ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() {
@@ -63,26 +66,37 @@ ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() {
return web_ui_->GetProfile()->GetProtocolHandlerRegistry();
}
-DictionaryValue* HandlerOptionsHandler::GetHandlersForProtocol(
- const std::string& protocol) {
- ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry();
- DictionaryValue* handlers_value = new DictionaryValue();
- handlers_value->SetString("protocol", protocol);
- handlers_value->SetInteger("default_handler",
- registry->GetHandlerIndex(protocol));
-
- ListValue* handler_list = new ListValue();
- ProtocolHandlerRegistry::ProtocolHandlerList handlers =
- registry->GetHandlersFor(protocol);
+static void GetHandlersAsListValue(
+ const ProtocolHandlerRegistry::ProtocolHandlerList& handlers,
+ ListValue* handler_list) {
ProtocolHandlerRegistry::ProtocolHandlerList::const_iterator handler;
for (handler = handlers.begin(); handler != handlers.end(); ++handler) {
ListValue* handlerValue = new ListValue();
+ handlerValue->Append(Value::CreateStringValue(handler->protocol()));
handlerValue->Append(Value::CreateStringValue(handler->url().spec()));
handlerValue->Append(Value::CreateStringValue(handler->title()));
handler_list->Append(handlerValue);
}
- handlers_value->Set("handlers", handler_list);
- return handlers_value;
+}
+
+void HandlerOptionsHandler::GetHandlersForProtocol(
+ const std::string& protocol,
+ DictionaryValue* handlers_value) {
+ ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry();
+ handlers_value->SetString("protocol", protocol);
+ handlers_value->SetInteger("default_handler",
+ registry->GetHandlerIndex(protocol));
+
+ ListValue* handlers_list = new ListValue();
+ GetHandlersAsListValue(registry->GetHandlersFor(protocol), handlers_list);
+ handlers_value->Set("handlers", handlers_list);
+}
+
+void HandlerOptionsHandler::GetIgnoredHandlers(ListValue* handlers) {
+ ProtocolHandlerRegistry* registry = GetProtocolHandlerRegistry();
+ ProtocolHandlerRegistry::ProtocolHandlerList ignored_handlers =
+ registry->GetIgnoredHandlers();
+ return GetHandlersAsListValue(ignored_handlers, handlers);
}
void HandlerOptionsHandler::UpdateHandlerList() {
@@ -94,10 +108,16 @@ void HandlerOptionsHandler::UpdateHandlerList() {
ListValue handlers;
for (std::vector<std::string>::iterator protocol = protocols.begin();
protocol != protocols.end(); protocol++) {
- handlers.Append(GetHandlersForProtocol(*protocol));
+ DictionaryValue* handler_value = new DictionaryValue();
+ GetHandlersForProtocol(*protocol, handler_value);
+ handlers.Append(handler_value);
}
+ scoped_ptr<ListValue> ignored_handlers(new ListValue());
+ GetIgnoredHandlers(ignored_handlers.get());
web_ui_->CallJavascriptFunction("HandlerOptions.setHandlers", handlers);
+ web_ui_->CallJavascriptFunction("HandlerOptions.setIgnoredHandlers",
+ *ignored_handlers);
#endif // defined(ENABLE_REGISTER_PROTOCOL_HANDLER)
}
@@ -116,6 +136,17 @@ void HandlerOptionsHandler::RemoveHandler(const ListValue* args) {
// then.
}
+void HandlerOptionsHandler::RemoveIgnoredHandler(const ListValue* args) {
+ ListValue* list;
+ if (!args->GetList(0, &list)) {
+ NOTREACHED();
+ return;
+ }
+
+ ProtocolHandler handler(ParseHandlerFromArgs(list));
+ GetProtocolHandlerRegistry()->RemoveIgnoredHandler(handler);
+}
+
void HandlerOptionsHandler::SetHandlersEnabled(const ListValue* args) {
bool enabled = true;
CHECK(args->GetBoolean(0, &enabled));
diff --git a/chrome/browser/ui/webui/options/handler_options_handler.h b/chrome/browser/ui/webui/options/handler_options_handler.h
index f0ab822..33132b1 100644
--- a/chrome/browser/ui/webui/options/handler_options_handler.h
+++ b/chrome/browser/ui/webui/options/handler_options_handler.h
@@ -48,7 +48,11 @@ class HandlerOptionsHandler : public OptionsPageUIHandler {
// Returns a JSON object describing the set of protocol handlers for the
// given protocol.
- base::DictionaryValue* GetHandlersForProtocol(const std::string& protocol);
+ void GetHandlersForProtocol(const std::string& protocol,
+ base::DictionaryValue* value);
+
+ // Returns a JSON list of the ignored protocol handlers.
+ void GetIgnoredHandlers(ListValue* handlers);
// Called when the JS PasswordManager object is initialized.
void UpdateHandlerList();
@@ -57,6 +61,10 @@ class HandlerOptionsHandler : public OptionsPageUIHandler {
// |args| is a list of [protocol, url, title].
void RemoveHandler(const ListValue* args);
+ // Remove an ignored handler.
+ // |args| is a list of [protocol, url, title].
+ void RemoveIgnoredHandler(const ListValue* args);
+
ProtocolHandlerRegistry* GetProtocolHandlerRegistry();
NotificationRegistrar notification_registrar_;