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

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: Responded to comments, prevents rph on privileged protocols. 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 "base/metrics/histogram.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autofill/autofill_cc_infobar.h"
10 #include "chrome/browser/autofill/autofill_manager.h"
11 #include "chrome/browser/browser_list.h"
12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/tab_contents/tab_contents.h"
15 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
16 #include "chrome/common/pref_names.h"
17 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h"
20 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.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 ProtocolHandler* old_handler = registry_->GetHandlerFor(handler_->protocol());
46 if (old_handler) {
47 return l10n_util::GetStringFUTF16(
48 IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, handler_->title(),
49 UTF8ToUTF16(handler_->protocol()), old_handler->title());
50 }
51 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
52 handler_->title(), UTF8ToUTF16(handler_->protocol()));
53 }
54
55 SkBitmap* RegisterProtocolHandlerInfoBarDelegate::GetIcon() const {
56 return NULL;
57 }
58
59 int RegisterProtocolHandlerInfoBarDelegate::GetButtons() const {
60 return BUTTON_OK | BUTTON_CANCEL;
61 }
62
63 string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
64 ConfirmInfoBarDelegate::InfoBarButton button) const {
65 if (button == BUTTON_OK)
jam 2011/02/15 18:48:39 need brace brackets for this block of code per goo
koz (OOO until 15th September) 2011/02/16 03:37:48 Done.
66 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT,
67 handler_->title());
68 else if (button == BUTTON_CANCEL)
69 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
70 else
71 NOTREACHED();
72
73 return string16();
74 }
75
76 bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
77 registry_->OnAcceptRegisterProtocolHandler(handler_);
78 return true;
79 }
80
81 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
82 registry_->OnDenyRegisterProtocolHandler(handler_);
83 return true;
84 }
85
86 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() {
87 // TODO(koz): Make this a 'learn more' link.
88 return string16();
89 }
90
91 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
92 WindowOpenDisposition disposition) {
93 return false;
94 }
95
96 InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() {
97 return PAGE_ACTION_TYPE;
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698