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 { |
| 28 DictionaryValue* result = ExtensionWindowController::CreateWindowValue(); |
| 29 |
| 30 result->SetString(keys::kWindowTypeKey, |
| 31 ExtensionTabUtil::GetWindowTypeText(browser_)); |
| 32 result->SetString(keys::kShowStateKey, |
| 33 ExtensionTabUtil::GetWindowShowStateText(browser_)); |
| 34 |
| 35 return result; |
| 36 } |
| 37 |
| 38 base::DictionaryValue* |
| 39 BrowserExtensionWindowController::CreateWindowValueWithTabs() const { |
| 40 DictionaryValue* result = CreateWindowValue(); |
| 41 |
| 42 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); |
| 43 |
| 44 return result; |
| 45 } |
| 46 |
| 47 bool BrowserExtensionWindowController::CanClose( |
| 48 ExtensionWindowController::Reason* reason) const { |
| 49 // Don't let an extension remove the window if the user is dragging tabs |
| 50 // in that window. |
| 51 if (!browser_->IsTabStripEditable()) { |
| 52 *reason = ExtensionWindowController::REASON_TAB_STRIP_NOT_EDITABLE; |
| 53 return false; |
| 54 } |
| 55 return true; |
| 56 } |
| 57 |
| 58 void BrowserExtensionWindowController::SetFullscreenMode( |
| 59 bool is_fullscreen, |
| 60 const GURL& extension_url) const { |
| 61 if (browser_->window()->IsFullscreen() != is_fullscreen) |
| 62 browser_->ToggleFullscreenModeWithExtension(extension_url); |
| 63 } |
OLD | NEW |