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

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. 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) {
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
74 return string16();
75 }
76
77 bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
78 registry_->OnAcceptRegisterProtocolHandler(handler_);
79 return true;
80 }
81
82 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
83 registry_->OnDenyRegisterProtocolHandler(handler_);
84 return true;
85 }
86
87 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() {
88 // TODO(koz): Make this a 'learn more' link.
89 return string16();
90 }
91
92 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
93 WindowOpenDisposition disposition) {
94 return false;
95 }
96
97 InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() {
98 return PAGE_ACTION_TYPE;
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698