| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/browser_extension_window_controller.h" | 5 #include "chrome/browser/extensions/browser_extension_window_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 8 #include "chrome/browser/extensions/extension_tab_util.h" | 8 #include "chrome/browser/extensions/extension_tab_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_tabstrip.h" | 12 #include "chrome/browser/ui/browser_tabstrip.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 | 15 |
| 16 BrowserExtensionWindowController::BrowserExtensionWindowController( | 16 BrowserExtensionWindowController::BrowserExtensionWindowController( |
| 17 Browser* browser) | 17 Browser* browser) |
| 18 : ExtensionWindowController(browser->window(), browser->profile()), | 18 : extensions::WindowController(browser->window(), browser->profile()), |
| 19 browser_(browser) { | 19 browser_(browser) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 int BrowserExtensionWindowController::GetWindowId() const { | 22 int BrowserExtensionWindowController::GetWindowId() const { |
| 23 return static_cast<int>(browser_->session_id().id()); | 23 return static_cast<int>(browser_->session_id().id()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace keys = extensions::tabs_constants; | 26 namespace keys = extensions::tabs_constants; |
| 27 | 27 |
| 28 std::string BrowserExtensionWindowController::GetWindowTypeText() const { | 28 std::string BrowserExtensionWindowController::GetWindowTypeText() const { |
| 29 if (browser_->is_type_popup()) | 29 if (browser_->is_type_popup()) |
| 30 return keys::kWindowTypeValuePopup; | 30 return keys::kWindowTypeValuePopup; |
| 31 if (browser_->is_type_panel()) | 31 if (browser_->is_type_panel()) |
| 32 return keys::kWindowTypeValuePanel; | 32 return keys::kWindowTypeValuePanel; |
| 33 if (browser_->is_app()) | 33 if (browser_->is_app()) |
| 34 return keys::kWindowTypeValueApp; | 34 return keys::kWindowTypeValueApp; |
| 35 return keys::kWindowTypeValueNormal; | 35 return keys::kWindowTypeValueNormal; |
| 36 } | 36 } |
| 37 | 37 |
| 38 base::DictionaryValue* | 38 base::DictionaryValue* |
| 39 BrowserExtensionWindowController::CreateWindowValue() const { | 39 BrowserExtensionWindowController::CreateWindowValue() const { |
| 40 DictionaryValue* result = ExtensionWindowController::CreateWindowValue(); | 40 DictionaryValue* result = extensions::WindowController::CreateWindowValue(); |
| 41 return result; | 41 return result; |
| 42 } | 42 } |
| 43 | 43 |
| 44 base::DictionaryValue* | 44 base::DictionaryValue* |
| 45 BrowserExtensionWindowController::CreateWindowValueWithTabs() const { | 45 BrowserExtensionWindowController::CreateWindowValueWithTabs() const { |
| 46 DictionaryValue* result = CreateWindowValue(); | 46 DictionaryValue* result = CreateWindowValue(); |
| 47 | 47 |
| 48 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); | 48 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_)); |
| 49 | 49 |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool BrowserExtensionWindowController::CanClose(Reason* reason) const { | 53 bool BrowserExtensionWindowController::CanClose(Reason* reason) const { |
| 54 // Don't let an extension remove the window if the user is dragging tabs | 54 // Don't let an extension remove the window if the user is dragging tabs |
| 55 // in that window. | 55 // in that window. |
| 56 if (!chrome::IsTabStripEditable(browser_)) { | 56 if (!chrome::IsTabStripEditable(browser_)) { |
| 57 *reason = ExtensionWindowController::REASON_NOT_EDITABLE; | 57 *reason = extensions::WindowController::REASON_NOT_EDITABLE; |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void BrowserExtensionWindowController::SetFullscreenMode( | 63 void BrowserExtensionWindowController::SetFullscreenMode( |
| 64 bool is_fullscreen, | 64 bool is_fullscreen, |
| 65 const GURL& extension_url) const { | 65 const GURL& extension_url) const { |
| 66 if (browser_->window()->IsFullscreen() != is_fullscreen) | 66 if (browser_->window()->IsFullscreen() != is_fullscreen) |
| 67 browser_->ToggleFullscreenModeWithExtension(extension_url); | 67 browser_->ToggleFullscreenModeWithExtension(extension_url); |
| 68 } | 68 } |
| 69 | 69 |
| 70 Browser* BrowserExtensionWindowController::GetBrowser() const { | 70 Browser* BrowserExtensionWindowController::GetBrowser() const { |
| 71 return browser_; | 71 return browser_; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool BrowserExtensionWindowController::IsVisibleToExtension( | 74 bool BrowserExtensionWindowController::IsVisibleToExtension( |
| 75 const extensions::Extension* extension) const { | 75 const extensions::Extension* extension) const { |
| 76 // Platform apps can only see their own windows. | 76 // Platform apps can only see their own windows. |
| 77 // TODO(mihaip): what about non-Aura panels? | 77 // TODO(mihaip): what about non-Aura panels? |
| 78 return !extension->is_platform_app(); | 78 return !extension->is_platform_app(); |
| 79 } | 79 } |
| OLD | NEW |