Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Brave omaha #109

Merged
merged 12 commits into from
Jun 26, 2018
Merged

Integrate Brave omaha #109

merged 12 commits into from
Jun 26, 2018

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented May 21, 2018

Testing with https://github.com/brave/omaha

When refresh settings/help, BraveUpdate.exe process runs and terminated.

Work together with brave/brave-browser#303.

Closes: brave/brave-browser#179

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions

@simonhong simonhong self-assigned this May 21, 2018
@simonhong simonhong force-pushed the integrate_omaha branch 3 times, most recently from 0e71e58 to 12564dd Compare May 30, 2018 02:58
@simonhong simonhong force-pushed the integrate_omaha branch 2 times, most recently from 4e7777a to 3aa703a Compare June 7, 2018 15:53
@simonhong simonhong force-pushed the integrate_omaha branch 2 times, most recently from 6587bdc to 0c13a11 Compare June 14, 2018 05:00
@simonhong simonhong changed the title WIP: Integrate Brave omaha Integrate Brave omaha Jun 14, 2018
+#if defined(BRAVE_CHROMIUM_BUILD) && defined(OFFICIAL_BUILD)
+// Reflect brave branded-omaha variable name.
+// Company name(BraveSoftware) + Product name(Update).
+const char kGoogleUpdateIsMachineEnvVar[] = "BraveSoftwareUpdateIsMachine";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary? I think it would be better to have consistent behavior for this env var with Chrome

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This var name comes from omaha.
To customize omaha for brave, company name should be changed to BraveSoftware because it is related with install directory. Then omaha makes env var by using it.
So, I think we should follow omaha var name in here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be done with the later string substitution method.

+const wchar_t kGoogleUpdatePoliciesKey[] =
+ L"SOFTWARE\\Policies\\BraveSoftware\\Update";
+const wchar_t kCheckPeriodOverrideMinutes[] = L"AutoUpdateCheckPeriodMinutes";
+const wchar_t kUpdatePolicyValue[] = L"UpdateDefault";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of these values look identical to the google versions. Seems like it would be better to use the undefine/redefine override. @bbondy can help with that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good way to use def/undef override for variable change?
I think the result would be same with the copying.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const overriding should work just like method overriding. same def/undef applies

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would the result be the same as copying if we're only changing some of the values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I referred browser_about_handler.cc in chromium_src.
In that file, upstream method name was changed and reused with additional implementation(FixupBrowserAboutURLBraveImpl).

I don't know how to adopt this technique to this file w/o changing functions implementation in this file.
Do you mean variable like re-define kGoogleUpdatePoliciesKey to kGoogleUpdatePoliciesKey_ChromiumImpl?

I think I don't know how to adopt undefine/redefine technique here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but whether we patch or do something else, we only need the values we are overriding. We should not include things like kCheckPeriodOverrideMinutes or kCheckPeriodOverrideMinutesMax that we are not changing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that work correctly? It doesn't seem like it would

It doesn't work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to apply override technique like this (b23256e) to other files in this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it won't work if they're in an anonymous namespace like that. There's not way to reference/override them afaik

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll revert b23256e to patch, and will try override to non-anonymous symbols.

using installer::InstallationState;

const wchar_t GoogleUpdateSettings::kPoliciesKey[] =
+#if defined(BRAVE_CHROMIUM_BUILD) && defined(OFFICIAL_BUILD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below undefine/redefine override

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you advice how to override variable? I still don't have any idea how to do it with separate file in chormium_src.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's difficult to use override technique to member var/method.

I tried to override ClassA::MethodA, in new class_a.cc in chromium_src like below.

#define MethodA MethodA_ChromiumImpl
#include ".../class_a.cc"
#undef MethodA

void ClassA::MethodA() {
...
}

Compiler will complain like this error: no member named MethodA in ClassA.
I think the reason is header file(class_a.h) included in this file was also affected by macro.
So, there is no MethodA in this file.
Overriding member variable will have same error.
@bbondy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replied below.

diff --git a/chrome/installer/mini_installer/appid.h b/chrome/installer/mini_installer/appid.h
index c408242814504aae086fc332f0d8bbd7872821a2..deadf14c9c8a17d7d83fcf3428cd3734a92d70b1 100644
--- a/chrome/installer/mini_installer/appid.h
+++ b/chrome/installer/mini_installer/appid.h
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we modifying this when we already have brave_appid?

Copy link
Member Author

@simonhong simonhong Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
appid.h is copied into chromium_src.

"mini_installer.h",
"mini_installer.rc",
- "mini_installer_constants.cc",
+ "//brave/installer/mini_installer/mini_installer_constants.cc",
Copy link
Collaborator

@bridiver bridiver Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are replacing the entire file it's better to use chromium_src which will work automatically without any patching

Copy link
Member Author

@simonhong simonhong Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
mini_installer_constants.cc is moved into chromium_src.


const GoogleUpdateSettings::UpdatePolicy
GoogleUpdateSettings::kDefaultUpdatePolicy =
-#if defined(GOOGLE_CHROME_BUILD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we doing this for all GOOGLE_CHROME_BUILD guards in this file? If so it would be easier to just define GOOGLE_CHROME_BUILD if BRAVE_CHROMIUM_BUILD && OFFICIAL_BUILD and then undef at the end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worrying about that situation when upstream add more GOOGLE_CHROME_BUILD guard in this file and it isn't related with brave. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the reverse just as likely?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with #define GOOGLE_CHROME_BUILD

}

std::string GoogleChromeDistribution::GetSafeBrowsingName() {
+#if defined(BRAVE_CHROMIUM_BUILD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted.

return base::ReplaceStringPlaceholders(url, language, NULL);
}

+// TODO(simonhong): Use brave's url.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't patch for comments. Open a ticket instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted.


-#if defined(GOOGLE_CHROME_BUILD)
+#if defined(GOOGLE_CHROME_BUILD) || (defined(BRAVE_CHROMIUM_BUILD) && defined(OFFICIAL_BUILD))
dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just patch here to create a BraveDistribution and get rid of most of the patches below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After addressing your review, all modification of GoogleChromeDistribution is gone.
So, just enabling this seems fine instead of creating BraveDistribution because we are using GoogleChromeDistribution w/o any change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

return std::wstring(L"Software\\").append(product);
}

+#if defined(BRAVE_CHROMIUM_BUILD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override with undefine/redefine

Copy link
Member Author

@simonhong simonhong Jun 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do for functions that are used by other functions in the same file.
Also, this is in anonymous namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do it for functions that are used by other functions in the same file, but you would also have to do the functions that use that function. You can just only do the functions that use that function I think in this case.

Copy link
Member Author

@simonhong simonhong Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comment for the record.
This is the reason why patching technique is used instead of overriding in this case.
In case of install_modes.cc, override technique causes modifying all functions in that file and can't reuse upstream functions. It is similar to copying technique.
IMO, patching technique is more better to copying for future rebase.
I thought def/undef technique is only useful when we can re-use upstream implementation

"webui/settings/incompatible_applications_handler_win.h",
]
deps += [ "//google_update" ]
+ } else if (brave_chromium_build && is_official_build) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just add these in our own gn file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,5747 @@


/* this ALWAYS GENERATED file contains the definitions for the interfaces */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this file generated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the build, midl.py generates these file in temp directory and compares it with pre-installed version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then why are we copying the output? Shouldn't we be modifying the inputs so we get the correct output?

Copy link
Member Author

@simonhong simonhong Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifying input files in src/third_party/win_bulid_output causes creating a lot of patch files.
So, I decided to use copying from our directory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brave/brave-browser#303 handles this.

Enable Omaha connection with UpgradeDetector and VersionUpdater.
Also, guids and registry pathes are changed to use brave branding.
TODO: uninstall survey url should be changed.
Our pre-generated midl files are copied to overwrite upstream pre-installed
midl files.
bsclifton added a commit that referenced this pull request Nov 13, 2023
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

I used #109 as a guide
bsclifton pushed a commit that referenced this pull request Nov 22, 2023
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

Using #109 as a guide

Also includes `.gitattributes` fix which prevents differences found
w/ filecmp.cmpfiles in MIDL compilation.
bsclifton pushed a commit that referenced this pull request Dec 11, 2023
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

Using #109 as a guide

Also includes `.gitattributes` fix which prevents differences found
w/ filecmp.cmpfiles in MIDL compilation.
bsclifton pushed a commit that referenced this pull request Jan 9, 2024
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

Using #109 as a guide

Also includes `.gitattributes` fix which prevents differences found
w/ filecmp.cmpfiles in MIDL compilation.
bsclifton pushed a commit that referenced this pull request Jan 12, 2024
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

Using #109 as a guide

Also includes `.gitattributes` fix which prevents differences found
w/ filecmp.cmpfiles in MIDL compilation.
bsclifton pushed a commit that referenced this pull request Jan 16, 2024
Moves the IDL file into chromium_src, patches BUILD.gn to use
chromium_src override. IDL output rebuilt at `./src` directory
using `python3 ./tools/win/update_idl.py`

Using #109 as a guide

Also includes `.gitattributes` fix which prevents differences found
w/ filecmp.cmpfiles in MIDL compilation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants