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

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: 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..48a59f0e831bcea9d9d437e506e87a83b3781bcc
--- /dev/null
+++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc
@@ -0,0 +1,92 @@
+// 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 "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
tony 2011/02/07 20:51:45 Sort these
koz (OOO until 15th September) 2011/02/13 22:33:48 Done.
+#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"
+
+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 {
+ return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
+ UTF8ToUTF16(handler_->title()), UTF8ToUTF16(handler_->protocol()));
+}
+
+SkBitmap* RegisterProtocolHandlerInfoBarDelegate::GetIcon() const {
+ return NULL;
+// return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+// IDR_INFOBAR_AUTOFILL);
tony 2011/02/07 20:51:45 dead code
koz (OOO until 15th September) 2011/02/13 22:33:48 Done.
+}
+
+int RegisterProtocolHandlerInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
+ ConfirmInfoBarDelegate::InfoBarButton button) const {
+ if (button == BUTTON_OK)
+ return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT);
+ 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 l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_LEARN_MORE);
+}
+
+bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
+ printf("Clicked the link!\n");
tony 2011/02/07 20:51:45 debug code
koz (OOO until 15th September) 2011/02/13 22:33:48 Done.
+ return false;
+}
+
+InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() {
+ return PAGE_ACTION_TYPE;
+}

Powered by Google App Engine
This is Rietveld 408576698