summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_toolstrip_api.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:59:41 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:59:41 +0000
commit0ec9203dac6b11c664adda8a39b77f3f00eb6072 (patch)
tree65e5cff3f9e04da87e32e9436ddc795a7811c278 /chrome/browser/extensions/extension_toolstrip_api.cc
parent630d1b047c8c4ea54eef06fa24a89ad516457875 (diff)
downloadchromium_src-0ec9203dac6b11c664adda8a39b77f3f00eb6072.zip
chromium_src-0ec9203dac6b11c664adda8a39b77f3f00eb6072.tar.gz
chromium_src-0ec9203dac6b11c664adda8a39b77f3f00eb6072.tar.bz2
Generalize the ExtensionFunctionDispatcher::Delegate interface a bit more. In particular remove GetExtensionHost() and GetExtensionDOMUI(). I'm going to add a new type of EFD::Delegate soon that is neither of these, and I don't think it makes sense to have the code assume that EFD::Delegate must be one of the two of them.
Some code still does RTTI stuff through RenderViewHostDelegate::GetRenderViewType(), but in that case it is more clear that there are a long list of potential view types, and that the caller must be more careful. Review URL: http://codereview.chromium.org/1149003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_toolstrip_api.cc')
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc
index 56ad0a2..a858150 100644
--- a/chrome/browser/extensions/extension_toolstrip_api.cc
+++ b/chrome/browser/extensions/extension_toolstrip_api.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/extension_shelf_model.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
namespace extension_toolstrip_api_events {
const char kOnToolstripExpanded[] = "toolstrip.onExpanded.%d";
@@ -35,26 +36,36 @@ namespace keys = extension_tabs_module_constants;
namespace events = extension_toolstrip_api_events;
bool ToolstripFunction::RunImpl() {
- ExtensionHost* host = dispatcher()->GetExtensionHost();
- if (!host) {
+ ViewType::Type view_type =
+ dispatcher()->render_view_host()->delegate()->GetRenderViewType();
+ if (view_type != ViewType::EXTENSION_TOOLSTRIP &&
+ view_type != ViewType::EXTENSION_MOLE) {
error_ = kNotAToolstripError;
return false;
}
- Browser* browser = GetBrowser();
+
+ Browser* browser = GetCurrentBrowser();
if (!browser) {
error_ = kNotAToolstripError;
return false;
}
+
model_ = browser->extension_shelf_model();
if (!model_) {
error_ = kNotAToolstripError;
return false;
}
+
+ // Since this is an EXTENSION_TOOLSTRIP or EXTESION_MOLE view type, we know
+ // the delegate must be an ExtensionHost.
+ ExtensionHost* host =
+ static_cast<ExtensionHost*>(dispatcher()->delegate());
toolstrip_ = model_->ToolstripForHost(host);
if (toolstrip_ == model_->end()) {
error_ = kNotAToolstripError;
return false;
}
+
return true;
}