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

Side by Side Diff: trunk/src/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 5 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
9 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/user_metrics.h" 11 #include "content/public/browser/user_metrics.h"
13 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
14 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
16 15
17 // static 16 // static
18 void RegisterProtocolHandlerInfoBarDelegate::Create( 17 void RegisterProtocolHandlerInfoBarDelegate::Create(
19 InfoBarService* infobar_service, 18 InfoBarService* infobar_service,
20 ProtocolHandlerRegistry* registry, 19 ProtocolHandlerRegistry* registry,
21 const ProtocolHandler& handler) { 20 const ProtocolHandler& handler) {
22 content::RecordAction( 21 content::RecordAction(
23 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 22 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
24 23
25 scoped_ptr<InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( 24 scoped_ptr<InfoBarDelegate> infobar(
26 scoped_ptr<ConfirmInfoBarDelegate>( 25 new RegisterProtocolHandlerInfoBarDelegate(infobar_service, registry,
27 new RegisterProtocolHandlerInfoBarDelegate(registry, handler)))); 26 handler));
28 27
29 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { 28 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
30 InfoBar* existing_infobar = infobar_service->infobar_at(i);
31 RegisterProtocolHandlerInfoBarDelegate* existing_delegate = 29 RegisterProtocolHandlerInfoBarDelegate* existing_delegate =
32 existing_infobar->delegate()-> 30 infobar_service->infobar_at(i)->
33 AsRegisterProtocolHandlerInfoBarDelegate(); 31 AsRegisterProtocolHandlerInfoBarDelegate();
34 if ((existing_delegate != NULL) && 32 if ((existing_delegate != NULL) &&
35 existing_delegate->handler_.IsEquivalent(handler)) { 33 existing_delegate->handler_.IsEquivalent(handler)) {
36 infobar_service->ReplaceInfoBar(existing_infobar, infobar.Pass()); 34 infobar_service->ReplaceInfoBar(existing_delegate, infobar.Pass());
37 return; 35 return;
38 } 36 }
39 } 37 }
40 38
41 infobar_service->AddInfoBar(infobar.Pass()); 39 infobar_service->AddInfoBar(infobar.Pass());
42 } 40 }
43 41
44 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( 42 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
43 InfoBarService* infobar_service,
45 ProtocolHandlerRegistry* registry, 44 ProtocolHandlerRegistry* registry,
46 const ProtocolHandler& handler) 45 const ProtocolHandler& handler)
47 : ConfirmInfoBarDelegate(), 46 : ConfirmInfoBarDelegate(infobar_service),
48 registry_(registry), 47 registry_(registry),
49 handler_(handler) { 48 handler_(handler) {
50 } 49 }
51 50
52 RegisterProtocolHandlerInfoBarDelegate:: 51 RegisterProtocolHandlerInfoBarDelegate::
53 ~RegisterProtocolHandlerInfoBarDelegate() { 52 ~RegisterProtocolHandlerInfoBarDelegate() {
54 } 53 }
55 54
56 InfoBarDelegate::InfoBarAutomationType 55 InfoBarDelegate::InfoBarAutomationType
57 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarAutomationType() const { 56 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarAutomationType() const {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 122 }
124 123
125 string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName( 124 string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName(
126 const ProtocolHandler& handler) const { 125 const ProtocolHandler& handler) const {
127 if (handler.protocol() == "mailto") 126 if (handler.protocol() == "mailto")
128 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); 127 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME);
129 if (handler.protocol() == "webcal") 128 if (handler.protocol() == "webcal")
130 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); 129 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME);
131 return UTF8ToUTF16(handler.protocol()); 130 return UTF8ToUTF16(handler.protocol());
132 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698