| 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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_context.h" | 7 #include "content/public/browser/browser_context.h" |
| 8 #include "content/public/browser/navigation_controller.h" | 8 #include "content/public/browser/navigation_controller.h" |
| 9 #include "content/public/browser/notification_details.h" | 9 #include "content/public/browser/notification_details.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| 11 #include "content/public/browser/notification_source.h" | 11 #include "content/public/browser/notification_source.h" |
| 12 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/browser/web_contents_view.h" |
| 15 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
| 16 #include "ui/base/accessibility/accessibility_types.h" | 18 #include "ui/base/accessibility/accessibility_types.h" |
| 17 #include "ui/base/accessibility/accessible_view_state.h" | 19 #include "ui/base/accessibility/accessible_view_state.h" |
| 18 #include "ui/base/events/event.h" | 20 #include "ui/base/events/event.h" |
| 19 #include "ui/views/controls/native/native_view_host.h" | 21 #include "ui/views/controls/native/native_view_host.h" |
| 20 #include "ui/views/focus/focus_manager.h" | 22 #include "ui/views/focus/focus_manager.h" |
| 21 #include "ui/views/views_delegate.h" | 23 #include "ui/views/views_delegate.h" |
| 22 | 24 |
| 25 #if defined(USE_AURA) |
| 26 #include "ui/aura/client/drag_drop_client.h" |
| 27 #include "ui/aura/client/drag_drop_delegate.h" |
| 28 #endif |
| 29 |
| 23 namespace views { | 30 namespace views { |
| 24 | 31 |
| 25 // static | 32 // static |
| 26 const char WebView::kViewClassName[] = | 33 const char WebView::kViewClassName[] = |
| 27 "ui/views/WebView"; | 34 "ui/views/WebView"; |
| 28 | 35 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
| 30 // WebView, public: | 37 // WebView, public: |
| 31 | 38 |
| 32 WebView::WebView(content::BrowserContext* browser_context) | 39 WebView::WebView(content::BrowserContext* browser_context) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return View::GetNativeViewAccessible(); | 149 return View::GetNativeViewAccessible(); |
| 143 } | 150 } |
| 144 | 151 |
| 145 gfx::Size WebView::GetPreferredSize() { | 152 gfx::Size WebView::GetPreferredSize() { |
| 146 if (preferred_size_ == gfx::Size()) | 153 if (preferred_size_ == gfx::Size()) |
| 147 return View::GetPreferredSize(); | 154 return View::GetPreferredSize(); |
| 148 else | 155 else |
| 149 return preferred_size_; | 156 return preferred_size_; |
| 150 } | 157 } |
| 151 | 158 |
| 159 #if defined(USE_AURA) |
| 160 bool WebView::CanDrop(const ui::OSExchangeData& data) { |
| 161 return true; |
| 162 } |
| 163 |
| 164 void WebView::OnDragEntered(const ui::DropTargetEvent& event) { |
| 165 aura::Window* window = web_contents_->GetView()->GetContentNativeView(); |
| 166 aura::client::DragDropDelegate* dnd_delegate = |
| 167 aura::client::GetDragDropDelegate(window); |
| 168 if (dnd_delegate) |
| 169 dnd_delegate->OnDragEntered(event); |
| 170 } |
| 171 |
| 172 int WebView::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 173 aura::Window* window = web_contents_->GetView()->GetContentNativeView(); |
| 174 aura::client::DragDropDelegate* dnd_delegate = |
| 175 aura::client::GetDragDropDelegate(window); |
| 176 if (dnd_delegate) |
| 177 return dnd_delegate->OnDragUpdated(event); |
| 178 return ui::DragDropTypes::DRAG_NONE; |
| 179 } |
| 180 |
| 181 void WebView::OnDragExited() { |
| 182 aura::Window* window = web_contents_->GetView()->GetContentNativeView(); |
| 183 aura::client::DragDropDelegate* dnd_delegate = |
| 184 aura::client::GetDragDropDelegate(window); |
| 185 if (dnd_delegate) |
| 186 dnd_delegate->OnDragExited(); |
| 187 } |
| 188 |
| 189 int WebView::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 190 aura::Window* window = web_contents_->GetView()->GetContentNativeView(); |
| 191 aura::client::DragDropDelegate* dnd_delegate = |
| 192 aura::client::GetDragDropDelegate(window); |
| 193 if (dnd_delegate) |
| 194 return dnd_delegate->OnPerformDrop(event); |
| 195 return ui::DragDropTypes::DRAG_NONE; |
| 196 } |
| 197 |
| 198 #endif |
| 199 |
| 152 //////////////////////////////////////////////////////////////////////////////// | 200 //////////////////////////////////////////////////////////////////////////////// |
| 153 // WebView, content::NotificationObserver implementation: | 201 // WebView, content::NotificationObserver implementation: |
| 154 | 202 |
| 155 void WebView::Observe(int type, | 203 void WebView::Observe(int type, |
| 156 const content::NotificationSource& source, | 204 const content::NotificationSource& source, |
| 157 const content::NotificationDetails& details) { | 205 const content::NotificationDetails& details) { |
| 158 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { | 206 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { |
| 159 std::pair<content::RenderViewHost*, content::RenderViewHost*>* | 207 std::pair<content::RenderViewHost*, content::RenderViewHost*>* |
| 160 switched_details = | 208 switched_details = |
| 161 content::Details<std::pair<content::RenderViewHost*, | 209 content::Details<std::pair<content::RenderViewHost*, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 return content::WebContents::Create(browser_context, | 301 return content::WebContents::Create(browser_context, |
| 254 site_instance, | 302 site_instance, |
| 255 MSG_ROUTING_NONE, | 303 MSG_ROUTING_NONE, |
| 256 NULL); | 304 NULL); |
| 257 } | 305 } |
| 258 | 306 |
| 259 return contents; | 307 return contents; |
| 260 } | 308 } |
| 261 | 309 |
| 262 } // namespace views | 310 } // namespace views |
| OLD | NEW |