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

Unified Diff: chrome/browser/extensions/browser_extension_window_controller.cc

Issue 9428018: Create BaseWindow and ExtensionWindowWrapper for extension API access to Panels (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments. Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
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..6ddb1043effc84434acc143f0a53ed5a5c880953
--- /dev/null
+++ b/chrome/browser/extensions/browser_extension_window_controller.cc
@@ -0,0 +1,73 @@
+// 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 {
+ 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();
+ SetWindowValueBounds(bounds, result);
+
+ 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 {
sky 2012/02/24 04:38:24 nit: each param on its own line.
stevenjb 2012/02/24 19:25:06 Done.
+ if (browser_->window()->IsFullscreen() != is_fullscreen)
+ browser_->ToggleFullscreenModeWithExtension(extension_url);
+}

Powered by Google App Engine
This is Rietveld 408576698