Add stub overridden VersionUpdaterMac implementation

This will be used for update checking by settings/help webui.
This commit is contained in:
Simon Hong
2018-06-25 20:24:00 +09:00
parent b619783dc8
commit 06273f7d0d
8 changed files with 116 additions and 14 deletions
+4 -2
View File
@@ -4,6 +4,8 @@ source_set("browser_process") {
sources = [
"autocomplete/brave_autocomplete_scheme_classifier.cc",
"autocomplete/brave_autocomplete_scheme_classifier.h",
"brave_app_controller_mac.mm",
"brave_app_controller_mac.h",
"brave_browser_main_extra_parts.cc",
"brave_browser_main_extra_parts.h",
"brave_browser_process_impl.cc",
@@ -27,10 +29,10 @@ source_set("browser_process") {
"importer/brave_profile_writer.h",
"importer/chrome_profile_lock.cc",
"importer/chrome_profile_lock.h",
"brave_app_controller_mac.mm",
"brave_app_controller_mac.h",
"sparkle_glue_mac.mm",
"sparkle_glue_mac.h",
"update_util.cc",
"update_util.h",
]
deps = [
+7 -12
View File
@@ -6,18 +6,12 @@
#include <string>
#import "brave/browser/sparkle_glue_mac.h"
#include "base/command_line.h"
#include "base/strings/sys_string_conversions.h"
#include "brave/common/brave_switches.h"
#import "brave/browser/sparkle_glue_mac.h"
#include "brave/browser/update_util.h"
namespace {
BOOL UpdateEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBraveUpdateTest);
}
std::string GetDescriptionFromAppcastItem(id item) {
return [SparkleGlue descriptionFromAppcastItem:item];
}
@@ -32,7 +26,7 @@ std::string GetDescriptionFromAppcastItem(id item) {
- (void)applicationWillFinishLaunching:(NSNotification*)notification {
[super applicationWillFinishLaunching:notification];
if (!UpdateEnabled())
if (!brave::UpdateEnabled())
return;
[self initializeBraveUpdater];
@@ -42,17 +36,18 @@ std::string GetDescriptionFromAppcastItem(id item) {
if ([super validateUserInterfaceItem:item])
return YES;
return [item action] == @selector(updateBrave:) ? UpdateEnabled() : NO;
return [item action] == @selector(updateBrave:) ? brave::UpdateEnabled()
: NO;
}
- (IBAction)updateBrave:(id)sender {
DCHECK(UpdateEnabled());
DCHECK(brave::UpdateEnabled());
[sparkle_glue_ checkForUpdates:sender];
}
- (void)initializeBraveUpdater {
DCHECK(UpdateEnabled());
DCHECK(brave::UpdateEnabled());
sparkle_glue_ = [SparkleGlue sharedSparkleGlue];
[sparkle_glue_ setDelegate:self];
+1
View File
@@ -21,6 +21,7 @@
- (void)setDelegate:(id)delegate;
- (void)checkForUpdates:(id)sender;
- (void)checkForUpdatesInBackground;
@end // @interface SparkleGlue
+4
View File
@@ -59,4 +59,8 @@ id GetSUUpdater() {
[su_updater_ checkForUpdates:sender];
}
- (void)checkForUpdatesInBackground {
[su_updater_ checkForUpdatesInBackground];
}
@end
+18
View File
@@ -0,0 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "brave/browser/update_util.h"
#include "base/command_line.h"
#include "brave/common/brave_switches.h"
namespace brave {
bool UpdateEnabled() {
// TODO(simonhong): Remove this flag and enable update only in official build.
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBraveUpdateTest);
}
} //namespace brave
+14
View File
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_BROWSER_UPDATE_UTIL_H_
#define BRAVE_BROWSER_UPDATE_UTIL_H_
namespace brave {
bool UpdateEnabled();
} // namespace brave
#endif // BRAVE_BROWSER_UPDATE_UTIL_MAC_H_
@@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
#define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
#include "base/macros.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
// OS X implementation of version update functionality, used by the WebUI
// About/Help page.
class VersionUpdaterMac : public VersionUpdater {
public:
// VersionUpdater implementation.
void CheckForUpdate(const StatusCallback& status_callback,
const PromoteCallback& promote_callback) override;
void PromoteUpdater() const override;
protected:
friend class VersionUpdater;
// Clients must use VersionUpdater::Create().
VersionUpdaterMac();
~VersionUpdaterMac() override;
private:
DISALLOW_COPY_AND_ASSIGN(VersionUpdaterMac);
};
#endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_MAC_H_
@@ -0,0 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "chrome/browser/ui/webui/help/version_updater_mac.h"
#import "brave/browser/sparkle_glue_mac.h"
#include "brave/browser/update_util.h"
VersionUpdater* VersionUpdater::Create(
content::WebContents* web_contents) {
return new VersionUpdaterMac;
}
VersionUpdaterMac::VersionUpdaterMac() {
}
VersionUpdaterMac::~VersionUpdaterMac() {
}
void VersionUpdaterMac::CheckForUpdate(
const StatusCallback& status_callback,
const PromoteCallback& promote_callback) {
if (brave::UpdateEnabled()) {
[[SparkleGlue sharedSparkleGlue] checkForUpdatesInBackground];
// TODO(simonhong): Update status from sparkle.
status_callback.Run(DISABLED, 0, std::string(), 0, base::string16());
NOTIMPLEMENTED();
} else {
status_callback.Run(DISABLED, 0, std::string(), 0, base::string16());
}
}
void VersionUpdaterMac::PromoteUpdater() const {
NOTIMPLEMENTED();
}