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

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

Issue 396503003: DomDistiller: fix 0 document width (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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"
Yaron 2014/07/16 17:46:28 You'll need a chrome/browser/extensions OWNER
kuan 2014/07/17 09:57:25 Acknowledged.
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"
11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/extensions/api/reading_list_private.h" 13 #include "chrome/common/extensions/api/reading_list_private.h"
14 #include "components/dom_distiller/core/article_entry.h" 14 #include "components/dom_distiller/core/article_entry.h"
15 #include "components/dom_distiller/core/dom_distiller_service.h" 15 #include "components/dom_distiller/core/dom_distiller_service.h"
16 #include "content/public/browser/web_contents.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 namespace AddEntry = api::reading_list_private::AddEntry; 20 namespace AddEntry = api::reading_list_private::AddEntry;
20 namespace RemoveEntry = api::reading_list_private::RemoveEntry; 21 namespace RemoveEntry = api::reading_list_private::RemoveEntry;
21 namespace GetEntries = api::reading_list_private::GetEntries; 22 namespace GetEntries = api::reading_list_private::GetEntries;
22 23
23 using api::reading_list_private::Entry; 24 using api::reading_list_private::Entry;
24 using dom_distiller::ArticleEntry; 25 using dom_distiller::ArticleEntry;
25 using dom_distiller::DomDistillerService; 26 using dom_distiller::DomDistillerService;
26 using dom_distiller::DomDistillerServiceFactory; 27 using dom_distiller::DomDistillerServiceFactory;
27 28
28 bool ReadingListPrivateAddEntryFunction::RunAsync() { 29 bool ReadingListPrivateAddEntryFunction::RunAsync() {
29 scoped_ptr<AddEntry::Params> params(AddEntry::Params::Create(*args_)); 30 scoped_ptr<AddEntry::Params> params(AddEntry::Params::Create(*args_));
30 EXTENSION_FUNCTION_VALIDATE(params); 31 EXTENSION_FUNCTION_VALIDATE(params);
31 GURL url_to_add(params->entry.url); 32 GURL url_to_add(params->entry.url);
32 if (!url_to_add.is_valid()) { 33 if (!url_to_add.is_valid()) {
33 error_ = "Invalid url specified."; 34 error_ = "Invalid url specified.";
34 SendResponse(false); 35 SendResponse(false);
35 return false; 36 return false;
36 } 37 }
37 38
38 DomDistillerService* service = 39 DomDistillerService* service =
39 DomDistillerServiceFactory::GetForBrowserContext(GetProfile()); 40 DomDistillerServiceFactory::GetForBrowserContext(GetProfile());
41 gfx::Size render_view_size;
42 content::WebContents* web_contents = GetAssociatedWebContents();
43 if (web_contents)
44 render_view_size = web_contents->GetContainerBounds().size();
40 const std::string& id = service->AddToList( 45 const std::string& id = service->AddToList(
41 url_to_add, 46 url_to_add,
42 service->CreateDefaultDistillerPage().Pass(), 47 service->CreateDefaultDistillerPage(render_view_size).Pass(),
43 base::Bind(&ReadingListPrivateAddEntryFunction::SendResponse, this)); 48 base::Bind(&ReadingListPrivateAddEntryFunction::SendResponse, this));
44 Entry new_entry; 49 Entry new_entry;
45 new_entry.id = id; 50 new_entry.id = id;
46 results_ = AddEntry::Results::Create(new_entry); 51 results_ = AddEntry::Results::Create(new_entry);
47 return true; 52 return true;
48 } 53 }
49 54
50 bool ReadingListPrivateRemoveEntryFunction::RunSync() { 55 bool ReadingListPrivateRemoveEntryFunction::RunSync() {
51 scoped_ptr<RemoveEntry::Params> params(RemoveEntry::Params::Create(*args_)); 56 scoped_ptr<RemoveEntry::Params> params(RemoveEntry::Params::Create(*args_));
52 EXTENSION_FUNCTION_VALIDATE(params); 57 EXTENSION_FUNCTION_VALIDATE(params);
(...skipping 20 matching lines...) Expand all
73 ++i) { 78 ++i) {
74 linked_ptr<Entry> e(new Entry); 79 linked_ptr<Entry> e(new Entry);
75 e->id = i->entry_id(); 80 e->id = i->entry_id();
76 result.push_back(e); 81 result.push_back(e);
77 } 82 }
78 results_ = GetEntries::Results::Create(result); 83 results_ = GetEntries::Results::Create(result);
79 return true; 84 return true;
80 } 85 }
81 86
82 } // namespace extensions 87 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698