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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 years 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.h" 5 #include "chrome/browser/extensions/api/tabs/tabs.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 *web_contents = chrome::GetActiveWebContents(browser); 1632 *web_contents = chrome::GetActiveWebContents(browser);
1633 if (*web_contents == NULL) { 1633 if (*web_contents == NULL) {
1634 error_ = keys::kInternalVisibleTabCaptureError; 1634 error_ = keys::kInternalVisibleTabCaptureError;
1635 return false; 1635 return false;
1636 } 1636 }
1637 1637
1638 return true; 1638 return true;
1639 }; 1639 };
1640 1640
1641 bool CaptureVisibleTabFunction::RunImpl() { 1641 bool CaptureVisibleTabFunction::RunImpl() {
1642 PrefService* service = profile()->GetPrefs(); 1642 PrefServiceSyncable* service = profile()->GetPrefs();
Mattias Nissler (ping if slow) 2012/12/19 19:50:22 Can we use PrefServiceBase here?
Jói 2012/12/20 16:30:31 Done.
1643 if (service->GetBoolean(prefs::kDisableScreenshots)) { 1643 if (service->GetBoolean(prefs::kDisableScreenshots)) {
1644 error_ = keys::kScreenshotsDisabled; 1644 error_ = keys::kScreenshotsDisabled;
1645 return false; 1645 return false;
1646 } 1646 }
1647 1647
1648 WebContents* web_contents = NULL; 1648 WebContents* web_contents = NULL;
1649 if (!GetTabToCapture(&web_contents)) 1649 if (!GetTabToCapture(&web_contents))
1650 return false; 1650 return false;
1651 1651
1652 image_format_ = FORMAT_JPEG; // Default format is JPEG. 1652 image_format_ = FORMAT_JPEG; // Default format is JPEG.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 base::StringPiece stream_as_string( 1793 base::StringPiece stream_as_string(
1794 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 1794 reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
1795 1795
1796 base::Base64Encode(stream_as_string, &base64_result); 1796 base::Base64Encode(stream_as_string, &base64_result);
1797 base64_result.insert(0, base::StringPrintf("data:%s;base64,", 1797 base64_result.insert(0, base::StringPrintf("data:%s;base64,",
1798 mime_type.c_str())); 1798 mime_type.c_str()));
1799 SetResult(new StringValue(base64_result)); 1799 SetResult(new StringValue(base64_result));
1800 SendResponse(true); 1800 SendResponse(true);
1801 } 1801 }
1802 1802
1803 void CaptureVisibleTabFunction::RegisterUserPrefs(PrefService* service) { 1803 void CaptureVisibleTabFunction::RegisterUserPrefs(
1804 PrefServiceSyncable* service) {
1804 service->RegisterBooleanPref(prefs::kDisableScreenshots, false, 1805 service->RegisterBooleanPref(prefs::kDisableScreenshots, false,
1805 PrefService::UNSYNCABLE_PREF); 1806 PrefServiceSyncable::UNSYNCABLE_PREF);
1806 } 1807 }
1807 1808
1808 bool DetectTabLanguageFunction::RunImpl() { 1809 bool DetectTabLanguageFunction::RunImpl() {
1809 int tab_id = 0; 1810 int tab_id = 0;
1810 Browser* browser = NULL; 1811 Browser* browser = NULL;
1811 WebContents* contents = NULL; 1812 WebContents* contents = NULL;
1812 1813
1813 // If |tab_id| is specified, look for it. Otherwise default to selected tab 1814 // If |tab_id| is specified, look for it. Otherwise default to selected tab
1814 // in the current window. 1815 // in the current window.
1815 if (HasOptionalArgument(0)) { 1816 if (HasOptionalArgument(0)) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 // called for every API call the extension made. 1875 // called for every API call the extension made.
1875 GotLanguage(language); 1876 GotLanguage(language);
1876 } 1877 }
1877 1878
1878 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1879 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1879 SetResult(Value::CreateStringValue(language.c_str())); 1880 SetResult(Value::CreateStringValue(language.c_str()));
1880 SendResponse(true); 1881 SendResponse(true);
1881 1882
1882 Release(); // Balanced in Run() 1883 Release(); // Balanced in Run()
1883 } 1884 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698