1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6#include "nsISupports.idl"
7#include "domstubs.idl"
8
9interface mozIDOMWindowProxy;
10interface nsIEditor;
11
12[scriptable, uuid(24f963d1-e6fc-43ea-a206-99ac5fcc5265)]
13
14interface nsIEditingSession : nsISupports
15{
16  /**
17   *  Error codes when we fail to create an editor
18   *  is placed in attribute editorStatus
19   */
20  const long eEditorOK = 0;
21  const long eEditorCreationInProgress = 1;
22  const long eEditorErrorCantEditMimeType = 2;
23  const long eEditorErrorFileNotFound = 3;
24  const long eEditorErrorCantEditFramesets = 8;
25  const long eEditorErrorUnknown = 9;
26
27  /**
28   *  Status after editor creation and document loading
29   *  Value is one of the above error codes
30   */
31  readonly attribute unsigned long editorStatus;
32
33  /**
34   *  Make this window editable
35   *  @param aWindow nsIDOMWindow, the window the embedder needs to make editable
36   *  @param aEditorType string, "html" "htmlsimple" "text" "textsimple"
37   *  @param aMakeWholeDocumentEditable if PR_TRUE make the whole document in
38   *                                    aWindow editable, otherwise it's the
39   *                                    embedder who should make the document
40   *                                    (or part of it) editable.
41   *  @param aInteractive if PR_FALSE turn off scripting and plugins
42   */
43  void makeWindowEditable(in mozIDOMWindowProxy window,
44                          in string aEditorType,
45                          in boolean doAfterUriLoad,
46                          in boolean aMakeWholeDocumentEditable,
47                          in boolean aInteractive);
48
49  /**
50   *  Test whether a specific window has had its editable flag set; it may have an editor
51   *  now, or will get one after the uri load.
52   *
53   *  Use this, passing the content root window, to test if we've set up editing
54   *  for this content.
55   */
56  boolean windowIsEditable(in mozIDOMWindowProxy window);
57
58  /**
59   *  Get the editor for this window. May return null
60   */
61	nsIEditor getEditorForWindow(in mozIDOMWindowProxy window);
62
63  /**
64   *  Setup editor and related support objects
65   */
66  void setupEditorOnWindow(in mozIDOMWindowProxy window);
67
68  /**
69   *   Destroy editor and related support objects
70   */
71  void tearDownEditorOnWindow(in mozIDOMWindowProxy window);
72
73  void setEditorOnControllers(in mozIDOMWindowProxy aWindow,
74                              in nsIEditor aEditor);
75
76  /**
77   * Disable scripts and plugins in aWindow.
78   */
79  void disableJSAndPlugins(in mozIDOMWindowProxy aWindow);
80
81  /**
82   * Restore JS and plugins (enable/disable them) according to the state they
83   * were before the last call to disableJSAndPlugins.
84   */
85  void restoreJSAndPlugins(in mozIDOMWindowProxy aWindow);
86
87  /**
88   * Removes all the editor's controllers/listeners etc and makes the window
89   * uneditable.
90   */
91  void detachFromWindow(in mozIDOMWindowProxy aWindow);
92
93  /**
94   * Undos detachFromWindow(), reattaches this editing session/editor
95   * to the window.
96   */
97  void reattachToWindow(in mozIDOMWindowProxy aWindow);
98
99  /**
100   * Whether this session has disabled JS and plugins.
101   */
102  readonly attribute boolean jsAndPluginsDisabled;
103};
104
105