Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2360)

Unified Diff: apps/shell/browser/shell_app_window_api.cc

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/shell/browser/shell_app_window_api.h ('k') | chrome/browser/chromeos/extensions/echo_private_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell/browser/shell_app_window_api.cc
diff --git a/apps/shell/browser/shell_app_window_api.cc b/apps/shell/browser/shell_app_window_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de1012cd22ace78df9f301960af674cf625b4f14
--- /dev/null
+++ b/apps/shell/browser/shell_app_window_api.cc
@@ -0,0 +1,85 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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 {
+
+// Returns stub values for window bounds.
+DictionaryValue* CreateStubBoundsProperties() {
+ DictionaryValue* properties = new DictionaryValue;
+ properties->SetInteger("left", 0);
+ properties->SetInteger("top", 0);
+ properties->SetInteger("width", 0);
+ properties->SetInteger("height", 0);
+ return properties;
+}
+
+// Creates a function call result to send to the renderer.
+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"));
+
+ // Add stub window property data.
+ 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;
+}
+
+} // namespace
+
+ShellAppWindowCreateFunction::ShellAppWindowCreateFunction() {
+}
+
+ShellAppWindowCreateFunction::~ShellAppWindowCreateFunction() {
+}
+
+bool ShellAppWindowCreateFunction::RunAsync() {
+ // 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;
+
+ // Convert "main.html" to "chrome-extension:/<id>/main.html".
+ GURL url = GetExtension()->GetResourceURL(url_string);
+ if (!url.is_valid())
+ return false;
+
+ // The desktop keeps ownership of the window.
+ apps::ShellAppWindow* app_window =
+ apps::ShellDesktopController::instance()->CreateAppWindow(
+ browser_context());
+ app_window->LoadURL(url);
+
+ // Create the reply to send to the renderer.
+ DictionaryValue* result = CreateResult(app_window);
+ SetResult(result);
+
+ SendResponse(true /* success */);
+ return true;
+}
+
+} // namespace extensions
« no previous file with comments | « apps/shell/browser/shell_app_window_api.h ('k') | chrome/browser/chromeos/extensions/echo_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698