OLD | NEW |
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_API_TABS_TABS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class PrefRegistrySyncable; | 42 class PrefRegistrySyncable; |
43 } | 43 } |
44 | 44 |
45 namespace extensions { | 45 namespace extensions { |
46 | 46 |
47 // Converts a ZoomMode to its ZoomSettings representation. | 47 // Converts a ZoomMode to its ZoomSettings representation. |
48 void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode, | 48 void ZoomModeToZoomSettings(zoom::ZoomController::ZoomMode zoom_mode, |
49 api::tabs::ZoomSettings* zoom_settings); | 49 api::tabs::ZoomSettings* zoom_settings); |
50 | 50 |
51 // Windows | 51 // Windows |
52 class WindowsGetFunction : public ChromeSyncExtensionFunction { | 52 class WindowsGetFunction : public UIThreadExtensionFunction { |
53 ~WindowsGetFunction() override {} | 53 ~WindowsGetFunction() override {} |
54 bool RunSync() override; | 54 ResponseAction Run() override; |
55 DECLARE_EXTENSION_FUNCTION("windows.get", WINDOWS_GET) | 55 DECLARE_EXTENSION_FUNCTION("windows.get", WINDOWS_GET) |
56 }; | 56 }; |
57 class WindowsGetCurrentFunction : public ChromeSyncExtensionFunction { | 57 class WindowsGetCurrentFunction : public UIThreadExtensionFunction { |
58 ~WindowsGetCurrentFunction() override {} | 58 ~WindowsGetCurrentFunction() override {} |
59 bool RunSync() override; | 59 ResponseAction Run() override; |
60 DECLARE_EXTENSION_FUNCTION("windows.getCurrent", WINDOWS_GETCURRENT) | 60 DECLARE_EXTENSION_FUNCTION("windows.getCurrent", WINDOWS_GETCURRENT) |
61 }; | 61 }; |
62 class WindowsGetLastFocusedFunction : public ChromeSyncExtensionFunction { | 62 class WindowsGetLastFocusedFunction : public UIThreadExtensionFunction { |
63 ~WindowsGetLastFocusedFunction() override {} | 63 ~WindowsGetLastFocusedFunction() override {} |
64 bool RunSync() override; | 64 ResponseAction Run() override; |
65 DECLARE_EXTENSION_FUNCTION("windows.getLastFocused", WINDOWS_GETLASTFOCUSED) | 65 DECLARE_EXTENSION_FUNCTION("windows.getLastFocused", WINDOWS_GETLASTFOCUSED) |
66 }; | 66 }; |
67 class WindowsGetAllFunction : public ChromeSyncExtensionFunction { | 67 class WindowsGetAllFunction : public UIThreadExtensionFunction { |
68 ~WindowsGetAllFunction() override {} | 68 ~WindowsGetAllFunction() override {} |
69 bool RunSync() override; | 69 ResponseAction Run() override; |
70 DECLARE_EXTENSION_FUNCTION("windows.getAll", WINDOWS_GETALL) | 70 DECLARE_EXTENSION_FUNCTION("windows.getAll", WINDOWS_GETALL) |
71 }; | 71 }; |
72 class WindowsCreateFunction : public ChromeSyncExtensionFunction { | 72 class WindowsCreateFunction : public UIThreadExtensionFunction { |
73 ~WindowsCreateFunction() override {} | 73 ~WindowsCreateFunction() override {} |
74 bool RunSync() override; | 74 ResponseAction Run() override; |
75 // Returns whether the window should be created in incognito mode. | 75 // Returns whether the window should be created in incognito mode. |
76 // |create_data| are the options passed by the extension. It may be NULL. | 76 // |create_data| are the options passed by the extension. It may be NULL. |
77 // |urls| is the list of urls to open. If we are creating an incognito window, | 77 // |urls| is the list of urls to open. If we are creating an incognito window, |
78 // the function will remove these urls which may not be opened in incognito | 78 // the function will remove these urls which may not be opened in incognito |
79 // mode. If window creation leads the browser into an erroneous state, | 79 // mode. If window creation leads the browser into an erroneous state, |
80 // |is_error| is set to true (also, error_ member variable is assigned | 80 // |is_error| is set to true (also, error_ member variable is assigned |
81 // the proper error message). | 81 // the proper error message). |
82 bool ShouldOpenIncognitoWindow( | 82 bool ShouldOpenIncognitoWindow( |
83 const api::windows::Create::Params::CreateData* create_data, | 83 const api::windows::Create::Params::CreateData* create_data, |
84 std::vector<GURL>* urls, | 84 std::vector<GURL>* urls, |
85 bool* is_error); | 85 std::string* error); |
86 DECLARE_EXTENSION_FUNCTION("windows.create", WINDOWS_CREATE) | 86 DECLARE_EXTENSION_FUNCTION("windows.create", WINDOWS_CREATE) |
87 }; | 87 }; |
88 class WindowsUpdateFunction : public ChromeSyncExtensionFunction { | 88 class WindowsUpdateFunction : public UIThreadExtensionFunction { |
89 ~WindowsUpdateFunction() override {} | 89 ~WindowsUpdateFunction() override {} |
90 bool RunSync() override; | 90 ResponseAction Run() override; |
91 DECLARE_EXTENSION_FUNCTION("windows.update", WINDOWS_UPDATE) | 91 DECLARE_EXTENSION_FUNCTION("windows.update", WINDOWS_UPDATE) |
92 }; | 92 }; |
93 class WindowsRemoveFunction : public ChromeSyncExtensionFunction { | 93 class WindowsRemoveFunction : public UIThreadExtensionFunction { |
94 ~WindowsRemoveFunction() override {} | 94 ~WindowsRemoveFunction() override {} |
95 bool RunSync() override; | 95 ResponseAction Run() override; |
96 DECLARE_EXTENSION_FUNCTION("windows.remove", WINDOWS_REMOVE) | 96 DECLARE_EXTENSION_FUNCTION("windows.remove", WINDOWS_REMOVE) |
97 }; | 97 }; |
98 | 98 |
99 // Tabs | 99 // Tabs |
100 class TabsGetFunction : public ChromeSyncExtensionFunction { | 100 class TabsGetFunction : public UIThreadExtensionFunction { |
101 ~TabsGetFunction() override {} | 101 ~TabsGetFunction() override {} |
102 bool RunSync() override; | 102 ResponseAction Run() override; |
103 DECLARE_EXTENSION_FUNCTION("tabs.get", TABS_GET) | 103 DECLARE_EXTENSION_FUNCTION("tabs.get", TABS_GET) |
104 }; | 104 }; |
105 class TabsGetCurrentFunction : public ChromeSyncExtensionFunction { | 105 class TabsGetCurrentFunction : public UIThreadExtensionFunction { |
106 ~TabsGetCurrentFunction() override {} | 106 ~TabsGetCurrentFunction() override {} |
107 bool RunSync() override; | 107 ResponseAction Run() override; |
108 DECLARE_EXTENSION_FUNCTION("tabs.getCurrent", TABS_GETCURRENT) | 108 DECLARE_EXTENSION_FUNCTION("tabs.getCurrent", TABS_GETCURRENT) |
109 }; | 109 }; |
110 class TabsGetSelectedFunction : public ChromeSyncExtensionFunction { | 110 class TabsGetSelectedFunction : public UIThreadExtensionFunction { |
111 ~TabsGetSelectedFunction() override {} | 111 ~TabsGetSelectedFunction() override {} |
112 bool RunSync() override; | 112 ResponseAction Run() override; |
113 DECLARE_EXTENSION_FUNCTION("tabs.getSelected", TABS_GETSELECTED) | 113 DECLARE_EXTENSION_FUNCTION("tabs.getSelected", TABS_GETSELECTED) |
114 }; | 114 }; |
115 class TabsGetAllInWindowFunction : public ChromeSyncExtensionFunction { | 115 class TabsGetAllInWindowFunction : public UIThreadExtensionFunction { |
116 ~TabsGetAllInWindowFunction() override {} | 116 ~TabsGetAllInWindowFunction() override {} |
117 bool RunSync() override; | 117 ResponseAction Run() override; |
118 DECLARE_EXTENSION_FUNCTION("tabs.getAllInWindow", TABS_GETALLINWINDOW) | 118 DECLARE_EXTENSION_FUNCTION("tabs.getAllInWindow", TABS_GETALLINWINDOW) |
119 }; | 119 }; |
120 class TabsQueryFunction : public ChromeSyncExtensionFunction { | 120 class TabsQueryFunction : public UIThreadExtensionFunction { |
121 ~TabsQueryFunction() override {} | 121 ~TabsQueryFunction() override {} |
122 bool RunSync() override; | 122 ResponseAction Run() override; |
123 DECLARE_EXTENSION_FUNCTION("tabs.query", TABS_QUERY) | 123 DECLARE_EXTENSION_FUNCTION("tabs.query", TABS_QUERY) |
124 }; | 124 }; |
125 class TabsCreateFunction : public ChromeSyncExtensionFunction { | 125 class TabsCreateFunction : public UIThreadExtensionFunction { |
126 ~TabsCreateFunction() override {} | 126 ~TabsCreateFunction() override {} |
127 bool RunSync() override; | 127 ResponseAction Run() override; |
128 DECLARE_EXTENSION_FUNCTION("tabs.create", TABS_CREATE) | 128 DECLARE_EXTENSION_FUNCTION("tabs.create", TABS_CREATE) |
129 }; | 129 }; |
130 class TabsDuplicateFunction : public ChromeSyncExtensionFunction { | 130 class TabsDuplicateFunction : public UIThreadExtensionFunction { |
131 ~TabsDuplicateFunction() override {} | 131 ~TabsDuplicateFunction() override {} |
132 bool RunSync() override; | 132 ResponseAction Run() override; |
133 DECLARE_EXTENSION_FUNCTION("tabs.duplicate", TABS_DUPLICATE) | 133 DECLARE_EXTENSION_FUNCTION("tabs.duplicate", TABS_DUPLICATE) |
134 }; | 134 }; |
135 class TabsHighlightFunction : public ChromeSyncExtensionFunction { | 135 class TabsHighlightFunction : public UIThreadExtensionFunction { |
136 ~TabsHighlightFunction() override {} | 136 ~TabsHighlightFunction() override {} |
137 bool RunSync() override; | 137 ResponseAction Run() override; |
138 bool HighlightTab(TabStripModel* tabstrip, | 138 bool HighlightTab(TabStripModel* tabstrip, |
139 ui::ListSelectionModel* selection, | 139 ui::ListSelectionModel* selection, |
140 int* active_index, | 140 int* active_index, |
141 int index); | 141 int index, |
| 142 std::string* error); |
142 DECLARE_EXTENSION_FUNCTION("tabs.highlight", TABS_HIGHLIGHT) | 143 DECLARE_EXTENSION_FUNCTION("tabs.highlight", TABS_HIGHLIGHT) |
143 }; | 144 }; |
144 class TabsUpdateFunction : public ChromeAsyncExtensionFunction { | 145 class TabsUpdateFunction : public ChromeAsyncExtensionFunction { |
145 public: | 146 public: |
146 TabsUpdateFunction(); | 147 TabsUpdateFunction(); |
147 | 148 |
148 protected: | 149 protected: |
149 ~TabsUpdateFunction() override {} | 150 ~TabsUpdateFunction() override {} |
150 virtual bool UpdateURL(const std::string& url, | 151 virtual bool UpdateURL(const std::string& url, |
151 int tab_id, | 152 int tab_id, |
152 bool* is_async); | 153 bool* is_async); |
153 virtual void PopulateResult(); | 154 virtual void PopulateResult(); |
154 | 155 |
155 content::WebContents* web_contents_; | 156 content::WebContents* web_contents_; |
156 | 157 |
157 private: | 158 private: |
158 bool RunAsync() override; | 159 bool RunAsync() override; |
159 void OnExecuteCodeFinished(const std::string& error, | 160 void OnExecuteCodeFinished(const std::string& error, |
160 const GURL& on_url, | 161 const GURL& on_url, |
161 const base::ListValue& script_result); | 162 const base::ListValue& script_result); |
162 | 163 |
163 DECLARE_EXTENSION_FUNCTION("tabs.update", TABS_UPDATE) | 164 DECLARE_EXTENSION_FUNCTION("tabs.update", TABS_UPDATE) |
164 }; | 165 }; |
165 class TabsMoveFunction : public ChromeSyncExtensionFunction { | 166 class TabsMoveFunction : public UIThreadExtensionFunction { |
166 ~TabsMoveFunction() override {} | 167 ~TabsMoveFunction() override {} |
167 bool RunSync() override; | 168 ResponseAction Run() override; |
168 bool MoveTab(int tab_id, | 169 bool MoveTab(int tab_id, |
169 int* new_index, | 170 int* new_index, |
170 int iteration, | 171 int iteration, |
171 base::ListValue* tab_values, | 172 base::ListValue* tab_values, |
172 int* window_id); | 173 int* window_id, |
| 174 std::string* error); |
173 DECLARE_EXTENSION_FUNCTION("tabs.move", TABS_MOVE) | 175 DECLARE_EXTENSION_FUNCTION("tabs.move", TABS_MOVE) |
174 }; | 176 }; |
175 class TabsReloadFunction : public ChromeSyncExtensionFunction { | 177 class TabsReloadFunction : public UIThreadExtensionFunction { |
176 ~TabsReloadFunction() override {} | 178 ~TabsReloadFunction() override {} |
177 bool RunSync() override; | 179 ResponseAction Run() override; |
178 DECLARE_EXTENSION_FUNCTION("tabs.reload", TABS_RELOAD) | 180 DECLARE_EXTENSION_FUNCTION("tabs.reload", TABS_RELOAD) |
179 }; | 181 }; |
180 class TabsRemoveFunction : public ChromeSyncExtensionFunction { | 182 class TabsRemoveFunction : public UIThreadExtensionFunction { |
181 ~TabsRemoveFunction() override {} | 183 ~TabsRemoveFunction() override {} |
182 bool RunSync() override; | 184 ResponseAction Run() override; |
183 bool RemoveTab(int tab_id); | 185 bool RemoveTab(int tab_id, std::string* error); |
184 DECLARE_EXTENSION_FUNCTION("tabs.remove", TABS_REMOVE) | 186 DECLARE_EXTENSION_FUNCTION("tabs.remove", TABS_REMOVE) |
185 }; | 187 }; |
186 class TabsDetectLanguageFunction : public ChromeAsyncExtensionFunction, | 188 class TabsDetectLanguageFunction : public ChromeAsyncExtensionFunction, |
187 public content::NotificationObserver { | 189 public content::NotificationObserver { |
188 private: | 190 private: |
189 ~TabsDetectLanguageFunction() override {} | 191 ~TabsDetectLanguageFunction() override {} |
190 bool RunAsync() override; | 192 bool RunAsync() override; |
191 | 193 |
192 void Observe(int type, | 194 void Observe(int type, |
193 const content::NotificationSource& source, | 195 const content::NotificationSource& source, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 336 |
335 // ExtensionFunction: | 337 // ExtensionFunction: |
336 ExtensionFunction::ResponseAction Run() override; | 338 ExtensionFunction::ResponseAction Run() override; |
337 | 339 |
338 DISALLOW_COPY_AND_ASSIGN(TabsDiscardFunction); | 340 DISALLOW_COPY_AND_ASSIGN(TabsDiscardFunction); |
339 }; | 341 }; |
340 | 342 |
341 } // namespace extensions | 343 } // namespace extensions |
342 | 344 |
343 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ | 345 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ |
OLD | NEW |