Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: extensions/browser/app_window/app_window.cc

Issue 1340163002: PlzNavigate: fix timing issue in app window creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-throttle
Patch Set: Addressed nits Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/callback_helpers.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/task_runner.h"
16 #include "base/thread_task_runner_handle.h"
14 #include "base/values.h" 17 #include "base/values.h"
15 #include "components/web_modal/web_contents_modal_dialog_manager.h" 18 #include "components/web_modal/web_contents_modal_dialog_manager.h"
16 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/invalidate_type.h" 20 #include "content/public/browser/invalidate_type.h"
18 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/resource_dispatcher_host.h" 23 #include "content/public/browser/resource_dispatcher_host.h"
21 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
23 #include "content/public/common/media_stream_request.h" 26 #include "content/public/common/media_stream_request.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 438
436 void AppWindow::DidFirstVisuallyNonEmptyPaint() { 439 void AppWindow::DidFirstVisuallyNonEmptyPaint() {
437 first_paint_complete_ = true; 440 first_paint_complete_ = true;
438 if (show_on_first_paint_) { 441 if (show_on_first_paint_) {
439 DCHECK(delayed_show_type_ == SHOW_ACTIVE || 442 DCHECK(delayed_show_type_ == SHOW_ACTIVE ||
440 delayed_show_type_ == SHOW_INACTIVE); 443 delayed_show_type_ == SHOW_INACTIVE);
441 Show(delayed_show_type_); 444 Show(delayed_show_type_);
442 } 445 }
443 } 446 }
444 447
448 void AppWindow::SetOnFirstCommitCallback(const base::Closure& callback) {
449 DCHECK(on_first_commit_callback_.is_null());
450 on_first_commit_callback_ = callback;
451 }
452
453 void AppWindow::OnReadyToCommitFirstNavigation() {
454 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
455 ::switches::kEnableBrowserSideNavigation));
456 WindowEventsReady();
457 if (on_first_commit_callback_.is_null())
458 return;
459 // It is important that the callback executes after the calls to
460 // WebContentsObserver::ReadyToCommitNavigation have been processed. The
461 // CommitNavigation IPC that will properly set up the renderer will only be
462 // sent after these, and it must be sent before the callback gets to run,
463 // hence the use of PostTask.
464 base::ThreadTaskRunnerHandle::Get()->PostTask(
465 FROM_HERE, base::ResetAndReturn(&on_first_commit_callback_));
466 }
467
445 void AppWindow::OnNativeClose() { 468 void AppWindow::OnNativeClose() {
446 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this); 469 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this);
447 if (app_window_contents_) { 470 if (app_window_contents_) {
448 WebContentsModalDialogManager* modal_dialog_manager = 471 WebContentsModalDialogManager* modal_dialog_manager =
449 WebContentsModalDialogManager::FromWebContents(web_contents()); 472 WebContentsModalDialogManager::FromWebContents(web_contents());
450 if (modal_dialog_manager) // May be null in unit tests. 473 if (modal_dialog_manager) // May be null in unit tests.
451 modal_dialog_manager->SetDelegate(nullptr); 474 modal_dialog_manager->SetDelegate(nullptr);
452 app_window_contents_->NativeWindowClosed(); 475 app_window_contents_->NativeWindowClosed();
453 } 476 }
454 delete this; 477 delete this;
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 region.bounds.x(), 1110 region.bounds.x(),
1088 region.bounds.y(), 1111 region.bounds.y(),
1089 region.bounds.right(), 1112 region.bounds.right(),
1090 region.bounds.bottom(), 1113 region.bounds.bottom(),
1091 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1114 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1092 } 1115 }
1093 return sk_region; 1116 return sk_region;
1094 } 1117 }
1095 1118
1096 } // namespace extensions 1119 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/app_window/app_window.h ('k') | extensions/browser/app_window/app_window_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698