Closed Bug 106940 Opened 23 years ago Closed 20 years ago

MozillaBrowser.cpp should use the newer nsIPrefService APIs instead of nsIPref

Categories

(Core :: Preferences: Backend, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: chipc, Assigned: gerlofs)

References

Details

(Whiteboard: [good first bug])

Attachments

(2 files)

This is part of a larger clean up project to move from nsIPref to nsIPrefService
and nsIPrefBranch
Blocks: 68946
Status: UNCONFIRMED → NEW
Ever confirmed: true
Target Milestone: --- → mozilla1.2
Blocks: 175193
Whiteboard: [good first bug]
Assignee: bnesse → prefs
Summary: MozillaBrowser.cpp using nsIPref - not nsIPrefService → MozillaBrowser.cpp should use the newer nsIPrefService APIs instead of nsIPref
Target Milestone: mozilla1.2alpha → ---
Assignee: prefs → gerlofs
Replaced refrences to nsIPref from mozilla/src/embedding/browser/activex and
replaced with nsIPrefBranch and friends.
Attachment #152944 - Flags: review?(mkaply)
Comment on attachment 152944 [details] [diff] [review]
Replace nsIPref with nsIPrefBranch and friends

In some of the comments, you changed prefs to prefBranch.

In those cases, prefs makes more sense.

r=mkaply
Attachment #152944 - Flags: superreview?(darin)
Attachment #152944 - Flags: review?(mkaply)
Attachment #152944 - Flags: review+
Comment on attachment 152944 [details] [diff] [review]
Replace nsIPref with nsIPrefBranch and friends

>Index: common/IWebBrowserImpl.h

>         CComBSTR bstrUrl(L"http://home.netscape.com/");
> 
>+        // Find the home page stored in prefBranch
>+        nsCOMPtr<nsIPrefBranch> prefBranch;
>+        if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefBranch))))
>+        {
>+            nsCOMPtr<nsIPrefLocalizedString> homePage;
>+            prefBranch->GetComplexValue("browser.startup.homepage",
>+                                             NS_GET_IID(nsIPrefLocalizedString),
>+                                             getter_AddRefs(homePage));
>+
>+            if (homePage)
>             {
>+               nsXPIDLString homePageString;
>+               nsresult rv=homePage->ToString(getter_Copies(homePageString));
>+               if (rv == NS_OK)
>+               {
>+                 bstrUrl = homePageString.get();
>+               }
>             }
>         }

a few nits in the above code:

 - indentation is not uniform; should be 4 white spaces
 - add whitespace around '=' sign, |nsresult rv = homepage...|
 - |if (rv == NS_OK)| should be |if (NS_SUCCEEDED(rv))|


>+        // Find the home page stored in prefBranch
>+        nsCOMPtr<nsIPrefBranch> prefBranch;
>+        if (NS_SUCCEEDED(GetPrefs(getter_AddRefs(prefBranch))))
>         {
>+            // TODO find and navigate to the search page stored in prefBranch
>             //      and not this hard coded address
>         }

seems to me that this code should just be commented out since
it does nothing at the moment.


>Index: control/StdAfx.h

>+#include "nsIPrefBranch.h"
>+#include "nsIPrefService.h"

the fact that StdAfx.h includes nsIPrefBranch.h and nsIPrefService.h
seems to suggest that the .cpp files shouldn't need to include them
explicitly.  is that true?  if so, how about removing the redundant
includes from the .cpp files.


>Index: plugin/XPCBrowser.cpp

>+nsresult IEBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
> {
>+    NS_ENSURE_ARG_POINTER(aPrefBranch);
>     nsresult rv;
>+    nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
>+    *aPrefBranch = prefBranch;
>+    NS_IF_ADDREF(*aPrefBranch);
>     return rv;
> }

you can also write this function like so:

  nsresult IEBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
  {
      return CallGetService(NS_PREFSERVICE_CONTRACTID, aPrefBranch);
  }


sr=darin with these revisions.
Attachment #152944 - Flags: superreview?(darin) → superreview-
No updates were made to /mozilla/embedding/browser/activex/src/control/StdAfx.h
from the last patch, since it is used only in the control subdirectory.
fixed-on-trunk
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: