OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/discovery/discovery_api.h" | 5 #include "chrome/browser/extensions/api/discovery/discovery_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/discovery/suggested_link.h" | 8 #include "chrome/browser/extensions/api/discovery/suggested_link.h" |
9 #include "chrome/browser/extensions/api/discovery/suggested_links_registry.h" | 9 #include "chrome/browser/extensions/api/discovery/suggested_links_registry.h" |
10 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h" | 10 #include "chrome/browser/extensions/api/discovery/suggested_links_registry_facto ry.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 double score = 1.0; | 28 double score = 1.0; |
29 if (params->details.score != NULL) { | 29 if (params->details.score != NULL) { |
30 score = *params->details.score; | 30 score = *params->details.score; |
31 if (score < 0.0 || score > 1.0) { | 31 if (score < 0.0 || score > 1.0) { |
32 error_ = kInvalidScore; | 32 error_ = kInvalidScore; |
33 return false; | 33 return false; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 std::string empty; | |
38 const std::string* url_image(&empty); | |
Evan Stade
2012/07/26 04:26:02
think it's easier to read if you don't use () cons
beaudoin
2012/07/26 17:08:37
Done.
| |
39 if (params->details.url_image != NULL) { | |
Evan Stade
2012/07/26 04:26:02
no curlies
beaudoin
2012/07/26 17:08:37
Done.
| |
40 url_image = params->details.url_image.get(); | |
41 } | |
42 | |
37 extensions::SuggestedLinksRegistry* registry = | 43 extensions::SuggestedLinksRegistry* registry = |
38 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); | 44 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); |
39 scoped_ptr<extensions::SuggestedLink> suggested_link( | 45 scoped_ptr<extensions::SuggestedLink> suggested_link( |
40 new extensions::SuggestedLink(params->details.link_url, | 46 new extensions::SuggestedLink(params->details.link_url, |
41 params->details.link_text, score)); | 47 params->details.link_text, |
48 *url_image, | |
49 score)); | |
42 registry->Add(extension_id(), suggested_link.Pass()); | 50 registry->Add(extension_id(), suggested_link.Pass()); |
43 return true; | 51 return true; |
44 } | 52 } |
45 | 53 |
46 bool DiscoveryRemoveSuggestionFunction::RunImpl() { | 54 bool DiscoveryRemoveSuggestionFunction::RunImpl() { |
47 scoped_ptr<discovery::RemoveSuggestion::Params> params( | 55 scoped_ptr<discovery::RemoveSuggestion::Params> params( |
48 discovery::RemoveSuggestion::Params::Create(*args_)); | 56 discovery::RemoveSuggestion::Params::Create(*args_)); |
49 EXTENSION_FUNCTION_VALIDATE(params.get()); | 57 EXTENSION_FUNCTION_VALIDATE(params.get()); |
50 | 58 |
51 extensions::SuggestedLinksRegistry* registry = | 59 extensions::SuggestedLinksRegistry* registry = |
52 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); | 60 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); |
53 registry->Remove(extension_id(), params->link_url); | 61 registry->Remove(extension_id(), params->link_url); |
54 | 62 |
55 return true; | 63 return true; |
56 } | 64 } |
57 | 65 |
58 bool DiscoveryClearAllSuggestionsFunction::RunImpl() { | 66 bool DiscoveryClearAllSuggestionsFunction::RunImpl() { |
59 extensions::SuggestedLinksRegistry* registry = | 67 extensions::SuggestedLinksRegistry* registry = |
60 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); | 68 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); |
61 registry->ClearAll(extension_id()); | 69 registry->ClearAll(extension_id()); |
62 | 70 |
63 return true; | 71 return true; |
64 } | 72 } |
65 | 73 |
66 } // namespace extensions | 74 } // namespace extensions |
67 | 75 |
OLD | NEW |