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

Side by Side Diff: chrome/browser/extensions/api/reading_list_private/reading_list_private_api.cc

Issue 254483003: Start requiring DistillerPage for calls to DomDistillerService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fixes (full git cl format) Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/reading_list_private/reading_list_privat e_api.h" 5 #include "chrome/browser/extensions/api/reading_list_private/reading_list_privat e_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 19 matching lines...) Expand all
30 EXTENSION_FUNCTION_VALIDATE(params); 30 EXTENSION_FUNCTION_VALIDATE(params);
31 GURL url_to_add(params->entry.url); 31 GURL url_to_add(params->entry.url);
32 if (!url_to_add.is_valid()) { 32 if (!url_to_add.is_valid()) {
33 error_ = "Invalid url specified."; 33 error_ = "Invalid url specified.";
34 SendResponse(false); 34 SendResponse(false);
35 return false; 35 return false;
36 } 36 }
37 37
38 DomDistillerService* service = 38 DomDistillerService* service =
39 DomDistillerServiceFactory::GetForBrowserContext(GetProfile()); 39 DomDistillerServiceFactory::GetForBrowserContext(GetProfile());
40 const std::string& id = service->AddToList(url_to_add, base::Bind( 40 const std::string& id = service->AddToList(
41 &ReadingListPrivateAddEntryFunction::SendResponse, this)); 41 url_to_add,
42 service->CreateDefaultDistillerPage().Pass(),
43 base::Bind(&ReadingListPrivateAddEntryFunction::SendResponse, this));
42 Entry new_entry; 44 Entry new_entry;
43 new_entry.id = id; 45 new_entry.id = id;
44 results_ = AddEntry::Results::Create(new_entry); 46 results_ = AddEntry::Results::Create(new_entry);
45 return true; 47 return true;
46 } 48 }
47 49
48 bool ReadingListPrivateRemoveEntryFunction::RunImpl() { 50 bool ReadingListPrivateRemoveEntryFunction::RunImpl() {
49 scoped_ptr<RemoveEntry::Params> params(RemoveEntry::Params::Create(*args_)); 51 scoped_ptr<RemoveEntry::Params> params(RemoveEntry::Params::Create(*args_));
50 EXTENSION_FUNCTION_VALIDATE(params); 52 EXTENSION_FUNCTION_VALIDATE(params);
51 DomDistillerService* service = 53 DomDistillerService* service =
52 DomDistillerServiceFactory::GetForBrowserContext(GetProfile()); 54 DomDistillerServiceFactory::GetForBrowserContext(GetProfile());
53 scoped_ptr<ArticleEntry> entry(service->RemoveEntry(params->id)); 55 scoped_ptr<ArticleEntry> entry(service->RemoveEntry(params->id));
54 if (entry == NULL) { 56 if (entry == NULL) {
55 results_ = make_scoped_ptr(new base::ListValue()); 57 results_ = make_scoped_ptr(new base::ListValue());
56 } else { 58 } else {
57 Entry removed_entry; 59 Entry removed_entry;
58 removed_entry.id = entry->entry_id(); 60 removed_entry.id = entry->entry_id();
59 results_ = RemoveEntry::Results::Create(removed_entry); 61 results_ = RemoveEntry::Results::Create(removed_entry);
60 } 62 }
61 return true; 63 return true;
62 } 64 }
63 65
64 bool ReadingListPrivateGetEntriesFunction::RunImpl() { 66 bool ReadingListPrivateGetEntriesFunction::RunImpl() {
65 DomDistillerService* service = 67 DomDistillerService* service =
66 DomDistillerServiceFactory::GetForBrowserContext(GetProfile()); 68 DomDistillerServiceFactory::GetForBrowserContext(GetProfile());
67 const std::vector<ArticleEntry>& entries = service->GetEntries(); 69 const std::vector<ArticleEntry>& entries = service->GetEntries();
68 std::vector<linked_ptr<Entry> > result; 70 std::vector<linked_ptr<Entry> > result;
69 for (std::vector<ArticleEntry>::const_iterator i = entries.begin(); 71 for (std::vector<ArticleEntry>::const_iterator i = entries.begin();
70 i != entries.end(); 72 i != entries.end();
71 ++i) { 73 ++i) {
72 linked_ptr<Entry> e(new Entry); 74 linked_ptr<Entry> e(new Entry);
73 e->id = i->entry_id(); 75 e->id = i->entry_id();
74 result.push_back(e); 76 result.push_back(e);
75 } 77 }
76 results_ = GetEntries::Results::Create(result); 78 results_ = GetEntries::Results::Create(result);
77 return true; 79 return true;
78 } 80 }
79 81
80 } // namespace extensions 82 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698