Merge pull request #6486 from MarshallOfSound/master

Add a getFeedURL API for the autoUpdater
This commit is contained in:
Cheng Zhao 2016-07-15 10:02:05 +09:00 committed by GitHub
commit 5db758297f
8 changed files with 39 additions and 0 deletions

View file

@ -109,6 +109,7 @@ void AutoUpdater::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
}

View file

@ -44,6 +44,7 @@ class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
void OnWindowAllClosed() override;
private:
std::string GetFeedURL();
void SetFeedURL(const std::string& url, mate::Arguments* args);
void QuitAndInstall();

View file

@ -17,6 +17,10 @@ void AutoUpdater::SetDelegate(Delegate* delegate) {
}
#if !defined(OS_MACOSX) || defined(MAS_BUILD)
std::string AutoUpdater::GetFeedURL() {
return "";
}
void AutoUpdater::SetFeedURL(const std::string& url,
const HeaderMap& requestHeaders) {
}

View file

@ -49,6 +49,7 @@ class AutoUpdater {
static Delegate* GetDelegate();
static void SetDelegate(Delegate* delegate);
static std::string GetFeedURL();
static void SetFeedURL(const std::string& url,
const HeaderMap& requestHeaders);
static void CheckForUpdates();

View file

@ -25,9 +25,14 @@ SQRLUpdater* g_updater = nil;
namespace {
bool g_update_available = false;
std::string update_url_ = "";
}
std::string AutoUpdater::GetFeedURL() {
return update_url_;
}
// static
void AutoUpdater::SetFeedURL(const std::string& feed,
const HeaderMap& requestHeaders) {
@ -35,6 +40,8 @@ void AutoUpdater::SetFeedURL(const std::string& feed,
if (!delegate)
return;
update_url_ = feed;
NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)];
NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url];