summaryrefslogtreecommitdiffstats
path: root/components/html_viewer/html_document_application_delegate.cc
diff options
context:
space:
mode:
authoryzshen <yzshen@chromium.org>2015-08-26 15:13:17 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-26 22:13:59 +0000
commit143f0071ab9197af4b5ec163606ee716e0be3793 (patch)
treecdcd4f4567a0db572d0e4a3a18e4d9b936e8225b /components/html_viewer/html_document_application_delegate.cc
parenta93c58151c01a8ccc6d98697f04c851f8992ef92 (diff)
downloadchromium_src-143f0071ab9197af4b5ec163606ee716e0be3793.zip
chromium_src-143f0071ab9197af4b5ec163606ee716e0be3793.tar.gz
chromium_src-143f0071ab9197af4b5ec163606ee716e0be3793.tar.bz2
Mandoline: fix the issue of same-URL navigation.
Sometimes, typing the same URL as the current one into the omnibox doesn't load the page again (but loses the previous load). This is actually caused by three bugs: - The identity used for application instance registration and lookup are actually constructed differently. So the application manager is confused. In some cases, it creates/registers multiple instances under the same identity. - HTMLDocumentApplicationDelegate doesn't retain the application while waiting for URL load completion. So if there is no other HTMLDocumentOOPIF instances are alive, the app will be shutdown. - When an app for "about:blank" already exists, it is reused and we end up in HTMLDocumentApplicationDelegate::ConfigureIncomingConnection(), trying to fetch the URL. We cannot fetch the URL using mojo::URLLoader because it is not an actual Web resource. BUG=524539 Review URL: https://codereview.chromium.org/1313253002 Cr-Commit-Position: refs/heads/master@{#345694}
Diffstat (limited to 'components/html_viewer/html_document_application_delegate.cc')
-rw-r--r--components/html_viewer/html_document_application_delegate.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/components/html_viewer/html_document_application_delegate.cc b/components/html_viewer/html_document_application_delegate.cc
index 08afc2d..8bdad48 100644
--- a/components/html_viewer/html_document_application_delegate.cc
+++ b/components/html_viewer/html_document_application_delegate.cc
@@ -98,8 +98,22 @@ void HTMLDocumentApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
bool HTMLDocumentApplicationDelegate::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
if (initial_response_) {
- OnResponseReceived(mojo::URLLoaderPtr(), connection, nullptr,
+ OnResponseReceived(nullptr, mojo::URLLoaderPtr(), connection, nullptr,
initial_response_.Pass());
+ } else if (url_ == "about:blank") {
+ // This is a little unfortunate. At the browser side, when starting a new
+ // app for "about:blank", the application manager uses
+ // mojo::runner::AboutFetcher to construct a response for "about:blank".
+ // However, when an app for "about:blank" already exists, it is reused and
+ // we end up here. We cannot fetch the URL using mojo::URLLoader because it
+ // is not an actual Web resource.
+ // TODO(yzshen): find out a better approach.
+ mojo::URLResponsePtr response(mojo::URLResponse::New());
+ response->url = url_;
+ response->status_code = 200;
+ response->mime_type = "text/html";
+ OnResponseReceived(nullptr, mojo::URLLoaderPtr(), connection, nullptr,
+ response.Pass());
} else {
// HTMLDocument provides services, but is created asynchronously. Queue up
// requests until the HTMLDocument is created.
@@ -117,11 +131,16 @@ bool HTMLDocumentApplicationDelegate::ConfigureIncomingConnection(
// callback. Because order of evaluation is undefined, a reference to the
// raw pointer is needed.
mojo::URLLoader* raw_loader = loader.get();
+ // The app needs to stay alive while waiting for the response to be
+ // available.
+ scoped_ptr<mojo::AppRefCount> app_retainer(
+ app_.app_lifetime_helper()->CreateAppRefCount());
raw_loader->Start(
request.Pass(),
base::Bind(&HTMLDocumentApplicationDelegate::OnResponseReceived,
- weak_factory_.GetWeakPtr(), base::Passed(&loader),
- connection, base::Passed(&service_connector_queue)));
+ weak_factory_.GetWeakPtr(), base::Passed(&app_retainer),
+ base::Passed(&loader), connection,
+ base::Passed(&service_connector_queue)));
}
return true;
}
@@ -133,6 +152,7 @@ void HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2(
}
void HTMLDocumentApplicationDelegate::OnResponseReceived(
+ scoped_ptr<mojo::AppRefCount> app_refcount,
mojo::URLLoaderPtr loader,
mojo::ApplicationConnection* connection,
scoped_ptr<ServiceConnectorQueue> connector_queue,