| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/api/tabs/ash_panel_contents.h" | 5 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
| 11 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 11 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
| 12 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
| 13 #include "chrome/browser/extensions/window_controller_list.h" | 13 #include "chrome/browser/extensions/window_controller_list.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sessions/session_tab_helper.h" | 15 #include "chrome/browser/sessions/session_tab_helper.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "extensions/browser/app_window/native_app_window.h" | 19 #include "extensions/browser/app_window/native_app_window.h" |
| 20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "extensions/common/extension_messages.h" | 21 #include "extensions/common/extension_messages.h" |
| 22 #include "extensions/common/permissions/api_permission.h" |
| 23 #include "extensions/common/permissions/permissions_data.h" |
| 22 #include "ui/gfx/image/image.h" | 24 #include "ui/gfx/image/image.h" |
| 23 | 25 |
| 24 using extensions::AppWindow; | 26 using extensions::AppWindow; |
| 25 using extensions::NativeAppWindow; | 27 using extensions::NativeAppWindow; |
| 26 | 28 |
| 27 // AshPanelWindowController ---------------------------------------------------- | 29 // AshPanelWindowController ---------------------------------------------------- |
| 28 | 30 |
| 29 // This class enables an AppWindow instance to be accessed (to a limited | 31 // This class enables an AppWindow instance to be accessed (to a limited |
| 30 // extent) via the chrome.windows and chrome.tabs API. This is a temporary | 32 // extent) via the chrome.windows and chrome.tabs API. This is a temporary |
| 31 // bridge to support instantiating AppWindows from v1 apps, specifically | 33 // bridge to support instantiating AppWindows from v1 apps, specifically |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return true; | 135 return true; |
| 134 } | 136 } |
| 135 | 137 |
| 136 void AshPanelWindowController::SetFullscreenMode( | 138 void AshPanelWindowController::SetFullscreenMode( |
| 137 bool is_fullscreen, const GURL& extension_url) const { | 139 bool is_fullscreen, const GURL& extension_url) const { |
| 138 // Do nothing. Panels cannot be fullscreen. | 140 // Do nothing. Panels cannot be fullscreen. |
| 139 } | 141 } |
| 140 | 142 |
| 141 bool AshPanelWindowController::IsVisibleToExtension( | 143 bool AshPanelWindowController::IsVisibleToExtension( |
| 142 const extensions::Extension* extension) const { | 144 const extensions::Extension* extension) const { |
| 145 if (extension->permissions_data()->HasAPIPermission( |
| 146 extensions::APIPermission::kTabGlobal)) |
| 147 return true; |
| 143 return extension->id() == app_window_->extension_id(); | 148 return extension->id() == app_window_->extension_id(); |
| 144 } | 149 } |
| 145 | 150 |
| 146 void AshPanelWindowController::NativeWindowChanged() { | 151 void AshPanelWindowController::NativeWindowChanged() { |
| 147 bool active = app_window_->GetBaseWindow()->IsActive(); | 152 bool active = app_window_->GetBaseWindow()->IsActive(); |
| 148 if (active == is_active_) | 153 if (active == is_active_) |
| 149 return; | 154 return; |
| 150 is_active_ = active; | 155 is_active_ = active; |
| 151 // Let the extension API know that the active window changed. | 156 // Let the extension API know that the active window changed. |
| 152 extensions::TabsWindowsAPI* tabs_windows_api = | 157 extensions::TabsWindowsAPI* tabs_windows_api = |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 243 |
| 239 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { | 244 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { |
| 240 return web_contents_.get(); | 245 return web_contents_.get(); |
| 241 } | 246 } |
| 242 | 247 |
| 243 void AshPanelContents::OnRequest( | 248 void AshPanelContents::OnRequest( |
| 244 const ExtensionHostMsg_Request_Params& params) { | 249 const ExtensionHostMsg_Request_Params& params) { |
| 245 extension_function_dispatcher_->Dispatch( | 250 extension_function_dispatcher_->Dispatch( |
| 246 params, web_contents_->GetRenderViewHost()); | 251 params, web_contents_->GetRenderViewHost()); |
| 247 } | 252 } |
| OLD | NEW |