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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
6
7 #include "ui/base/l10n/l10n_util.h"
8 #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.
9 #include "base/metrics/histogram.h"
10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/autofill/autofill_cc_infobar.h"
12 #include "chrome/browser/autofill/autofill_manager.h"
13 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tab_contents/tab_contents.h"
17 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
18 #include "chrome/common/pref_names.h"
19 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
23
24 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
25 TabContents* tab_contents, ProtocolHandlerRegistry* registry,
26 ProtocolHandler* handler)
27 : ConfirmInfoBarDelegate(tab_contents),
28 registry_(registry),
29 handler_(handler) {
30 }
31
32 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire(
33 const NavigationController::LoadCommittedDetails& details) const {
34 // The user has submitted a form, causing the page to navigate elsewhere. We
35 // don't want the infobar to be expired at this point, because the user won't
36 // get a chance to answer the question.
37 return false;
38 }
39
40 void RegisterProtocolHandlerInfoBarDelegate::InfoBarClosed() {
41 delete this;
42 }
43
44 string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const {
45 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
46 UTF8ToUTF16(handler_->title()), UTF8ToUTF16(handler_->protocol()));
47 }
48
49 SkBitmap* RegisterProtocolHandlerInfoBarDelegate::GetIcon() const {
50 return NULL;
51 // return ResourceBundle::GetSharedInstance().GetBitmapNamed(
52 // IDR_INFOBAR_AUTOFILL);
tony 2011/02/07 20:51:45 dead code
koz (OOO until 15th September) 2011/02/13 22:33:48 Done.
53 }
54
55 int RegisterProtocolHandlerInfoBarDelegate::GetButtons() const {
56 return BUTTON_OK | BUTTON_CANCEL;
57 }
58
59 string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
60 ConfirmInfoBarDelegate::InfoBarButton button) const {
61 if (button == BUTTON_OK)
62 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT);
63 else if (button == BUTTON_CANCEL)
64 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
65 else
66 NOTREACHED();
67
68 return string16();
69 }
70
71 bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
72 registry_->OnAcceptRegisterProtocolHandler(handler_);
73 return true;
74 }
75
76 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
77 registry_->OnDenyRegisterProtocolHandler(handler_);
78 return true;
79 }
80
81 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() {
82 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_LEARN_MORE);
83 }
84
85 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(WindowOpenDisposition d isposition) {
86 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.
87 return false;
88 }
89
90 InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() {
91 return PAGE_ACTION_TYPE;
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698