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

Unified Diff: chrome/browser/ui/extensions/hosted_app_browser_controller.cc

Issue 1164873003: Show origin for hosted apps that navigate away from their start origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback for the stig Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/hosted_app_browser_controller.cc
diff --git a/chrome/browser/ui/extensions/bookmark_app_browser_controller.cc b/chrome/browser/ui/extensions/hosted_app_browser_controller.cc
similarity index 73%
rename from chrome/browser/ui/extensions/bookmark_app_browser_controller.cc
rename to chrome/browser/ui/extensions/hosted_app_browser_controller.cc
index 773250a19dd5658545faecfdeddabb97a0edb493..7a3a9307742659cf804cdf1dfdd96a00318a53fa 100644
--- a/chrome/browser/ui/extensions/bookmark_app_browser_controller.cc
+++ b/chrome/browser/ui/extensions/hosted_app_browser_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/extensions/bookmark_app_browser_controller.h"
+#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "base/command_line.h"
#include "chrome/browser/profiles/profile.h"
@@ -18,6 +18,7 @@
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
+#include "net/base/net_util.h"
#include "url/gurl.h"
namespace extensions {
@@ -25,9 +26,11 @@ namespace extensions {
namespace {
bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) {
+ const std::string www("www.");
return (app_url.scheme() == page_url.scheme() ||
page_url.scheme() == url::kHttpsScheme) &&
- app_url.host() == page_url.host() &&
+ (app_url.host() == page_url.host() ||
+ www + app_url.host() == page_url.host()) &&
app_url.port() == page_url.port();
}
@@ -39,32 +42,37 @@ bool IsWebAppFrameEnabled() {
} // namespace
// static
-bool BookmarkAppBrowserController::IsForBookmarkApp(Browser* browser) {
+bool HostedAppBrowserController::IsForHostedApp(Browser* browser) {
const std::string extension_id =
web_app::GetExtensionIdFromApplicationName(browser->app_name());
const Extension* extension =
ExtensionRegistry::Get(browser->profile())->GetExtensionById(
extension_id, ExtensionRegistry::EVERYTHING);
- return extension && extension->from_bookmark();
+ return extension && extension->is_hosted_app();
}
-BookmarkAppBrowserController::BookmarkAppBrowserController(Browser* browser)
+HostedAppBrowserController::HostedAppBrowserController(Browser* browser)
: browser_(browser),
extension_id_(
- web_app::GetExtensionIdFromApplicationName(browser->app_name())),
- should_use_web_app_frame_(browser->host_desktop_type() ==
- chrome::HOST_DESKTOP_TYPE_ASH &&
- IsWebAppFrameEnabled()) {
+ web_app::GetExtensionIdFromApplicationName(browser->app_name())) {
+ const Extension* extension =
+ ExtensionRegistry::Get(browser->profile())->GetExtensionById(
+ extension_id_, ExtensionRegistry::EVERYTHING);
+ DCHECK(extension);
+ should_use_web_app_frame_ =
+ extension->from_bookmark() &&
+ browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH &&
+ IsWebAppFrameEnabled();
}
-BookmarkAppBrowserController::~BookmarkAppBrowserController() {
+HostedAppBrowserController::~HostedAppBrowserController() {
}
-bool BookmarkAppBrowserController::SupportsLocationBar() {
+bool HostedAppBrowserController::SupportsLocationBar() const {
return !should_use_web_app_frame();
}
-bool BookmarkAppBrowserController::ShouldShowLocationBar() {
+bool HostedAppBrowserController::ShouldShowLocationBar() const {
const Extension* extension =
ExtensionRegistry::Get(browser_->profile())->GetExtensionById(
extension_id_, ExtensionRegistry::EVERYTHING);
@@ -77,7 +85,7 @@ bool BookmarkAppBrowserController::ShouldShowLocationBar() {
if (!extension || !web_contents)
return false;
- if (!extension->from_bookmark())
+ if (!extension->is_hosted_app())
return false;
// Don't show a location bar until a navigation has occurred.
@@ -96,7 +104,8 @@ bool BookmarkAppBrowserController::ShouldShowLocationBar() {
web_contents->GetLastCommittedURL()));
}
-void BookmarkAppBrowserController::UpdateLocationBarVisibility(bool animate) {
+void HostedAppBrowserController::UpdateLocationBarVisibility(
+ bool animate) const {
if (!SupportsLocationBar())
return;
« no previous file with comments | « chrome/browser/ui/extensions/hosted_app_browser_controller.h ('k') | chrome/browser/ui/extensions/hosted_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698