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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 1627024: Add ExtensionFunctionDispatcher::Delegate::GetAssociatedTabContents (Closed)
Patch Set: cr changes Created 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index f575ba2c12cab079b51ec9298f956fede26ccb50..17058af3df0f138fdde2094a80a1b595c681cc98 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -622,40 +622,11 @@ bool GetTabFunction::RunImpl() {
}
bool GetCurrentTabFunction::RunImpl() {
- DCHECK(dispatcher() && dispatcher()->render_view_host());
+ DCHECK(dispatcher());
- RenderViewHostDelegate* rvh_delegate =
- dispatcher()->render_view_host()->delegate();
-
- TabContents* contents = rvh_delegate->GetAsTabContents();
- if (contents) {
- // Caller is running inside a TabContents.
+ TabContents* contents = dispatcher()->delegate()->associated_tab_contents();
+ if (contents)
result_.reset(ExtensionTabUtil::CreateTabValue(contents));
- return true;
- }
-
- ExtensionHost* host = reinterpret_cast<ExtensionHost*>(rvh_delegate);
- Browser* browser = GetCurrentBrowser();
- if (browser && ViewType::EXTENSION_INFOBAR == host->extension_host_type()) {
- // Unfortunately, now we have to iterate over each TabContents and each
- // Infobar to try to find the one corresponding to this ExtensionHost.
- TabStripModel* tab_strip = browser->tabstrip_model();
- int tab_count = tab_strip->count();
- for (int tab_index = 0; tab_index < tab_count; ++tab_index) {
- contents = tab_strip->GetTabContentsAt(tab_index);
- int infobar_count = contents->infobar_delegate_count();
- for (int infobar_index = 0; infobar_index < infobar_count;
- ++infobar_index) {
- ExtensionInfoBarDelegate* infobar_delegate =
- contents->GetInfoBarDelegateAt(infobar_index)
- ->AsExtensionInfoBarDelegate();
- if (infobar_delegate && infobar_delegate->extension_host() == host) {
- result_.reset(ExtensionTabUtil::CreateTabValue(contents));
- return true;
- }
- }
- }
- }
return true;
}
« no previous file with comments | « chrome/browser/extensions/extension_infobar_delegate.cc ('k') | chrome/browser/notifications/balloon_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698