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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 545973002: Cleaning up capture_web_contents_function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 9c877f42f71dc655ec978a27b17c77b5fdbdf917..c4055ae73f702eacec4501cb5fdabf758844cce7 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -64,7 +64,6 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
-#include "extensions/browser/api/capture_web_contents_function_impl.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/browser/extension_function_util.h"
@@ -105,8 +104,6 @@ namespace tabs = api::tabs;
using core_api::extension_types::InjectDetails;
-template class CaptureWebContentsFunction<ChromeAsyncExtensionFunction>;
-
namespace {
bool GetBrowserFromWindowID(ChromeUIThreadExtensionFunction* function,
@@ -125,6 +122,22 @@ bool GetBrowserFromWindowID(ChromeUIThreadExtensionFunction* function,
return true;
}
+bool GetBrowserFromWindowID(ChromeExtensionFunctionDetails* details,
+ int window_id,
+ Browser** browser) {
+ std::string error;
+ Browser* result;
+ result =
+ ExtensionTabUtil::GetBrowserFromWindowID(*details, window_id, &error);
+ if (!result) {
+ details->function()->SetError(error);
+ return false;
+ }
+
+ *browser = result;
+ return true;
+}
+
// |error_message| can optionally be passed in and will be set with an
// appropriate message if the tab cannot be found by id.
bool GetTabById(int tab_id,
@@ -1498,8 +1511,12 @@ bool TabsRemoveFunction::RemoveTab(int tab_id) {
return true;
}
+TabsCaptureVisibleTabFunction::TabsCaptureVisibleTabFunction()
+ : chrome_details_(this) {
+}
+
bool TabsCaptureVisibleTabFunction::IsScreenshotEnabled() {
- PrefService* service = GetProfile()->GetPrefs();
+ PrefService* service = chrome_details_.GetProfile()->GetPrefs();
if (service->GetBoolean(prefs::kDisableScreenshots)) {
error_ = keys::kScreenshotsDisabled;
return false;
@@ -1509,7 +1526,7 @@ bool TabsCaptureVisibleTabFunction::IsScreenshotEnabled() {
WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID(int window_id) {
Browser* browser = NULL;
- if (!GetBrowserFromWindowID(this, window_id, &browser))
+ if (!GetBrowserFromWindowID(&chrome_details_, window_id, &browser))
return NULL;
WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.h ('k') | chrome/browser/extensions/api/web_view/web_view_internal_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698