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

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

Issue 140433003: tab capture: Change the permissions for tabs.captureVisibleTab(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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 (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 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 Browser* browser = NULL; 1669 Browser* browser = NULL;
1670 if (!GetBrowserFromWindowID(this, window_id, &browser)) 1670 if (!GetBrowserFromWindowID(this, window_id, &browser))
1671 return NULL; 1671 return NULL;
1672 1672
1673 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); 1673 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
1674 if (!contents) { 1674 if (!contents) {
1675 error_ = keys::kInternalVisibleTabCaptureError; 1675 error_ = keys::kInternalVisibleTabCaptureError;
1676 return NULL; 1676 return NULL;
1677 } 1677 }
1678 1678
1679 // Use the last committed URL rather than the active URL for permissions
1680 // checking, since the visible page won't be updated until it has been
1681 // committed. A canonical example of this is interstitials, which show the
1682 // URL of the new/loading page (active) but would capture the content of the
1683 // old page (last committed).
1684 //
1685 // TODO(creis): Use WebContents::GetLastCommittedURL instead.
1686 // http://crbug.com/237908.
1687 NavigationEntry* last_committed_entry =
1688 contents->GetController().GetLastCommittedEntry();
1689 GURL last_committed_url = last_committed_entry ?
1690 last_committed_entry->GetURL() : GURL();
1691 if (!PermissionsData::CanCaptureVisiblePage(GetExtension(), 1679 if (!PermissionsData::CanCaptureVisiblePage(GetExtension(),
1692 last_committed_url,
1693 SessionID::IdForTab(contents), 1680 SessionID::IdForTab(contents),
1694 &error_)) { 1681 &error_)) {
1695 return NULL; 1682 return NULL;
1696 } 1683 }
1697 return contents; 1684 return contents;
1698 } 1685 }
1699 1686
1700 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) { 1687 void TabsCaptureVisibleTabFunction::OnCaptureFailure(FailureReason reason) {
1701 error_ = keys::kInternalVisibleTabCaptureError; 1688 error_ = keys::kInternalVisibleTabCaptureError;
1702 SendResponse(false); 1689 SendResponse(false);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 execute_tab_id_ = tab_id; 1907 execute_tab_id_ = tab_id;
1921 details_ = details.Pass(); 1908 details_ = details.Pass();
1922 return true; 1909 return true;
1923 } 1910 }
1924 1911
1925 bool TabsInsertCSSFunction::ShouldInsertCSS() const { 1912 bool TabsInsertCSSFunction::ShouldInsertCSS() const {
1926 return true; 1913 return true;
1927 } 1914 }
1928 1915
1929 } // namespace extensions 1916 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_tab_unittest.cc ('k') | chrome/browser/extensions/extension_tabs_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698