summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 21:08:04 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 21:08:04 +0000
commit42451a727ee52e29ce489bddd9951f9bcdb7564f (patch)
treef8c213c2908ed8c14a75eeb87cc37db881ce8c80 /apps
parent3febebe90d62a419d49ccc80eaf7228ac632c2fa (diff)
downloadchromium_src-42451a727ee52e29ce489bddd9951f9bcdb7564f.zip
chromium_src-42451a727ee52e29ce489bddd9951f9bcdb7564f.tar.gz
chromium_src-42451a727ee52e29ce489bddd9951f9bcdb7564f.tar.bz2
Use EXTENSION_FUNCTION_VALIDATE for ShellCreateWindowFunction in app_shell
Instead of attempting to validate the parameters by hand. I did not change ShellAppWindowCreateFunction as that class is going away in https://codereview.chromium.org/258053010/ BUG=368706 TEST=manual, changing Calculator example app to call createWindow() with bad params causes appropriate validation failures, with good params still opens a window Review URL: https://codereview.chromium.org/261653002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267330 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/shell/browser/api/shell/shell_api.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/shell/browser/api/shell/shell_api.cc b/apps/shell/browser/api/shell/shell_api.cc
index 929d1db..6a51667 100644
--- a/apps/shell/browser/api/shell/shell_api.cc
+++ b/apps/shell/browser/api/shell/shell_api.cc
@@ -6,10 +6,13 @@
#include "apps/shell/browser/shell_app_window.h"
#include "apps/shell/browser/shell_desktop_controller.h"
+#include "apps/shell/common/api/shell.h"
#include "base/values.h"
using base::DictionaryValue;
+namespace CreateWindow = apps::shell_api::shell::CreateWindow;
+
namespace apps {
namespace {
@@ -31,17 +34,11 @@ ShellCreateWindowFunction::~ShellCreateWindowFunction() {
}
bool ShellCreateWindowFunction::RunImpl() {
- // Arguments must contain a URL and may contain options and a callback.
- if (args_->GetSize() < 1 || args_->GetSize() > 3)
- return false;
-
- // Extract the URL for the window contents, e.g. "main.html".
- std::string url_string;
- if (!args_->GetString(0, &url_string))
- return false;
+ scoped_ptr<CreateWindow::Params> params(CreateWindow::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
// Convert "main.html" to "chrome-extension:/<id>/main.html".
- GURL url = GetExtension()->GetResourceURL(url_string);
+ GURL url = GetExtension()->GetResourceURL(params->url);
if (!url.is_valid())
return false;