Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 11193049: Add the app.windows.getBounds method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avoid unnecessary writes to disk Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 web_contents_->GetRenderViewHost()); 457 web_contents_->GetRenderViewHost());
458 } 458 }
459 459
460 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, 460 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
461 const std::string& message) { 461 const std::string& message) {
462 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 462 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
463 rvh->Send(new ExtensionMsg_AddMessageToConsole( 463 rvh->Send(new ExtensionMsg_AddMessageToConsole(
464 rvh->GetRoutingID(), level, message)); 464 rvh->GetRoutingID(), level, message));
465 } 465 }
466 466
467 void ShellWindow::SaveWindowPosition() 467 void ShellWindow::SendBoundsUpdate() {
468 { 468 if (!native_window_ || !web_contents_)
469 return;
470 gfx::Rect bounds = native_window_->GetBounds();
471 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
472 ListValue args;
473 DictionaryValue* update = new DictionaryValue();
474 args.Append(update);
475 update->SetInteger("left", bounds.x());
476 update->SetInteger("top", bounds.y());
477 update->SetInteger("width", bounds.width());
478 update->SetInteger("height", bounds.height());
479 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
480 extension_->id(),
481 "updateAppWindowBounds",
482 args,
483 GURL(),
484 false));
485 }
486
487 void ShellWindow::SaveWindowPosition() {
488 SendBoundsUpdate();
469 if (window_key_.empty()) 489 if (window_key_.empty())
470 return; 490 return;
471 491
472 extensions::ShellWindowGeometryCache* cache = 492 extensions::ShellWindowGeometryCache* cache =
473 extensions::ExtensionSystem::Get(profile())-> 493 extensions::ExtensionSystem::Get(profile())->
474 shell_window_geometry_cache(); 494 shell_window_geometry_cache();
475 495
476 gfx::Rect bounds = native_window_->GetBounds(); 496 gfx::Rect bounds = native_window_->GetBounds();
477 cache->SaveGeometry(extension()->id(), window_key_, bounds); 497 cache->SaveGeometry(extension()->id(), window_key_, bounds);
478 } 498 }
479 499
480 // static 500 // static
481 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( 501 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion(
482 const std::vector<extensions::DraggableRegion>& regions) { 502 const std::vector<extensions::DraggableRegion>& regions) {
483 SkRegion* sk_region = new SkRegion; 503 SkRegion* sk_region = new SkRegion;
484 for (std::vector<extensions::DraggableRegion>::const_iterator iter = 504 for (std::vector<extensions::DraggableRegion>::const_iterator iter =
485 regions.begin(); 505 regions.begin();
486 iter != regions.end(); ++iter) { 506 iter != regions.end(); ++iter) {
487 const extensions::DraggableRegion& region = *iter; 507 const extensions::DraggableRegion& region = *iter;
488 sk_region->op( 508 sk_region->op(
489 region.bounds.x(), 509 region.bounds.x(),
490 region.bounds.y(), 510 region.bounds.y(),
491 region.bounds.right(), 511 region.bounds.right(),
492 region.bounds.bottom(), 512 region.bounds.bottom(),
493 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 513 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
494 } 514 }
495 return sk_region; 515 return sk_region;
496 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698