Chromium Code Reviews| 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" |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 web_contents_->GetRenderViewHost()); | 443 web_contents_->GetRenderViewHost()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, | 446 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, |
| 447 const std::string& message) { | 447 const std::string& message) { |
| 448 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 448 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 449 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 449 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 450 rvh->GetRoutingID(), level, message)); | 450 rvh->GetRoutingID(), level, message)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void ShellWindow::SaveWindowPosition() | 453 void ShellWindow::SendBoundsUpdate() { |
| 454 { | 454 if (!native_window_ || !web_contents_) |
| 455 return; | |
| 456 gfx::Rect bounds = native_window_->GetBounds(); | |
| 457 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | |
| 458 ListValue args; | |
| 459 DictionaryValue* update = new DictionaryValue(); | |
|
Mihai Parparita -not on Chrome
2012/11/02 20:05:14
Can you use the generated C++ class for Bounds in
asargent_no_longer_on_chrome
2012/11/02 20:55:50
Done.
| |
| 460 args.Append(update); | |
| 461 update->SetInteger("left", bounds.x()); | |
| 462 update->SetInteger("top", bounds.y()); | |
| 463 update->SetInteger("width", bounds.width()); | |
| 464 update->SetInteger("height", bounds.height()); | |
| 465 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(), | |
| 466 extension_->id(), | |
| 467 "updateAppWindowBounds", | |
| 468 args, | |
| 469 GURL(), | |
| 470 false)); | |
| 471 } | |
| 472 | |
| 473 void ShellWindow::SaveWindowPosition() { | |
| 474 SendBoundsUpdate(); | |
| 455 if (window_key_.empty()) | 475 if (window_key_.empty()) |
| 456 return; | 476 return; |
| 457 | 477 |
| 458 extensions::ShellWindowGeometryCache* cache = | 478 extensions::ShellWindowGeometryCache* cache = |
| 459 extensions::ExtensionSystem::Get(profile())-> | 479 extensions::ExtensionSystem::Get(profile())-> |
| 460 shell_window_geometry_cache(); | 480 shell_window_geometry_cache(); |
| 461 | 481 |
| 462 gfx::Rect bounds = native_window_->GetBounds(); | 482 gfx::Rect bounds = native_window_->GetBounds(); |
| 463 cache->SaveGeometry(extension()->id(), window_key_, bounds); | 483 cache->SaveGeometry(extension()->id(), window_key_, bounds); |
| 464 } | 484 } |
| 465 | 485 |
| 466 // static | 486 // static |
| 467 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( | 487 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( |
| 468 const std::vector<extensions::DraggableRegion>& regions) { | 488 const std::vector<extensions::DraggableRegion>& regions) { |
| 469 SkRegion* sk_region = new SkRegion; | 489 SkRegion* sk_region = new SkRegion; |
| 470 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | 490 for (std::vector<extensions::DraggableRegion>::const_iterator iter = |
| 471 regions.begin(); | 491 regions.begin(); |
| 472 iter != regions.end(); ++iter) { | 492 iter != regions.end(); ++iter) { |
| 473 const extensions::DraggableRegion& region = *iter; | 493 const extensions::DraggableRegion& region = *iter; |
| 474 sk_region->op( | 494 sk_region->op( |
| 475 region.bounds.x(), | 495 region.bounds.x(), |
| 476 region.bounds.y(), | 496 region.bounds.y(), |
| 477 region.bounds.right(), | 497 region.bounds.right(), |
| 478 region.bounds.bottom(), | 498 region.bounds.bottom(), |
| 479 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 499 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 480 } | 500 } |
| 481 return sk_region; | 501 return sk_region; |
| 482 } | 502 } |
| OLD | NEW |