1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/extensions/api/browser/browser_api.h"
6
7#include "chrome/browser/extensions/extension_tab_util.h"
8
9namespace extensions {
10namespace api {
11
12BrowserOpenTabFunction::~BrowserOpenTabFunction() {
13}
14
15bool BrowserOpenTabFunction::RunSync() {
16  scoped_ptr<browser::OpenTab::Params> params(
17      browser::OpenTab::Params::Create(*args_));
18  EXTENSION_FUNCTION_VALIDATE(params.get());
19
20  ExtensionTabUtil::OpenTabParams options;
21  options.create_browser_if_needed = true;
22  options.url.reset(new std::string(params->options.url));
23
24  std::string error;
25  scoped_ptr<base::DictionaryValue> result(
26      ExtensionTabUtil::OpenTab(this, options, &error));
27  if (!result) {
28    SetError(error);
29    return false;
30  }
31
32  return true;
33}
34
35}  // namespace api
36}  // namespace extensions
37