[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "chrome/browser/extensions/external_loader.h" | ||||
6 | |||||
7 | #include "base/logging.h" | ||||
8 | #include "base/values.h" | ||||
9 | #include "chrome/browser/extensions/external_provider_impl.h" | ||||
10 | #include "content/public/browser/browser_thread.h" | ||||
11 | |||||
12 | using content::BrowserThread; | ||||
13 | |||||
14 | namespace extensions { | ||||
15 | |||||
16 | ExternalLoader::ExternalLoader() | ||||
[email protected] | 14036d9 | 2013-07-24 17:32:20 | [diff] [blame] | 17 | : owner_(NULL) { |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 18 | } |
19 | |||||
20 | void ExternalLoader::Init(ExternalProviderImpl* owner) { | ||||
Istiaque Ahmed | f6e7262 | 2017-09-08 23:14:17 | [diff] [blame] | 21 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 22 | owner_ = owner; |
23 | } | ||||
24 | |||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 25 | const base::FilePath ExternalLoader::GetBaseCrxFilePath() { |
Istiaque Ahmed | f6e7262 | 2017-09-08 23:14:17 | [diff] [blame] | 26 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 27 | |
28 | // By default, relative paths are not supported. | ||||
29 | // Subclasses that wish to support them should override this method. | ||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 30 | return base::FilePath(); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 31 | } |
32 | |||||
33 | void ExternalLoader::OwnerShutdown() { | ||||
Istiaque Ahmed | f6e7262 | 2017-09-08 23:14:17 | [diff] [blame] | 34 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 35 | owner_ = NULL; |
36 | } | ||||
37 | |||||
38 | ExternalLoader::~ExternalLoader() {} | ||||
39 | |||||
Istiaque Ahmed | ef99c8ea | 2017-09-06 21:19:57 | [diff] [blame] | 40 | void ExternalLoader::LoadFinished( |
41 | std::unique_ptr<base::DictionaryValue> prefs) { | ||||
Istiaque Ahmed | f6e7262 | 2017-09-08 23:14:17 | [diff] [blame] | 42 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 43 | if (owner_) { |
Istiaque Ahmed | ef99c8ea | 2017-09-06 21:19:57 | [diff] [blame] | 44 | owner_->SetPrefs(std::move(prefs)); |
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 45 | } |
46 | } | ||||
47 | |||||
lazyboy | e863417 | 2016-01-28 00:10:48 | [diff] [blame] | 48 | void ExternalLoader::OnUpdated( |
dcheng | c963c714 | 2016-04-08 03:55:22 | [diff] [blame] | 49 | std::unique_ptr<base::DictionaryValue> updated_prefs) { |
Istiaque Ahmed | f6e7262 | 2017-09-08 23:14:17 | [diff] [blame] | 50 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
lazyboy | e863417 | 2016-01-28 00:10:48 | [diff] [blame] | 51 | if (owner_) |
Istiaque Ahmed | a7431b3 | 2017-08-20 18:33:37 | [diff] [blame] | 52 | owner_->UpdatePrefs(std::move(updated_prefs)); |
lazyboy | e863417 | 2016-01-28 00:10:48 | [diff] [blame] | 53 | } |
54 | |||||
[email protected] | 5df038b | 2012-07-16 19:03:27 | [diff] [blame] | 55 | } // namespace extensions |