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

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: Created 8 years, 2 months 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 web_contents_->GetRenderViewHost()); 458 web_contents_->GetRenderViewHost());
459 } 459 }
460 460
461 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, 461 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
462 const std::string& message) { 462 const std::string& message) {
463 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 463 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
464 rvh->Send(new ExtensionMsg_AddMessageToConsole( 464 rvh->Send(new ExtensionMsg_AddMessageToConsole(
465 rvh->GetRoutingID(), level, message)); 465 rvh->GetRoutingID(), level, message));
466 } 466 }
467 467
468 void ShellWindow::SaveWindowPosition() 468 void ShellWindow::SendBoundsUpdate() {
469 { 469 gfx::Rect bounds = native_window_->GetBounds();
470 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
471 ListValue args;
472 DictionaryValue* update = new DictionaryValue();
473 args.Append(update);
474 update->SetInteger("x", bounds.x());
475 update->SetInteger("y", bounds.y());
476 update->SetInteger("width", bounds.width());
477 update->SetInteger("height", bounds.height());
478 rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
479 extension_->id(),
480 "updateAppWindowBounds",
481 args,
482 GURL(),
483 false));
484 }
485
486 void ShellWindow::SaveWindowPosition() {
487 SendBoundsUpdate();
jeremya 2012/10/19 00:26:45 I don't think SaveWindowPosition is sufficient her
470 if (window_key_.empty()) 488 if (window_key_.empty())
471 return; 489 return;
472 490
473 extensions::ShellWindowGeometryCache* cache = 491 extensions::ShellWindowGeometryCache* cache =
474 extensions::ExtensionSystem::Get(profile())-> 492 extensions::ExtensionSystem::Get(profile())->
475 shell_window_geometry_cache(); 493 shell_window_geometry_cache();
476 494
477 gfx::Rect bounds = native_window_->GetBounds(); 495 gfx::Rect bounds = native_window_->GetBounds();
478 cache->SaveGeometry(extension()->id(), window_key_, bounds); 496 cache->SaveGeometry(extension()->id(), window_key_, bounds);
479 } 497 }
480 498
481 // static 499 // static
482 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( 500 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion(
483 const std::vector<extensions::DraggableRegion>& regions) { 501 const std::vector<extensions::DraggableRegion>& regions) {
484 SkRegion* sk_region = new SkRegion; 502 SkRegion* sk_region = new SkRegion;
485 for (std::vector<extensions::DraggableRegion>::const_iterator iter = 503 for (std::vector<extensions::DraggableRegion>::const_iterator iter =
486 regions.begin(); 504 regions.begin();
487 iter != regions.end(); ++iter) { 505 iter != regions.end(); ++iter) {
488 const extensions::DraggableRegion& region = *iter; 506 const extensions::DraggableRegion& region = *iter;
489 sk_region->op( 507 sk_region->op(
490 region.bounds.x(), 508 region.bounds.x(),
491 region.bounds.y(), 509 region.bounds.y(),
492 region.bounds.right(), 510 region.bounds.right(),
493 region.bounds.bottom(), 511 region.bounds.bottom(),
494 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 512 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
495 } 513 }
496 return sk_region; 514 return sk_region;
497 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698