This source file includes following definitions.
- CreateStubBoundsProperties
- CreateResult
- RunImpl
#include "apps/shell/browser/shell_app_window_api.h"
#include "apps/shell/browser/shell_app_window.h"
#include "apps/shell/browser/shell_desktop_controller.h"
#include "base/values.h"
using base::DictionaryValue;
namespace extensions {
namespace {
DictionaryValue* CreateStubBoundsProperties() {
DictionaryValue* properties = new DictionaryValue;
properties->SetInteger("left", 0);
properties->SetInteger("top", 0);
properties->SetInteger("width", 0);
properties->SetInteger("height", 0);
return properties;
}
DictionaryValue* CreateResult(apps::ShellAppWindow* app_window) {
int view_id = app_window->GetRenderViewRoutingID();
DictionaryValue* result = new DictionaryValue;
result->Set("viewId", new base::FundamentalValue(view_id));
result->Set("injectTitlebar", new base::FundamentalValue(false));
result->Set("id", new base::StringValue("app_shell"));
result->SetBoolean("fullscreen", true);
result->SetBoolean("minimized", false);
result->SetBoolean("maximized", false);
result->SetBoolean("alwaysOnTop", false);
result->SetBoolean("hasFrameColor", false);
result->SetInteger("frameColor", 0);
result->Set("innerBounds", CreateStubBoundsProperties());
result->Set("outerBounds", CreateStubBoundsProperties());
return result;
}
}
ShellAppWindowCreateFunction::ShellAppWindowCreateFunction() {}
ShellAppWindowCreateFunction::~ShellAppWindowCreateFunction() {}
bool ShellAppWindowCreateFunction::RunImpl() {
if (args_->GetSize() < 1 || args_->GetSize() > 3)
return false;
std::string url_string;
if (!args_->GetString(0, &url_string))
return false;
GURL url = GetExtension()->GetResourceURL(url_string);
if (!url.is_valid())
return false;
apps::ShellAppWindow* app_window =
apps::ShellDesktopController::instance()->CreateAppWindow(
browser_context());
app_window->LoadURL(url);
DictionaryValue* result = CreateResult(app_window);
SetResult(result);
SendResponse(true );
return true;
}
}