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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.h ('k') | chrome/browser/infobars/infobar_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
10 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
12 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 16
16 using content::NavigationEntry; 17 using content::NavigationEntry;
17 18
18 // InfoBarDelegate ------------------------------------------------------------ 19 // InfoBarDelegate ------------------------------------------------------------
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 92 }
92 93
93 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() { 94 ThreeDAPIInfoBarDelegate* InfoBarDelegate::AsThreeDAPIInfoBarDelegate() {
94 return NULL; 95 return NULL;
95 } 96 }
96 97
97 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { 98 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
98 return NULL; 99 return NULL;
99 } 100 }
100 101
102 void InfoBarDelegate::StoreActiveEntryUniqueID() {
103 DCHECK(web_contents());
104 NavigationEntry* active_entry =
105 web_contents()->GetController().GetActiveEntry();
106 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
107 }
108
101 gfx::Image InfoBarDelegate::GetIcon() const { 109 gfx::Image InfoBarDelegate::GetIcon() const {
102 int icon_id = GetIconID(); 110 int icon_id = GetIconID();
103 return (icon_id == kNoIconID) ? gfx::Image() : 111 return (icon_id == kNoIconID) ? gfx::Image() :
104 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); 112 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
105 } 113 }
106 114
107 InfoBarDelegate::InfoBarDelegate(InfoBarService* owner) 115 content::WebContents* InfoBarDelegate::web_contents() {
108 : contents_unique_id_(0), 116 return (infobar_ && infobar_->owner()) ?
109 owner_(owner) { 117 infobar_->owner()->web_contents() : NULL;
110 if (owner_)
111 StoreActiveEntryUniqueID();
112 } 118 }
113 119
114 void InfoBarDelegate::StoreActiveEntryUniqueID() { 120 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
115 DCHECK(web_contents());
116 NavigationEntry* active_entry =
117 web_contents()->GetController().GetActiveEntry();
118 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
119 } 121 }
120 122
121 bool InfoBarDelegate::ShouldExpireInternal( 123 bool InfoBarDelegate::ShouldExpireInternal(
122 const content::LoadCommittedDetails& details) const { 124 const content::LoadCommittedDetails& details) const {
123 // NOTE: If you change this, be sure to check and adjust the behavior of 125 // NOTE: If you change this, be sure to check and adjust the behavior of
124 // anyone who overrides this as necessary! 126 // anyone who overrides this as necessary!
125 return (contents_unique_id_ != details.entry->GetUniqueID()) || 127 return (contents_unique_id_ != details.entry->GetUniqueID()) ||
126 (content::PageTransitionStripQualifier( 128 (content::PageTransitionStripQualifier(
127 details.entry->GetTransitionType()) == 129 details.entry->GetTransitionType()) ==
128 content::PAGE_TRANSITION_RELOAD); 130 content::PAGE_TRANSITION_RELOAD);
129 } 131 }
130
131 void InfoBarDelegate::RemoveSelf() {
132 if (owner_)
133 owner_->RemoveInfoBar(this); // Clears |owner_|.
134 }
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.h ('k') | chrome/browser/infobars/infobar_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698