| 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 "apps/shell_window_geometry_cache.h" |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 9 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/app_window_contents.h" | 10 #include "chrome/browser/extensions/app_window_contents.h" |
| 10 #include "chrome/browser/extensions/extension_process_manager.h" | 11 #include "chrome/browser/extensions/extension_process_manager.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/image_loader.h" | 13 #include "chrome/browser/extensions/image_loader.h" |
| 13 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | |
| 14 #include "chrome/browser/extensions/shell_window_registry.h" | 14 #include "chrome/browser/extensions/shell_window_registry.h" |
| 15 #include "chrome/browser/extensions/suggest_permission_util.h" | 15 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 16 #include "chrome/browser/favicon/favicon_tab_helper.h" | 16 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 17 #include "chrome/browser/file_select_helper.h" | 17 #include "chrome/browser/file_select_helper.h" |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
| 19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/sessions/session_id.h" | 21 #include "chrome/browser/sessions/session_id.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (bounds.height() == 0) | 129 if (bounds.height() == 0) |
| 130 bounds.set_height(kDefaultHeight); | 130 bounds.set_height(kDefaultHeight); |
| 131 | 131 |
| 132 // If left and top are left undefined, the native shell window will center | 132 // If left and top are left undefined, the native shell window will center |
| 133 // the window on the main screen in a platform-defined manner. | 133 // the window on the main screen in a platform-defined manner. |
| 134 | 134 |
| 135 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT; | 135 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT; |
| 136 if (!params.window_key.empty()) { | 136 if (!params.window_key.empty()) { |
| 137 window_key_ = params.window_key; | 137 window_key_ = params.window_key; |
| 138 | 138 |
| 139 extensions::ShellWindowGeometryCache* cache = | 139 apps::ShellWindowGeometryCache* cache = |
| 140 extensions::ExtensionSystem::Get(profile())-> | 140 apps::ShellWindowGeometryCache::Get(profile()); |
| 141 shell_window_geometry_cache(); | 141 |
| 142 gfx::Rect cached_bounds; | 142 gfx::Rect cached_bounds; |
| 143 if (cache->GetGeometry(extension()->id(), params.window_key, | 143 if (cache->GetGeometry(extension()->id(), params.window_key, |
| 144 &cached_bounds, &cached_state)) { | 144 &cached_bounds, &cached_state)) { |
| 145 bounds = cached_bounds; | 145 bounds = cached_bounds; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 CreateParams new_params = params; | 149 CreateParams new_params = params; |
| 150 | 150 |
| 151 gfx::Size& minimum_size = new_params.minimum_size; | 151 gfx::Size& minimum_size = new_params.minimum_size; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 561 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 562 rvh->GetRoutingID(), level, message)); | 562 rvh->GetRoutingID(), level, message)); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void ShellWindow::SaveWindowPosition() { | 565 void ShellWindow::SaveWindowPosition() { |
| 566 if (window_key_.empty()) | 566 if (window_key_.empty()) |
| 567 return; | 567 return; |
| 568 if (!native_app_window_) | 568 if (!native_app_window_) |
| 569 return; | 569 return; |
| 570 | 570 |
| 571 extensions::ShellWindowGeometryCache* cache = | 571 apps::ShellWindowGeometryCache* cache = |
| 572 extensions::ExtensionSystem::Get(profile())-> | 572 apps::ShellWindowGeometryCache::Get(profile()); |
| 573 shell_window_geometry_cache(); | |
| 574 | 573 |
| 575 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); | 574 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); |
| 576 bounds.Inset(native_app_window_->GetFrameInsets()); | 575 bounds.Inset(native_app_window_->GetFrameInsets()); |
| 577 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); | 576 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); |
| 578 cache->SaveGeometry(extension()->id(), window_key_, bounds, window_state); | 577 cache->SaveGeometry(extension()->id(), window_key_, bounds, window_state); |
| 579 } | 578 } |
| 580 | 579 |
| 581 // static | 580 // static |
| 582 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( | 581 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( |
| 583 const std::vector<extensions::DraggableRegion>& regions) { | 582 const std::vector<extensions::DraggableRegion>& regions) { |
| 584 SkRegion* sk_region = new SkRegion; | 583 SkRegion* sk_region = new SkRegion; |
| 585 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | 584 for (std::vector<extensions::DraggableRegion>::const_iterator iter = |
| 586 regions.begin(); | 585 regions.begin(); |
| 587 iter != regions.end(); ++iter) { | 586 iter != regions.end(); ++iter) { |
| 588 const extensions::DraggableRegion& region = *iter; | 587 const extensions::DraggableRegion& region = *iter; |
| 589 sk_region->op( | 588 sk_region->op( |
| 590 region.bounds.x(), | 589 region.bounds.x(), |
| 591 region.bounds.y(), | 590 region.bounds.y(), |
| 592 region.bounds.right(), | 591 region.bounds.right(), |
| 593 region.bounds.bottom(), | 592 region.bounds.bottom(), |
| 594 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 593 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 595 } | 594 } |
| 596 return sk_region; | 595 return sk_region; |
| 597 } | 596 } |
| OLD | NEW |