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

Side by Side Diff: chrome/browser/external_protocol/external_protocol_handler.h

Issue 7790021: Open external application dialog should not show for Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits addressed Created 9 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/external_protocol/external_protocol_handler.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 5 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/shell_integration.h"
12
11 class GURL; 13 class GURL;
12 class PrefService; 14 class PrefService;
13 15
14 namespace base { 16 namespace base {
15 class DictionaryValue; 17 class DictionaryValue;
16 } 18 }
17 19
18 class ExternalProtocolHandler { 20 class ExternalProtocolHandler {
19 public: 21 public:
20 enum BlockState { 22 enum BlockState {
21 DONT_BLOCK, 23 DONT_BLOCK,
22 BLOCK, 24 BLOCK,
23 UNKNOWN, 25 UNKNOWN,
24 }; 26 };
25 27
28 // Delegate to allow unit testing to provide different behavior.
29 class Delegate {
30 public:
31 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
32 ShellIntegration::DefaultWebClientObserver* observer,
33 const std::string& protocol) = 0;
34 virtual BlockState GetBlockState(const std::string& scheme) = 0;
35 virtual void BlockRequest() = 0;
36 virtual void RunExternalProtocolDialog(const GURL& url,
37 int render_process_host_id,
38 int routing_id) = 0;
39 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) = 0;
40 virtual void FinishedProcessingCheck() = 0;
41 virtual ~Delegate() {}
42 };
43
26 // Returns whether we should block a given scheme. 44 // Returns whether we should block a given scheme.
27 static BlockState GetBlockState(const std::string& scheme); 45 static BlockState GetBlockState(const std::string& scheme);
28 46
29 // Sets whether we should block a given scheme. 47 // Sets whether we should block a given scheme.
30 static void SetBlockState(const std::string& scheme, BlockState state); 48 static void SetBlockState(const std::string& scheme, BlockState state);
31 49
32 // Checks to see if the protocol is allowed, if it is whitelisted, 50 // Checks to see if the protocol is allowed, if it is whitelisted,
33 // the application associated with the protocol is launched on the io thread, 51 // the application associated with the protocol is launched on the io thread,
34 // if it is blacklisted, returns silently. Otherwise, an 52 // if it is blacklisted, returns silently. Otherwise, an
35 // ExternalProtocolDialog is created asking the user. If the user accepts, 53 // ExternalProtocolDialog is created asking the user. If the user accepts,
36 // LaunchUrlWithoutSecurityCheck is called on the io thread and the 54 // LaunchUrlWithoutSecurityCheck is called on the io thread and the
37 // application is launched. 55 // application is launched.
38 // Must run on the UI thread. 56 // Must run on the UI thread.
39 static void LaunchUrl(const GURL& url, int render_process_host_id, 57 static void LaunchUrl(const GURL& url, int render_process_host_id,
40 int tab_contents_id); 58 int tab_contents_id) {
59 LaunchUrlWithDelegate(url, render_process_host_id, tab_contents_id, NULL);
60 }
61
62 // Version of LaunchUrl allowing use of a delegate to facilitate unit
63 // testing.
64 static void LaunchUrlWithDelegate(const GURL& url, int render_process_host_id,
65 int tab_contents_id, Delegate* delegate);
41 66
42 // Creates and runs a External Protocol dialog box. 67 // Creates and runs a External Protocol dialog box.
43 // |url| - The url of the request. 68 // |url| - The url of the request.
44 // |render_process_host_id| and |routing_id| are used by 69 // |render_process_host_id| and |routing_id| are used by
45 // tab_util::GetTabContentsByID to aquire the tab contents associated with 70 // tab_util::GetTabContentsByID to aquire the tab contents associated with
46 // this dialog. 71 // this dialog.
47 // NOTE: There is a race between the Time of Check and the Time Of Use for 72 // NOTE: There is a race between the Time of Check and the Time Of Use for
48 // the command line. Since the caller (web page) does not have access 73 // the command line. Since the caller (web page) does not have access
49 // to change the command line by itself, we do not do anything special 74 // to change the command line by itself, we do not do anything special
50 // to protect against this scenario. 75 // to protect against this scenario.
(...skipping 21 matching lines...) Expand all
72 static void PrepopulateDictionary(base::DictionaryValue* win_pref); 97 static void PrepopulateDictionary(base::DictionaryValue* win_pref);
73 98
74 // Allows LaunchUrl to proceed with launching an external protocol handler. 99 // Allows LaunchUrl to proceed with launching an external protocol handler.
75 // This is typically triggered by a user gesture, but is also called for 100 // This is typically triggered by a user gesture, but is also called for
76 // each extension API function. Note that each call to LaunchUrl resets 101 // each extension API function. Note that each call to LaunchUrl resets
77 // the state to false (not allowed). 102 // the state to false (not allowed).
78 static void PermitLaunchUrl(); 103 static void PermitLaunchUrl();
79 }; 104 };
80 105
81 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_ 106 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_EXTERNAL_PROTOCOL_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/external_protocol/external_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698