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_controller.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 BrowserExtensionWindowController::BrowserExtensionWindowController( | |
15 Browser* browser) | |
16 : ExtensionWindowController(browser->window(), browser->profile()), | |
17 browser_(browser) { | |
18 } | |
19 | |
20 const SessionID& BrowserExtensionWindowController::GetSessionId() const { | |
21 return browser_->session_id(); | |
22 } | |
23 | |
24 namespace keys = extension_tabs_module_constants; | |
25 | |
26 base::DictionaryValue* | |
27 BrowserExtensionWindowController::CreateWindowValue() const { | |
Mihai Parparita -not on Chrome
2012/02/23 02:35:36
I don't know if this is what Scott meant when he s
stevenjb
2012/02/23 19:57:51
I forgot to update my comment. It turns out that t
| |
28 DictionaryValue* result = new DictionaryValue(); | |
29 result->SetInteger(keys::kIdKey, browser_->session_id().id()); | |
30 result->SetBoolean(keys::kIncognitoKey, | |
31 browser_->profile()->IsOffTheRecord()); | |
32 result->SetBoolean(keys::kFocusedKey, window()->IsActive()); | |
33 | |
34 gfx::Rect bounds; | |
35 if (window()->IsMaximized() || browser_->window()->IsFullscreen()) | |
36 bounds = window()->GetBounds(); | |
37 else | |
38 bounds = window()->GetRestoredBounds(); | |
39 result->SetInteger(keys::kLeftKey, bounds.x()); | |
40 result->SetInteger(keys::kTopKey, bounds.y()); | |
41 result->SetInteger(keys::kWidthKey, bounds.width()); | |
42 result->SetInteger(keys::kHeightKey, bounds.height()); | |
43 | |
44 result->SetString(keys::kWindowTypeKey, | |
45 ExtensionTabUtil::GetWindowTypeText(browser_)); | |
46 result->SetString(keys::kShowStateKey, | |
47 ExtensionTabUtil::GetWindowShowStateText(browser_)); | |
48 | |
49 return result; | |
50 } | |
51 | |
52 base::DictionaryValue* | |
53 BrowserExtensionWindowController::CreateWindowValueWithTabs() const { | |
54 DictionaryValue* result = CreateWindowValue(); | |
55 | |
56 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); | |
57 | |
58 return result; | |
59 } | |
60 | |
61 bool BrowserExtensionWindowController::CanClose( | |
62 ExtensionWindowController::Reason* reason) const { | |
63 // Don't let an extension remove the window if the user is dragging tabs | |
64 // in that window. | |
65 if (!browser_->IsTabStripEditable()) { | |
66 *reason = ExtensionWindowController::REASON_TAB_STRIP_NOT_EDITABLE; | |
67 return false; | |
68 } | |
69 return true; | |
70 } | |
71 | |
72 void BrowserExtensionWindowController::SetFullscreenMode( | |
73 bool is_fullscreen, const GURL& extension_url) const { | |
74 if (browser_->window()->IsFullscreen() != is_fullscreen) | |
75 browser_->ToggleFullscreenModeWithExtension(extension_url); | |
76 } | |
OLD | NEW |