Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: chrome/browser/extensions/api/discovery/discovery_api.cc

Issue 10647003: Discovery API supports specifying a tile in a URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/discovery/suggested_link.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
39 if (params->details.url_image != NULL)
40 url_image = params->details.url_image.get();
41
37 extensions::SuggestedLinksRegistry* registry = 42 extensions::SuggestedLinksRegistry* registry =
38 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); 43 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile());
39 scoped_ptr<extensions::SuggestedLink> suggested_link( 44 scoped_ptr<extensions::SuggestedLink> suggested_link(
40 new extensions::SuggestedLink(params->details.link_url, 45 new extensions::SuggestedLink(params->details.link_url,
41 params->details.link_text, score)); 46 params->details.link_text,
47 *url_image,
48 score));
42 registry->Add(extension_id(), suggested_link.Pass()); 49 registry->Add(extension_id(), suggested_link.Pass());
43 return true; 50 return true;
44 } 51 }
45 52
46 bool DiscoveryRemoveSuggestionFunction::RunImpl() { 53 bool DiscoveryRemoveSuggestionFunction::RunImpl() {
47 scoped_ptr<discovery::RemoveSuggestion::Params> params( 54 scoped_ptr<discovery::RemoveSuggestion::Params> params(
48 discovery::RemoveSuggestion::Params::Create(*args_)); 55 discovery::RemoveSuggestion::Params::Create(*args_));
49 EXTENSION_FUNCTION_VALIDATE(params.get()); 56 EXTENSION_FUNCTION_VALIDATE(params.get());
50 57
51 extensions::SuggestedLinksRegistry* registry = 58 extensions::SuggestedLinksRegistry* registry =
52 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); 59 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile());
53 registry->Remove(extension_id(), params->link_url); 60 registry->Remove(extension_id(), params->link_url);
54 61
55 return true; 62 return true;
56 } 63 }
57 64
58 bool DiscoveryClearAllSuggestionsFunction::RunImpl() { 65 bool DiscoveryClearAllSuggestionsFunction::RunImpl() {
59 extensions::SuggestedLinksRegistry* registry = 66 extensions::SuggestedLinksRegistry* registry =
60 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile()); 67 extensions::SuggestedLinksRegistryFactory::GetForProfile(profile());
61 registry->ClearAll(extension_id()); 68 registry->ClearAll(extension_id());
62 69
63 return true; 70 return true;
64 } 71 }
65 72
66 } // namespace extensions 73 } // namespace extensions
67 74
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/discovery/suggested_link.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698