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

Unified Diff: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc

Issue 10878040: Move context-sensitive app.window.* functions to app.window.current().* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 4 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
Index: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
diff --git a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..751bc4c9faa707c24b5a6390fe06bdcd0b4345da
--- /dev/null
+++ b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 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 "chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h"
+#include "chrome/browser/extensions/shell_window_registry.h"
+#include "chrome/browser/ui/extensions/shell_window.h"
+#include "chrome/common/extensions/extension_error_utils.h"
+
+namespace extensions {
+
+namespace {
+const char kNoAssociatedShellWindow[] =
+ "The context from which the function was called did not have an "
+ "associated shell window.";
+};
+
+bool AppCurrentWindowInternalExtensionFunction::RunImpl() {
+ ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile());
+ CHECK(registry);
+ content::RenderViewHost* rvh = render_view_host();
+ if (!rvh)
+ // No need to set an error, since we won't return to the caller anyway if
+ // there's no RVH.
+ return false;
+ ShellWindow* window = registry->GetShellWindowForRenderViewHost(rvh);
+ if (!window) {
+ error_ = kNoAssociatedShellWindow;
+ return false;
+ }
+ return RunWithWindow(window);
+}
+
+bool AppCurrentWindowInternalFocusFunction::RunWithWindow(ShellWindow* window) {
+ window->GetBaseWindow()->Activate();
+ return true;
+}
+
+bool AppCurrentWindowInternalMaximizeFunction::RunWithWindow(
+ ShellWindow* window) {
+ window->GetBaseWindow()->Maximize();
+ return true;
+}
+
+bool AppCurrentWindowInternalMinimizeFunction::RunWithWindow(
+ ShellWindow* window) {
+ window->GetBaseWindow()->Minimize();
+ return true;
+}
+
+bool AppCurrentWindowInternalRestoreFunction::RunWithWindow(
+ ShellWindow* window) {
+ window->GetBaseWindow()->Restore();
+ return true;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698