Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window.h" | 5 #include "extensions/browser/app_window/app_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.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/task_runner.h" | |
| 15 #include "base/thread_task_runner_handle.h" | |
| 14 #include "base/values.h" | 16 #include "base/values.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/invalidate_type.h" | 19 #include "content/public/browser/invalidate_type.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/resource_dispatcher_host.h" | 22 #include "content/public/browser/resource_dispatcher_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/media_stream_request.h" | 25 #include "content/public/common/media_stream_request.h" |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 | 437 |
| 436 void AppWindow::DidFirstVisuallyNonEmptyPaint() { | 438 void AppWindow::DidFirstVisuallyNonEmptyPaint() { |
| 437 first_paint_complete_ = true; | 439 first_paint_complete_ = true; |
| 438 if (show_on_first_paint_) { | 440 if (show_on_first_paint_) { |
| 439 DCHECK(delayed_show_type_ == SHOW_ACTIVE || | 441 DCHECK(delayed_show_type_ == SHOW_ACTIVE || |
| 440 delayed_show_type_ == SHOW_INACTIVE); | 442 delayed_show_type_ == SHOW_INACTIVE); |
| 441 Show(delayed_show_type_); | 443 Show(delayed_show_type_); |
| 442 } | 444 } |
| 443 } | 445 } |
| 444 | 446 |
| 447 void AppWindow::SetOnFirstCommitCallback(base::Callback<void(void)> callback) { | |
| 448 on_first_commit_callback_ = callback; | |
|
Devlin
2015/09/16 21:44:04
Can we DCHECK(on_first_commit_callback_.is_null())
clamy
2015/09/16 22:19:39
Done.
| |
| 449 } | |
| 450 | |
| 451 void AppWindow::OnReadyToCommit() { | |
| 452 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 453 ::switches::kEnableBrowserSideNavigation)); | |
| 454 WindowEventsReady(); | |
| 455 if (on_first_commit_callback_.is_null()) | |
| 456 return; | |
| 457 // It is important that the callback executes after the calls to | |
| 458 // WebContentsObserver::AboutToCommitNavigation have been processed. The | |
|
Devlin
2015/09/16 21:44:04
Two notes:
- AboutToCommitNavigation seems to have
clamy
2015/09/16 22:19:39
Updated the comment.
As for the ReadyToCommitNavi
Devlin
2015/09/16 22:37:14
But even after all these IPCs, we still have a gua
clamy
2015/09/16 23:08:25
Yes I have verified that. Since we block requests
| |
| 459 // CommitNavigation IPC that will properly set up the renderer will only be | |
| 460 // sent after these, and it must be sent before the callback gets to run, | |
| 461 // hence the use of PostTask. | |
| 462 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | |
| 463 on_first_commit_callback_); | |
|
Devlin
2015/09/16 21:44:04
nit: base::ResetAndReturn(&on_first_commit_callbac
clamy
2015/09/16 22:19:39
Done.
| |
| 464 on_first_commit_callback_.Reset(); | |
| 465 } | |
| 466 | |
| 445 void AppWindow::OnNativeClose() { | 467 void AppWindow::OnNativeClose() { |
| 446 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this); | 468 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this); |
| 447 if (app_window_contents_) { | 469 if (app_window_contents_) { |
| 448 WebContentsModalDialogManager* modal_dialog_manager = | 470 WebContentsModalDialogManager* modal_dialog_manager = |
| 449 WebContentsModalDialogManager::FromWebContents(web_contents()); | 471 WebContentsModalDialogManager::FromWebContents(web_contents()); |
| 450 if (modal_dialog_manager) // May be null in unit tests. | 472 if (modal_dialog_manager) // May be null in unit tests. |
| 451 modal_dialog_manager->SetDelegate(nullptr); | 473 modal_dialog_manager->SetDelegate(nullptr); |
| 452 app_window_contents_->NativeWindowClosed(); | 474 app_window_contents_->NativeWindowClosed(); |
| 453 } | 475 } |
| 454 delete this; | 476 delete this; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 region.bounds.x(), | 1109 region.bounds.x(), |
| 1088 region.bounds.y(), | 1110 region.bounds.y(), |
| 1089 region.bounds.right(), | 1111 region.bounds.right(), |
| 1090 region.bounds.bottom(), | 1112 region.bounds.bottom(), |
| 1091 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1113 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 1092 } | 1114 } |
| 1093 return sk_region; | 1115 return sk_region; |
| 1094 } | 1116 } |
| 1095 | 1117 |
| 1096 } // namespace extensions | 1118 } // namespace extensions |
| OLD | NEW |