summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorchrome-bot@google.com <chrome-bot@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-02 00:14:02 +0000
committerchrome-bot@google.com <chrome-bot@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-02 00:14:02 +0000
commit4523fd290e2915710025b46c15be689cb7638a00 (patch)
tree85ab2b1efd9ec09e08ac247128c8dda0735b4399 /chrome/browser/extensions
parentbf0b51cbeef6ec8f7dc0d5fb46c76a739be5f84d (diff)
downloadchromium_src-4523fd290e2915710025b46c15be689cb7638a00.zip
chromium_src-4523fd290e2915710025b46c15be689cb7638a00.tar.gz
chromium_src-4523fd290e2915710025b46c15be689cb7638a00.tar.bz2
Rolling back change 22245.
Too much red :-( BUG=None TEST=None TBR=erikkay Review URL: http://codereview.chromium.org/159763 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc18
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.h6
-rw-r--r--chrome/browser/extensions/extension_host.cc11
-rw-r--r--chrome/browser/extensions/extension_host.h1
-rw-r--r--chrome/browser/extensions/extension_shelf_model.cc71
-rw-r--r--chrome/browser/extensions/extension_shelf_model.h99
-rw-r--r--chrome/browser/extensions/extension_shelf_model_unittest.cc10
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.cc114
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.h33
9 files changed, 70 insertions, 293 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 5d03e1f..40c5996 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -16,12 +16,10 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
-#include "chrome/browser/extensions/extension_toolstrip_api.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/common/result_codes.h"
-#include "chrome/common/url_constants.h"
// FactoryRegistry -------------------------------------------------------------
@@ -69,7 +67,6 @@ void FactoryRegistry::ResetFunctions() {
namespace tabs = extension_tabs_module_constants;
namespace page_actions = extension_page_actions_module_constants;
namespace bookmarks = extension_bookmarks_module_constants;
- namespace toolstrip = extension_toolstrip_api_functions;
// Windows
factories_[tabs::kGetWindowFunction] =
@@ -130,12 +127,6 @@ void FactoryRegistry::ResetFunctions() {
&NewExtensionFunction<MoveBookmarkFunction>;
factories_[bookmarks::kSetBookmarkTitleFunction] =
&NewExtensionFunction<SetBookmarkTitleFunction>;
-
- // Toolstrips.
- factories_[toolstrip::kExpandFunction] =
- &NewExtensionFunction<ToolstripExpandFunction>;
- factories_[toolstrip::kCollapseFunction] =
- &NewExtensionFunction<ToolstripCollapseFunction>;
}
void FactoryRegistry::GetAllNames(std::vector<std::string>* names) {
@@ -196,10 +187,6 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
delegate_(delegate),
url_(url),
ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
- // TODO(erikkay) should we do something for these errors in Release?
- DCHECK(url.SchemeIs(chrome::kExtensionScheme));
- DCHECK(profile()->GetExtensionsService()->GetExtensionByURL(url));
-
all_instances()->insert(this);
// Notify the ExtensionProcessManager that the view was created.
@@ -220,11 +207,6 @@ Browser* ExtensionFunctionDispatcher::GetBrowser() {
return retval;
}
-ExtensionHost* ExtensionFunctionDispatcher::GetExtensionHost() {
- DCHECK(delegate_);
- return delegate_->GetExtensionHost();
-}
-
void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
const std::string& args,
int request_id,
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 7a47b3f..0e79882 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -14,7 +14,6 @@
class Browser;
class ExtensionFunction;
-class ExtensionHost;
class Profile;
class RenderViewHost;
class RenderViewHostDelegate;
@@ -30,7 +29,6 @@ class ExtensionFunctionDispatcher {
class Delegate {
public:
virtual Browser* GetBrowser() = 0;
- virtual ExtensionHost* GetExtensionHost() { return NULL; }
};
// The peer object allows us to notify ExtensionFunctions when we are
@@ -70,10 +68,6 @@ class ExtensionFunctionDispatcher {
// example, for positioning windows, or alert boxes, or creating tabs.
Browser* GetBrowser();
- // Gets the ExtensionHost associated with this object. In the case of
- // tab hosted extension pages, this will return NULL.
- ExtensionHost* GetExtensionHost();
-
// Handle a malformed message. Possibly the result of an attack, so kill
// the renderer.
void HandleBadMessage(ExtensionFunction* api);
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index b4fbd00..78ec493 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -26,7 +26,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
-#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
@@ -194,10 +193,6 @@ void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
}
url_ = params.url;
- if (!url_.SchemeIs(chrome::kExtensionScheme)) {
- extension_function_dispatcher_.reset(NULL);
- return;
- }
extension_function_dispatcher_.reset(
new ExtensionFunctionDispatcher(render_view_host_, this, url_));
}
@@ -249,10 +244,8 @@ void ExtensionHost::ProcessDOMUIMessage(const std::string& message,
const std::string& content,
int request_id,
bool has_callback) {
- if (extension_function_dispatcher_.get()) {
- extension_function_dispatcher_->HandleRequest(message, content, request_id,
- has_callback);
- }
+ extension_function_dispatcher_->HandleRequest(message, content, request_id,
+ has_callback);
}
void ExtensionHost::DidInsertCSS() {
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 18fedd3..8961dfe 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -124,7 +124,6 @@ class ExtensionHost : public RenderViewHostDelegate,
// part of. If this is a global background page, we use the active Browser
// instead.
virtual Browser* GetBrowser();
- virtual ExtensionHost* GetExtensionHost() { return this; }
// The extension that we're hosting in this view.
Extension* extension_;
diff --git a/chrome/browser/extensions/extension_shelf_model.cc b/chrome/browser/extensions/extension_shelf_model.cc
index 6b7bd0c..1449d97 100644
--- a/chrome/browser/extensions/extension_shelf_model.cc
+++ b/chrome/browser/extensions/extension_shelf_model.cc
@@ -39,13 +39,11 @@ ExtensionShelfModel::ExtensionShelfModel(Browser* browser)
}
ExtensionShelfModel::~ExtensionShelfModel() {
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ShelfModelDeleting());
-
while (observers_.size())
observers_.RemoveObserver(observers_.GetElementAt(0));
- for (iterator t = toolstrips_.begin(); t != toolstrips_.end(); ++t)
+ ExtensionToolstrips::iterator t;
+ for (t = toolstrips_.begin(); t != toolstrips_.end(); ++t)
delete t->host;
toolstrips_.clear();
}
@@ -73,7 +71,7 @@ void ExtensionShelfModel::InsertToolstripAt(int index,
}
void ExtensionShelfModel::RemoveToolstripAt(int index) {
- ExtensionHost* host = ToolstripAt(index).host;
+ ExtensionHost* host = ToolstripAt(index);
FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
ToolstripRemovingAt(host, index));
toolstrips_.erase(toolstrips_.begin() + index);
@@ -96,52 +94,33 @@ void ExtensionShelfModel::MoveToolstripAt(int index, int to_index) {
UpdatePrefs();
}
-int ExtensionShelfModel::IndexOfHost(ExtensionHost* host) {
- for (iterator i = toolstrips_.begin(); i != toolstrips_.end(); ++i) {
- if (i->host == host)
+int ExtensionShelfModel::IndexOfToolstrip(ExtensionHost* toolstrip) {
+ ExtensionToolstrips::iterator i;
+ for (i = toolstrips_.begin(); i != toolstrips_.end(); ++i) {
+ if (i->host == toolstrip)
return i - toolstrips_.begin();
}
return -1;
}
-ExtensionShelfModel::iterator ExtensionShelfModel::ToolstripForHost(
- ExtensionHost* host) {
- for (iterator i = toolstrips_.begin(); i != toolstrips_.end(); ++i) {
- if (i->host == host)
- return i;
- }
- return toolstrips_.end();
-}
-
-const ExtensionShelfModel::ToolstripItem& ExtensionShelfModel::ToolstripAt(
- int index) {
+ExtensionHost* ExtensionShelfModel::ToolstripAt(int index) {
DCHECK(index >= 0);
- return toolstrips_[index];
+ return toolstrips_[index].host;
}
-void ExtensionShelfModel::SetToolstripDataAt(int index, void* data) {
+Extension::ToolstripInfo& ExtensionShelfModel::ToolstripInfoAt(int index) {
DCHECK(index >= 0);
- toolstrips_[index].data = data;
+ return toolstrips_[index].info;
}
-void ExtensionShelfModel::ExpandToolstrip(iterator toolstrip,
- const GURL& url, int height) {
- if (toolstrip == end())
- return;
- toolstrip->height = height;
- toolstrip->url = url;
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripChanged(toolstrip));
+void* ExtensionShelfModel::ToolstripDataAt(int index) {
+ DCHECK(index >= 0);
+ return toolstrips_[index].data;
}
-void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip,
- const GURL& url) {
- if (toolstrip == end())
- return;
- toolstrip->height = 0;
- toolstrip->url = url;
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripChanged(toolstrip));
+void ExtensionShelfModel::SetToolstripDataAt(int index, void* data) {
+ DCHECK(index >= 0);
+ toolstrips_[index].data = data;
}
void ExtensionShelfModel::Observe(NotificationType type,
@@ -157,8 +136,7 @@ void ExtensionShelfModel::Observe(NotificationType type,
break;
case NotificationType::EXTENSIONS_READY:
if (browser_->profile()->GetExtensionsService()) {
- AddExtensions(
- browser_->profile()->GetExtensionsService()->extensions());
+ AddExtensions(browser_->profile()->GetExtensionsService()->extensions());
SortToolstrips();
}
ready_ = true;
@@ -189,7 +167,6 @@ void ExtensionShelfModel::AddExtension(Extension* extension) {
item.host = manager->CreateView(extension, url, browser_);
item.info = *toolstrip;
item.data = NULL;
- item.height = 0;
AppendToolstrip(item);
}
}
@@ -205,7 +182,7 @@ void ExtensionShelfModel::AddExtensions(const ExtensionList* extensions) {
void ExtensionShelfModel::RemoveExtension(Extension* extension) {
bool changed = false;
for (int i = count() - 1; i >= 0; --i) {
- ExtensionHost* t = ToolstripAt(i).host;
+ ExtensionHost* t = ToolstripAt(i);
if (t->extension()->id() == extension->id()) {
changed = true;
RemoveToolstripAt(i);
@@ -225,7 +202,7 @@ void ExtensionShelfModel::UpdatePrefs() {
// It's easiest to just rebuild the list each time.
ExtensionPrefs::URLList urls;
for (int i = 0; i < count(); ++i)
- urls.push_back(ToolstripAt(i).host->GetURL());
+ urls.push_back(ToolstripAt(i)->GetURL());
prefs_->SetShelfToolstripOrder(urls);
NotificationService::current()->Notify(
@@ -236,15 +213,15 @@ void ExtensionShelfModel::UpdatePrefs() {
void ExtensionShelfModel::SortToolstrips() {
ExtensionPrefs::URLList urls = prefs_->GetShelfToolstripOrder();
- ToolstripList copy =
- ToolstripList(toolstrips_.begin(), toolstrips_.end());
+ ExtensionToolstrips copy =
+ ExtensionToolstrips(toolstrips_.begin(), toolstrips_.end());
toolstrips_.clear();
// Go through the urls and find the matching toolstrip, re-adding it to the
// new list in the proper order.
for (size_t i = 0; i < urls.size(); ++i) {
GURL& url = urls[i];
- for (iterator toolstrip = copy.begin();
+ for (ExtensionToolstrips::iterator toolstrip = copy.begin();
toolstrip != copy.end(); ++toolstrip) {
if (url == toolstrip->host->GetURL()) {
// Note that it's technically possible for the same URL to appear in
@@ -261,7 +238,7 @@ void ExtensionShelfModel::SortToolstrips() {
// Any toolstrips remaining in |copy| were somehow missing from the prefs,
// so just append them to the end.
- for (iterator toolstrip = copy.begin();
+ for (ExtensionToolstrips::iterator toolstrip = copy.begin();
toolstrip != copy.end(); ++toolstrip) {
toolstrips_.push_back(*toolstrip);
}
diff --git a/chrome/browser/extensions/extension_shelf_model.h b/chrome/browser/extensions/extension_shelf_model.h
index 29f6592..28fb00b 100644
--- a/chrome/browser/extensions/extension_shelf_model.h
+++ b/chrome/browser/extensions/extension_shelf_model.h
@@ -16,7 +16,36 @@
class Browser;
class ExtensionPrefs;
-class ExtensionShelfModelObserver;
+
+// Objects implement this interface when they wish to be notified of changes to
+// the ExtensionShelfModel.
+//
+// Register your ExtensionShelfModelObserver with the ExtensionShelfModel using
+// Add/RemoveObserver methods.
+class ExtensionShelfModelObserver {
+ public:
+ // A new toolstrip was inserted into ExtensionShelfModel at |index|.
+ virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {}
+
+ // The specified toolstrip is being removed and destroyed.
+ virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {}
+
+ // |toolstrip| moved from |from_index| to |to_index|.
+ virtual void ToolstripMoved(ExtensionHost* toolstrip,
+ int from_index,
+ int to_index) {}
+
+ // The specified toolstrip changed in some way (currently only size changes)
+ virtual void ToolstripChangedAt(ExtensionHost* toolstrip, int index) {}
+
+ // There are no more toolstrips in the model.
+ virtual void ExtensionShelfEmpty() {}
+
+ // The entire model may have changed.
+ virtual void ShelfModelReloaded() {}
+
+ // TODO(erikkay) - any more?
+};
// The model representing the toolstrips on an ExtensionShelf. The order of
// the toolstrips is common across all of the models for a given Profile,
@@ -31,13 +60,8 @@ class ExtensionShelfModel : public NotificationObserver {
ExtensionHost* host;
Extension::ToolstripInfo info;
void* data;
- int height;
- GURL url;
};
- typedef std::vector<ToolstripItem> ToolstripList;
- typedef ToolstripList::iterator iterator;
-
// Add and remove observers to changes within this ExtensionShelfModel.
void AddObserver(ExtensionShelfModelObserver* observer);
void RemoveObserver(ExtensionShelfModelObserver* observer);
@@ -46,10 +70,6 @@ class ExtensionShelfModel : public NotificationObserver {
int count() const { return static_cast<int>(toolstrips_.size()); }
bool empty() const { return toolstrips_.empty(); }
- // Iterators for the toolstrips in the model.
- iterator begin() { return toolstrips_.begin(); }
- ExtensionShelfModel::iterator end() { return toolstrips_.end(); }
-
// Add |toolstrip| to the end of the shelf.
void AppendToolstrip(const ToolstripItem& toolstrip);
@@ -62,28 +82,18 @@ class ExtensionShelfModel : public NotificationObserver {
// Move the toolstrip at |index| to |to_index|.
void MoveToolstripAt(int index, int to_index);
- // Lookup the index of |host|. Returns -1 if not present.
- int IndexOfHost(ExtensionHost* host);
+ // Lookup the index of |toolstrip|. Returns -1 if not present.
+ int IndexOfToolstrip(ExtensionHost* toolstrip);
// Return the toolstrip at |index|.
- const ToolstripItem& ToolstripAt(int index);
+ ExtensionHost* ToolstripAt(int index);
- // Return the ToolstripItem associated with |host| or NULL if it's not
- // present.
- ToolstripList::iterator ToolstripForHost(ExtensionHost* host);
+ // Return the ToolstripInfo at |index|.
+ Extension::ToolstripInfo& ToolstripInfoAt(int index);
- // Set some arbitrary data associated with a particular toolstrip.
+ // Get/Set some arbitrary data associated with a particular toolstrip.
void SetToolstripDataAt(int index, void* data);
-
- // Update the ToolstripItem for |toolstrip| to set its |url| and |height|
- // and then call ToolstripChanged for all observers.
- // If |url| is empty, no navigation is requested.
- void ExpandToolstrip(iterator toolstrip, const GURL& url, int height);
-
- // Update the ToolstripItem for |toolstrip| to set its |url| and its height
- // to 0, and then call ToolstripChanged for all observers.
- // If |url| is empty, no navigation is requested.
- void CollapseToolstrip(iterator toolstrip, const GURL& url);
+ void* ToolstripDataAt(int index);
// NotificationObserver
virtual void Observe(NotificationType type,
@@ -116,7 +126,8 @@ class ExtensionShelfModel : public NotificationObserver {
NotificationRegistrar registrar_;
// The Toolstrips loaded in this model. The model owns these objects.
- ToolstripList toolstrips_;
+ typedef std::vector<ToolstripItem> ExtensionToolstrips;
+ ExtensionToolstrips toolstrips_;
// Our observers.
typedef ObserverList<ExtensionShelfModelObserver>
@@ -129,36 +140,4 @@ class ExtensionShelfModel : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(ExtensionShelfModel);
};
-// Objects implement this interface when they wish to be notified of changes to
-// the ExtensionShelfModel.
-//
-// Register your ExtensionShelfModelObserver with the ExtensionShelfModel using
-// Add/RemoveObserver methods.
-class ExtensionShelfModelObserver {
- public:
- // A new toolstrip was inserted into ExtensionShelfModel at |index|.
- virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {}
-
- // The specified toolstrip is being removed and destroyed.
- virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {}
-
- // |toolstrip| moved from |from_index| to |to_index|.
- virtual void ToolstripMoved(ExtensionHost* toolstrip,
- int from_index,
- int to_index) {}
-
- // The specified toolstrip changed in some way (currently only size changes)
- virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip) {}
-
- // There are no more toolstrips in the model.
- virtual void ExtensionShelfEmpty() {}
-
- // The entire model may have changed.
- virtual void ShelfModelReloaded() {}
-
- // The model is being destroyed.
- virtual void ShelfModelDeleting() {}
-};
-
-
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SHELF_MODEL_H_
diff --git a/chrome/browser/extensions/extension_shelf_model_unittest.cc b/chrome/browser/extensions/extension_shelf_model_unittest.cc
index 59cf318..d1e2217 100644
--- a/chrome/browser/extensions/extension_shelf_model_unittest.cc
+++ b/chrome/browser/extensions/extension_shelf_model_unittest.cc
@@ -80,18 +80,18 @@ IN_PROC_BROWSER_TEST_F(ExtensionShelfModelTest, Basic) {
// extension1 has two toolstrips
EXPECT_EQ(inserted_count_, 2);
- ExtensionHost* one = model_->ToolstripAt(0).host;
- ExtensionHost* two = model_->ToolstripAt(1).host;
+ ExtensionHost* one = model_->ToolstripAt(0);
+ ExtensionHost* two = model_->ToolstripAt(1);
EXPECT_EQ(one->GetURL().path(), "/toolstrip1.html");
EXPECT_EQ(two->GetURL().path(), "/toolstrip2.html");
model_->MoveToolstripAt(0, 1);
- EXPECT_EQ(two, model_->ToolstripAt(0).host);
- EXPECT_EQ(one, model_->ToolstripAt(1).host);
+ EXPECT_EQ(two, model_->ToolstripAt(0));
+ EXPECT_EQ(one, model_->ToolstripAt(1));
EXPECT_EQ(moved_count_, 1);
model_->RemoveToolstripAt(0);
- EXPECT_EQ(one, model_->ToolstripAt(0).host);
+ EXPECT_EQ(one, model_->ToolstripAt(0));
EXPECT_EQ(1, model_->count());
EXPECT_EQ(removed_count_, 1);
}
diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc
deleted file mode 100644
index 248eedb..0000000
--- a/chrome/browser/extensions/extension_toolstrip_api.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/extension_toolstrip_api.h"
-
-#include "chrome/browser/browser.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-
-namespace extension_toolstrip_api_functions {
-const char kExpandFunction[] = "toolstrip.expand";
-const char kCollapseFunction[] = "toolstrip.collapse";
-}; // namespace extension_toolstrip_api_functions
-
-namespace {
-// Errors.
-const char kNotAToolstripError[] = "This page is not a toolstrip.";
-const char kAlreadyExpandedError[] = "This toolstrip is already expanded.";
-const char kAlreadyCollapsedError[] = "This toolstrip is already collapsed.";
-const char kInvalidURLError[] = "Invalid URL";
-const char kBadHeightError[] = "Bad height.";
-
-// TODO(erikkay) what are good values here?
-const int kMinHeight = 50;
-const int kMaxHeight = 1000;
-}; // namespace
-
-bool ToolstripFunction::RunImpl() {
- ExtensionHost* host = dispatcher()->GetExtensionHost();
- if (!host) {
- error_ = kNotAToolstripError;
- return false;
- }
- Browser* browser = dispatcher()->GetBrowser();
- if (!browser) {
- error_ = kNotAToolstripError;
- return false;
- }
- model_ = browser->extension_shelf_model();
- if (!model_) {
- error_ = kNotAToolstripError;
- return false;
- }
- toolstrip_ = model_->ToolstripForHost(host);
- if (toolstrip_ == model_->end()) {
- error_ = kNotAToolstripError;
- return false;
- }
- return true;
-}
-
-bool ToolstripExpandFunction::RunImpl() {
- if (!ToolstripFunction::RunImpl())
- return false;
- if (toolstrip_->height != 0) {
- error_ = kAlreadyExpandedError;
- return false;
- }
-
- EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
- const ListValue* args = static_cast<const ListValue*>(args_);
- EXTENSION_FUNCTION_VALIDATE(args->GetSize() <= 2);
-
- int height;
- EXTENSION_FUNCTION_VALIDATE(args->GetInteger(0, &height));
- EXTENSION_FUNCTION_VALIDATE(height >= 0);
- if (height < kMinHeight || height > kMaxHeight) {
- error_ = kBadHeightError;
- return false;
- }
-
- GURL url;
- if (args->GetSize() == 2) {
- Value* url_val;
- EXTENSION_FUNCTION_VALIDATE(args->Get(1, &url_val));
- if (url_val->GetType() != Value::TYPE_NULL) {
- std::string url_str;
- EXTENSION_FUNCTION_VALIDATE(url_val->GetAsString(&url_str));
- url = GURL(url_str);
- if (!url.is_valid() && !url.is_empty()) {
- error_ = kInvalidURLError;
- return false;
- }
- }
- }
-
- model_->ExpandToolstrip(toolstrip_, url, height);
- return true;
-}
-
-bool ToolstripCollapseFunction::RunImpl() {
- if (!ToolstripFunction::RunImpl())
- return false;
-
- if (toolstrip_->height == 0) {
- error_ = kAlreadyCollapsedError;
- return false;
- }
-
- GURL url;
- if (args_->GetType() != Value::TYPE_NULL) {
- std::string url_str;
- EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&url_str));
- url = GURL(url_str);
- if (!url.is_valid() && !url.is_empty()) {
- error_ = kInvalidURLError;
- return false;
- }
- }
-
- model_->CollapseToolstrip(toolstrip_, url);
- return true;
-}
diff --git a/chrome/browser/extensions/extension_toolstrip_api.h b/chrome/browser/extensions/extension_toolstrip_api.h
deleted file mode 100644
index 127c952..0000000
--- a/chrome/browser/extensions/extension_toolstrip_api.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_
-
-#include "chrome/browser/extensions/extension_function.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-
-// Function names.
-namespace extension_toolstrip_api_functions {
- extern const char kExpandFunction[];
- extern const char kCollapseFunction[];
-}; // namespace extension_toolstrip_api_functions
-
-class ToolstripFunction : public SyncExtensionFunction {
- protected:
- virtual bool RunImpl();
-
- ExtensionShelfModel* model_;
- ExtensionShelfModel::iterator toolstrip_;
-};
-
-class ToolstripExpandFunction : public ToolstripFunction {
- virtual bool RunImpl();
-};
-
-class ToolstripCollapseFunction : public ToolstripFunction {
- virtual bool RunImpl();
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_