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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 707853003: Show a better error message for captureVisibleTab than just "internal error". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_constants.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/tabs/tabs_api.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 return true; 1538 return true;
1539 } 1539 }
1540 1540
1541 WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID(int window_id) { 1541 WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID(int window_id) {
1542 Browser* browser = NULL; 1542 Browser* browser = NULL;
1543 if (!GetBrowserFromWindowID(&chrome_details_, window_id, &browser)) 1543 if (!GetBrowserFromWindowID(&chrome_details_, window_id, &browser))
1544 return NULL; 1544 return NULL;
1545 1545
1546 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); 1546 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
1547 if (!contents) { 1547 if (!contents) {
1548 error_ = keys::kInternalVisibleTabCaptureError; 1548 error_ = "No active web contents to capture";
1549 return NULL; 1549 return NULL;
1550 } 1550 }
1551 1551
1552 if (!extension()->permissions_data()->CanCaptureVisiblePage( 1552 if (!extension()->permissions_data()->CanCaptureVisiblePage(
1553 SessionTabHelper::IdForTab(contents), &error_)) { 1553 SessionTabHelper::IdForTab(contents), &error_)) {
1554 return NULL; 1554 return NULL;
1555 } 1555 }
1556 return contents; 1556 return contents;
1557 } 1557 }
1558 1558
1559 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) { 1559 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) {
1560 error_ = keys::kInternalVisibleTabCaptureError; 1560 const char* reason_description = "internal error";
1561 switch (reason) {
1562 case FAILURE_REASON_UNKNOWN:
1563 reason_description = "unknown error";
1564 break;
1565 case FAILURE_REASON_ENCODING_FAILED:
1566 reason_description = "encoding failed";
1567 break;
1568 case FAILURE_REASON_VIEW_INVISIBLE:
1569 reason_description = "view is invisible";
1570 break;
1571 }
1572 error_ = ErrorUtils::FormatErrorMessage("Failed to capture tab: *",
1573 reason_description);
1561 SendResponse(false); 1574 SendResponse(false);
1562 } 1575 }
1563 1576
1564 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs( 1577 void TabsCaptureVisibleTabFunction::RegisterProfilePrefs(
1565 user_prefs::PrefRegistrySyncable* registry) { 1578 user_prefs::PrefRegistrySyncable* registry) {
1566 registry->RegisterBooleanPref( 1579 registry->RegisterBooleanPref(
1567 prefs::kDisableScreenshots, 1580 prefs::kDisableScreenshots,
1568 false, 1581 false,
1569 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 1582 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
1570 } 1583 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); 1941 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
1929 api::tabs::ZoomSettings zoom_settings; 1942 api::tabs::ZoomSettings zoom_settings;
1930 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 1943 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
1931 1944
1932 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 1945 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
1933 SendResponse(true); 1946 SendResponse(true);
1934 return true; 1947 return true;
1935 } 1948 }
1936 1949
1937 } // namespace extensions 1950 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698