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

Side by Side Diff: extensions/browser/api/execute_code_function.h

Issue 1004253002: Enable <webview>.executeScript outside of Apps and Extensions [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Devlin's comments. 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
7 7
8 #include "extensions/browser/extension_function.h" 8 #include "extensions/browser/extension_function.h"
9 #include "extensions/browser/script_executor.h" 9 #include "extensions/browser/script_executor.h"
10 #include "extensions/common/api/extension_types.h" 10 #include "extensions/common/api/extension_types.h"
(...skipping 27 matching lines...) Expand all
38 const base::ListValue& result); 38 const base::ListValue& result);
39 39
40 // The injection details. 40 // The injection details.
41 scoped_ptr<core_api::extension_types::InjectDetails> details_; 41 scoped_ptr<core_api::extension_types::InjectDetails> details_;
42 42
43 const HostID& host_id() const { return host_id_; } 43 const HostID& host_id() const { return host_id_; }
44 void set_host_id(HostID host_id) { 44 void set_host_id(HostID host_id) {
45 host_id_ = host_id; 45 host_id_ = host_id;
46 } 46 }
47 47
48 protected:
49 virtual bool LoadFile(const std::string& file);
50
51 // Run in UI thread. Code string contains the code to be executed. Returns
52 // true on success. If true is returned, this does an AddRef.
53 bool Execute(const std::string& code_string);
Devlin 2015/03/25 17:55:15 This shouldn't be protected anymore, right?
Xi Han 2015/03/25 20:49:21 Good catch:)
54
55 // Abstracts the details of DidLoadAndLocalizeFile to this function with the
56 // path of file passed in. It can be called by sub classes who load files as
57 // web URLs.
58 void DidLoadFileForHost(const std::string& file,
59 bool success,
60 const std::string& data);
61
48 private: 62 private:
49 // Called when contents from the file whose path is specified in JSON 63 // Called when contents from the file whose path is specified in JSON
50 // arguments has been loaded. 64 // arguments has been loaded.
51 void DidLoadFile(bool success, const std::string& data); 65 void DidLoadFile(bool success, const std::string& data);
52 66
53 // Runs on FILE thread. Loads message bundles for the extension and 67 // Runs on FILE thread. Loads message bundles for the extension and
54 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. 68 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread.
55 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, 69 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type,
56 const std::string& data, 70 const std::string& data,
57 const std::string& extension_id, 71 const std::string& extension_id,
58 const base::FilePath& extension_path, 72 const base::FilePath& extension_path,
59 const std::string& extension_default_locale); 73 const std::string& extension_default_locale);
60 74
61 // Called when contents from the loaded file have been localized. 75 // Called when contents from the loaded file have been localized.
62 void DidLoadAndLocalizeFile(bool success, const std::string& data); 76 void DidLoadAndLocalizeFile(bool success, const std::string& data);
63 77
64 // Run in UI thread. Code string contains the code to be executed. Returns
65 // true on success. If true is returned, this does an AddRef.
66 bool Execute(const std::string& code_string);
67
68 // Contains extension resource built from path of file which is 78 // Contains extension resource built from path of file which is
69 // specified in JSON arguments. 79 // specified in JSON arguments.
70 ExtensionResource resource_; 80 ExtensionResource resource_;
71 81
72 // The URL of the file being injected into the page. 82 // The URL of the file being injected into the page.
73 GURL file_url_; 83 GURL file_url_;
74 84
75 // The ID of the injection host. 85 // The ID of the injection host.
76 HostID host_id_; 86 HostID host_id_;
77 }; 87 };
78 88
79 } // namespace extensions 89 } // namespace extensions
80 90
81 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 91 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698