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

Side by Side Diff: chrome/browser/infobars/infobar_delegate.cc

Issue 15067008: [InfoBar] Add InfoBarDelegate::GetIconID() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit fixes redux Created 7 years, 7 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
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/infobars/infobar_delegate.h" 5 #include "chrome/browser/infobars/infobar_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
12 #include "content/public/browser/navigation_entry.h" 12 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "ui/base/resource/resource_bundle.h"
14 15
15 using content::NavigationEntry; 16 using content::NavigationEntry;
16 17
17 // InfoBarDelegate ------------------------------------------------------------ 18 // InfoBarDelegate ------------------------------------------------------------
18 19
20 const int InfoBarDelegate::kNoIconID = 0;
21
19 InfoBarDelegate::~InfoBarDelegate() { 22 InfoBarDelegate::~InfoBarDelegate() {
20 } 23 }
21 24
22 InfoBarDelegate::InfoBarAutomationType 25 InfoBarDelegate::InfoBarAutomationType
23 InfoBarDelegate::GetInfoBarAutomationType() const { 26 InfoBarDelegate::GetInfoBarAutomationType() const {
24 return UNKNOWN_INFOBAR; 27 return UNKNOWN_INFOBAR;
25 } 28 }
26 29
27 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { 30 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
28 return false; 31 return false;
29 } 32 }
30 33
31 bool InfoBarDelegate::ShouldExpire( 34 bool InfoBarDelegate::ShouldExpire(
32 const content::LoadCommittedDetails& details) const { 35 const content::LoadCommittedDetails& details) const {
33 if (!details.is_navigation_to_different_page()) 36 if (!details.is_navigation_to_different_page())
34 return false; 37 return false;
35 38
36 return ShouldExpireInternal(details); 39 return ShouldExpireInternal(details);
37 } 40 }
38 41
39 void InfoBarDelegate::InfoBarDismissed() { 42 void InfoBarDelegate::InfoBarDismissed() {
40 } 43 }
41 44
42 gfx::Image* InfoBarDelegate::GetIcon() const { 45 int InfoBarDelegate::GetIconID() const {
43 return NULL; 46 return kNoIconID;
44 } 47 }
45 48
46 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { 49 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
47 return WARNING_TYPE; 50 return WARNING_TYPE;
48 } 51 }
49 52
50 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() { 53 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
51 return NULL; 54 return NULL;
52 } 55 }
53 56
(...skipping 30 matching lines...) Expand all
84 } 87 }
85 88
86 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() { 89 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
87 return NULL; 90 return NULL;
88 } 91 }
89 92
90 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { 93 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
91 return NULL; 94 return NULL;
92 } 95 }
93 96
97 gfx::Image InfoBarDelegate::GetIcon() const {
98 int icon_id = GetIconID();
99 return (icon_id == kNoIconID) ? gfx::Image() :
100 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
101 }
102
94 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service) 103 InfoBarDelegate::InfoBarDelegate(InfoBarService* infobar_service)
95 : contents_unique_id_(0), 104 : contents_unique_id_(0),
96 owner_(infobar_service) { 105 owner_(infobar_service) {
97 if (infobar_service) 106 if (infobar_service)
98 StoreActiveEntryUniqueID(); 107 StoreActiveEntryUniqueID();
99 } 108 }
100 109
101 void InfoBarDelegate::StoreActiveEntryUniqueID() { 110 void InfoBarDelegate::StoreActiveEntryUniqueID() {
102 DCHECK(web_contents()); 111 DCHECK(web_contents());
103 NavigationEntry* active_entry = 112 NavigationEntry* active_entry =
104 web_contents()->GetController().GetActiveEntry(); 113 web_contents()->GetController().GetActiveEntry();
105 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; 114 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
106 } 115 }
107 116
108 bool InfoBarDelegate::ShouldExpireInternal( 117 bool InfoBarDelegate::ShouldExpireInternal(
109 const content::LoadCommittedDetails& details) const { 118 const content::LoadCommittedDetails& details) const {
110 // NOTE: If you change this, be sure to check and adjust the behavior of 119 // NOTE: If you change this, be sure to check and adjust the behavior of
111 // anyone who overrides this as necessary! 120 // anyone who overrides this as necessary!
112 return (contents_unique_id_ != details.entry->GetUniqueID()) || 121 return (contents_unique_id_ != details.entry->GetUniqueID()) ||
113 (content::PageTransitionStripQualifier( 122 (content::PageTransitionStripQualifier(
114 details.entry->GetTransitionType()) == 123 details.entry->GetTransitionType()) ==
115 content::PAGE_TRANSITION_RELOAD); 124 content::PAGE_TRANSITION_RELOAD);
116 } 125 }
117 126
118 void InfoBarDelegate::RemoveSelf() { 127 void InfoBarDelegate::RemoveSelf() {
119 if (owner_) 128 if (owner_)
120 owner_->RemoveInfoBar(this); // Clears |owner_|. 129 owner_->RemoveInfoBar(this); // Clears |owner_|.
121 } 130 }
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.h ('k') | chrome/browser/infobars/simple_alert_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698