Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_disabled_infobar_delegate.h" | 5 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 const NotificationSource& source, | 151 const NotificationSource& source, |
| 152 const NotificationDetails& details) { | 152 const NotificationDetails& details) { |
| 153 // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting | 153 // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting |
| 154 // deleted. | 154 // deleted. |
| 155 const Extension* extension; | 155 const Extension* extension; |
| 156 if (type.value == NotificationType::EXTENSION_LOADED) { | 156 if (type.value == NotificationType::EXTENSION_LOADED) { |
| 157 extension = Details<const Extension>(details).ptr(); | 157 extension = Details<const Extension>(details).ptr(); |
| 158 } else { | 158 } else { |
| 159 DCHECK_EQ(NotificationType::EXTENSION_UNLOADED, type.value); | 159 DCHECK_EQ(NotificationType::EXTENSION_UNLOADED, type.value); |
| 160 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr(); | 160 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr(); |
| 161 extension = (info->reason == UnloadedExtensionInfo::DISABLE) ? | 161 if (info->reason == UnloadedExtensionInfo::DISABLE || |
|
Mihai Parparita -not on Chrome
2011/06/08 23:20:44
Won't this leave extension uninitialized if it's n
| |
| 162 info->extension : NULL; | 162 info->reason == UnloadedExtensionInfo::UNINSTALL) |
| 163 extension = info->extension; | |
| 163 } | 164 } |
| 164 if (extension == extension_) | 165 if (extension == extension_) |
| 165 tab_contents_->RemoveInfoBar(this); | 166 tab_contents_->RemoveInfoBar(this); |
| 166 } | 167 } |
| 167 | 168 |
| 168 | 169 |
| 169 // Globals -------------------------------------------------------------------- | 170 // Globals -------------------------------------------------------------------- |
| 170 | 171 |
| 171 void ShowExtensionDisabledUI(ExtensionService* service, Profile* profile, | 172 void ShowExtensionDisabledUI(ExtensionService* service, Profile* profile, |
| 172 const Extension* extension) { | 173 const Extension* extension) { |
| 173 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 174 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
| 174 if (!browser) | 175 if (!browser) |
| 175 return; | 176 return; |
| 176 | 177 |
| 177 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); | 178 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); |
| 178 if (!tab_contents) | 179 if (!tab_contents) |
| 179 return; | 180 return; |
| 180 | 181 |
| 181 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( | 182 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( |
| 182 tab_contents, service, extension)); | 183 tab_contents, service, extension)); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, | 186 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, |
| 186 const Extension* extension) { | 187 const Extension* extension) { |
| 187 // This object manages its own lifetime. | 188 // This object manages its own lifetime. |
| 188 new ExtensionDisabledDialogDelegate(profile, service, extension); | 189 new ExtensionDisabledDialogDelegate(profile, service, extension); |
| 189 } | 190 } |
| OLD | NEW |