OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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/browser_extension_window_wrapper.h" | |
6 | |
7 #include "chrome/browser/extensions/extension_tab_util.h" | |
8 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/browser/sessions/session_id.h" | |
11 #include "chrome/browser/ui/browser.h" | |
12 #include "chrome/browser/ui/browser_window.h" | |
13 | |
14 BrowserExtensionWindowWrapper::BrowserExtensionWindowWrapper(Browser* browser) | |
15 : ExtensionWindowWrapper(browser->window(), browser->profile()), | |
16 browser_(browser) { | |
17 } | |
18 | |
19 const SessionID& BrowserExtensionWindowWrapper::GetSessionId() const { | |
20 return browser_->session_id(); | |
21 } | |
22 | |
23 namespace keys = extension_tabs_module_constants; | |
24 | |
25 base::DictionaryValue* BrowserExtensionWindowWrapper::CreateWindowValue( | |
26 bool populate_tabs) const { | |
27 DictionaryValue* result = new DictionaryValue(); | |
sky
2012/02/22 21:46:25
There's a lot of duplicate code between this and t
stevenjb
2012/02/23 02:19:15
Done.
| |
28 result->SetInteger(keys::kIdKey, browser_->session_id().id()); | |
29 result->SetBoolean(keys::kIncognitoKey, | |
30 browser_->profile()->IsOffTheRecord()); | |
31 result->SetBoolean(keys::kFocusedKey, window()->IsActive()); | |
32 | |
33 gfx::Rect bounds; | |
34 if (window()->IsMaximized() || browser_->window()->IsFullscreen()) | |
35 bounds = window()->GetBounds(); | |
36 else | |
37 bounds = window()->GetRestoredBounds(); | |
38 result->SetInteger(keys::kLeftKey, bounds.x()); | |
39 result->SetInteger(keys::kTopKey, bounds.y()); | |
40 result->SetInteger(keys::kWidthKey, bounds.width()); | |
41 result->SetInteger(keys::kHeightKey, bounds.height()); | |
42 | |
43 result->SetString(keys::kWindowTypeKey, | |
44 ExtensionTabUtil::GetWindowTypeText(browser_)); | |
45 result->SetString(keys::kShowStateKey, | |
46 ExtensionTabUtil::GetWindowShowStateText(browser_)); | |
47 | |
48 if (populate_tabs) | |
49 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); | |
50 | |
51 return result; | |
52 } | |
53 | |
54 bool BrowserExtensionWindowWrapper::CanClose( | |
55 ExtensionWindowWrapper::Reason* reason) const { | |
56 // Don't let an extension remove the window if the user is dragging tabs | |
57 // in that window. | |
58 if (!browser_->IsTabStripEditable()) { | |
59 *reason = ExtensionWindowWrapper::REASON_TAB_STRIP_NOT_EDITABLE; | |
60 return false; | |
61 } | |
62 return true; | |
63 } | |
OLD | NEW |