summaryrefslogtreecommitdiffstats
path: root/ceee/ie/plugin/toolband/toolband.idl
blob: f85fff9efedcf86442be3d04fb5bf3e83ea706e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// @file
// Interface and object declarations for CEEE IE toolband.
//
// Note: We hand-register the proxy/stubs for the marshalable interfaces
//    in this file in each COM apartment that needs to use them. 
//    If you add new marshalable interfaces to this file be sure to update
//    the list of interface proxy/stubs in toolband_proxy.cc, and to
//    call RegisterProxyStubs and UnregisterProxyStubs appropriately.
import "oaidl.idl";
import "ocidl.idl";

[
  object,
  uuid(07995791-0923-4c4e-B861-AA3B933A31CC),
  dual,
  local,  // no marshaling for this interface
  nonextensible,
  pointer_default(unique)
]
// Native interface to content scripts. This interface is exposed to
// ceee_boostrap.js, and is used to satisfy the same contract as
// Chrome's native functions declared in event_bindings.js and
// renderer_extension_bindings.js. Additionally this interface exposes
// properties for the dispatch functions declared in the same files.
// At any given time, this interface should to be synonymous with what you'd
// see by searching the two above files for the strings "dispatchOn" and
// "native function".
interface ICeeeContentScriptNativeApi : IDispatch {
  // Supports JS console.log and console.error.
  HRESULT Log([in] BSTR level, [in] BSTR message);

  // Port-related functions.
  HRESULT OpenChannelToExtension([in] BSTR source_id,
                                 [in] BSTR target_id,
                                 [in] BSTR name,
                                 [out, retval] long* port_id);
  HRESULT CloseChannel([in] long port_id);
  HRESULT PortAddRef([in] long port_id);
  HRESULT PortRelease([in] long port_id);
  HRESULT PostMessage([in] long port_id, [in] BSTR msg);

  // Event-related functions.
  HRESULT AttachEvent([in] BSTR event_name);
  HRESULT DetachEvent([in] BSTR event_name);

  // Event notification callbacks to script.
  [propput] HRESULT onLoad(IDispatch* callback);
  [propput] HRESULT onUnload(IDispatch* callback);

  // Port notification callbacks.
  [propput] HRESULT onPortConnect(IDispatch* callback);
  [propput] HRESULT onPortDisconnect(IDispatch* callback);
  [propput] HRESULT onPortMessage(IDispatch* callback);
};

// An invalid tab Id. This is declared here so that both the BHO and the broker
// knows about it.
const int kInvalidChromeSessionId = -1;

typedef long CeeeWindowHandle;

typedef enum tagCeeeTabStatus {
  kCeeeTabStatusLoading = 0,
  kCeeeTabStatusComplete = 1,
} CeeeTabStatus;

// Information about a tab.
typedef struct tagCeeeTabInfo {
  BSTR url;
  BSTR title;
  CeeeTabStatus status;
  BSTR fav_icon_url;
} CeeeTabInfo;

typedef enum tagCeeeTabCodeType {
  kCeeeTabCodeTypeCss = 0,
  kCeeeTabCodeTypeJs = 1,
} CeeeTabCodeType;

// Information about a window.
typedef struct  {
  BOOL focused;
  RECT rect;
  // We use a BSTR to dynamically allocate a list of couple (HWND, index).
  // These are stored as a JSON list of longs, the even indexes are for ids
  // and their associated odd numbers are the tab index.
  // This value can be NULL if the caller didn't request to populate tabs.
  BSTR tab_list;
} CeeeWindowInfo;

// Information about an HTTP cookie.
typedef struct  {
  BSTR name;
  BSTR value;
  BSTR domain;
  BOOL host_only;
  BSTR path;
  BOOL secure;
  BOOL http_only;
  BOOL session;
  double expiration_date;
  BSTR store_id;
} CeeeCookieInfo;

[
  object,
  uuid(66CDB7E2-B326-493e-B469-16234426C89B),
  nonextensible,
  helpstring("ICeeeWindowExecutor Interface"),
  pointer_default(unique),
]
// Object provided to the broker to execute code in a given window's thread.
interface ICeeeWindowExecutor : IUnknown {
  // Initializes the executor to work with the given CeeeWindowHandle.
  //
  // @param hwnd The HWND of the window the executor represents.
  HRESULT Initialize([in] CeeeWindowHandle hwnd);

  // Returns information about the window represented by this executor.
  //
  // @param populate_tabs Specifies whether we want to receive the list of tabs.
  // @param window_info Where to return the info about the window. The
  //                    @p tab_list field are only set if @p populate_tabs is
  //                    true.
  HRESULT GetWindow([in] BOOL populate_tabs,
                    [out, ref] CeeeWindowInfo* window_info);

  // Returns the list of tabs of this window. We return both the tab HWND and
  // the tab index (encoded in the @p tab_list BSTR) so that our callers don't
  // need an extra IPC to get the tab index later on.
  //
  // @param tab_list Where to return the tab identifiers in the same format as
  //                 described for tagCeeeWindowInfo::tab_ids.
  HRESULT GetTabs([out, retval] BSTR* tab_list);

  // Updates the window with the given set of parameters.
  //
  // @param left The new left position of the window. -1 to leave unchanged.
  // @param top The new top position of the window. -1 to leave unchanged.
  // @param width The new width of the window. -1 to leave unchanged.
  // @param height The new height of the window. -1 to leave unchanged.
  // @param window_info Where to return the new info about the updated window.
  HRESULT UpdateWindow(
      [in] long left, [in] long top, [in] long width, [in] long height,
      [out, ref] CeeeWindowInfo* window_info);

  // Close the window represented by our FrameExecutor.
  //
  // @retval S_OK We could successfully and silently removed the window.
  // @retval S_FALSE We failed to <b>silently</b> remove the window,
  //                 so the caller should try other alternatives (e.g.,
  //                 posting WM_CLOSE to the window).
  HRESULT RemoveWindow();

  // Returns the index of the given tab.
  //
  // @param tab The window handle (HWND) of the tab we want the index of.
  // @param index Where to return the index.
  HRESULT GetTabIndex([in] CeeeWindowHandle tab, [out, ref] long* index);

  // Moves the tab specified by @p tab to the index identified by @p index.
  //
  // @param tab The window handle (HWND) of the tab to move.
  // @param index Where to move the tab.
  HRESULT MoveTab([in] CeeeWindowHandle tab, [in] long index);

  // Removes the specified tab.
  //
  // @param tab The window handle (HWND) of the tab to be removed.
  HRESULT RemoveTab([in] CeeeWindowHandle tab);

  // Selects the specified tab.
  //
  // @param tab The window handle (HWND) of the tab to be selected.
  HRESULT SelectTab([in] CeeeWindowHandle tab);
};

[
  object,
  uuid(1F509E26-002A-461b-9083-ABD1002BD4E2),
  async_uuid(EDF51257-5A41-4391-8186-44DB3E84FBE6),
  nonextensible,
  helpstring("ICeeeTabExecutor Interface"),
  pointer_default(unique),
]
// Object provided to the broker to execute code in a given window's thread.
interface ICeeeTabExecutor : IUnknown {
  // Initializes the executor to work with the given CeeeWindowHandle.
  //
  // @param hwnd The HWND of the tab the executor represents.
  HRESULT Initialize([in] CeeeWindowHandle hwnd);

  // Returns information about the tab represented by the TabExecutor in
  // @p tab_info structure used to return the information.
  //
  // @param tab_info Where to return the tab information.
  //
  // @rvalue S_OK Success
  // @return Other failure HRESULTs may also be returned in case of cascading
  //         errors.
  HRESULT GetTabInfo([out, ref] CeeeTabInfo* tab_info);

  // Navigate to the given url from the given properties.
  //
  // @param url The URL where to navigate the tab to. Can NOT be NULL.
  // @param flags Specifies the type of navigation based on the
  //              BrowserNavConstants enum values.
  // @param target Specifies the navigation target (e.g., _top or _blank).
  //
  // @rvalue S_OK Success
  //         S_FALSE Nothing needed to be done since the URL was already set.
  // @return Other failure HRESULTs may also be returned in case of cascading
  //         errors.
  HRESULT Navigate([in] BSTR url, [in] long flags, [in] BSTR target);

  // Execute or insert code inside a tab.
  //
  // @param code The code to execute or insert.
  // @param file A path to the file that contains the script to execute.
  //             This path is relative to the extension root.
  // @param all_frames If true, applies to the top level frame as well as
  //                   contained iframes.  Otherwise, applies onlt to the
  //                   top level frame.
  HRESULT InsertCode([in] BSTR code,
                     [in] BSTR file,
                     [in] BOOL all_frames,
                     [in] CeeeTabCodeType type);
};

[
  object,
  uuid(875DB992-6ADA-4330-AD3F-28B3E3B9DB01),
  nonextensible,
  helpstring("ICeeeCookieExecutor Interface"),
  pointer_default(unique),
]
// Object provided to the broker to execute code in a given window's thread.
interface ICeeeCookieExecutor : IUnknown {
  // Returns information about the cookie identified by the @c name field of
  // the @p cookie_info structure used to return the information.
  //
  // @param url The URL with which the cookie to retrieve is associated.
  // @param name The name of the cookie to retrieve.
  // @param cookie_info Where to return the cookie information.
  HRESULT GetCookie([in] BSTR url, [in] BSTR name,
                    [out, ref] CeeeCookieInfo* cookie_info);

  // Registers the executor's process as a known cookie store; used to indicate
  // that the cookie store ID has been issued for this process and may be used
  // in other cookie APIs.
  // This API is used to ensure that stale cookie store IDs don't inadvertently
  // match new cookie store processes. This may happen because IE derives the
  // cookie store ID from the IE process ID, which may be recycled by Windows.
  // The first time a cookie store ID is issued for an IE process, this
  // RegisterCookieStore function should be called to indicate that the IE
  // process may now be selected by a user-provided store ID. All cookie APIs
  // should verify that CookieStoreIsRegistered() returns S_OK before matching
  // a user-provided cookie store ID to an IE process.
  HRESULT RegisterCookieStore();

  // Returns S_OK if the executor's process has been registered as a cookie
  // store, S_FALSE if not. All cookie API implementations must ensure this
  // call returns S_OK before accessing a cookie store via a user-provided
  // cookie store ID; if it doesn't, the store ID is stale.
  HRESULT CookieStoreIsRegistered();
};

[
  object,
  uuid(C79A1479-33F6-419f-970F-2FB3D1388922),
  nonextensible,
  helpstring("ICeeeInfobarExecutor Interface"),
  pointer_default(unique),
]
// Object provided to the broker to execute code in a given window's thread.
interface ICeeeInfobarExecutor : IUnknown {
  // Stores the id of our extension.
  // @param extension_id The id of the extension.
  HRESULT SetExtensionId([in] BSTR extension_id);

  // Creates infobar and opens @p url in it. Translates relative path to the
  // absolute path using "chrome-extension://extension_id" prefix where
  // extension_id is the id set by SetExtensionId() call.
  // @param url The URL the infobar window should be navigated to.
  // @param window_handle Where to return the handle of the window in which
  //                      this infobar was created.
  HRESULT ShowInfobar([in] BSTR url,
                      [out, ref] CeeeWindowHandle* window_handle);

  // Notifies infobar about OnBeforeNavigate2 event for the browser top frame.
  // @param url The URL the top frame is about to navigate to.
  HRESULT OnTopFrameBeforeNavigate([in] BSTR url);
};

[
  object,
  uuid(BBB10A7B-DB0D-4f1a-8669-65378DAD0C99),
  nonextensible,
  helpstring("ICeeeExecutorCreator Interface"),
  pointer_default(unique),
  local
]
// Creates an executor in a destination thread, and registers it in the
// CeeeBroker.

// Used to instantiate a CeeeExecutor.
interface ICeeeExecutorCreator : IUnknown {
  // Creates a CeeeExecutor for the given @p thread_id.
  //
  // @param thread_id The identifier of the destination thread where we want
  //                  an executor to be creared.
  // @param window The window handle (HWND) the new executor represents.
  HRESULT CreateWindowExecutor([in] long thread_id,
                               [in] CeeeWindowHandle window);

  // Teardown what was left hanging while waiting for the
  // new executor to be registered for the given @p thread_id.
  //
  // @param thread_id The identifier of the destination thread for which we want
  //                  to tear down our infrastructure.
  HRESULT Teardown([in] long thread_id);
};

[
  uuid(7C09079D-F9CB-4E9E-9293-D224B071D8BA),
  version(1.0),
  helpstring("Google CEEE 1.0 Type Library")
]
library ToolbandLib {
  importlib("stdole2.tlb");

  // include type info in .tlb
  interface ICEEEContentScriptNativeApi;
  interface ICeeeTabExecutor;
  interface ICeeeWindowExecutor;

  [
    uuid(E49EBDB7-CEC9-4014-A5F5-8D3C8F5997DC),
    helpstring("BrowserHelperObject Class")
  ]
  coclass BrowserHelperObject {
    [default] interface IUnknown;
  };
  [
    uuid(2F1A2D6B-55F6-4B63-8C37-F698D28FDC2B),
    helpstring("ToolBand Class")
  ]
  coclass ToolBand {
    [default] interface IUnknown;
  };
  [
    uuid(4A562910-2D54-4e98-B87F-D4A7F5F5D0B9),
    helpstring("CEEE Executor Creator Class")
  ]
  coclass CeeeExecutorCreator {
    [default] interface IUnknown;
  };
  [
    uuid(057FCFE3-F872-483d-86B0-0430E375E41F),
    helpstring("CEEE Executor Class")
  ]
  coclass CeeeExecutor {
    [default] interface IUnknown;
    interface ICeeeTabExecutor;
    interface ICeeeWindowExecutor;
    interface ICeeeCookieExecutor;
    interface ICeeeInfobarExecutor;
  };
};