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

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

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes Created 6 years, 8 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
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" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 16
17 namespace {
18 content::WebContents* WebContentsFromInfoBar(InfoBar* infobar) {
droger 2014/04/08 12:11:00 The plan would be to make this helper function pub
19 if (!infobar || !infobar->owner())
20 return NULL;
21
22 InfoBarService* infobar_service =
23 static_cast<InfoBarService*>(infobar->owner());
24 return infobar_service->web_contents();
25 }
26 } // namespace
27
17 using content::NavigationEntry; 28 using content::NavigationEntry;
18 29
19 // InfoBarDelegate ------------------------------------------------------------ 30 // InfoBarDelegate ------------------------------------------------------------
20 31
21 const int InfoBarDelegate::kNoIconID = 0; 32 const int InfoBarDelegate::kNoIconID = 0;
22 33
23 InfoBarDelegate::~InfoBarDelegate() { 34 InfoBarDelegate::~InfoBarDelegate() {
24 } 35 }
25 36
26 InfoBarDelegate::InfoBarAutomationType 37 InfoBarDelegate::InfoBarAutomationType
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; 112 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0;
102 } 113 }
103 114
104 gfx::Image InfoBarDelegate::GetIcon() const { 115 gfx::Image InfoBarDelegate::GetIcon() const {
105 int icon_id = GetIconID(); 116 int icon_id = GetIconID();
106 return (icon_id == kNoIconID) ? gfx::Image() : 117 return (icon_id == kNoIconID) ? gfx::Image() :
107 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); 118 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id);
108 } 119 }
109 120
110 content::WebContents* InfoBarDelegate::web_contents() { 121 content::WebContents* InfoBarDelegate::web_contents() {
111 return (infobar_ && infobar_->owner()) ? 122 return WebContentsFromInfoBar(infobar_);
112 infobar_->owner()->web_contents() : NULL;
113 } 123 }
114 124
115 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { 125 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) {
116 } 126 }
117 127
118 bool InfoBarDelegate::ShouldExpireInternal( 128 bool InfoBarDelegate::ShouldExpireInternal(
119 const NavigationDetails& details) const { 129 const NavigationDetails& details) const {
120 // NOTE: If you change this, be sure to check and adjust the behavior of 130 // NOTE: If you change this, be sure to check and adjust the behavior of
121 // anyone who overrides this as necessary! 131 // anyone who overrides this as necessary!
122 return (contents_unique_id_ != details.entry_id) || details.is_reload; 132 return (contents_unique_id_ != details.entry_id) || details.is_reload;
123 } 133 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/infobars/infobar_manager.h » ('j') | chrome/browser/infobars/infobar_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698