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

Side by Side Diff: chrome/browser/extensions/extension_ui_util.cc

Issue 1006273002: Show location for bookmark apps that have navigated across origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 5 years, 9 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
« no previous file with comments | « chrome/browser/extensions/extension_ui_util.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/extensions/extension_ui_util.h" 5 #include "chrome/browser/extensions/extension_ui_util.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
10 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/extension_util.h" 13 #include "extensions/browser/extension_util.h"
12 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
13 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
14 16
15 namespace extensions { 17 namespace extensions {
16 18
17 namespace { 19 namespace {
18 20
19 bool IsBlockedByPolicy(const Extension* app, content::BrowserContext* context) { 21 bool IsBlockedByPolicy(const Extension* app, content::BrowserContext* context) {
20 Profile* profile = Profile::FromBrowserContext(context); 22 Profile* profile = Profile::FromBrowserContext(context);
21 DCHECK(profile); 23 DCHECK(profile);
22 24
23 return (app->id() == extensions::kWebStoreAppId || 25 return (app->id() == extensions::kWebStoreAppId ||
24 app->id() == extension_misc::kEnterpriseWebStoreAppId) && 26 app->id() == extension_misc::kEnterpriseWebStoreAppId) &&
25 profile->GetPrefs()->GetBoolean(prefs::kHideWebStoreIcon); 27 profile->GetPrefs()->GetBoolean(prefs::kHideWebStoreIcon);
26 } 28 }
27 29
30 bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) {
31 return (app_url.scheme() == page_url.scheme() ||
32 page_url.scheme() == url::kHttpsScheme) &&
33 app_url.host() == page_url.host() &&
34 app_url.port() == page_url.port();
35 }
36
28 } // namespace 37 } // namespace
29 38
30 namespace ui_util { 39 namespace ui_util {
31 40
32 bool ShouldDisplayInAppLauncher(const Extension* extension, 41 bool ShouldDisplayInAppLauncher(const Extension* extension,
33 content::BrowserContext* context) { 42 content::BrowserContext* context) {
34 return CanDisplayInAppLauncher(extension, context) && 43 return CanDisplayInAppLauncher(extension, context) &&
35 !util::IsEphemeralApp(extension->id(), context); 44 !util::IsEphemeralApp(extension->id(), context);
36 } 45 }
37 46
(...skipping 15 matching lines...) Expand all
53 return extension->ShouldDisplayInExtensionSettings() && 62 return extension->ShouldDisplayInExtensionSettings() &&
54 !util::IsEphemeralApp(extension->id(), context); 63 !util::IsEphemeralApp(extension->id(), context);
55 } 64 }
56 65
57 bool ShouldNotBeVisible(const Extension* extension, 66 bool ShouldNotBeVisible(const Extension* extension,
58 content::BrowserContext* context) { 67 content::BrowserContext* context) {
59 return extension->ShouldNotBeVisible() || 68 return extension->ShouldNotBeVisible() ||
60 util::IsEphemeralApp(extension->id(), context); 69 util::IsEphemeralApp(extension->id(), context);
61 } 70 }
62 71
72 bool ShouldShowLocationBar(const Extension* extension,
73 const content::WebContents* web_contents) {
74 // Default to not showing the location bar if either |extension| or
75 // |web_contents| are null. |extension| is null for the dev tools.
76 if (!extension || !web_contents)
77 return false;
78
79 GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension);
felt 2015/03/18 14:42:03 Since launch_url isn't being used until after this
benwells 2015/03/19 01:23:43 Done.
80 if (!extension->from_bookmark())
81 return false;
82
83 return !(IsSameOriginOrMoreSecure(launch_url,
84 web_contents->GetVisibleURL()) &&
85 IsSameOriginOrMoreSecure(launch_url,
86 web_contents->GetLastCommittedURL()));
87 }
88
63 } // namespace ui_util 89 } // namespace ui_util
64 } // namespace extensions 90 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_ui_util.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698