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 24 matching lines...) Expand all Loading... |
35 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
36 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/resource_dispatcher_host.h" | 39 #include "content/public/browser/resource_dispatcher_host.h" |
40 #include "content/public/browser/site_instance.h" | 40 #include "content/public/browser/site_instance.h" |
41 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
42 #include "content/public/browser/web_intents_dispatcher.h" | 42 #include "content/public/browser/web_intents_dispatcher.h" |
43 #include "content/public/common/media_stream_request.h" | 43 #include "content/public/common/media_stream_request.h" |
44 #include "content/public/common/renderer_preferences.h" | 44 #include "content/public/common/renderer_preferences.h" |
| 45 #include "third_party/skia/include/core/SkRegion.h" |
45 | 46 |
46 using content::BrowserThread; | 47 using content::BrowserThread; |
47 using content::ConsoleMessageLevel; | 48 using content::ConsoleMessageLevel; |
48 using content::RenderViewHost; | 49 using content::RenderViewHost; |
49 using content::ResourceDispatcherHost; | 50 using content::ResourceDispatcherHost; |
50 using content::SiteInstance; | 51 using content::SiteInstance; |
51 using content::WebContents; | 52 using content::WebContents; |
52 using extensions::APIPermission; | 53 using extensions::APIPermission; |
53 | 54 |
54 namespace { | 55 namespace { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 308 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
308 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, | 309 IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions, |
309 UpdateDraggableRegions) | 310 UpdateDraggableRegions) |
310 IPC_MESSAGE_UNHANDLED(handled = false) | 311 IPC_MESSAGE_UNHANDLED(handled = false) |
311 IPC_END_MESSAGE_MAP() | 312 IPC_END_MESSAGE_MAP() |
312 return handled; | 313 return handled; |
313 } | 314 } |
314 | 315 |
315 void ShellWindow::UpdateDraggableRegions( | 316 void ShellWindow::UpdateDraggableRegions( |
316 const std::vector<extensions::DraggableRegion>& regions) { | 317 const std::vector<extensions::DraggableRegion>& regions) { |
317 // Decide if we want to treat it as old syntax by checking labels. | 318 native_window_->UpdateDraggableRegions(regions); |
318 // TODO(jianli): to be removed after WebKit patch that changes the draggable | |
319 // region syntax is landed. | |
320 bool new_syntax = true; | |
321 for (std::vector<extensions::DraggableRegion>::const_iterator iter = | |
322 regions.begin(); | |
323 iter != regions.end(); ++iter) { | |
324 const extensions::DraggableRegion& region = *iter; | |
325 if (!region.label.empty() || !region.clip.IsEmpty()) { | |
326 new_syntax = false; | |
327 break; | |
328 } | |
329 } | |
330 | |
331 if (new_syntax) | |
332 native_window_->UpdateDraggableRegions(regions); | |
333 else | |
334 native_window_->UpdateLegacyDraggableRegions(regions); | |
335 } | 319 } |
336 | 320 |
337 void ShellWindow::OnImageLoaded(const gfx::Image& image, | 321 void ShellWindow::OnImageLoaded(const gfx::Image& image, |
338 const std::string& extension_id, | 322 const std::string& extension_id, |
339 int index) { | 323 int index) { |
340 if (!image.IsEmpty()) { | 324 if (!image.IsEmpty()) { |
341 app_icon_ = image; | 325 app_icon_ = image; |
342 native_window_->UpdateWindowIcon(); | 326 native_window_->UpdateWindowIcon(); |
343 } | 327 } |
344 app_icon_loader_.reset(); | 328 app_icon_loader_.reset(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 if (window_key_.empty()) | 456 if (window_key_.empty()) |
473 return; | 457 return; |
474 | 458 |
475 extensions::ShellWindowGeometryCache* cache = | 459 extensions::ShellWindowGeometryCache* cache = |
476 extensions::ExtensionSystem::Get(profile())-> | 460 extensions::ExtensionSystem::Get(profile())-> |
477 shell_window_geometry_cache(); | 461 shell_window_geometry_cache(); |
478 | 462 |
479 gfx::Rect bounds = native_window_->GetBounds(); | 463 gfx::Rect bounds = native_window_->GetBounds(); |
480 cache->SaveGeometry(extension()->id(), window_key_, bounds); | 464 cache->SaveGeometry(extension()->id(), window_key_, bounds); |
481 } | 465 } |
| 466 |
| 467 // static |
| 468 SkRegion* ShellWindow::RawDraggableRegionsToSkRegion( |
| 469 const std::vector<extensions::DraggableRegion>& regions) { |
| 470 SkRegion* sk_region = new SkRegion; |
| 471 for (std::vector<extensions::DraggableRegion>::const_iterator iter = |
| 472 regions.begin(); |
| 473 iter != regions.end(); ++iter) { |
| 474 const extensions::DraggableRegion& region = *iter; |
| 475 sk_region->op( |
| 476 region.bounds.x(), |
| 477 region.bounds.y(), |
| 478 region.bounds.right(), |
| 479 region.bounds.bottom(), |
| 480 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 481 } |
| 482 return sk_region; |
| 483 } |
OLD | NEW |