Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2585)

Unified Diff: chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc

Issue 6410115: Adds navigator.registerProtocolHandler. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Responded to comments, simplified file format. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2fb6905d5e937b2d4df5e56797f4d1ccb280bac3
--- /dev/null
+++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
@@ -0,0 +1,95 @@
+// 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/custom_handlers/register_protocol_handler_infobar_delegate.h"
+
+#include "base/metrics/histogram.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/autofill/autofill_cc_infobar.h"
+#include "chrome/browser/autofill/autofill_manager.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+#include "chrome/common/pref_names.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+
+RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
+ TabContents* tab_contents, ProtocolHandlerRegistry* registry,
+ ProtocolHandler* handler)
+ : ConfirmInfoBarDelegate(tab_contents),
+ registry_(registry),
+ handler_(handler) {
+}
+
+bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ // The user has submitted a form, causing the page to navigate elsewhere. We
+ // don't want the infobar to be expired at this point, because the user won't
+ // get a chance to answer the question.
+ return false;
+}
+
+void RegisterProtocolHandlerInfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const {
+ ProtocolHandler* old_handler = registry_->GetHandlerFor(handler_->protocol());
+ if (old_handler) {
+ return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE,
+ handler_->title(), UTF8ToUTF16(handler_->protocol()), old_handler->title());
+ }
+ return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
+ handler_->title(), UTF8ToUTF16(handler_->protocol()));
+}
+
+SkBitmap* RegisterProtocolHandlerInfoBarDelegate::GetIcon() const {
+ return NULL;
+}
+
+int RegisterProtocolHandlerInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const {
+ if (button == BUTTON_OK)
+ return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT,
+ handler_->title());
+ else if (button == BUTTON_CANCEL)
+ return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
+ else
+ NOTREACHED();
+
+ return string16();
+}
+
+bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
+ registry_->OnAcceptRegisterProtocolHandler(handler_);
+ return true;
+}
+
+bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
+ registry_->OnDenyRegisterProtocolHandler(handler_);
+ return true;
+}
+
+string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() {
+ return string16();
tony 2011/02/14 23:40:07 We'll probably want a "Learn more" link for this f
koz (OOO until 15th September) 2011/02/15 03:37:27 Yep, true. Done.
+}
+
+bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
+ return false;
+}
+
+InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() {
+ return PAGE_ACTION_TYPE;
+}

Powered by Google App Engine
This is Rietveld 408576698