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

Sparkle: update server url and enable background update when browser stars #242

Merged
merged 3 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions brave_init_settings.gni
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ declare_args() {
# "" for stable channel release.
brave_channel = ""

# Update feed url on MacOS
# TODO(simonhong): This url is stub. Replace with real update server or your
# test server.
brave_feed_url = "http://localhost:9090"
base_sparkle_update_url = ""

brave_dsa_file = "dsa_pub.pem"
}

if (base_sparkle_update_url == "") {
base_sparkle_update_url = "https://updates.bravesoftware.com/sparkle/Brave-Browser"
}
_update_channel = brave_channel
if (_update_channel == "") {
_update_channel = "stable"
}
brave_feed_url = "$base_sparkle_update_url/$_update_channel/appcast.xml"
10 changes: 10 additions & 0 deletions browser/brave_app_controller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ - (IBAction)updateBrave:(id)sender {
- (void)initializeBraveUpdater {
DCHECK(brave::UpdateEnabled());

// Background update check interval.
constexpr int kBraveUpdateCheckIntervalInSec = 3 * 60 * 60;

sparkle_glue_ = [SparkleGlue sharedSparkleGlue];

[sparkle_glue_ setDelegate:self];
[sparkle_glue_ setAutomaticallyChecksForUpdates:YES];
[sparkle_glue_ setAutomaticallyDownloadsUpdates:YES];
[sparkle_glue_ setUpdateCheckInterval:kBraveUpdateCheckIntervalInSec];

// Start background update.
[sparkle_glue_ checkForUpdatesInBackground];
}

#pragma mark - SUUpdaterDelegate
Expand Down
3 changes: 3 additions & 0 deletions browser/sparkle_glue_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
- (void)setDelegate:(id)delegate;
- (void)checkForUpdates:(id)sender;
- (void)checkForUpdatesInBackground;
- (void)setAutomaticallyChecksForUpdates:(BOOL)enable;
- (void)setAutomaticallyDownloadsUpdates:(BOOL)enable;
- (void)setUpdateCheckInterval:(NSTimeInterval)interval;

@end // @interface SparkleGlue

Expand Down
12 changes: 12 additions & 0 deletions browser/sparkle_glue_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,16 @@ - (void)checkForUpdatesInBackground {
[su_updater_ checkForUpdatesInBackground];
}

- (void)setAutomaticallyChecksForUpdates:(BOOL)enable {
[su_updater_ setAutomaticallyChecksForUpdates:enable];
}

- (void)setAutomaticallyDownloadsUpdates:(BOOL)enable {
[su_updater_ setAutomaticallyDownloadsUpdates:enable];
}

- (void)setUpdateCheckInterval:(NSTimeInterval)interval {
[su_updater_ setUpdateCheckInterval:interval];
}

@end
9 changes: 6 additions & 3 deletions browser/update_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
namespace brave {

bool UpdateEnabled() {
// TODO(simonhong): Remove this flag and enable update only in official build.
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBraveUpdateTest);
#if defined(OFFICIAL_BUILD)
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBraveUpdate);
#else
return false;
#endif
}

} //namespace brave
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
const StatusCallback& status_callback,
const PromoteCallback& promote_callback) {
if (brave::UpdateEnabled()) {
[[SparkleGlue sharedSparkleGlue] checkForUpdatesInBackground];
[[SparkleGlue sharedSparkleGlue] checkForUpdates:nil];

// TODO(simonhong): Update status from sparkle.
status_callback.Run(DISABLED, 0, std::string(), 0, base::string16());
NOTIMPLEMENTED();
Expand Down
10 changes: 2 additions & 8 deletions common/brave_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ const char kDisableBraveExtension[] = "disable-brave-extension";
// Allows disabling the PDFJS extension.
const char kDisablePDFJSExtension[] = "disable-pdfjs-extension";

// This switch enables update module(Sparkle).
// When you use this flag for update test, make sure to fix the feed URL
// |brave_feed_url| in brave/brave_init_settings.gni.
// This switch is introduced for update feature development.
// When update test is fininshed, update module should be enabled only in
// official build.
// TODO(shong): Remove this switch when update development is done.
const char kEnableBraveUpdateTest[] = "enable-brave-update-test";
// This switch disables update module(Sparkle).
const char kDisableBraveUpdate[] = "disable-brave-update";

} // namespace switches
4 changes: 2 additions & 2 deletions common/brave_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace switches {
// alongside the definition of their values in the .cc file.
extern const char kDisableBraveExtension[];

extern const char kDisablePDFJSExtension[];
extern const char kDisableBraveUpdate[];

extern const char kEnableBraveUpdateTest[];
extern const char kDisablePDFJSExtension[];

} // namespace switches

Expand Down