summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_ui_util.cc
diff options
context:
space:
mode:
authorbenwells <benwells@chromium.org>2015-03-18 21:58:19 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-19 04:58:59 +0000
commit919e79baf8bfcff29f44b8f9bd6ffa468d9f700d (patch)
tree4333860223f0477911cc6712140ae233438e6b83 /chrome/browser/extensions/extension_ui_util.cc
parent2764ed907d5c43614d287b4a5c39a80e88782c53 (diff)
downloadchromium_src-919e79baf8bfcff29f44b8f9bd6ffa468d9f700d.zip
chromium_src-919e79baf8bfcff29f44b8f9bd6ffa468d9f700d.tar.gz
chromium_src-919e79baf8bfcff29f44b8f9bd6ffa468d9f700d.tar.bz2
Show location for bookmark apps that have navigated across origin.
It is important that this is shown for security reasons. BUG=463405 Review URL: https://codereview.chromium.org/1006273002 Cr-Commit-Position: refs/heads/master@{#321297}
Diffstat (limited to 'chrome/browser/extensions/extension_ui_util.cc')
-rw-r--r--chrome/browser/extensions/extension_ui_util.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_ui_util.cc b/chrome/browser/extensions/extension_ui_util.cc
index 4cf4fa8..fe19155 100644
--- a/chrome/browser/extensions/extension_ui_util.cc
+++ b/chrome/browser/extensions/extension_ui_util.cc
@@ -7,7 +7,9 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h"
+#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
@@ -25,6 +27,13 @@ bool IsBlockedByPolicy(const Extension* app, content::BrowserContext* context) {
profile->GetPrefs()->GetBoolean(prefs::kHideWebStoreIcon);
}
+bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) {
+ return (app_url.scheme() == page_url.scheme() ||
+ page_url.scheme() == url::kHttpsScheme) &&
+ app_url.host() == page_url.host() &&
+ app_url.port() == page_url.port();
+}
+
} // namespace
namespace ui_util {
@@ -60,5 +69,22 @@ bool ShouldNotBeVisible(const Extension* extension,
util::IsEphemeralApp(extension->id(), context);
}
+bool ShouldShowLocationBar(const Extension* extension,
+ const content::WebContents* web_contents) {
+ // Default to not showing the location bar if either |extension| or
+ // |web_contents| are null. |extension| is null for the dev tools.
+ if (!extension || !web_contents)
+ return false;
+
+ if (!extension->from_bookmark())
+ return false;
+
+ GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension);
+ return !(IsSameOriginOrMoreSecure(launch_url,
+ web_contents->GetVisibleURL()) &&
+ IsSameOriginOrMoreSecure(launch_url,
+ web_contents->GetLastCommittedURL()));
+}
+
} // namespace ui_util
} // namespace extensions