diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 03:18:46 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 03:18:46 +0000 |
commit | 671e6c1cecf01e46dc0267e020971aa0f98de0a2 (patch) | |
tree | 61db92254d4030103b4f4f68b7b8a7ad342f6d93 /chrome/browser/extensions/extension_file_util.cc | |
parent | 37e1bb64e696f39acb8a80021af58356af8e3bf1 (diff) | |
download | chromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.zip chromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.tar.gz chromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.tar.bz2 |
Implement Browser Actions extensions.
Browser Actions are like Page Actions, except they appear next to the Omnibox and are always visible. For details see http://code.google.com/p/chromium/wiki/BrowserActions.
Added a simple browser action sample that adds a Print button to the chrome toolbar (which brings up the Print dialog for the current page).
Removed |type| from PageActions, which is currently ignored and was already removed from the docs.
Each extension can only have 1 browser_action. Each browser action can specify more than one icon, but only the first is used. And no API has been added yet (besides the event definition).
BUG=22099
TEST=Install the sample browser action, navigate to google.com, press the print button. A print dialog should come up.
Review URL: http://codereview.chromium.org/243001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_file_util.cc')
-rw-r--r-- | chrome/browser/extensions/extension_file_util.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_file_util.cc b/chrome/browser/extensions/extension_file_util.cc index ac34470..5c49e05 100644 --- a/chrome/browser/extensions/extension_file_util.cc +++ b/chrome/browser/extensions/extension_file_util.cc @@ -212,10 +212,10 @@ bool ValidateExtension(Extension* extension, std::string* error) { } // Validate icon location for page actions. - const PageActionMap& page_actions = extension->page_actions(); - for (PageActionMap::const_iterator i(page_actions.begin()); + const ContextualActionMap& page_actions = extension->page_actions(); + for (ContextualActionMap::const_iterator i(page_actions.begin()); i != page_actions.end(); ++i) { - PageAction* page_action = i->second; + ContextualAction* page_action = i->second; const std::vector<std::string>& icon_paths = page_action->icon_paths(); for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); iter != icon_paths.end(); ++iter) { @@ -227,6 +227,20 @@ bool ValidateExtension(Extension* extension, std::string* error) { } } + // Validate icon location for browser actions. + const ContextualAction* browser_action = extension->browser_action(); + if (browser_action) { + const std::vector<std::string>& icon_paths = browser_action->icon_paths(); + for (std::vector<std::string>::const_iterator iter = icon_paths.begin(); + iter != icon_paths.end(); ++iter) { + if (!file_util::PathExists(extension->GetResourcePath(*iter))) { + *error = StringPrintf("Could not load icon '%s' for browser action.", + iter->c_str()); + return false; + } + } + } + // Check children of extension root to see if any of them start with _ and is // not on the reserved list. if (!CheckForIllegalFilenames(extension->path(), error)) { |