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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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.h" 9 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h"
15 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
16 11
17 using content::NavigationEntry;
18 12
19 // InfoBarDelegate ------------------------------------------------------------ 13 // InfoBarDelegate ------------------------------------------------------------
20 14
21 const int InfoBarDelegate::kNoIconID = 0; 15 const int InfoBarDelegate::kNoIconID = 0;
22 16
23 InfoBarDelegate::~InfoBarDelegate() { 17 InfoBarDelegate::~InfoBarDelegate() {
24 } 18 }
25 19
26 InfoBarDelegate::InfoBarAutomationType 20 InfoBarDelegate::InfoBarAutomationType
27 InfoBarDelegate::GetInfoBarAutomationType() const { 21 InfoBarDelegate::GetInfoBarAutomationType() const {
28 return UNKNOWN_INFOBAR; 22 return UNKNOWN_INFOBAR;
29 } 23 }
30 24
31 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { 25 bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
32 return false; 26 return false;
33 } 27 }
34 28
35 bool InfoBarDelegate::ShouldExpire( 29 bool InfoBarDelegate::ShouldExpire(const NavigationDetails& details) const {
36 const content::LoadCommittedDetails& details) const { 30 if (!details.is_navigation_to_different_page)
37 if (!details.is_navigation_to_different_page())
38 return false; 31 return false;
39 32
40 return ShouldExpireInternal(details); 33 return ShouldExpireInternal(details);
41 } 34 }
42 35
43 void InfoBarDelegate::InfoBarDismissed() { 36 void InfoBarDelegate::InfoBarDismissed() {
44 } 37 }
45 38
46 int InfoBarDelegate::GetIconID() const { 39 int InfoBarDelegate::GetIconID() const {
47 return kNoIconID; 40 return kNoIconID;
48 } 41 }
49 42
50 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { 43 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
51 return WARNING_TYPE; 44 return WARNING_TYPE;
52 } 45 }
53 46
47 void InfoBarDelegate::CleanUp() {}
droger 2014/03/18 15:59:53 The default implementation of CleanUp does nothing
48
54 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() { 49 AutoLoginInfoBarDelegate* InfoBarDelegate::AsAutoLoginInfoBarDelegate() {
55 return NULL; 50 return NULL;
56 } 51 }
57 52
58 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { 53 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
59 return NULL; 54 return NULL;
60 } 55 }
61 56
62 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() { 57 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
63 return NULL; 58 return NULL;
(...skipping 28 matching lines...) Expand all
92 } 87 }
93 88
94 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() { 89 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
95 return NULL; 90 return NULL;
96 } 91 }
97 92
98 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { 93 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
99 return NULL; 94 return NULL;
100 } 95 }
101 96
102 void InfoBarDelegate::StoreActiveEntryUniqueID() { 97 void InfoBarDelegate::StoreActiveEntryUniqueID(int entry_id) {
103 DCHECK(web_contents()); 98 contents_unique_id_ = entry_id;
104 NavigationEntry* active_entry =
105 web_contents()->GetController().GetActiveEntry();
106 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
107 } 99 }
108 100
109 gfx::Image InfoBarDelegate::GetIcon() const { 101 gfx::Image InfoBarDelegate::GetIcon() const {
110 int icon_id = GetIconID(); 102 int icon_id = GetIconID();
111 return (icon_id == kNoIconID) ? gfx::Image() : 103 return (icon_id == kNoIconID) ? gfx::Image() :
112 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); 104 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
113 } 105 }
114 106
115 content::WebContents* InfoBarDelegate::web_contents() {
116 return (infobar_ && infobar_->owner()) ?
117 infobar_->owner()->web_contents() : NULL;
118 }
119
120 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { 107 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
121 } 108 }
122 109
123 bool InfoBarDelegate::ShouldExpireInternal( 110 bool InfoBarDelegate::ShouldExpireInternal(
124 const content::LoadCommittedDetails& details) const { 111 const NavigationDetails& details) const {
125 // NOTE: If you change this, be sure to check and adjust the behavior of 112 // NOTE: If you change this, be sure to check and adjust the behavior of
126 // anyone who overrides this as necessary! 113 // anyone who overrides this as necessary!
127 return (contents_unique_id_ != details.entry->GetUniqueID()) || 114 return (contents_unique_id_ != details.entry_id) || details.is_reload;
128 (content::PageTransitionStripQualifier(
129 details.entry->GetTransitionType()) ==
130 content::PAGE_TRANSITION_RELOAD);
131 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698