Chromium Code Reviews| Index: chrome/browser/extensions/browser_extension_window_controller.cc |
| diff --git a/chrome/browser/extensions/browser_extension_window_controller.cc b/chrome/browser/extensions/browser_extension_window_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c816246c32c540352d92e4e3442d9193adc98a82 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/browser_extension_window_controller.cc |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2011 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/browser_extension_window_controller.h" |
| + |
| +#include "chrome/browser/extensions/extension_tab_util.h" |
| +#include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/sessions/session_id.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| + |
| +BrowserExtensionWindowController::BrowserExtensionWindowController( |
| + Browser* browser) |
| + : ExtensionWindowController(browser->window(), browser->profile()), |
| + browser_(browser) { |
| +} |
| + |
| +const SessionID& BrowserExtensionWindowController::GetSessionId() const { |
| + return browser_->session_id(); |
| +} |
| + |
| +namespace keys = extension_tabs_module_constants; |
| + |
| +base::DictionaryValue* |
| +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
|
| + DictionaryValue* result = new DictionaryValue(); |
| + result->SetInteger(keys::kIdKey, browser_->session_id().id()); |
| + result->SetBoolean(keys::kIncognitoKey, |
| + browser_->profile()->IsOffTheRecord()); |
| + result->SetBoolean(keys::kFocusedKey, window()->IsActive()); |
| + |
| + gfx::Rect bounds; |
| + if (window()->IsMaximized() || browser_->window()->IsFullscreen()) |
| + bounds = window()->GetBounds(); |
| + else |
| + bounds = window()->GetRestoredBounds(); |
| + result->SetInteger(keys::kLeftKey, bounds.x()); |
| + result->SetInteger(keys::kTopKey, bounds.y()); |
| + result->SetInteger(keys::kWidthKey, bounds.width()); |
| + result->SetInteger(keys::kHeightKey, bounds.height()); |
| + |
| + result->SetString(keys::kWindowTypeKey, |
| + ExtensionTabUtil::GetWindowTypeText(browser_)); |
| + result->SetString(keys::kShowStateKey, |
| + ExtensionTabUtil::GetWindowShowStateText(browser_)); |
| + |
| + return result; |
| +} |
| + |
| +base::DictionaryValue* |
| +BrowserExtensionWindowController::CreateWindowValueWithTabs() const { |
| + DictionaryValue* result = CreateWindowValue(); |
| + |
| + result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); |
| + |
| + return result; |
| +} |
| + |
| +bool BrowserExtensionWindowController::CanClose( |
| + ExtensionWindowController::Reason* reason) const { |
| + // Don't let an extension remove the window if the user is dragging tabs |
| + // in that window. |
| + if (!browser_->IsTabStripEditable()) { |
| + *reason = ExtensionWindowController::REASON_TAB_STRIP_NOT_EDITABLE; |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +void BrowserExtensionWindowController::SetFullscreenMode( |
| + bool is_fullscreen, const GURL& extension_url) const { |
| + if (browser_->window()->IsFullscreen() != is_fullscreen) |
| + browser_->ToggleFullscreenModeWithExtension(extension_url); |
| +} |