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

Side by Side Diff: chrome/browser/extensions/extension_tab_util.h

Issue 2434063002: Move extensions code from WebContents::GetURL to GetLastCommittedURL.
Patch Set: Refactor to simplify. Created 4 years, 2 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) 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 static Browser* GetBrowserFromWindowID( 77 static Browser* GetBrowserFromWindowID(
78 ChromeUIThreadExtensionFunction* function, 78 ChromeUIThreadExtensionFunction* function,
79 int window_id, 79 int window_id,
80 std::string* error_message); 80 std::string* error_message);
81 81
82 static Browser* GetBrowserFromWindowID( 82 static Browser* GetBrowserFromWindowID(
83 const ChromeExtensionFunctionDetails& details, 83 const ChromeExtensionFunctionDetails& details,
84 int window_id, 84 int window_id,
85 std::string* error_message); 85 std::string* error_message);
86 86
87 enum UrlType { LastCommitted, Visible };
nasko 2016/10/20 00:48:42 This along with the methods taking it can potentia
Devlin 2016/10/20 17:27:24 I'm fine with it here (and think it should be; see
88
87 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with 89 // Creates a Tab object (see chrome/common/extensions/api/tabs.json) with
88 // information about the state of a browser tab. Depending on the 90 // information about the state of a browser tab. Depending on the
89 // permissions of the extension, the object may or may not include sensitive 91 // permissions of the extension, the object may or may not include sensitive
90 // data such as the tab's URL. 92 // data such as the tab's URL.
91 static std::unique_ptr<api::tabs::Tab> CreateTabObject( 93 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
92 content::WebContents* web_contents, 94 content::WebContents* web_contents,
93 const Extension* extension) { 95 const Extension* extension) {
94 return CreateTabObject(web_contents, nullptr, -1, extension); 96 return CreateTabObject(web_contents, nullptr, -1, extension,
97 UrlType::LastCommitted);
95 } 98 }
96 static std::unique_ptr<api::tabs::Tab> CreateTabObject( 99 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
97 content::WebContents* web_contents, 100 content::WebContents* web_contents,
98 TabStripModel* tab_strip, 101 TabStripModel* tab_strip,
99 int tab_index, 102 int tab_index,
100 const Extension* extension); 103 const Extension* extension) {
104 return CreateTabObject(web_contents, nullptr, -1, extension,
105 UrlType::LastCommitted);
106 }
107 static std::unique_ptr<api::tabs::Tab> CreateTabObjectVisibleUrl(
Devlin 2016/10/20 17:27:24 In the tabs API, we'll also scrub the tab object o
108 content::WebContents* web_contents,
109 const Extension* extension) {
110 return CreateTabObject(web_contents, nullptr, -1, extension,
111 UrlType::Visible);
112 }
113 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
114 content::WebContents* web_contents,
115 TabStripModel* tab_strip,
116 int tab_index,
117 const Extension* extension,
118 UrlType url_type);
101 119
102 // Creates a Tab object but performs no extension permissions checks; the 120 // Creates a Tab object but performs no extension permissions checks; the
103 // returned object will contain privacy-sensitive data. 121 // returned object will contain privacy-sensitive data.
104 static std::unique_ptr<api::tabs::Tab> CreateTabObject( 122 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
105 content::WebContents* web_contents) { 123 content::WebContents* web_contents) {
106 return CreateTabObject(web_contents, nullptr, -1); 124 return CreateTabObject(web_contents, nullptr, -1, UrlType::LastCommitted);
107 } 125 }
108 static std::unique_ptr<api::tabs::Tab> CreateTabObject( 126 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
109 content::WebContents* web_contents, 127 content::WebContents* web_contents,
110 TabStripModel* tab_strip, 128 TabStripModel* tab_strip,
111 int tab_index); 129 int tab_index) {
130 return CreateTabObject(web_contents, tab_strip, tab_index,
131 UrlType::LastCommitted);
132 }
133 static std::unique_ptr<api::tabs::Tab> CreateTabObject(
134 content::WebContents* web_contents,
135 TabStripModel* tab_strip,
136 int tab_index,
137 UrlType url_type);
112 138
113 // Creates a tab MutedInfo object (see chrome/common/extensions/api/tabs.json) 139 // Creates a tab MutedInfo object (see chrome/common/extensions/api/tabs.json)
114 // with information about the mute state of a browser tab. 140 // with information about the mute state of a browser tab.
115 static std::unique_ptr<api::tabs::MutedInfo> CreateMutedInfo( 141 static std::unique_ptr<api::tabs::MutedInfo> CreateMutedInfo(
116 content::WebContents* contents); 142 content::WebContents* contents);
117 143
118 // Removes any privacy-sensitive fields from a Tab object if appropriate, 144 // Removes any privacy-sensitive fields from a Tab object if appropriate,
119 // given the permissions of the extension and the tab in question. The 145 // given the permissions of the extension and the tab in question. The
120 // tab object is modified in place. 146 // tab object is modified in place.
121 static void ScrubTabForExtension(const Extension* extension, 147 static void ScrubTabForExtension(const Extension* extension,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 static bool OpenOptionsPage(const Extension* extension, Browser* browser); 201 static bool OpenOptionsPage(const Extension* extension, Browser* browser);
176 202
177 // Returns true if the given Browser can report tabs to extensions. 203 // Returns true if the given Browser can report tabs to extensions.
178 // Example of Browsers which don't support tabs include apps and devtools. 204 // Example of Browsers which don't support tabs include apps and devtools.
179 static bool BrowserSupportsTabs(Browser* browser); 205 static bool BrowserSupportsTabs(Browser* browser);
180 }; 206 };
181 207
182 } // namespace extensions 208 } // namespace extensions
183 209
184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_ 210 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698