summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 22:08:37 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 22:08:37 +0000
commit883fd6284db5ba9abe08b8433c8efabe18af139f (patch)
tree194fa57f433ccafe5cdb6bd2a91e057f3c2911ed /chrome/browser
parenta0810b268b459d6d451882123ad12513dafb11f1 (diff)
downloadchromium_src-883fd6284db5ba9abe08b8433c8efabe18af139f.zip
chromium_src-883fd6284db5ba9abe08b8433c8efabe18af139f.tar.gz
chromium_src-883fd6284db5ba9abe08b8433c8efabe18af139f.tar.bz2
Reverting 11294.
Review URL: http://codereview.chromium.org/40321 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11295 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension.cc13
-rw-r--r--chrome/browser/extensions/extension.h55
-rwxr-xr-xchrome/browser/extensions/extension_view.cc2
-rwxr-xr-xchrome/browser/extensions/extension_view.h2
-rw-r--r--chrome/browser/extensions/extensions_service.cc10
-rw-r--r--chrome/browser/extensions/extensions_service.h4
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc94
-rw-r--r--chrome/browser/views/bookmark_bar_view.h9
8 files changed, 54 insertions, 135 deletions
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index 437169d..d83f9d9 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -26,7 +26,6 @@ const wchar_t* Extension::kVersionKey = L"version";
const wchar_t* Extension::kZipHashKey = L"zip_hash";
const wchar_t* Extension::kPluginsDirKey = L"plugins_dir";
const wchar_t* Extension::kThemeKey = L"theme";
-const wchar_t* Extension::kToolstripKey = L"toolstrip";
const char* Extension::kRunAtDocumentStartValue = "document_start";
const char* Extension::kRunAtDocumentEndValue = "document_end";
@@ -71,8 +70,6 @@ const char* Extension::kInvalidZipHashError =
"Required key 'zip_hash' is missing or invalid.";
const char* Extension::kInvalidPluginsDirError =
"Invalid value for 'plugins_dir'.";
-const char* Extension::kInvalidToolstripError =
- "Invalid value for 'toolstrip'.";
const size_t Extension::kIdSize = 20; // SHA1 (160 bits) == 20 bytes
@@ -263,16 +260,6 @@ bool Extension::InitFromValue(const DictionaryValue& source,
plugins_dir_ = path_.AppendASCII(plugins_dir);
}
- // Initialize toolstrip (optional).
- if (source.HasKey(kToolstripKey)) {
- std::string toolstrip_path;
- if (!source.GetString(kToolstripKey, &toolstrip_path)) {
- *error = kInvalidToolstripError;
- return false;
- }
- toolstrip_url_ = GetResourceURL(extension_url_, toolstrip_path);
- }
-
if (source.HasKey(kThemeKey)) {
DictionaryValue* dict_value;
if (source.GetDictionary(kThemeKey, &dict_value)) {
diff --git a/chrome/browser/extensions/extension.h b/chrome/browser/extensions/extension.h
index 87290ca..5ca86d3 100644
--- a/chrome/browser/extensions/extension.h
+++ b/chrome/browser/extensions/extension.h
@@ -42,7 +42,6 @@ class Extension {
static const wchar_t* kZipHashKey;
static const wchar_t* kPluginsDirKey;
static const wchar_t* kThemeKey;
- static const wchar_t* kToolstripKey;
// Some values expected in manifests.
static const char* kRunAtDocumentStartValue;
@@ -66,7 +65,6 @@ class Extension {
static const char* kInvalidVersionError;
static const char* kInvalidZipHashError;
static const char* kInvalidPluginsDirError;
- static const char* kInvalidToolstripError;
// The number of bytes in a legal id.
static const size_t kIdSize;
@@ -87,9 +85,6 @@ class Extension {
static FilePath GetResourcePath(const FilePath& extension_path,
const std::string& relative_path);
- // Initialize the extension from a parsed manifest.
- bool InitFromValue(const DictionaryValue& value, std::string* error);
-
// Returns an absolute path to a resource inside of an extension if the
// extension has a theme defined with the given |resource_id|. Otherwise
// the path will be empty. Note that this method is not static as it is
@@ -97,31 +92,53 @@ class Extension {
// as providing a theme.
FilePath GetThemeResourcePath(const int resource_id);
+ // The path to the folder the extension is stored in.
const FilePath& path() const { return path_; }
+
+ // The base URL for the extension.
const GURL& url() const { return extension_url_; }
+
+ // A human-readable ID for the extension. The convention is to use something
+ // like 'com.example.myextension', but this is not currently enforced. An
+ // extension's ID is used in things like directory structures and URLs, and
+ // is expected to not change across versions. In the case of conflicts,
+ // updates will only be allowed if the extension can be validated using the
+ // previous version's update key.
const std::string& id() const { return id_; }
+
+ // The version number for the extension.
const Version* version() const { return version_.get(); }
+
// String representation of the version number.
const std::string VersionString() const;
+
+ // A human-readable name of the extension.
const std::string& name() const { return name_; }
+
+ // An optional longer description of the extension.
const std::string& description() const { return description_; }
- const UserScriptList& content_scripts() const { return content_scripts_; }
- const FilePath& plugins_dir() const { return plugins_dir_; }
- const GURL& toolstrip_url() const { return toolstrip_url_; }
+
+ // Paths to the content scripts that the extension contains.
+ const UserScriptList& content_scripts() const {
+ return content_scripts_;
+ }
+
+ // Path to the directory of NPAPI plugins that the extension contains.
+ const FilePath& plugins_dir() const {
+ return plugins_dir_;
+ }
+
+ // Initialize the extension from a parsed manifest.
+ bool InitFromValue(const DictionaryValue& value, std::string* error);
private:
- // The absolute path to the directory the extension is stored in.
+ // The path to the directory the extension is stored in.
FilePath path_;
// The base extension url for the extension.
GURL extension_url_;
- // A human-readable ID for the extension. The convention is to use something
- // like 'com.example.myextension', but this is not currently enforced. An
- // extension's ID is used in things like directory structures and URLs, and
- // is expected to not change across versions. In the case of conflicts,
- // updates will only be allowed if the extension can be validated using the
- // previous version's update key.
+ // The extension's ID.
std::string id_;
// The extension's version.
@@ -130,19 +147,15 @@ class Extension {
// The extension's human-readable name.
std::string name_;
- // An optional longer description of the extension.
+ // An optional description for the extension.
std::string description_;
// Paths to the content scripts the extension contains.
UserScriptList content_scripts_;
- // Optional absolute path to the directory of NPAPI plugins that the extension
- // contains.
+ // Path to the directory of NPAPI plugins that the extension contains.
FilePath plugins_dir_;
- // Optional URL of an HTML file to be displayed in the toolbar.
- GURL toolstrip_url_;
-
// A SHA1 hash of the contents of the zip file. Note that this key is only
// present in the manifest that's prepended to the zip. The inner manifest
// will not have this key.
diff --git a/chrome/browser/extensions/extension_view.cc b/chrome/browser/extensions/extension_view.cc
index 6cd9c97b..883ac3a 100755
--- a/chrome/browser/extensions/extension_view.cc
+++ b/chrome/browser/extensions/extension_view.cc
@@ -8,8 +8,6 @@
ExtensionView::ExtensionView(const GURL& url, Profile* profile) :
HWNDHtmlView(url, this, false), profile_(profile) {
- // TODO(mpcomplete): query this from the renderer somehow?
- set_preferred_size(gfx::Size(100, 100));
}
void ExtensionView::CreatingRenderer() {
diff --git a/chrome/browser/extensions/extension_view.h b/chrome/browser/extensions/extension_view.h
index 6bb9e7a5..d95b745 100755
--- a/chrome/browser/extensions/extension_view.h
+++ b/chrome/browser/extensions/extension_view.h
@@ -42,8 +42,6 @@ class ExtensionView : public HWNDHtmlView,
private:
Profile* profile_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionView);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 1b66bea..32492cc 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -103,6 +103,13 @@ bool ExtensionsService::Init() {
return true;
}
+void ExtensionsService::LaunchExtensionProcess(Extension* extension) {
+ // TODO(mpcomplete): Do something useful here.
+ GURL url = Extension::GetResourceURL(extension->url(), "index.html");
+ ExtensionView* view = new ExtensionView(url, profile_);
+ view->InitHidden();
+}
+
MessageLoop* ExtensionsService::GetMessageLoop() {
return message_loop_;
}
@@ -129,7 +136,8 @@ void ExtensionsService::LoadExtension(const FilePath& extension_path) {
scoped_refptr<ExtensionsServiceFrontendInterface>(this)));
}
-void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) {
+void ExtensionsService::OnExtensionsLoaded(
+ ExtensionList* new_extensions) {
extensions_.insert(extensions_.end(), new_extensions->begin(),
new_extensions->end());
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 5c08685..56e0afa 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -63,6 +63,10 @@ class ExtensionsService : public ExtensionsServiceFrontendInterface {
// Initialize and start all installed extensions.
bool Init();
+ // Start the extension process for this extension. TODO(mpcomplete): not sure
+ // how this should actually work yet.
+ void LaunchExtensionProcess(Extension* extension);
+
// ExtensionsServiceFrontendInterface
virtual MessageLoop* GetMessageLoop();
virtual void InstallExtension(const FilePath& extension_path);
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 6738791..43c48bdf 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -16,9 +16,6 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/drag_utils.h"
#include "chrome/browser/download/download_util.h"
-#include "chrome/browser/extensions/extension.h"
-#include "chrome/browser/extensions/extension_view.h"
-#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
@@ -318,37 +315,6 @@ class BookmarkFolderButton : public views::MenuButton {
DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton);
};
-// ExtensionToolstrip -------------------------------------------------------
-
-// A simple container with a border for an ExtensionView.
-class ExtensionToolstrip : public views::View {
- public:
- static const int kPadding = 2;
-
- ExtensionToolstrip(const GURL& url, Profile* profile)
- : view_(new ExtensionView(url, profile)) {
- AddChildView(view_);
- set_border(views::Border::CreateEmptyBorder(
- kPadding, kPadding, kPadding, kPadding));
- }
-
- virtual gfx::Size GetPreferredSize() {
- gfx::Size size = view_->GetPreferredSize();
- size.Enlarge(kPadding*2, kPadding*2);
- return size;
- }
-
- virtual void DidChangeBounds(const gfx::Rect& previous,
- const gfx::Rect& current) {
- view_->SetBounds(GetLocalBounds(false));
- }
-
- private:
- ExtensionView* view_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionToolstrip);
-};
-
// DropInfo -------------------------------------------------------------------
// Tracks drops on the BookmarkBarView.
@@ -723,8 +689,7 @@ BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser)
overflow_button_(NULL),
instructions_(NULL),
bookmarks_separator_view_(NULL),
- throbbing_view_(NULL),
- num_extension_toolstrips_(0) {
+ throbbing_view_(NULL) {
SetID(VIEW_ID_BOOKMARK_BAR);
Init();
SetProfile(profile);
@@ -755,9 +720,8 @@ void BookmarkBarView::SetProfile(Profile* profile) {
// Cancels the current cancelable.
NotifyModelChanged();
- // Remove the current buttons and extension toolstrips.
- for (int i = GetBookmarkButtonCount() + num_extension_toolstrips_ - 1;
- i >= 0; --i) {
+ // Remove the current buttons.
+ for (int i = GetBookmarkButtonCount() - 1; i >= 0; --i) {
View* child = GetChildViewAt(i);
RemoveChildView(child);
delete child;
@@ -778,8 +742,6 @@ void BookmarkBarView::SetProfile(Profile* profile) {
ns->AddObserver(this, NotificationType::BOOKMARK_BUBBLE_HIDDEN, ns_source);
ns->AddObserver(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources());
- ns->AddObserver(this, NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources());
model_ = profile_->GetBookmarkModel();
model_->AddObserver(this);
@@ -873,17 +835,6 @@ void BookmarkBarView::Layout() {
}
}
- // Extension toolstrips.
- for (int i = GetBookmarkButtonCount();
- i < GetBookmarkButtonCount() + num_extension_toolstrips_; ++i) {
- views::View* child = GetChildViewAt(i);
- gfx::Size pref = child->GetPreferredSize();
- int next_x = x + pref.width() + kButtonPadding;
- child->SetVisible(next_x < max_x);
- child->SetBounds(x, y, pref.width(), height);
- x = next_x;
- }
-
// Layout the right side of the bar.
const bool all_visible =
(GetBookmarkButtonCount() == 0 ||
@@ -1267,10 +1218,10 @@ MenuButton* BookmarkBarView::CreateOverflowButton() {
}
int BookmarkBarView::GetBookmarkButtonCount() {
- // We contain at least four non-bookmark button views: recently bookmarked,
- // bookmarks separator, chevrons (for overflow), the instruction
- // label, as well as any ExtensionViews displaying toolstrips.
- return GetChildViewCount() - 4 - num_extension_toolstrips_;
+ // We contain four non-bookmark button views: recently bookmarked,
+ // bookmarks separator, chevrons (for overflow) and the instruction
+ // label.
+ return GetChildViewCount() - 4;
}
void BookmarkBarView::Loaded(BookmarkModel* model) {
@@ -1280,9 +1231,6 @@ void BookmarkBarView::Loaded(BookmarkModel* model) {
for (int i = 0; i < node->GetChildCount(); ++i)
AddChildView(i, CreateBookmarkButton(node->GetChild(i)));
other_bookmarked_button_->SetEnabled(true);
-
- AddExtensionToolstrips(profile_->GetExtensionsService()->extensions());
-
Layout();
SchedulePaint();
}
@@ -1634,35 +1582,9 @@ void BookmarkBarView::Observe(NotificationType type,
StopThrobbing(false);
bubble_url_ = GURL();
break;
-
- case NotificationType::EXTENSIONS_LOADED: {
- const ExtensionList* extensions = Details<ExtensionList>(details).ptr();
- if (AddExtensionToolstrips(extensions)) {
- Layout();
- SchedulePaint();
- }
- break;
- }
}
}
-bool BookmarkBarView::AddExtensionToolstrips(const ExtensionList* extensions) {
- bool added_toolstrip = false;
- for (ExtensionList::const_iterator extension = extensions->begin();
- extension != extensions->end(); ++extension) {
- if (!(*extension)->toolstrip_url().is_empty()) {
- ExtensionToolstrip* view =
- new ExtensionToolstrip((*extension)->toolstrip_url(), profile_);
- int index = GetBookmarkButtonCount() + num_extension_toolstrips_;
- AddChildView(index, view);
- added_toolstrip = true;
- ++num_extension_toolstrips_;
- }
- }
-
- return added_toolstrip;
-}
-
void BookmarkBarView::RemoveNotificationObservers() {
NotificationService* ns = NotificationService::current();
Source<Profile> ns_source(profile_->GetOriginalProfile());
@@ -1671,8 +1593,6 @@ void BookmarkBarView::RemoveNotificationObservers() {
ns->RemoveObserver(this,
NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
NotificationService::AllSources());
- ns->RemoveObserver(this, NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources());
}
void BookmarkBarView::NotifyModelChanged() {
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index 909af16..06b9e6c6 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -7,7 +7,6 @@
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/common/slide_animation.h"
#include "chrome/views/label.h"
#include "chrome/views/menu.h"
@@ -385,11 +384,6 @@ class BookmarkBarView : public views::View,
// throbs.
void StopThrobbing(bool immediate);
- // Add any extension toolstrips which may be requested by the given
- // extensions. Views for the toolstrips are inserted after the last bookmark
- // button. Returns true if there were any new toolstrips added.
- bool AddExtensionToolstrips(const ExtensionList* extensions);
-
Profile* profile_;
// Used for opening urls.
@@ -442,9 +436,6 @@ class BookmarkBarView : public views::View,
// overflow_button_ or a button on the bar.
views::BaseButton* throbbing_view_;
- // How many extension toolstrips we have showing in the toolbar.
- int num_extension_toolstrips_;
-
DISALLOW_COPY_AND_ASSIGN(BookmarkBarView);
};