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

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

Issue 148153008: Protocol handler dialogs should only be enabled by browser or page actions [Not committed] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/active_tab_permission_granter.h" 5 #include "chrome/browser/extensions/active_tab_permission_granter.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/external_protocol/external_protocol_handler.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/session_id.h" 11 #include "chrome/browser/sessions/session_id.h"
11 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
12 #include "content/public/browser/navigation_details.h" 13 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 14 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
(...skipping 11 matching lines...) Expand all
30 content::WebContents* web_contents, int tab_id, Profile* profile) 31 content::WebContents* web_contents, int tab_id, Profile* profile)
31 : WebContentsObserver(web_contents), tab_id_(tab_id) { 32 : WebContentsObserver(web_contents), tab_id_(tab_id) {
32 registrar_.Add(this, 33 registrar_.Add(this,
33 chrome::NOTIFICATION_EXTENSION_UNLOADED, 34 chrome::NOTIFICATION_EXTENSION_UNLOADED,
34 content::Source<Profile>(profile)); 35 content::Source<Profile>(profile));
35 } 36 }
36 37
37 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} 38 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
38 39
39 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { 40 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
41
42 // Active tab implies user gesture, which should enable external protocol
43 // handler dialog.
44 ExternalProtocolHandler::PermitLaunchUrl();
45
40 if (granted_extensions_.Contains(extension->id())) 46 if (granted_extensions_.Contains(extension->id()))
41 return; 47 return;
42 48
43 APIPermissionSet new_apis; 49 APIPermissionSet new_apis;
44 URLPatternSet new_hosts; 50 URLPatternSet new_hosts;
45 51
46 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { 52 if (extension->HasAPIPermission(APIPermission::kActiveTab)) {
47 URLPattern pattern(UserScript::ValidUserScriptSchemes()); 53 URLPattern pattern(UserScript::ValidUserScriptSchemes());
48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. 54 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
49 if (pattern.Parse(web_contents()->GetURL().spec()) == 55 if (pattern.Parse(web_contents()->GetURL().spec()) ==
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 it != granted_extensions_.end(); ++it) { 118 it != granted_extensions_.end(); ++it) {
113 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); 119 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_);
114 extension_ids.push_back((*it)->id()); 120 extension_ids.push_back((*it)->id());
115 } 121 }
116 122
117 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 123 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
118 granted_extensions_.Clear(); 124 granted_extensions_.Clear();
119 } 125 }
120 126
121 } // namespace extensions 127 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698