| 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/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
| 11 #include "chrome/browser/extensions/shell_window_registry.h" | 11 #include "chrome/browser/extensions/shell_window_registry.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
| 13 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 14 #include "chrome/browser/file_select_helper.h" | 14 #include "chrome/browser/file_select_helper.h" |
| 15 #include "chrome/browser/intents/web_intents_util.h" | 15 #include "chrome/browser/intents/web_intents_util.h" |
| 16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sessions/session_id.h" | 18 #include "chrome/browser/sessions/session_id.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 23 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 24 #include "chrome/browser/ui/extensions/native_shell_window.h" | 24 #include "chrome/browser/ui/extensions/native_shell_window.h" |
| 25 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 25 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 26 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 26 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 28 #include "chrome/browser/view_type_utils.h" | 28 #include "chrome/browser/view_type_utils.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/extensions/api/app_window.h" |
| 30 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| 31 #include "chrome/common/extensions/extension_messages.h" | 32 #include "chrome/common/extensions/extension_messages.h" |
| 32 #include "chrome/common/extensions/request_media_access_permission_helper.h" | 33 #include "chrome/common/extensions/request_media_access_permission_helper.h" |
| 33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/invalidate_type.h" | 35 #include "content/public/browser/invalidate_type.h" |
| 35 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
| 36 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
| 37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
| 39 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
| 40 #include "content/public/browser/render_process_host.h" | 41 #include "content/public/browser/render_process_host.h" |
| 41 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
| 42 #include "content/public/browser/resource_dispatcher_host.h" | 43 #include "content/public/browser/resource_dispatcher_host.h" |
| 43 #include "content/public/browser/site_instance.h" | 44 #include "content/public/browser/site_instance.h" |
| 44 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 45 #include "content/public/browser/web_intents_dispatcher.h" | 46 #include "content/public/browser/web_intents_dispatcher.h" |
| 46 #include "content/public/common/media_stream_request.h" | 47 #include "content/public/common/media_stream_request.h" |
| 47 #include "content/public/common/renderer_preferences.h" | 48 #include "content/public/common/renderer_preferences.h" |
| 48 #include "third_party/skia/include/core/SkRegion.h" | 49 #include "third_party/skia/include/core/SkRegion.h" |
| 49 | 50 |
| 51 namespace app_window = extensions::api::app_window; |
| 52 |
| 50 using content::BrowserThread; | 53 using content::BrowserThread; |
| 51 using content::ConsoleMessageLevel; | 54 using content::ConsoleMessageLevel; |
| 52 using content::RenderViewHost; | 55 using content::RenderViewHost; |
| 53 using content::ResourceDispatcherHost; | 56 using content::ResourceDispatcherHost; |
| 54 using content::SiteInstance; | 57 using content::SiteInstance; |
| 55 using content::WebContents; | 58 using content::WebContents; |
| 56 using extensions::APIPermission; | 59 using extensions::APIPermission; |
| 57 using extensions::RequestMediaAccessPermissionHelper; | 60 using extensions::RequestMediaAccessPermissionHelper; |
| 58 | 61 |
| 59 namespace { | 62 namespace { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 web_contents_->GetRenderViewHost()); | 458 web_contents_->GetRenderViewHost()); |
| 456 } | 459 } |
| 457 | 460 |
| 458 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 461 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| 459 const std::string& message) { | 462 const std::string& message) { |
| 460 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 463 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 461 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 464 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 462 rvh->GetRoutingID(), level, message)); | 465 rvh->GetRoutingID(), level, message)); |
| 463 } | 466 } |
| 464 | 467 |
| 465 void ShellWindow::SaveWindowPosition() | 468 void ShellWindow::SendBoundsUpdate() { |
| 466 { | 469 if (!native_window_ || !web_contents_) |
| 470 return; |
| 471 gfx::Rect bounds = native_window_->GetBounds(); |
| 472 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 473 ListValue args; |
| 474 app_window::Bounds update; |
| 475 update.left.reset(new int(bounds.x())); |
| 476 update.top.reset(new int(bounds.y())); |
| 477 update.width.reset(new int(bounds.width())); |
| 478 update.height.reset(new int(bounds.height())); |
| 479 args.Append(update.ToValue().release()); |
| 480 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), |
| 481 extension_->id(), |
| 482 "updateAppWindowBounds", |
| 483 args, |
| 484 GURL(), |
| 485 false)); |
| 486 } |
| 487 |
| 488 void ShellWindow::SaveWindowPosition() { |
| 489 SendBoundsUpdate(); |
| 467 if (window_key_.empty()) | 490 if (window_key_.empty()) |
| 468 return; | 491 return; |
| 469 if (!native_window_) | 492 if (!native_window_) |
| 470 return; | 493 return; |
| 471 | 494 |
| 472 extensions::ShellWindowGeometryCache* cache = | 495 extensions::ShellWindowGeometryCache* cache = |
| 473 extensions::ExtensionSystem::Get(profile())-> | 496 extensions::ExtensionSystem::Get(profile())-> |
| 474 shell_window_geometry_cache(); | 497 shell_window_geometry_cache(); |
| 475 | 498 |
| 476 gfx::Rect bounds = native_window_->GetBounds(); | 499 gfx::Rect bounds = native_window_->GetBounds(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 487 const extensions::DraggableRegion& region = *iter; | 510 const extensions::DraggableRegion& region = *iter; |
| 488 sk_region->op( | 511 sk_region->op( |
| 489 region.bounds.x(), | 512 region.bounds.x(), |
| 490 region.bounds.y(), | 513 region.bounds.y(), |
| 491 region.bounds.right(), | 514 region.bounds.right(), |
| 492 region.bounds.bottom(), | 515 region.bounds.bottom(), |
| 493 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 516 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 494 } | 517 } |
| 495 return sk_region; | 518 return sk_region; |
| 496 } | 519 } |
| OLD | NEW |