embedding/tests/winEmbed/WebBrowserChrome.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* ***** BEGIN LICENSE BLOCK *****
michael@0 2 * Version: Mozilla-sample-code 1.0
michael@0 3 *
michael@0 4 * Copyright (c) 2002 Netscape Communications Corporation and
michael@0 5 * other contributors
michael@0 6 *
michael@0 7 * Permission is hereby granted, free of charge, to any person obtaining a
michael@0 8 * copy of this Mozilla sample software and associated documentation files
michael@0 9 * (the "Software"), to deal in the Software without restriction, including
michael@0 10 * without limitation the rights to use, copy, modify, merge, publish,
michael@0 11 * distribute, sublicense, and/or sell copies of the Software, and to permit
michael@0 12 * persons to whom the Software is furnished to do so, subject to the
michael@0 13 * following conditions:
michael@0 14 *
michael@0 15 * The above copyright notice and this permission notice shall be included
michael@0 16 * in all copies or substantial portions of the Software.
michael@0 17 *
michael@0 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
michael@0 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
michael@0 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
michael@0 21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
michael@0 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
michael@0 23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
michael@0 24 * DEALINGS IN THE SOFTWARE.
michael@0 25 *
michael@0 26 * Contributor(s):
michael@0 27 *
michael@0 28 * ***** END LICENSE BLOCK ***** */
michael@0 29
michael@0 30 // Local includes
michael@0 31 #include "resource.h"
michael@0 32 #include "winEmbed.h"
michael@0 33 #include "WebBrowserChrome.h"
michael@0 34
michael@0 35 // OS headers
michael@0 36 #include <stdio.h>
michael@0 37
michael@0 38 // Frozen APIs
michael@0 39
michael@0 40 #include "nsStringAPI.h"
michael@0 41 #include "nsIComponentManager.h"
michael@0 42 #include "nsIDOMWindow.h"
michael@0 43 #include "nsIInterfaceRequestor.h"
michael@0 44 #include "nsIRequest.h"
michael@0 45 #include "nsIURI.h"
michael@0 46 #include "nsIWebProgress.h"
michael@0 47 #include "nsCWebBrowser.h"
michael@0 48
michael@0 49 // Glue APIs (not frozen, but safe to use because they are statically linked)
michael@0 50 #include "nsComponentManagerUtils.h"
michael@0 51
michael@0 52 // NON-FROZEN APIS!
michael@0 53 #include "nsIWebNavigation.h"
michael@0 54
michael@0 55 WebBrowserChrome::WebBrowserChrome()
michael@0 56 {
michael@0 57 mNativeWindow = nullptr;
michael@0 58 mSizeSet = false;
michael@0 59 }
michael@0 60
michael@0 61 WebBrowserChrome::~WebBrowserChrome()
michael@0 62 {
michael@0 63 WebBrowserChromeUI::Destroyed(this);
michael@0 64 }
michael@0 65
michael@0 66 nsresult WebBrowserChrome::CreateBrowser(int32_t aX, int32_t aY,
michael@0 67 int32_t aCX, int32_t aCY,
michael@0 68 nsIWebBrowser **aBrowser)
michael@0 69 {
michael@0 70 NS_ENSURE_ARG_POINTER(aBrowser);
michael@0 71 *aBrowser = nullptr;
michael@0 72
michael@0 73 mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
michael@0 74
michael@0 75 if (!mWebBrowser)
michael@0 76 return NS_ERROR_FAILURE;
michael@0 77
michael@0 78 (void)mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(this));
michael@0 79
michael@0 80 nsCOMPtr<nsIBaseWindow> browserBaseWindow = do_QueryInterface(mWebBrowser);
michael@0 81
michael@0 82 mNativeWindow = WebBrowserChromeUI::CreateNativeWindow(static_cast<nsIWebBrowserChrome*>(this));
michael@0 83
michael@0 84 if (!mNativeWindow)
michael@0 85 return NS_ERROR_FAILURE;
michael@0 86
michael@0 87 browserBaseWindow->InitWindow( mNativeWindow,
michael@0 88 nullptr,
michael@0 89 aX, aY, aCX, aCY);
michael@0 90 browserBaseWindow->Create();
michael@0 91
michael@0 92 nsCOMPtr<nsIWebProgressListener> listener(static_cast<nsIWebProgressListener*>(this));
michael@0 93 nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
michael@0 94 (void)mWebBrowser->AddWebBrowserListener(thisListener,
michael@0 95 NS_GET_IID(nsIWebProgressListener));
michael@0 96
michael@0 97 // The window has been created. Now register for history notifications
michael@0 98 mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsISHistoryListener));
michael@0 99
michael@0 100 if (mWebBrowser)
michael@0 101 {
michael@0 102 *aBrowser = mWebBrowser;
michael@0 103 NS_ADDREF(*aBrowser);
michael@0 104 return NS_OK;
michael@0 105 }
michael@0 106 return NS_ERROR_FAILURE;
michael@0 107 }
michael@0 108
michael@0 109 //*****************************************************************************
michael@0 110 // WebBrowserChrome::nsISupports
michael@0 111 //*****************************************************************************
michael@0 112
michael@0 113 NS_IMPL_ADDREF(WebBrowserChrome)
michael@0 114 NS_IMPL_RELEASE(WebBrowserChrome)
michael@0 115
michael@0 116 NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
michael@0 117 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
michael@0 118 NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
michael@0 119 NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
michael@0 120 NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
michael@0 121 NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) // optional
michael@0 122 NS_INTERFACE_MAP_ENTRY(nsISHistoryListener)
michael@0 123 NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
michael@0 124 NS_INTERFACE_MAP_ENTRY(nsIObserver)
michael@0 125 NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
michael@0 126 NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
michael@0 127 NS_INTERFACE_MAP_END
michael@0 128
michael@0 129 //*****************************************************************************
michael@0 130 // WebBrowserChrome::nsIInterfaceRequestor
michael@0 131 //*****************************************************************************
michael@0 132
michael@0 133 NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
michael@0 134 {
michael@0 135 NS_ENSURE_ARG_POINTER(aInstancePtr);
michael@0 136
michael@0 137 *aInstancePtr = 0;
michael@0 138 if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
michael@0 139 {
michael@0 140 if (mWebBrowser)
michael@0 141 {
michael@0 142 return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
michael@0 143 }
michael@0 144 return NS_ERROR_NOT_INITIALIZED;
michael@0 145 }
michael@0 146 return QueryInterface(aIID, aInstancePtr);
michael@0 147 }
michael@0 148
michael@0 149 //*****************************************************************************
michael@0 150 // WebBrowserChrome::nsIWebBrowserChrome
michael@0 151 //*****************************************************************************
michael@0 152
michael@0 153 NS_IMETHODIMP WebBrowserChrome::SetStatus(uint32_t aType, const char16_t* aStatus)
michael@0 154 {
michael@0 155 WebBrowserChromeUI::UpdateStatusBarText(this, aStatus);
michael@0 156 return NS_OK;
michael@0 157 }
michael@0 158
michael@0 159 NS_IMETHODIMP WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
michael@0 160 {
michael@0 161 NS_ENSURE_ARG_POINTER(aWebBrowser);
michael@0 162 *aWebBrowser = mWebBrowser;
michael@0 163 NS_IF_ADDREF(*aWebBrowser);
michael@0 164 return NS_OK;
michael@0 165 }
michael@0 166
michael@0 167 NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
michael@0 168 {
michael@0 169 mWebBrowser = aWebBrowser;
michael@0 170 return NS_OK;
michael@0 171 }
michael@0 172
michael@0 173 NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(uint32_t* aChromeMask)
michael@0 174 {
michael@0 175 *aChromeMask = mChromeFlags;
michael@0 176 return NS_OK;
michael@0 177 }
michael@0 178
michael@0 179 NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(uint32_t aChromeMask)
michael@0 180 {
michael@0 181 mChromeFlags = aChromeMask;
michael@0 182 return NS_OK;
michael@0 183 }
michael@0 184
michael@0 185 NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void)
michael@0 186 {
michael@0 187 WebBrowserChromeUI::Destroy(this);
michael@0 188 return NS_OK;
michael@0 189 }
michael@0 190
michael@0 191
michael@0 192 // IN: The desired browser client area dimensions.
michael@0 193 NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(int32_t aWidth, int32_t aHeight)
michael@0 194 {
michael@0 195 /* This isn't exactly correct: we're setting the whole window to
michael@0 196 the size requested for the browser. At time of writing, though,
michael@0 197 it's fine and useful for winEmbed's purposes. */
michael@0 198 WebBrowserChromeUI::SizeTo(this, aWidth, aHeight);
michael@0 199 mSizeSet = true;
michael@0 200 return NS_OK;
michael@0 201 }
michael@0 202
michael@0 203
michael@0 204 NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void)
michael@0 205 {
michael@0 206 if (mDependentParent)
michael@0 207 AppCallbacks::EnableChromeWindow(mDependentParent, false);
michael@0 208
michael@0 209 mContinueModalLoop = true;
michael@0 210 AppCallbacks::RunEventLoop(mContinueModalLoop);
michael@0 211
michael@0 212 if (mDependentParent)
michael@0 213 AppCallbacks::EnableChromeWindow(mDependentParent, true);
michael@0 214
michael@0 215 return NS_OK;
michael@0 216 }
michael@0 217
michael@0 218 NS_IMETHODIMP WebBrowserChrome::IsWindowModal(bool *_retval)
michael@0 219 {
michael@0 220 *_retval = false;
michael@0 221 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 222 }
michael@0 223
michael@0 224 NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
michael@0 225 {
michael@0 226 mContinueModalLoop = false;
michael@0 227 return NS_OK;
michael@0 228 }
michael@0 229
michael@0 230 //*****************************************************************************
michael@0 231 // WebBrowserChrome::nsIWebBrowserChromeFocus
michael@0 232 //*****************************************************************************
michael@0 233
michael@0 234 NS_IMETHODIMP WebBrowserChrome::FocusNextElement()
michael@0 235 {
michael@0 236 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 237 }
michael@0 238
michael@0 239 NS_IMETHODIMP WebBrowserChrome::FocusPrevElement()
michael@0 240 {
michael@0 241 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 242 }
michael@0 243
michael@0 244 //*****************************************************************************
michael@0 245 // WebBrowserChrome::nsIWebProgressListener
michael@0 246 //*****************************************************************************
michael@0 247
michael@0 248 NS_IMETHODIMP WebBrowserChrome::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
michael@0 249 int32_t curSelfProgress, int32_t maxSelfProgress,
michael@0 250 int32_t curTotalProgress, int32_t maxTotalProgress)
michael@0 251 {
michael@0 252 WebBrowserChromeUI::UpdateProgress(this, curTotalProgress, maxTotalProgress);
michael@0 253 return NS_OK;
michael@0 254 }
michael@0 255
michael@0 256 NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
michael@0 257 uint32_t progressStateFlags, nsresult status)
michael@0 258 {
michael@0 259 if ((progressStateFlags & STATE_START) && (progressStateFlags & STATE_IS_DOCUMENT))
michael@0 260 {
michael@0 261 WebBrowserChromeUI::UpdateBusyState(this, true);
michael@0 262 }
michael@0 263
michael@0 264 if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_DOCUMENT))
michael@0 265 {
michael@0 266 WebBrowserChromeUI::UpdateBusyState(this, false);
michael@0 267 WebBrowserChromeUI::UpdateProgress(this, 0, 100);
michael@0 268 WebBrowserChromeUI::UpdateStatusBarText(this, nullptr);
michael@0 269 ContentFinishedLoading();
michael@0 270 }
michael@0 271
michael@0 272 return NS_OK;
michael@0 273 }
michael@0 274
michael@0 275
michael@0 276 NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress,
michael@0 277 nsIRequest* aRequest,
michael@0 278 nsIURI *location,
michael@0 279 uint32_t aFlags)
michael@0 280 {
michael@0 281 bool isSubFrameLoad = false; // Is this a subframe load
michael@0 282 if (aWebProgress) {
michael@0 283 nsCOMPtr<nsIDOMWindow> domWindow;
michael@0 284 nsCOMPtr<nsIDOMWindow> topDomWindow;
michael@0 285 aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
michael@0 286 if (domWindow) { // Get root domWindow
michael@0 287 domWindow->GetTop(getter_AddRefs(topDomWindow));
michael@0 288 }
michael@0 289 if (domWindow != topDomWindow)
michael@0 290 isSubFrameLoad = true;
michael@0 291 }
michael@0 292 if (!isSubFrameLoad)
michael@0 293 WebBrowserChromeUI::UpdateCurrentURI(this);
michael@0 294 return NS_OK;
michael@0 295 }
michael@0 296
michael@0 297 NS_IMETHODIMP
michael@0 298 WebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress,
michael@0 299 nsIRequest* aRequest,
michael@0 300 nsresult aStatus,
michael@0 301 const char16_t* aMessage)
michael@0 302 {
michael@0 303 WebBrowserChromeUI::UpdateStatusBarText(this, aMessage);
michael@0 304 return NS_OK;
michael@0 305 }
michael@0 306
michael@0 307
michael@0 308
michael@0 309 NS_IMETHODIMP
michael@0 310 WebBrowserChrome::OnSecurityChange(nsIWebProgress *aWebProgress,
michael@0 311 nsIRequest *aRequest,
michael@0 312 uint32_t state)
michael@0 313 {
michael@0 314 return NS_OK;
michael@0 315 }
michael@0 316
michael@0 317 //*****************************************************************************
michael@0 318 // WebBrowserChrome::nsISHistoryListener
michael@0 319 //*****************************************************************************
michael@0 320
michael@0 321 NS_IMETHODIMP
michael@0 322 WebBrowserChrome::OnHistoryNewEntry(nsIURI * aNewURI)
michael@0 323 {
michael@0 324 return SendHistoryStatusMessage(aNewURI, "add");
michael@0 325 }
michael@0 326
michael@0 327 NS_IMETHODIMP
michael@0 328 WebBrowserChrome::OnHistoryGoBack(nsIURI * aBackURI, bool * aContinue)
michael@0 329 {
michael@0 330 // For now, let the operation continue
michael@0 331 *aContinue = true;
michael@0 332 return SendHistoryStatusMessage(aBackURI, "back");
michael@0 333 }
michael@0 334
michael@0 335
michael@0 336 NS_IMETHODIMP
michael@0 337 WebBrowserChrome::OnHistoryGoForward(nsIURI * aForwardURI, bool * aContinue)
michael@0 338 {
michael@0 339 // For now, let the operation continue
michael@0 340 *aContinue = true;
michael@0 341 return SendHistoryStatusMessage(aForwardURI, "forward");
michael@0 342 }
michael@0 343
michael@0 344
michael@0 345 NS_IMETHODIMP
michael@0 346 WebBrowserChrome::OnHistoryGotoIndex(int32_t aIndex, nsIURI * aGotoURI, bool * aContinue)
michael@0 347 {
michael@0 348 // For now, let the operation continue
michael@0 349 *aContinue = true;
michael@0 350 return SendHistoryStatusMessage(aGotoURI, "goto", aIndex);
michael@0 351 }
michael@0 352
michael@0 353 NS_IMETHODIMP
michael@0 354 WebBrowserChrome::OnHistoryReload(nsIURI * aURI, uint32_t aReloadFlags, bool * aContinue)
michael@0 355 {
michael@0 356 // For now, let the operation continue
michael@0 357 *aContinue = true;
michael@0 358 return SendHistoryStatusMessage(aURI, "reload", 0 /* no info to pass here */, aReloadFlags);
michael@0 359 }
michael@0 360
michael@0 361 NS_IMETHODIMP
michael@0 362 WebBrowserChrome::OnHistoryPurge(int32_t aNumEntries, bool *aContinue)
michael@0 363 {
michael@0 364 // For now let the operation continue
michael@0 365 *aContinue = false;
michael@0 366 return SendHistoryStatusMessage(nullptr, "purge", aNumEntries);
michael@0 367 }
michael@0 368
michael@0 369 NS_IMETHODIMP
michael@0 370 WebBrowserChrome::OnHistoryReplaceEntry(int32_t aIndex)
michael@0 371 {
michael@0 372 return SendHistoryStatusMessage(nullptr, "replace", aIndex);
michael@0 373 }
michael@0 374
michael@0 375 static void
michael@0 376 AppendIntToCString(int32_t info1, nsCString& aResult)
michael@0 377 {
michael@0 378 char intstr[10];
michael@0 379 _snprintf(intstr, sizeof(intstr) - 1, "%i", info1);
michael@0 380 intstr[sizeof(intstr) - 1] = '\0';
michael@0 381 aResult.Append(intstr);
michael@0 382 }
michael@0 383
michael@0 384 nsresult
michael@0 385 WebBrowserChrome::SendHistoryStatusMessage(nsIURI * aURI, char * operation, int32_t info1, uint32_t aReloadFlags)
michael@0 386 {
michael@0 387 nsCString uriSpec;
michael@0 388 if (aURI)
michael@0 389 {
michael@0 390 aURI->GetSpec(uriSpec);
michael@0 391 }
michael@0 392
michael@0 393 nsCString status;
michael@0 394
michael@0 395 if(!(strcmp(operation, "back")))
michael@0 396 {
michael@0 397 status.Assign("Going back to url: ");
michael@0 398 status.Append(uriSpec);
michael@0 399 }
michael@0 400 else if (!(strcmp(operation, "forward")))
michael@0 401 {
michael@0 402 // Going forward. XXX Get string from a resource file
michael@0 403 status.Assign("Going forward to url: ");
michael@0 404 status.Append(uriSpec);
michael@0 405 }
michael@0 406 else if (!(strcmp(operation, "reload")))
michael@0 407 {
michael@0 408 // Reloading. XXX Get string from a resource file
michael@0 409 if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
michael@0 410 aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
michael@0 411 {
michael@0 412 status.Assign("Reloading url, (bypassing proxy and cache): ");
michael@0 413 }
michael@0 414 else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY)
michael@0 415 {
michael@0 416 status.Assign("Reloading url, (bypassing proxy): ");
michael@0 417 }
michael@0 418 else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
michael@0 419 {
michael@0 420 status.Assign("Reloading url, (bypassing cache): ");
michael@0 421 }
michael@0 422 else
michael@0 423 {
michael@0 424 status.Assign("Reloading url, (normal): ");
michael@0 425 }
michael@0 426 status.Append(uriSpec);
michael@0 427 }
michael@0 428 else if (!(strcmp(operation, "add")))
michael@0 429 {
michael@0 430 status.Assign(uriSpec);
michael@0 431 status.Append(" added to session History");
michael@0 432 }
michael@0 433 else if (!(strcmp(operation, "goto")))
michael@0 434 {
michael@0 435 status.Assign("Going to HistoryIndex: ");
michael@0 436
michael@0 437 AppendIntToCString(info1, status);
michael@0 438
michael@0 439 status.Append(" Url: ");
michael@0 440 status.Append(uriSpec);
michael@0 441 }
michael@0 442 else if (!(strcmp(operation, "purge")))
michael@0 443 {
michael@0 444 AppendIntToCString(info1, status);
michael@0 445 status.Append(" purged from Session History");
michael@0 446 }
michael@0 447 else if (!(strcmp(operation, "replace")))
michael@0 448 {
michael@0 449 status.Assign("Replacing HistoryIndex: ");
michael@0 450 AppendIntToCString(info1, status);
michael@0 451 }
michael@0 452
michael@0 453 nsString wstatus;
michael@0 454 NS_CStringToUTF16(status, NS_CSTRING_ENCODING_UTF8, wstatus);
michael@0 455 WebBrowserChromeUI::UpdateStatusBarText(this, wstatus.get());
michael@0 456
michael@0 457 return NS_OK;
michael@0 458 }
michael@0 459
michael@0 460 void WebBrowserChrome::ContentFinishedLoading()
michael@0 461 {
michael@0 462 // if it was a chrome window and no one has already specified a size,
michael@0 463 // size to content
michael@0 464 if (mWebBrowser && !mSizeSet &&
michael@0 465 (mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
michael@0 466 nsCOMPtr<nsIDOMWindow> contentWin;
michael@0 467 mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin));
michael@0 468 if (contentWin)
michael@0 469 contentWin->SizeToContent();
michael@0 470 WebBrowserChromeUI::ShowWindow(this, true);
michael@0 471 }
michael@0 472 }
michael@0 473
michael@0 474
michael@0 475 //*****************************************************************************
michael@0 476 // WebBrowserChrome::nsIEmbeddingSiteWindow
michael@0 477 //*****************************************************************************
michael@0 478
michael@0 479 NS_IMETHODIMP WebBrowserChrome::SetDimensions(uint32_t aFlags, int32_t x, int32_t y, int32_t cx, int32_t cy)
michael@0 480 {
michael@0 481 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 482 }
michael@0 483
michael@0 484 NS_IMETHODIMP WebBrowserChrome::GetDimensions(uint32_t aFlags, int32_t *x, int32_t *y, int32_t *cx, int32_t *cy)
michael@0 485 {
michael@0 486 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
michael@0 487 {
michael@0 488 *x = 0;
michael@0 489 *y = 0;
michael@0 490 }
michael@0 491 if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
michael@0 492 aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
michael@0 493 {
michael@0 494 *cx = 0;
michael@0 495 *cy = 0;
michael@0 496 }
michael@0 497 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 498 }
michael@0 499
michael@0 500 /* void setFocus (); */
michael@0 501 NS_IMETHODIMP WebBrowserChrome::SetFocus()
michael@0 502 {
michael@0 503 WebBrowserChromeUI::SetFocus(this);
michael@0 504 return NS_OK;
michael@0 505 }
michael@0 506
michael@0 507 /* void blur (); */
michael@0 508 NS_IMETHODIMP WebBrowserChrome::Blur()
michael@0 509 {
michael@0 510 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 511 }
michael@0 512
michael@0 513 /* attribute wstring title; */
michael@0 514 NS_IMETHODIMP WebBrowserChrome::GetTitle(char16_t * *aTitle)
michael@0 515 {
michael@0 516 NS_ENSURE_ARG_POINTER(aTitle);
michael@0 517
michael@0 518 *aTitle = nullptr;
michael@0 519
michael@0 520 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 521 }
michael@0 522 NS_IMETHODIMP WebBrowserChrome::SetTitle(const char16_t * aTitle)
michael@0 523 {
michael@0 524 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 525 }
michael@0 526
michael@0 527 /* attribute boolean visibility; */
michael@0 528 NS_IMETHODIMP WebBrowserChrome::GetVisibility(bool * aVisibility)
michael@0 529 {
michael@0 530 NS_ENSURE_ARG_POINTER(aVisibility);
michael@0 531 *aVisibility = true;
michael@0 532 return NS_OK;
michael@0 533 }
michael@0 534 NS_IMETHODIMP WebBrowserChrome::SetVisibility(bool aVisibility)
michael@0 535 {
michael@0 536 return NS_OK;
michael@0 537 }
michael@0 538
michael@0 539 /* attribute nativeSiteWindow siteWindow */
michael@0 540 NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
michael@0 541 {
michael@0 542 NS_ENSURE_ARG_POINTER(aSiteWindow);
michael@0 543
michael@0 544 *aSiteWindow = mNativeWindow;
michael@0 545 return NS_OK;
michael@0 546 }
michael@0 547
michael@0 548
michael@0 549 //*****************************************************************************
michael@0 550 // WebBrowserChrome::nsIObserver
michael@0 551 //*****************************************************************************
michael@0 552
michael@0 553 NS_IMETHODIMP WebBrowserChrome::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
michael@0 554 {
michael@0 555 nsresult rv = NS_OK;
michael@0 556 if (strcmp(aTopic, "profile-change-teardown") == 0)
michael@0 557 {
michael@0 558 // A profile change means death for this window
michael@0 559 WebBrowserChromeUI::Destroy(this);
michael@0 560 }
michael@0 561 return rv;
michael@0 562 }
michael@0 563
michael@0 564 //*****************************************************************************
michael@0 565 // WebBrowserChrome::nsIContextMenuListener
michael@0 566 //*****************************************************************************
michael@0 567
michael@0 568 /* void OnShowContextMenu (in unsigned long aContextFlags, in nsIDOMEvent aEvent, in nsIDOMNode aNode); */
michael@0 569 NS_IMETHODIMP WebBrowserChrome::OnShowContextMenu(uint32_t aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
michael@0 570 {
michael@0 571 WebBrowserChromeUI::ShowContextMenu(this, aContextFlags, aEvent, aNode);
michael@0 572 return NS_OK;
michael@0 573 }
michael@0 574
michael@0 575 //*****************************************************************************
michael@0 576 // WebBrowserChrome::nsITooltipListener
michael@0 577 //*****************************************************************************
michael@0 578
michael@0 579 /* void OnShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */
michael@0 580 NS_IMETHODIMP WebBrowserChrome::OnShowTooltip(int32_t aXCoords, int32_t aYCoords, const char16_t *aTipText)
michael@0 581 {
michael@0 582 WebBrowserChromeUI::ShowTooltip(this, aXCoords, aYCoords, aTipText);
michael@0 583 return NS_OK;
michael@0 584 }
michael@0 585
michael@0 586 /* void OnHideTooltip (); */
michael@0 587 NS_IMETHODIMP WebBrowserChrome::OnHideTooltip()
michael@0 588 {
michael@0 589 WebBrowserChromeUI::HideTooltip(this);
michael@0 590 return NS_OK;
michael@0 591 }

mercurial