OLD | NEW |
| (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/extension_window_controller.h" | |
6 | |
7 #include "base/values.h" | |
8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | |
9 #include "chrome/browser/extensions/extension_window_list.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/browser/ui/base_window.h" | |
12 #include "ui/gfx/rect.h" | |
13 | |
14 /////////////////////////////////////////////////////////////////////////////// | |
15 // ExtensionWindowController | |
16 | |
17 ExtensionWindowController::ExtensionWindowController(BaseWindow* window, | |
18 Profile* profile) : | |
19 window_(window), | |
20 profile_(profile) { | |
21 ExtensionWindowList::GetInstance()->AddExtensionWindow(this); | |
22 } | |
23 | |
24 ExtensionWindowController::~ExtensionWindowController() { | |
25 ExtensionWindowList::GetInstance()->RemoveExtensionWindow(this); | |
26 } | |
27 | |
28 Browser* ExtensionWindowController::GetBrowser() const { | |
29 return NULL; | |
30 } | |
31 | |
32 namespace keys = extensions::tabs_constants; | |
33 | |
34 base::DictionaryValue* ExtensionWindowController::CreateWindowValue() const { | |
35 DictionaryValue* result = new DictionaryValue(); | |
36 | |
37 result->SetInteger(keys::kIdKey, GetWindowId()); | |
38 result->SetString(keys::kWindowTypeKey, GetWindowTypeText()); | |
39 result->SetBoolean(keys::kFocusedKey, window()->IsActive()); | |
40 result->SetBoolean(keys::kIncognitoKey, profile_->IsOffTheRecord()); | |
41 result->SetBoolean(keys::kAlwaysOnTopKey, window()->IsAlwaysOnTop()); | |
42 | |
43 std::string window_state; | |
44 if (window()->IsMinimized()) { | |
45 window_state = keys::kShowStateValueMinimized; | |
46 } else if (window()->IsFullscreen()) { | |
47 window_state = keys::kShowStateValueFullscreen; | |
48 } else if (window()->IsMaximized()) { | |
49 window_state = keys::kShowStateValueMaximized; | |
50 } else { | |
51 window_state = keys::kShowStateValueNormal; | |
52 } | |
53 result->SetString(keys::kShowStateKey, window_state); | |
54 | |
55 gfx::Rect bounds; | |
56 if (window()->IsMinimized()) | |
57 bounds = window()->GetRestoredBounds(); | |
58 else | |
59 bounds = window()->GetBounds(); | |
60 result->SetInteger(keys::kLeftKey, bounds.x()); | |
61 result->SetInteger(keys::kTopKey, bounds.y()); | |
62 result->SetInteger(keys::kWidthKey, bounds.width()); | |
63 result->SetInteger(keys::kHeightKey, bounds.height()); | |
64 | |
65 return result; | |
66 } | |
OLD | NEW |