| OLD | NEW |
| 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_manager.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" | 11 #include "ui/base/resource/resource_bundle.h" |
| 16 | 12 |
| 17 using content::NavigationEntry; | |
| 18 | |
| 19 // InfoBarDelegate ------------------------------------------------------------ | |
| 20 | |
| 21 const int InfoBarDelegate::kNoIconID = 0; | 13 const int InfoBarDelegate::kNoIconID = 0; |
| 22 | 14 |
| 23 InfoBarDelegate::~InfoBarDelegate() { | 15 InfoBarDelegate::~InfoBarDelegate() { |
| 24 } | 16 } |
| 25 | 17 |
| 26 InfoBarDelegate::InfoBarAutomationType | 18 InfoBarDelegate::InfoBarAutomationType |
| 27 InfoBarDelegate::GetInfoBarAutomationType() const { | 19 InfoBarDelegate::GetInfoBarAutomationType() const { |
| 28 return UNKNOWN_INFOBAR; | 20 return UNKNOWN_INFOBAR; |
| 29 } | 21 } |
| 30 | 22 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ThemeInstalledInfoBarDelegate* | 80 ThemeInstalledInfoBarDelegate* |
| 89 InfoBarDelegate::AsThemePreviewInfobarDelegate() { | 81 InfoBarDelegate::AsThemePreviewInfobarDelegate() { |
| 90 return NULL; | 82 return NULL; |
| 91 } | 83 } |
| 92 | 84 |
| 93 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { | 85 TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() { |
| 94 return NULL; | 86 return NULL; |
| 95 } | 87 } |
| 96 | 88 |
| 97 void InfoBarDelegate::StoreActiveEntryUniqueID() { | 89 void InfoBarDelegate::StoreActiveEntryUniqueID() { |
| 98 // TODO(droger): Remove this dependency on InfoBarService, see | 90 contents_unique_id_ = infobar()->owner()->GetActiveEntryID(); |
| 99 // http://crbug.com/354379. | |
| 100 content::WebContents* web_contents = | |
| 101 InfoBarService::WebContentsFromInfoBar(infobar()); | |
| 102 DCHECK(web_contents); | |
| 103 NavigationEntry* active_entry = | |
| 104 web_contents->GetController().GetActiveEntry(); | |
| 105 contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; | |
| 106 } | 91 } |
| 107 | 92 |
| 108 gfx::Image InfoBarDelegate::GetIcon() const { | 93 gfx::Image InfoBarDelegate::GetIcon() const { |
| 109 int icon_id = GetIconID(); | 94 int icon_id = GetIconID(); |
| 110 return (icon_id == kNoIconID) ? gfx::Image() : | 95 return (icon_id == kNoIconID) ? gfx::Image() : |
| 111 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); | 96 ResourceBundle::GetSharedInstance().GetNativeImageNamed(icon_id); |
| 112 } | 97 } |
| 113 | 98 |
| 114 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { | 99 InfoBarDelegate::InfoBarDelegate() : contents_unique_id_(0) { |
| 115 } | 100 } |
| 116 | 101 |
| 117 bool InfoBarDelegate::ShouldExpireInternal( | 102 bool InfoBarDelegate::ShouldExpireInternal( |
| 118 const NavigationDetails& details) const { | 103 const NavigationDetails& details) const { |
| 119 // NOTE: If you change this, be sure to check and adjust the behavior of | 104 // NOTE: If you change this, be sure to check and adjust the behavior of |
| 120 // anyone who overrides this as necessary! | 105 // anyone who overrides this as necessary! |
| 121 return (contents_unique_id_ != details.entry_id) || details.is_reload; | 106 return (contents_unique_id_ != details.entry_id) || details.is_reload; |
| 122 } | 107 } |
| OLD | NEW |