| 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "ui/base/events/event.h" | 51 #include "ui/base/events/event.h" |
| 52 #include "ui/base/events/event_utils.h" | 52 #include "ui/base/events/event_utils.h" |
| 53 #include "ui/base/hit_test.h" | 53 #include "ui/base/hit_test.h" |
| 54 #include "ui/compositor/layer.h" | 54 #include "ui/compositor/layer.h" |
| 55 #include "ui/compositor/scoped_layer_animation_settings.h" | 55 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 56 #include "ui/gfx/canvas.h" | 56 #include "ui/gfx/canvas.h" |
| 57 #include "ui/gfx/image/image.h" | 57 #include "ui/gfx/image/image.h" |
| 58 #include "ui/gfx/image/image_png_rep.h" | 58 #include "ui/gfx/image/image_png_rep.h" |
| 59 #include "ui/gfx/image/image_skia.h" | 59 #include "ui/gfx/image/image_skia.h" |
| 60 #include "ui/gfx/screen.h" | 60 #include "ui/gfx/screen.h" |
| 61 #include "ui/snapshot/snapshot.h" |
| 61 | 62 |
| 62 namespace content { | 63 namespace content { |
| 63 WebContentsViewPort* CreateWebContentsView( | 64 WebContentsViewPort* CreateWebContentsView( |
| 64 WebContentsImpl* web_contents, | 65 WebContentsImpl* web_contents, |
| 65 WebContentsViewDelegate* delegate, | 66 WebContentsViewDelegate* delegate, |
| 66 RenderViewHostDelegateView** render_view_host_delegate_view) { | 67 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 67 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); | 68 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); |
| 68 *render_view_host_delegate_view = rv; | 69 *render_view_host_delegate_view = rv; |
| 69 return rv; | 70 return rv; |
| 70 } | 71 } |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 } | 1314 } |
| 1314 | 1315 |
| 1315 void WebContentsViewAura::TakeFocus(bool reverse) { | 1316 void WebContentsViewAura::TakeFocus(bool reverse) { |
| 1316 if (web_contents_->GetDelegate() && | 1317 if (web_contents_->GetDelegate() && |
| 1317 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 1318 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
| 1318 delegate_.get()) { | 1319 delegate_.get()) { |
| 1319 delegate_->TakeFocus(reverse); | 1320 delegate_->TakeFocus(reverse); |
| 1320 } | 1321 } |
| 1321 } | 1322 } |
| 1322 | 1323 |
| 1324 bool WebContentsViewAura::GrabSnapshot(const std::string& format, |
| 1325 int quality, |
| 1326 double scale, |
| 1327 std::vector<uint8>* data) { |
| 1328 if (format != "png" || scale != 1) { |
| 1329 LOG(ERROR) << "Can only capture non-scaled PNG snapshots."; |
| 1330 return false; |
| 1331 } |
| 1332 return ui::GrabViewSnapshot(GetNativeView(), data, GetViewBounds()); |
| 1333 } |
| 1334 |
| 1323 //////////////////////////////////////////////////////////////////////////////// | 1335 //////////////////////////////////////////////////////////////////////////////// |
| 1324 // WebContentsViewAura, OverscrollControllerDelegate implementation: | 1336 // WebContentsViewAura, OverscrollControllerDelegate implementation: |
| 1325 | 1337 |
| 1326 void WebContentsViewAura::OnOverscrollUpdate(float delta_x, float delta_y) { | 1338 void WebContentsViewAura::OnOverscrollUpdate(float delta_x, float delta_y) { |
| 1327 if (current_overscroll_gesture_ == OVERSCROLL_NONE) | 1339 if (current_overscroll_gesture_ == OVERSCROLL_NONE) |
| 1328 return; | 1340 return; |
| 1329 | 1341 |
| 1330 aura::Window* target = GetWindowToAnimateForOverscroll(); | 1342 aura::Window* target = GetWindowToAnimateForOverscroll(); |
| 1331 ui::ScopedLayerAnimationSettings settings(target->layer()->GetAnimator()); | 1343 ui::ScopedLayerAnimationSettings settings(target->layer()->GetAnimator()); |
| 1332 settings.SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); | 1344 settings.SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 event.location(), | 1610 event.location(), |
| 1599 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1611 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| 1600 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1612 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1601 if (drag_dest_delegate_) | 1613 if (drag_dest_delegate_) |
| 1602 drag_dest_delegate_->OnDrop(); | 1614 drag_dest_delegate_->OnDrop(); |
| 1603 current_drop_data_.reset(); | 1615 current_drop_data_.reset(); |
| 1604 return current_drag_op_; | 1616 return current_drag_op_; |
| 1605 } | 1617 } |
| 1606 | 1618 |
| 1607 } // namespace content | 1619 } // namespace content |
| OLD | NEW |