Chromium Code Reviews| Index: extensions/browser/app_window/app_window.cc |
| diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc |
| index b6d7754c56a47124255bc3365a36b470696500b1..e799baa85a7822fec3e56c66169ba4b77b4f8b2a 100644 |
| --- a/extensions/browser/app_window/app_window.cc |
| +++ b/extensions/browser/app_window/app_window.cc |
| @@ -11,6 +11,8 @@ |
| #include "base/command_line.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/task_runner.h" |
| +#include "base/thread_task_runner_handle.h" |
| #include "base/values.h" |
| #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| #include "content/public/browser/browser_context.h" |
| @@ -442,6 +444,26 @@ void AppWindow::DidFirstVisuallyNonEmptyPaint() { |
| } |
| } |
| +void AppWindow::SetOnFirstCommitCallback(base::Callback<void(void)> callback) { |
| + 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.
|
| +} |
| + |
| +void AppWindow::OnReadyToCommit() { |
| + CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + ::switches::kEnableBrowserSideNavigation)); |
| + WindowEventsReady(); |
| + if (on_first_commit_callback_.is_null()) |
| + return; |
| + // It is important that the callback executes after the calls to |
| + // 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
|
| + // CommitNavigation IPC that will properly set up the renderer will only be |
| + // sent after these, and it must be sent before the callback gets to run, |
| + // hence the use of PostTask. |
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| + 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.
|
| + on_first_commit_callback_.Reset(); |
| +} |
| + |
| void AppWindow::OnNativeClose() { |
| AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this); |
| if (app_window_contents_) { |