Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 15 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 16 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 16 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 17 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" | 17 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" |
| 18 #include "content/browser/frame_host/navigation_controller_impl.h" | 18 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 19 #include "content/browser/frame_host/navigation_entry_impl.h" | 19 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 20 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 20 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 22 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 22 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 23 #include "content/browser/renderer_host/render_view_host_factory.h" | 23 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 24 #include "content/browser/renderer_host/render_view_host_impl.h" | 24 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 25 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 25 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 26 #include "content/browser/site_instance_impl.h" | 26 #include "content/browser/site_instance_impl.h" |
| 27 #include "content/browser/web_contents/web_contents_impl.h" | 27 #include "content/browser/web_contents/web_contents_impl.h" |
| 28 #include "content/browser/web_contents/web_contents_view.h" | 28 #include "content/browser/web_contents/web_contents_view.h" |
| 29 #include "content/common/frame_messages.h" | 29 #include "content/common/frame_messages.h" |
| 30 #include "content/common/input_messages.h" | |
| 30 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
| 31 #include "content/public/browser/browser_context.h" | 32 #include "content/public/browser/browser_context.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
| 34 #include "content/public/browser/dom_operation_notification_details.h" | 35 #include "content/public/browser/dom_operation_notification_details.h" |
| 35 #include "content/public/browser/interstitial_page_delegate.h" | 36 #include "content/public/browser/interstitial_page_delegate.h" |
| 36 #include "content/public/browser/invalidate_type.h" | 37 #include "content/public/browser/invalidate_type.h" |
| 37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
| 39 #include "content/public/browser/storage_partition.h" | 40 #include "content/public/browser/storage_partition.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 // It would be inconsistent to create an interstitial with no new navigation | 184 // It would be inconsistent to create an interstitial with no new navigation |
| 184 // (which is the case when the interstitial was triggered by a sub-resource on | 185 // (which is the case when the interstitial was triggered by a sub-resource on |
| 185 // a page) when we have a pending entry (in the process of loading a new top | 186 // a page) when we have a pending entry (in the process of loading a new top |
| 186 // frame). | 187 // frame). |
| 187 DCHECK(new_navigation || !web_contents->GetController().GetPendingEntry()); | 188 DCHECK(new_navigation || !web_contents->GetController().GetPendingEntry()); |
| 188 } | 189 } |
| 189 | 190 |
| 190 InterstitialPageImpl::~InterstitialPageImpl() { | 191 InterstitialPageImpl::~InterstitialPageImpl() { |
| 191 } | 192 } |
| 192 | 193 |
| 194 void InterstitialPageImpl::Undo() { | |
| 195 RenderFrameHostImpl* focused_frame = | |
| 196 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 197 if (!focused_frame) | |
| 198 return; | |
| 199 | |
| 200 focused_frame->Send(new InputMsg_Undo(focused_frame->GetRoutingID())); | |
| 201 RecordAction(base::UserMetricsAction("Undo")); | |
| 202 } | |
| 203 | |
| 204 void InterstitialPageImpl::Redo() { | |
| 205 RenderFrameHostImpl* focused_frame = | |
| 206 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 207 if (!focused_frame) | |
| 208 return; | |
| 209 focused_frame->Send(new InputMsg_Redo(focused_frame->GetRoutingID())); | |
|
nasko
2015/05/13 17:24:08
Incorrect indentation. In general, you can use "gi
lgarron
2015/05/13 21:58:40
Done.
(Not sure how that happened. In any case, I
| |
| 210 RecordAction(base::UserMetricsAction("Redo")); | |
| 211 } | |
| 212 | |
| 213 void InterstitialPageImpl::Cut() { | |
| 214 RenderFrameHostImpl* focused_frame = | |
| 215 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 216 if (!focused_frame) | |
| 217 return; | |
| 218 | |
| 219 focused_frame->Send(new InputMsg_Cut(focused_frame->GetRoutingID())); | |
| 220 RecordAction(base::UserMetricsAction("Cut")); | |
| 221 } | |
| 222 | |
| 223 void InterstitialPageImpl::Copy() { | |
| 224 RenderFrameHostImpl* focused_frame = | |
| 225 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 226 if (!focused_frame) | |
| 227 return; | |
| 228 | |
| 229 focused_frame->Send(new InputMsg_Copy(focused_frame->GetRoutingID())); | |
| 230 RecordAction(base::UserMetricsAction("Copy")); | |
| 231 } | |
| 232 | |
| 233 void InterstitialPageImpl::CopyToFindPboard() { | |
| 234 #if defined(OS_MACOSX) | |
| 235 RenderFrameHostImpl* focused_frame = | |
| 236 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 237 if (!focused_frame) | |
| 238 return; | |
| 239 | |
| 240 // Windows/Linux don't have the concept of a find pasteboard. | |
| 241 focused_frame->Send( | |
| 242 new InputMsg_CopyToFindPboard(focused_frame->GetRoutingID())); | |
| 243 RecordAction(base::UserMetricsAction("CopyToFindPboard")); | |
| 244 #endif | |
| 245 } | |
| 246 | |
| 247 void InterstitialPageImpl::Paste() { | |
| 248 RenderFrameHostImpl* focused_frame = | |
| 249 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 250 if (!focused_frame) | |
| 251 return; | |
| 252 | |
| 253 focused_frame->Send(new InputMsg_Paste(focused_frame->GetRoutingID())); | |
| 254 RecordAction(base::UserMetricsAction("Paste")); | |
| 255 } | |
| 256 | |
| 257 void InterstitialPageImpl::PasteAndMatchStyle() { | |
| 258 RenderFrameHostImpl* focused_frame = | |
| 259 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 260 if (!focused_frame) | |
| 261 return; | |
| 262 | |
| 263 focused_frame->Send(new InputMsg_PasteAndMatchStyle( | |
| 264 focused_frame->GetRoutingID())); | |
| 265 RecordAction(base::UserMetricsAction("PasteAndMatchStyle")); | |
| 266 } | |
| 267 | |
| 268 void InterstitialPageImpl::SelectAll() { | |
| 269 RenderFrameHostImpl* focused_frame = | |
| 270 frame_tree_.GetFocusedFrame()->current_frame_host(); | |
| 271 if (!focused_frame) | |
| 272 return; | |
| 273 | |
| 274 focused_frame->Send(new InputMsg_SelectAll(focused_frame->GetRoutingID())); | |
| 275 RecordAction(base::UserMetricsAction("SelectAll")); | |
| 276 } | |
| 277 | |
| 193 void InterstitialPageImpl::Show() { | 278 void InterstitialPageImpl::Show() { |
| 194 if (!enabled()) | 279 if (!enabled()) |
| 195 return; | 280 return; |
| 196 | 281 |
| 197 // If an interstitial is already showing or about to be shown, close it before | 282 // If an interstitial is already showing or about to be shown, close it before |
| 198 // showing the new one. | 283 // showing the new one. |
| 199 // Be careful not to take an action on the old interstitial more than once. | 284 // Be careful not to take an action on the old interstitial more than once. |
| 200 InterstitialPageMap::const_iterator iter = | 285 InterstitialPageMap::const_iterator iter = |
| 201 g_web_contents_to_interstitial_page->find(web_contents_); | 286 g_web_contents_to_interstitial_page->find(web_contents_); |
| 202 if (iter != g_web_contents_to_interstitial_page->end()) { | 287 if (iter != g_web_contents_to_interstitial_page->end()) { |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( | 978 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( |
| 894 const LoadCommittedDetails& load_details) { | 979 const LoadCommittedDetails& load_details) { |
| 895 interstitial_->OnNavigatingAwayOrTabClosing(); | 980 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 896 } | 981 } |
| 897 | 982 |
| 898 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { | 983 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { |
| 899 interstitial_->OnNavigatingAwayOrTabClosing(); | 984 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 900 } | 985 } |
| 901 | 986 |
| 902 } // namespace content | 987 } // namespace content |
| OLD | NEW |