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

Side by Side Diff: chrome/browser/extensions/api/app_current_window/app_current_window_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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/app_current_window/app_current_window_ap i.h"
6 #include "chrome/browser/extensions/shell_window_registry.h"
7 #include "chrome/browser/ui/extensions/shell_window.h"
8 #include "chrome/common/extensions/extension_error_utils.h"
9
10 namespace extensions {
11
12 namespace app_window_constants {
13 const char kNoAssociatedShellWindow[] =
14 "The context from which the function was called did not have an "
15 "associated shell window.";
16 };
17
18 bool AppCurrentWindowExtensionFunction::RunImpl() {
19 ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile());
20 CHECK(registry);
21 content::RenderViewHost* rvh = render_view_host();
22 if (!rvh)
23 // No need to set an error, since we won't return to the caller anyway if
24 // there's no RVH.
25 return false;
26 ShellWindow* window = registry->GetShellWindowForRenderViewHost(rvh);
27 if (!window) {
28 error_ = app_window_constants::kNoAssociatedShellWindow;
29 return false;
30 }
31 return RunWithWindow(window);
32 }
33
34 bool AppCurrentWindowFocusFunction::RunWithWindow(ShellWindow* window) {
35 window->GetBaseWindow()->Activate();
36 return true;
37 }
38
39 bool AppCurrentWindowMaximizeFunction::RunWithWindow(ShellWindow* window) {
40 window->GetBaseWindow()->Maximize();
41 return true;
42 }
43
44 bool AppCurrentWindowMinimizeFunction::RunWithWindow(ShellWindow* window) {
45 window->GetBaseWindow()->Minimize();
46 return true;
47 }
48
49 bool AppCurrentWindowRestoreFunction::RunWithWindow(ShellWindow* window) {
50 window->GetBaseWindow()->Restore();
51 return true;
52 }
53
54 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698