diff options
author | ricow@chromium.org <ricow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 12:19:33 +0000 |
---|---|---|
committer | ricow@chromium.org <ricow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 12:19:33 +0000 |
commit | 758b0b7056fc7b518147fd0546b3f615d9b6851a (patch) | |
tree | da66cd6c0403a3e23051d87cc5ab509c3d149b57 | |
parent | f5ec20caaf9afe15af718dbf7e2116572000de24 (diff) | |
download | chromium_src-758b0b7056fc7b518147fd0546b3f615d9b6851a.zip chromium_src-758b0b7056fc7b518147fd0546b3f615d9b6851a.tar.gz chromium_src-758b0b7056fc7b518147fd0546b3f615d9b6851a.tar.bz2 |
Revert revision 176015
This is a manual revert, drover did not like the deleted files
> Run the JSON Schema Compiler's bundle compilation on JSON files. Previously it
> was only run on IDL files. Clean up all the code which that simplifies.
>
> TBR=isherman@chromium.org,battre@chromium.org,akalin@chromium.org
> BUG=141318
>
> Review URL: https://chromiumcodereview.appspot.com/11747025
TBR=isherman@chromium.org,battre@chromium.org,akalin@chromium.org
Review URL: https://codereview.chromium.org/11778097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176054 0039d316-1c4b-4281-b951-d872f2087c98
122 files changed, 1553 insertions, 1417 deletions
diff --git a/build/json_schema_bundle_compile.gypi b/build/json_schema_bundle_compile.gypi index 11a6a28..ecefe41 100644 --- a/build/json_schema_bundle_compile.gypi +++ b/build/json_schema_bundle_compile.gypi @@ -5,7 +5,7 @@ { 'variables': { # When including this gypi, the following variables must be set: - # schema_files: an array of json or idl files that comprise the api model. + # idl_schema_files: an array of idl files that comprise the api model. # cc_dir: path to generated files # root_namespace: the C++ namespace that all generated files go under # Functions and namespaces can be excluded by setting "nocompile" to true. @@ -27,7 +27,7 @@ '<(api_gen_dir)/model.py', '<(api_gen_dir)/schema_bundle_generator.py', '<(api_gen_dir)/util_cc_helper.py', - '<@(schema_files)', + '<@(idl_schema_files)', ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/generated_api.h', @@ -41,7 +41,7 @@ '--destdir=<(SHARED_INTERMEDIATE_DIR)', '--namespace=<(root_namespace)', '--bundle', - '<@(schema_files)', + '<@(idl_schema_files)', ], 'message': 'Generating C++ API bundle code', 'process_outputs_as_sources': 1, diff --git a/build/json_schema_compile.gypi b/build/json_schema_compile.gypi index 6da8961..6c8f69c 100644 --- a/build/json_schema_compile.gypi +++ b/build/json_schema_compile.gypi @@ -5,7 +5,8 @@ { 'variables': { # When including this gypi, the following variables must be set: - # schema_files: a list of json or IDL files that comprise the api model. + # json_schema_files: a list of json files that comprise the api model. + # idl_schema_files: a list of IDL files that comprise the api model. # cc_dir: path to generated files # root_namespace: the C++ namespace that all generated files go under # Functions and namespaces can be excluded by setting "nocompile" to true. diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc index 45e8161..940a04f 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc @@ -10,10 +10,10 @@ // - Display 'save as' dialog using FileSelectorImpl which waits for the user // feedback. // - Once the user selects the file path (or cancels the selection), -// FileSelectorImpl notifies FileBrowserHandlerInternalSelectFileFunction of -// the selection result by calling FileHandlerSelectFile::OnFilePathSelected. -// - If the selection was canceled, -// FileBrowserHandlerInternalSelectFileFunction returns reporting failure. +// FileSelectorImpl notifies FileHandlerSelectFileFunction of the selection +// result by calling FileHandlerSelectFile::OnFilePathSelected. +// - If the selection was canceled, FileHandlerSelectFileFunction returns +// reporting failure. // - If the file path was selected, the function opens external file system // needed to create FileEntry object for the selected path // (opening file system will create file system name and root url for the @@ -119,11 +119,10 @@ class FileSelectorImpl : public FileSelector, // After this method is called, the selector implementation should not be // deleted by the caller. It will delete itself after it receives response // from SelectFielDialog. - virtual void SelectFile( - const FilePath& suggested_name, - const std::vector<std::string>& allowed_extensions, - Browser* browser, - FileBrowserHandlerInternalSelectFileFunction* function) OVERRIDE; + virtual void SelectFile(const FilePath& suggested_name, + const std::vector<std::string>& allowed_extensions, + Browser* browser, + FileHandlerSelectFileFunction* function) OVERRIDE; // ui::SelectFileDialog::Listener overrides. virtual void FileSelected(const FilePath& path, @@ -159,7 +158,7 @@ class FileSelectorImpl : public FileSelector, scoped_refptr<ui::SelectFileDialog> dialog_; // Extension function that uses the selector. - scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> function_; + scoped_refptr<FileHandlerSelectFileFunction> function_; DISALLOW_COPY_AND_ASSIGN(FileSelectorImpl); }; @@ -178,7 +177,7 @@ void FileSelectorImpl::SelectFile( const FilePath& suggested_name, const std::vector<std::string>& allowed_extensions, Browser* browser, - FileBrowserHandlerInternalSelectFileFunction* function) { + FileHandlerSelectFileFunction* function) { // We will hold reference to the function until it is notified of selection // result. function_ = function; @@ -290,25 +289,22 @@ void RunOpenFileSystemCallback( } // namespace -FileBrowserHandlerInternalSelectFileFunction:: - FileBrowserHandlerInternalSelectFileFunction() - : file_selector_factory_(new FileSelectorFactoryImpl()), - user_gesture_check_enabled_(true) { +FileHandlerSelectFileFunction::FileHandlerSelectFileFunction() + : file_selector_factory_(new FileSelectorFactoryImpl()), + user_gesture_check_enabled_(true) { } -FileBrowserHandlerInternalSelectFileFunction:: - FileBrowserHandlerInternalSelectFileFunction( - FileSelectorFactory* file_selector_factory, - bool enable_user_gesture_check) - : file_selector_factory_(file_selector_factory), - user_gesture_check_enabled_(enable_user_gesture_check) { +FileHandlerSelectFileFunction::FileHandlerSelectFileFunction( + FileSelectorFactory* file_selector_factory, + bool enable_user_gesture_check) + : file_selector_factory_(file_selector_factory), + user_gesture_check_enabled_(enable_user_gesture_check) { DCHECK(file_selector_factory); } -FileBrowserHandlerInternalSelectFileFunction:: - ~FileBrowserHandlerInternalSelectFileFunction() {} +FileHandlerSelectFileFunction::~FileHandlerSelectFileFunction() {} -bool FileBrowserHandlerInternalSelectFileFunction::RunImpl() { +bool FileHandlerSelectFileFunction::RunImpl() { scoped_ptr<SelectFile::Params> params(SelectFile::Params::Create(*args_)); FilePath suggested_name(params->selection_params.suggested_name); @@ -329,7 +325,7 @@ bool FileBrowserHandlerInternalSelectFileFunction::RunImpl() { return true; } -void FileBrowserHandlerInternalSelectFileFunction::OnFilePathSelected( +void FileHandlerSelectFileFunction::OnFilePathSelected( bool success, const FilePath& full_path) { if (!success) { @@ -346,12 +342,11 @@ void FileBrowserHandlerInternalSelectFileFunction::OnFilePathSelected( source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, base::Bind( &RunOpenFileSystemCallback, - base::Bind(&FileBrowserHandlerInternalSelectFileFunction:: - OnFileSystemOpened, + base::Bind(&FileHandlerSelectFileFunction::OnFileSystemOpened, this))); }; -void FileBrowserHandlerInternalSelectFileFunction::OnFileSystemOpened( +void FileHandlerSelectFileFunction::OnFileSystemOpened( bool success, const std::string& file_system_name, const GURL& file_system_root) { @@ -369,7 +364,7 @@ void FileBrowserHandlerInternalSelectFileFunction::OnFileSystemOpened( GrantPermissions(); } -void FileBrowserHandlerInternalSelectFileFunction::GrantPermissions() { +void FileHandlerSelectFileFunction::GrantPermissions() { fileapi::ExternalFileSystemMountPointProvider* external_provider = BrowserContext::GetDefaultStoragePartition(profile_)-> GetFileSystemContext()->external_provider(); @@ -405,12 +400,11 @@ void FileBrowserHandlerInternalSelectFileFunction::GrantPermissions() { profile(), gdata_paths.Pass(), &permissions_to_grant_, - base::Bind(&FileBrowserHandlerInternalSelectFileFunction:: - OnGotPermissionsToGrant, + base::Bind(&FileHandlerSelectFileFunction::OnGotPermissionsToGrant, this)); } -void FileBrowserHandlerInternalSelectFileFunction::OnGotPermissionsToGrant() { +void FileHandlerSelectFileFunction::OnGotPermissionsToGrant() { // At this point all needed permissions should be collected, so let's grant // them. for (size_t i = 0; i < permissions_to_grant_.size(); i++) { @@ -423,7 +417,7 @@ void FileBrowserHandlerInternalSelectFileFunction::OnGotPermissionsToGrant() { Respond(true); } -void FileBrowserHandlerInternalSelectFileFunction::Respond(bool success) { +void FileHandlerSelectFileFunction::Respond(bool success) { scoped_ptr<SelectFile::Results::Result> result( new SelectFile::Results::Result()); result->success = success; diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api.h b/chrome/browser/chromeos/extensions/file_browser_handler_api.h index db9a8db..a4a125d 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api.h +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api.h @@ -19,14 +19,14 @@ #include "chrome/browser/extensions/extension_function.h" class Browser; -class FileBrowserHandlerInternalSelectFileFunction; +class FileHandlerSelectFileFunction; namespace file_handler { -// Interface that is used by FileBrowserHandlerInternalSelectFileFunction to -// select the file path that should be reported back to the extension function -// caller. Nobody will take the ownership of the interface implementation, so -// it should delete itself once it's done. +// Interface that is used by FileHandlerSelectFileFunction to select the file +// path that should be reported back to the extension function caller. +// Nobody will take the ownership of the interface implementation, so it should +// delete itself once it's done. class FileSelector { public: virtual ~FileSelector() {} @@ -48,21 +48,19 @@ class FileSelector { // |SelectFile| will be called at most once by a single extension function. // The interface implementation should delete itself after the extension // function is notified of file selection result. - virtual void SelectFile( - const FilePath& suggested_name, - const std::vector<std::string>& allowed_extensions, - Browser* browser, - FileBrowserHandlerInternalSelectFileFunction* function) = 0; + virtual void SelectFile(const FilePath& suggested_name, + const std::vector<std::string>& allowed_extensions, + Browser* browser, + FileHandlerSelectFileFunction* function) = 0; }; -// Interface that is used by FileBrowserHandlerInternalSelectFileFunction to -// create a FileSelector it can use to select a file path. +// Interface that is used by FileHandlerSelectFileFunction to create a +// FileSelector it can use to select a file path. class FileSelectorFactory { public: virtual ~FileSelectorFactory() {} - // Creates a FileSelector instance for the - // FileBrowserHandlerInternalSelectFileFunction. + // Creates a FileSelector instance for the FileHandlerSelectFileFunction. virtual FileSelector* CreateFileSelector() const = 0; }; @@ -70,19 +68,18 @@ class FileSelectorFactory { // The fileBrowserHandlerInternal.selectFile extension function implementation. // See the file description for more info. -class FileBrowserHandlerInternalSelectFileFunction - : public AsyncExtensionFunction { +class FileHandlerSelectFileFunction : public AsyncExtensionFunction { public: // Default constructor used in production code. // It will create its own FileSelectorFactory implementation, and set the // value of |user_gesture_check_enabled| to true. - FileBrowserHandlerInternalSelectFileFunction(); + FileHandlerSelectFileFunction(); // This constructor should be used only in tests to inject test file selector // factory and to allow extension function to run even if it hasn't been // invoked by user gesture. // Created object will take the ownership of the |file_selector_factory|. - FileBrowserHandlerInternalSelectFileFunction( + FileHandlerSelectFileFunction( file_handler::FileSelectorFactory* file_selector_factory, bool enable_user_gesture_check); @@ -96,7 +93,7 @@ class FileBrowserHandlerInternalSelectFileFunction protected: // The class is ref counted, so destructor should not be public. - virtual ~FileBrowserHandlerInternalSelectFileFunction(); + virtual ~FileHandlerSelectFileFunction() OVERRIDE; // AsyncExtensionFunction implementation. // Runs the extension function implementation. diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc index c605ab7..5689100 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc @@ -64,7 +64,7 @@ void ExpectFileContentEquals(const FilePath& selected_path, EXPECT_EQ(expected_contents, test_file_contents); } -// Mocks FileSelector used by FileBrowserHandlerInternalSelectFileFunction. +// Mocks FileSelector used by FileHandlerSelectFileFunction. // When |SelectFile| is called, it will check that file name suggestion is as // expected, and respond to the extension function with specified selection // results. @@ -83,11 +83,10 @@ class MockFileSelector : public file_handler::FileSelector { // file_handler::FileSelector implementation. // |browser| is not used. - virtual void SelectFile( - const FilePath& suggested_name, - const std::vector<std::string>& allowed_extensions, - Browser* browser, - FileBrowserHandlerInternalSelectFileFunction* function) OVERRIDE { + virtual void SelectFile(const FilePath& suggested_name, + const std::vector<std::string>& allowed_extensions, + Browser* browser, + FileHandlerSelectFileFunction* function) OVERRIDE { // Confirm that the function suggested us the right name. EXPECT_EQ(suggested_name_, suggested_name); // Confirm that the function allowed us the right extensions. @@ -101,9 +100,8 @@ class MockFileSelector : public file_handler::FileSelector { // Send response to the extension function. // The callback will take a reference to the function and keep it alive. base::MessageLoopProxy::current()->PostTask(FROM_HERE, - base::Bind(&FileBrowserHandlerInternalSelectFileFunction:: - OnFilePathSelected, - function, success_, selected_path_)); + base::Bind(&FileHandlerSelectFileFunction::OnFilePathSelected, + function, success_, selected_path_)); delete this; } @@ -184,10 +182,10 @@ class FileBrowserHandlerExtensionTest : public ExtensionApiTest { return tmp_mount_point_.Append(relative_path); } - // Creates a new FileBrowserHandlerInternalSelectFileFunction to be used in - // the test. This function will be called from ExtensionFunctinoDispatcher - // whenever an extension function for fileBrowserHandlerInternal.selectFile - // will be needed. + // Creates a new FileHandlerSelectFileFunction to be used in the test. + // This function will be called from ExtensionFunctinoDispatcher whenever + // an extension function for fileBrowserHandlerInternal.selectFile will be + // needed. static ExtensionFunction* TestSelectFileFunctionFactory() { EXPECT_TRUE(test_cases_); EXPECT_TRUE(current_test_case_ < test_cases_->size()); @@ -195,15 +193,14 @@ class FileBrowserHandlerExtensionTest : public ExtensionApiTest { // If this happens, test failed. But, we still don't want to crash, so // return valid extension function. if (!test_cases_ && current_test_case_ >= test_cases_->size()) - return new FileBrowserHandlerInternalSelectFileFunction(); + return new FileHandlerSelectFileFunction(); // Create file creator factory for the current test case. MockFileSelectorFactory* mock_factory = new MockFileSelectorFactory(test_cases_->at(current_test_case_)); current_test_case_++; - return new FileBrowserHandlerInternalSelectFileFunction( - mock_factory, false); + return new FileHandlerSelectFileFunction(mock_factory, false); } // Sets up test parameters for extension function invocations that will be @@ -292,9 +289,8 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, EndToEnd) { // Tests that verifies the fileBrowserHandlerInternal.selectFile function fails // when invoked without user gesture. IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, NoUserGesture) { - scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> - select_file_function( - new FileBrowserHandlerInternalSelectFileFunction()); + scoped_refptr<FileHandlerSelectFileFunction> select_file_function( + new FileHandlerSelectFileFunction()); std::string error = utils::RunFunctionAndReturnError( @@ -317,11 +313,9 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, SelectionFailed) { false, FilePath()); - scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> - select_file_function( - new FileBrowserHandlerInternalSelectFileFunction( - new MockFileSelectorFactory(test_case), - false)); + scoped_refptr<FileHandlerSelectFileFunction> select_file_function( + new FileHandlerSelectFileFunction(new MockFileSelectorFactory(test_case), + false)); select_file_function->set_has_callback(true); select_file_function->set_user_gesture(true); @@ -346,11 +340,9 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, SuggestedFullPath) { false, FilePath()); - scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> - select_file_function( - new FileBrowserHandlerInternalSelectFileFunction( - new MockFileSelectorFactory(test_case), - false)); + scoped_refptr<FileHandlerSelectFileFunction> select_file_function( + new FileHandlerSelectFileFunction(new MockFileSelectorFactory(test_case), + false)); select_file_function->set_has_callback(true); select_file_function->set_user_gesture(true); diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc index 8f736a5..6e48b67 100644 --- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc +++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc @@ -88,6 +88,12 @@ bool AutotestPrivateLoginStatusFunction::RunImpl() { } AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { + ExtensionFunctionRegistry* registry = + ExtensionFunctionRegistry::GetInstance(); + registry->RegisterFunction<AutotestPrivateLogoutFunction>(); + registry->RegisterFunction<AutotestPrivateRestartFunction>(); + registry->RegisterFunction<AutotestPrivateShutdownFunction>(); + registry->RegisterFunction<AutotestPrivateLoginStatusFunction>(); } AutotestPrivateAPI::~AutotestPrivateAPI() { diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc index a245283..c3e3a65 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc @@ -449,8 +449,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesError) { } IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Permissions) { - PermissionsRequestFunction::SetAutoConfirmForTests(true); - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetAutoConfirmForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); EXPECT_CALL(*mock_adapter_, GetDevice(device1_->address())) .WillOnce(testing::Return(device1_.get())); diff --git a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h index 77b5850..0ed0bb2 100644 --- a/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h +++ b/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h @@ -7,7 +7,7 @@ #include "base/values.h" #include "chrome/browser/bookmarks/bookmark_node_data.h" -#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "chrome/browser/extensions/extension_function.h" #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" diff --git a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc b/chrome/browser/extensions/api/bookmarks/bookmark_api.cc index 08fa4ab3..c076813 100644 --- a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc +++ b/chrome/browser/extensions/api/bookmarks/bookmark_api.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "base/bind.h" #include "base/file_path.h" @@ -303,7 +303,7 @@ void BookmarkAPI::OnListenerAdded(const EventListenerInfo& details) { ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); } -bool BookmarksGetTreeFunction::RunImpl() { +bool GetBookmarksFunction::RunImpl() { scoped_ptr<bookmarks::Get::Params> params( bookmarks::Get::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -343,7 +343,7 @@ bool BookmarksGetTreeFunction::RunImpl() { return true; } -bool BookmarksGetChildrenFunction::RunImpl() { +bool GetBookmarkChildrenFunction::RunImpl() { scoped_ptr<bookmarks::GetChildren::Params> params( bookmarks::GetChildren::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -369,7 +369,7 @@ bool BookmarksGetChildrenFunction::RunImpl() { return true; } -bool BookmarksGetFunction::RunImpl() { +bool GetBookmarkRecentFunction::RunImpl() { scoped_ptr<bookmarks::GetRecent::Params> params( bookmarks::GetRecent::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -393,7 +393,7 @@ bool BookmarksGetFunction::RunImpl() { return true; } -bool BookmarksGetSubTreeFunction::RunImpl() { +bool GetBookmarkTreeFunction::RunImpl() { std::vector<linked_ptr<BookmarkTreeNode> > nodes; const BookmarkNode* node = BookmarkModelFactory::GetForProfile(profile())->root_node(); @@ -402,7 +402,7 @@ bool BookmarksGetSubTreeFunction::RunImpl() { return true; } -bool BookmarksGetRecentFunction::RunImpl() { +bool GetBookmarkSubTreeFunction::RunImpl() { scoped_ptr<bookmarks::GetSubTree::Params> params( bookmarks::GetSubTree::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -424,7 +424,7 @@ bool BookmarksGetRecentFunction::RunImpl() { return true; } -bool BookmarksSearchFunction::RunImpl() { +bool SearchBookmarksFunction::RunImpl() { scoped_ptr<bookmarks::Search::Params> params( bookmarks::Search::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -450,7 +450,7 @@ bool BookmarksSearchFunction::RunImpl() { } // static -bool BookmarksRemoveFunction::ExtractIds(const ListValue* args, +bool RemoveBookmarkFunction::ExtractIds(const ListValue* args, std::list<int64>* ids, bool* invalid_id) { std::string id_string; @@ -464,7 +464,7 @@ bool BookmarksRemoveFunction::ExtractIds(const ListValue* args, return true; } -bool BookmarksRemoveFunction::RunImpl() { +bool RemoveBookmarkFunction::RunImpl() { if (!EditBookmarksEnabled()) return false; @@ -479,7 +479,7 @@ bool BookmarksRemoveFunction::RunImpl() { } bool recursive = false; - if (name() == BookmarksRemoveTreeFunction::function_name()) + if (name() == RemoveTreeBookmarkFunction::function_name()) recursive = true; BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); @@ -489,7 +489,7 @@ bool BookmarksRemoveFunction::RunImpl() { return true; } -bool BookmarksCreateFunction::RunImpl() { +bool CreateBookmarkFunction::RunImpl() { if (!EditBookmarksEnabled()) return false; @@ -561,14 +561,14 @@ bool BookmarksCreateFunction::RunImpl() { } // static -bool BookmarksMoveFunction::ExtractIds(const ListValue* args, +bool MoveBookmarkFunction::ExtractIds(const ListValue* args, std::list<int64>* ids, bool* invalid_id) { // For now, Move accepts ID parameters in the same way as an Update. - return BookmarksUpdateFunction::ExtractIds(args, ids, invalid_id); + return UpdateBookmarkFunction::ExtractIds(args, ids, invalid_id); } -bool BookmarksMoveFunction::RunImpl() { +bool MoveBookmarkFunction::RunImpl() { if (!EditBookmarksEnabled()) return false; @@ -635,14 +635,14 @@ bool BookmarksMoveFunction::RunImpl() { } // static -bool BookmarksUpdateFunction::ExtractIds(const ListValue* args, +bool UpdateBookmarkFunction::ExtractIds(const ListValue* args, std::list<int64>* ids, bool* invalid_id) { // For now, Update accepts ID parameters in the same way as an Remove. - return BookmarksRemoveFunction::ExtractIds(args, ids, invalid_id); + return RemoveBookmarkFunction::ExtractIds(args, ids, invalid_id); } -bool BookmarksUpdateFunction::RunImpl() { +bool UpdateBookmarkFunction::RunImpl() { if (!EditBookmarksEnabled()) return false; @@ -719,7 +719,7 @@ class BookmarkBucketMapper : public BucketMapper { class CreateBookmarkBucketMapper : public BookmarkBucketMapper<std::string> { public: explicit CreateBookmarkBucketMapper(Profile* profile) : profile_(profile) {} - // TODO(tim): This should share code with BookmarksCreateFunction::RunImpl, + // TODO(tim): This should share code with CreateBookmarkFunction::RunImpl, // but I can't figure out a good way to do that with all the macros. virtual void GetBucketsForArgs(const ListValue* args, BucketList* buckets) { const DictionaryValue* json; @@ -763,7 +763,7 @@ class RemoveBookmarksBucketMapper : public BookmarkBucketMapper<std::string> { typedef std::list<int64> IdList; IdList ids; bool invalid_id = false; - if (!BookmarksRemoveFunction::ExtractIds(args, &ids, &invalid_id) || + if (!RemoveBookmarkFunction::ExtractIds(args, &ids, &invalid_id) || invalid_id) { return; } @@ -856,22 +856,22 @@ class BookmarksQuotaLimitFactory { }; // And finally, building the individual heuristics for each function. -void BookmarksRemoveFunction::GetQuotaLimitHeuristics( +void RemoveBookmarkFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { BookmarksQuotaLimitFactory::BuildForRemove(heuristics, profile()); } -void BookmarksMoveFunction::GetQuotaLimitHeuristics( +void MoveBookmarkFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { - BookmarksQuotaLimitFactory::Build<BookmarksMoveFunction>(heuristics); + BookmarksQuotaLimitFactory::Build<MoveBookmarkFunction>(heuristics); } -void BookmarksUpdateFunction::GetQuotaLimitHeuristics( +void UpdateBookmarkFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { - BookmarksQuotaLimitFactory::Build<BookmarksUpdateFunction>(heuristics); + BookmarksQuotaLimitFactory::Build<UpdateBookmarkFunction>(heuristics); }; -void BookmarksCreateFunction::GetQuotaLimitHeuristics( +void CreateBookmarkFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { BookmarksQuotaLimitFactory::BuildForCreate(heuristics, profile()); } @@ -949,14 +949,14 @@ void BookmarksIOFunction::MultiFilesSelected( NOTREACHED() << "Should not be able to select multiple files"; } -bool BookmarksImportFunction::RunImpl() { +bool ImportBookmarksFunction::RunImpl() { if (!EditBookmarksEnabled()) return false; SelectFile(ui::SelectFileDialog::SELECT_OPEN_FILE); return true; } -void BookmarksImportFunction::FileSelected(const FilePath& path, +void ImportBookmarksFunction::FileSelected(const FilePath& path, int index, void* params) { #if !defined(OS_ANDROID) @@ -976,12 +976,12 @@ void BookmarksImportFunction::FileSelected(const FilePath& path, Release(); // Balanced in BookmarksIOFunction::SelectFile() } -bool BookmarksExportFunction::RunImpl() { +bool ExportBookmarksFunction::RunImpl() { SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE); return true; } -void BookmarksExportFunction::FileSelected(const FilePath& path, +void ExportBookmarksFunction::FileSelected(const FilePath& path, int index, void* params) { #if !defined(OS_ANDROID) diff --git a/chrome/browser/extensions/api/bookmarks/bookmarks_api.h b/chrome/browser/extensions/api/bookmarks/bookmark_api.h index 0d2a240..c3008246 100644 --- a/chrome/browser/extensions/api/bookmarks/bookmarks_api.h +++ b/chrome/browser/extensions/api/bookmarks/bookmark_api.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARK_API_H_ +#define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARK_API_H_ #include <list> #include <string> @@ -116,73 +116,73 @@ class BookmarksFunction : public AsyncExtensionFunction, content::NotificationRegistrar registrar_; }; -class BookmarksGetTreeFunction : public BookmarksFunction { +class GetBookmarksFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.get") protected: - virtual ~BookmarksGetTreeFunction() {} + virtual ~GetBookmarksFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksGetChildrenFunction : public BookmarksFunction { +class GetBookmarkChildrenFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getChildren") protected: - virtual ~BookmarksGetChildrenFunction() {} + virtual ~GetBookmarkChildrenFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksGetFunction : public BookmarksFunction { +class GetBookmarkRecentFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getRecent") protected: - virtual ~BookmarksGetFunction() {} + virtual ~GetBookmarkRecentFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksGetSubTreeFunction : public BookmarksFunction { +class GetBookmarkTreeFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getTree") protected: - virtual ~BookmarksGetSubTreeFunction() {} + virtual ~GetBookmarkTreeFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksGetRecentFunction : public BookmarksFunction { +class GetBookmarkSubTreeFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.getSubTree") protected: - virtual ~BookmarksGetRecentFunction() {} + virtual ~GetBookmarkSubTreeFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksSearchFunction : public BookmarksFunction { +class SearchBookmarksFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.search") protected: - virtual ~BookmarksSearchFunction() {} + virtual ~SearchBookmarksFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksRemoveFunction : public BookmarksFunction { +class RemoveBookmarkFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.remove") @@ -195,21 +195,21 @@ class BookmarksRemoveFunction : public BookmarksFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; protected: - virtual ~BookmarksRemoveFunction() {} + virtual ~RemoveBookmarkFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksRemoveTreeFunction : public BookmarksRemoveFunction { +class RemoveTreeBookmarkFunction : public RemoveBookmarkFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.removeTree") protected: - virtual ~BookmarksRemoveTreeFunction() {} + virtual ~RemoveTreeBookmarkFunction() {} }; -class BookmarksCreateFunction : public BookmarksFunction { +class CreateBookmarkFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.create") @@ -218,13 +218,13 @@ class BookmarksCreateFunction : public BookmarksFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; protected: - virtual ~BookmarksCreateFunction() {} + virtual ~CreateBookmarkFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksMoveFunction : public BookmarksFunction { +class MoveBookmarkFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.move") @@ -236,13 +236,13 @@ class BookmarksMoveFunction : public BookmarksFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; protected: - virtual ~BookmarksMoveFunction() {} + virtual ~MoveBookmarkFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksUpdateFunction : public BookmarksFunction { +class UpdateBookmarkFunction : public BookmarksFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.update") @@ -254,7 +254,7 @@ class BookmarksUpdateFunction : public BookmarksFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; protected: - virtual ~BookmarksUpdateFunction() {} + virtual ~UpdateBookmarkFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -286,7 +286,7 @@ class BookmarksIOFunction : public BookmarksFunction, scoped_refptr<ui::SelectFileDialog> select_file_dialog_; }; -class BookmarksImportFunction : public BookmarksIOFunction { +class ImportBookmarksFunction : public BookmarksIOFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.import"); @@ -295,13 +295,13 @@ class BookmarksImportFunction : public BookmarksIOFunction { OVERRIDE; private: - virtual ~BookmarksImportFunction() {} + virtual ~ImportBookmarksFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class BookmarksExportFunction : public BookmarksIOFunction { +class ExportBookmarksFunction : public BookmarksIOFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.export"); @@ -310,7 +310,7 @@ class BookmarksExportFunction : public BookmarksIOFunction { OVERRIDE; private: - virtual ~BookmarksExportFunction() {} + virtual ~ExportBookmarksFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -318,4 +318,4 @@ class BookmarksExportFunction : public BookmarksIOFunction { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARK_API_H_ diff --git a/chrome/browser/extensions/api/bookmarks/bookmark_api_factory.cc b/chrome/browser/extensions/api/bookmarks/bookmark_api_factory.cc index 9c649bb..3f20629 100644 --- a/chrome/browser/extensions/api/bookmarks/bookmark_api_factory.cc +++ b/chrome/browser/extensions/api/bookmarks/bookmark_api_factory.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/api/bookmarks/bookmark_api_factory.h" -#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/profiles/profile_dependency_manager.h" diff --git a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc index 0c77b09..2bb3a84 100644 --- a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc +++ b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc @@ -31,16 +31,14 @@ CloudPrintTestsDelegate::~CloudPrintTestsDelegate() { instance_ = NULL; } -CloudPrintPrivateSetupConnectorFunction:: - CloudPrintPrivateSetupConnectorFunction() { +CloudPrintSetupConnectorFunction::CloudPrintSetupConnectorFunction() { } -CloudPrintPrivateSetupConnectorFunction:: - ~CloudPrintPrivateSetupConnectorFunction() { +CloudPrintSetupConnectorFunction::~CloudPrintSetupConnectorFunction() { } -bool CloudPrintPrivateSetupConnectorFunction::RunImpl() { +bool CloudPrintSetupConnectorFunction::RunImpl() { using extensions::api::cloud_print_private::SetupConnector::Params; scoped_ptr<Params> params(Params::Create(*args_)); if (CloudPrintTestsDelegate::instance()) { @@ -62,13 +60,13 @@ bool CloudPrintPrivateSetupConnectorFunction::RunImpl() { return true; } -CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() { +CloudPrintGetHostNameFunction::CloudPrintGetHostNameFunction() { } -CloudPrintPrivateGetHostNameFunction::~CloudPrintPrivateGetHostNameFunction() { +CloudPrintGetHostNameFunction::~CloudPrintGetHostNameFunction() { } -bool CloudPrintPrivateGetHostNameFunction::RunImpl() { +bool CloudPrintGetHostNameFunction::RunImpl() { SetResult(Value::CreateStringValue( CloudPrintTestsDelegate::instance() ? CloudPrintTestsDelegate::instance()->GetHostName() : @@ -77,19 +75,19 @@ bool CloudPrintPrivateGetHostNameFunction::RunImpl() { return true; } -CloudPrintPrivateGetPrintersFunction::CloudPrintPrivateGetPrintersFunction() { +CloudPrintGetPrintersFunction::CloudPrintGetPrintersFunction() { } -CloudPrintPrivateGetPrintersFunction::~CloudPrintPrivateGetPrintersFunction() { +CloudPrintGetPrintersFunction::~CloudPrintGetPrintersFunction() { } -void CloudPrintPrivateGetPrintersFunction::ReturnResult( +void CloudPrintGetPrintersFunction::ReturnResult( const base::ListValue* printers) { SetResult(printers->DeepCopy()); SendResponse(true); } -void CloudPrintPrivateGetPrintersFunction::CollectPrinters() { +void CloudPrintGetPrintersFunction::CollectPrinters() { scoped_ptr<base::ListValue> result(new base::ListValue()); if (CloudPrintTestsDelegate::instance()) { std::vector<std::string> printers = @@ -106,14 +104,14 @@ void CloudPrintPrivateGetPrintersFunction::CollectPrinters() { result->Append(Value::CreateStringValue(printers[i].printer_name)); } content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::Bind(&CloudPrintPrivateGetPrintersFunction::ReturnResult, this, + base::Bind(&CloudPrintGetPrintersFunction::ReturnResult, this, base::Owned(result.release()))); } -bool CloudPrintPrivateGetPrintersFunction::RunImpl() { +bool CloudPrintGetPrintersFunction::RunImpl() { content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, - base::Bind(&CloudPrintPrivateGetPrintersFunction::CollectPrinters, this)); + base::Bind(&CloudPrintGetPrintersFunction::CollectPrinters, this)); return true; } diff --git a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h index 030bf67..2a23b9e 100644 --- a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h +++ b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h @@ -36,40 +36,40 @@ class CloudPrintTestsDelegate { static CloudPrintTestsDelegate* instance_; }; -class CloudPrintPrivateSetupConnectorFunction : public AsyncExtensionFunction { +class CloudPrintSetupConnectorFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cloudPrintPrivate.setupConnector"); - CloudPrintPrivateSetupConnectorFunction(); + CloudPrintSetupConnectorFunction(); protected: - virtual ~CloudPrintPrivateSetupConnectorFunction(); + virtual ~CloudPrintSetupConnectorFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class CloudPrintPrivateGetHostNameFunction : public AsyncExtensionFunction { +class CloudPrintGetHostNameFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cloudPrintPrivate.getHostName"); - CloudPrintPrivateGetHostNameFunction(); + CloudPrintGetHostNameFunction(); protected: - virtual ~CloudPrintPrivateGetHostNameFunction(); + virtual ~CloudPrintGetHostNameFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class CloudPrintPrivateGetPrintersFunction : public AsyncExtensionFunction { +class CloudPrintGetPrintersFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cloudPrintPrivate.getPrinters"); - CloudPrintPrivateGetPrintersFunction(); + CloudPrintGetPrintersFunction(); protected: - virtual ~CloudPrintPrivateGetPrintersFunction(); + virtual ~CloudPrintGetPrintersFunction(); void CollectPrinters(); void ReturnResult(const base::ListValue* printers); diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc index e1c4a08..87c1798 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc +++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc @@ -62,7 +62,7 @@ namespace extensions { namespace helpers = content_settings_helpers; namespace keys = content_settings_api_constants; -bool ContentSettingsClearFunction::RunImpl() { +bool ClearContentSettingsFunction::RunImpl() { ContentSettingsType content_type; EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); @@ -96,7 +96,7 @@ bool ContentSettingsClearFunction::RunImpl() { return true; } -bool ContentSettingsGetFunction::RunImpl() { +bool GetContentSettingFunction::RunImpl() { ContentSettingsType content_type; EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); @@ -169,7 +169,7 @@ bool ContentSettingsGetFunction::RunImpl() { return true; } -bool ContentSettingsSetFunction::RunImpl() { +bool SetContentSettingFunction::RunImpl() { ContentSettingsType content_type; EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); @@ -250,7 +250,7 @@ bool ContentSettingsSetFunction::RunImpl() { return true; } -bool ContentSettingsGetResourceIdentifiersFunction::RunImpl() { +bool GetResourceIdentifiersFunction::RunImpl() { ContentSettingsType content_type; EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); @@ -261,15 +261,14 @@ bool ContentSettingsGetResourceIdentifiersFunction::RunImpl() { if (!g_testing_plugins_) { PluginService::GetInstance()->GetPlugins( - base::Bind(&ContentSettingsGetResourceIdentifiersFunction::OnGotPlugins, - this)); + base::Bind(&GetResourceIdentifiersFunction::OnGotPlugins, this)); } else { OnGotPlugins(*g_testing_plugins_); } return true; } -void ContentSettingsGetResourceIdentifiersFunction::OnGotPlugins( +void GetResourceIdentifiersFunction::OnGotPlugins( const std::vector<webkit::WebPluginInfo>& plugins) { PluginFinder* finder = PluginFinder::GetInstance(); std::set<std::string> group_identifiers; @@ -290,13 +289,11 @@ void ContentSettingsGetResourceIdentifiersFunction::OnGotPlugins( SetResult(list); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( - &ContentSettingsGetResourceIdentifiersFunction::SendResponse, - this, - true)); + &GetResourceIdentifiersFunction::SendResponse, this, true)); } // static -void ContentSettingsGetResourceIdentifiersFunction::SetPluginsForTesting( +void GetResourceIdentifiersFunction::SetPluginsForTesting( const std::vector<webkit::WebPluginInfo>* plugins) { g_testing_plugins_ = plugins; } diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.h b/chrome/browser/extensions/api/content_settings/content_settings_api.h index aac0b81..20ffcc7 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_api.h +++ b/chrome/browser/extensions/api/content_settings/content_settings_api.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H__ +#define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H__ #include "chrome/browser/extensions/extension_function.h" @@ -15,46 +15,45 @@ struct WebPluginInfo; namespace extensions { -class ContentSettingsClearFunction : public SyncExtensionFunction { +class ClearContentSettingsFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contentSettings.clear") protected: - virtual ~ContentSettingsClearFunction() {} + virtual ~ClearContentSettingsFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContentSettingsGetFunction : public SyncExtensionFunction { +class GetContentSettingFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contentSettings.get") protected: - virtual ~ContentSettingsGetFunction() {} + virtual ~GetContentSettingFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContentSettingsSetFunction : public SyncExtensionFunction { +class SetContentSettingFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contentSettings.set") protected: - virtual ~ContentSettingsSetFunction() {} + virtual ~SetContentSettingFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContentSettingsGetResourceIdentifiersFunction - : public AsyncExtensionFunction { +class GetResourceIdentifiersFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contentSettings.getResourceIdentifiers") protected: - virtual ~ContentSettingsGetResourceIdentifiersFunction() {} + virtual ~GetResourceIdentifiersFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -74,4 +73,4 @@ class ContentSettingsGetResourceIdentifiersFunction } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_API_H__ diff --git a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc index 381346e..69227d1 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc +++ b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/utf_string_conversions.h" +#include "chrome/browser/extensions/api/content_settings/content_settings_api.h" #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/extensions/api/content_settings/content_settings_api.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -120,12 +120,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, std::vector<webkit::WebPluginInfo> plugins; plugin_list.GetPlugins(&plugins); - ContentSettingsGetResourceIdentifiersFunction::SetPluginsForTesting(&plugins); + GetResourceIdentifiersFunction::SetPluginsForTesting(&plugins); EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) << message_; - ContentSettingsGetResourceIdentifiersFunction::SetPluginsForTesting(NULL); + GetResourceIdentifiersFunction::SetPluginsForTesting(NULL); } } // namespace extensions diff --git a/chrome/browser/extensions/api/context_menus/context_menus_api.cc b/chrome/browser/extensions/api/context_menu/context_menu_api.cc index 45f4264..0d98897 100644 --- a/chrome/browser/extensions/api/context_menus/context_menus_api.cc +++ b/chrome/browser/extensions/api/context_menu/context_menu_api.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/context_menus/context_menus_api.h" +#include "chrome/browser/extensions/api/context_menu/context_menu_api.h" #include <string> @@ -150,7 +150,7 @@ namespace Create = api::context_menus::Create; namespace Remove = api::context_menus::Remove; namespace Update = api::context_menus::Update; -bool ContextMenusCreateFunction::RunImpl() { +bool CreateContextMenuFunction::RunImpl() { MenuItem::Id id(profile()->IsOffTheRecord(), extension_id()); scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -245,7 +245,7 @@ bool ContextMenusCreateFunction::RunImpl() { return true; } -bool ContextMenusUpdateFunction::RunImpl() { +bool UpdateContextMenuFunction::RunImpl() { bool radio_item_updated = false; MenuItem::Id item_id(profile()->IsOffTheRecord(), extension_id()); scoped_ptr<Update::Params> params(Update::Params::Create(*args_)); @@ -354,7 +354,7 @@ bool ContextMenusUpdateFunction::RunImpl() { return true; } -bool ContextMenusRemoveFunction::RunImpl() { +bool RemoveContextMenuFunction::RunImpl() { scoped_ptr<Remove::Params> params(Remove::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -387,7 +387,7 @@ bool ContextMenusRemoveFunction::RunImpl() { return true; } -bool ContextMenusRemoveAllFunction::RunImpl() { +bool RemoveAllContextMenusFunction::RunImpl() { ExtensionService* service = profile()->GetExtensionService(); MenuManager* manager = service->menu_manager(); manager->RemoveAllContextItems(GetExtension()->id()); diff --git a/chrome/browser/extensions/api/context_menus/context_menus_api.h b/chrome/browser/extensions/api/context_menu/context_menu_api.h index d6b1217..5f15c92 100644 --- a/chrome/browser/extensions/api/context_menus/context_menus_api.h +++ b/chrome/browser/extensions/api/context_menu/context_menu_api.h @@ -2,52 +2,52 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENU_CONTEXT_MENU_API_H__ +#define CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENU_CONTEXT_MENU_API_H__ #include "chrome/browser/extensions/extension_function.h" namespace extensions { -class ContextMenusCreateFunction : public SyncExtensionFunction { +class CreateContextMenuFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.create") protected: - virtual ~ContextMenusCreateFunction() {} + virtual ~CreateContextMenuFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContextMenusUpdateFunction : public SyncExtensionFunction { +class UpdateContextMenuFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.update") protected: - virtual ~ContextMenusUpdateFunction() {} + virtual ~UpdateContextMenuFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContextMenusRemoveFunction : public SyncExtensionFunction { +class RemoveContextMenuFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.remove") protected: - virtual ~ContextMenusRemoveFunction() {} + virtual ~RemoveContextMenuFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ContextMenusRemoveAllFunction : public SyncExtensionFunction { +class RemoveAllContextMenusFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.removeAll") protected: - virtual ~ContextMenusRemoveAllFunction() {} + virtual ~RemoveAllContextMenusFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -55,4 +55,4 @@ class ContextMenusRemoveAllFunction : public SyncExtensionFunction { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENUS_CONTEXT_MENUS_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_CONTEXT_MENU_CONTEXT_MENU_API_H__ diff --git a/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc b/chrome/browser/extensions/api/context_menu/context_menu_apitest.cc index 85d2441..85d2441 100644 --- a/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc +++ b/chrome/browser/extensions/api/context_menu/context_menu_apitest.cc diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc index 26d401e..1a34a18 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.cc +++ b/chrome/browser/extensions/api/cookies/cookies_api.cc @@ -189,13 +189,13 @@ bool CookiesFunction::ParseStoreContext( return true; } -CookiesGetFunction::CookiesGetFunction() { +GetCookieFunction::GetCookieFunction() { } -CookiesGetFunction::~CookiesGetFunction() { +GetCookieFunction::~GetCookieFunction() { } -bool CookiesGetFunction::RunImpl() { +bool GetCookieFunction::RunImpl() { parsed_args_ = Get::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); @@ -216,23 +216,23 @@ bool CookiesGetFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&CookiesGetFunction::GetCookieOnIOThread, this)); + base::Bind(&GetCookieFunction::GetCookieOnIOThread, this)); DCHECK(rv); // Will finish asynchronously. return true; } -void CookiesGetFunction::GetCookieOnIOThread() { +void GetCookieFunction::GetCookieOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); net::CookieStore* cookie_store = store_context_->GetURLRequestContext()->cookie_store(); cookies_helpers::GetCookieListFromStore( cookie_store, url_, - base::Bind(&CookiesGetFunction::GetCookieCallback, this)); + base::Bind(&GetCookieFunction::GetCookieCallback, this)); } -void CookiesGetFunction::GetCookieCallback(const net::CookieList& cookie_list) { +void GetCookieFunction::GetCookieCallback(const net::CookieList& cookie_list) { net::CookieList::const_iterator it; for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { // Return the first matching cookie. Relies on the fact that the @@ -252,22 +252,22 @@ void CookiesGetFunction::GetCookieCallback(const net::CookieList& cookie_list) { bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CookiesGetFunction::RespondOnUIThread, this)); + base::Bind(&GetCookieFunction::RespondOnUIThread, this)); DCHECK(rv); } -void CookiesGetFunction::RespondOnUIThread() { +void GetCookieFunction::RespondOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); SendResponse(true); } -CookiesGetAllFunction::CookiesGetAllFunction() { +GetAllCookiesFunction::GetAllCookiesFunction() { } -CookiesGetAllFunction::~CookiesGetAllFunction() { +GetAllCookiesFunction::~GetAllCookiesFunction() { } -bool CookiesGetAllFunction::RunImpl() { +bool GetAllCookiesFunction::RunImpl() { parsed_args_ = GetAll::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); @@ -287,23 +287,23 @@ bool CookiesGetAllFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&CookiesGetAllFunction::GetAllCookiesOnIOThread, this)); + base::Bind(&GetAllCookiesFunction::GetAllCookiesOnIOThread, this)); DCHECK(rv); // Will finish asynchronously. return true; } -void CookiesGetAllFunction::GetAllCookiesOnIOThread() { +void GetAllCookiesFunction::GetAllCookiesOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); net::CookieStore* cookie_store = store_context_->GetURLRequestContext()->cookie_store(); cookies_helpers::GetCookieListFromStore( cookie_store, url_, - base::Bind(&CookiesGetAllFunction::GetAllCookiesCallback, this)); + base::Bind(&GetAllCookiesFunction::GetAllCookiesCallback, this)); } -void CookiesGetAllFunction::GetAllCookiesCallback( +void GetAllCookiesFunction::GetAllCookiesCallback( const net::CookieList& cookie_list) { const extensions::Extension* extension = GetExtension(); if (extension) { @@ -316,22 +316,22 @@ void CookiesGetAllFunction::GetAllCookiesCallback( } bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CookiesGetAllFunction::RespondOnUIThread, this)); + base::Bind(&GetAllCookiesFunction::RespondOnUIThread, this)); DCHECK(rv); } -void CookiesGetAllFunction::RespondOnUIThread() { +void GetAllCookiesFunction::RespondOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); SendResponse(true); } -CookiesSetFunction::CookiesSetFunction() : success_(false) { +SetCookieFunction::SetCookieFunction() : success_(false) { } -CookiesSetFunction::~CookiesSetFunction() { +SetCookieFunction::~SetCookieFunction() { } -bool CookiesSetFunction::RunImpl() { +bool SetCookieFunction::RunImpl() { parsed_args_ = Set::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); @@ -350,14 +350,14 @@ bool CookiesSetFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&CookiesSetFunction::SetCookieOnIOThread, this)); + base::Bind(&SetCookieFunction::SetCookieOnIOThread, this)); DCHECK(rv); // Will finish asynchronously. return true; } -void CookiesSetFunction::SetCookieOnIOThread() { +void SetCookieFunction::SetCookieOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); net::CookieMonster* cookie_monster = store_context_->GetURLRequestContext()->cookie_store()-> @@ -385,10 +385,10 @@ void CookiesSetFunction::SetCookieOnIOThread() { parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only : false, - base::Bind(&CookiesSetFunction::PullCookie, this)); + base::Bind(&SetCookieFunction::PullCookie, this)); } -void CookiesSetFunction::PullCookie(bool set_cookie_result) { +void SetCookieFunction::PullCookie(bool set_cookie_result) { // Pull the newly set cookie. net::CookieMonster* cookie_monster = store_context_->GetURLRequestContext()->cookie_store()-> @@ -396,11 +396,10 @@ void CookiesSetFunction::PullCookie(bool set_cookie_result) { success_ = set_cookie_result; cookies_helpers::GetCookieListFromStore( cookie_monster, url_, - base::Bind(&CookiesSetFunction::PullCookieCallback, this)); + base::Bind(&SetCookieFunction::PullCookieCallback, this)); } -void CookiesSetFunction::PullCookieCallback( - const net::CookieList& cookie_list) { +void SetCookieFunction::PullCookieCallback(const net::CookieList& cookie_list) { net::CookieList::const_iterator it; for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { // Return the first matching cookie. Relies on the fact that the @@ -418,11 +417,11 @@ void CookiesSetFunction::PullCookieCallback( bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CookiesSetFunction::RespondOnUIThread, this)); + base::Bind(&SetCookieFunction::RespondOnUIThread, this)); DCHECK(rv); } -void CookiesSetFunction::RespondOnUIThread() { +void SetCookieFunction::RespondOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!success_) { std::string name = parsed_args_->details.name.get() ? @@ -433,13 +432,13 @@ void CookiesSetFunction::RespondOnUIThread() { SendResponse(success_); } -CookiesRemoveFunction::CookiesRemoveFunction() { +RemoveCookieFunction::RemoveCookieFunction() { } -CookiesRemoveFunction::~CookiesRemoveFunction() { +RemoveCookieFunction::~RemoveCookieFunction() { } -bool CookiesRemoveFunction::RunImpl() { +bool RemoveCookieFunction::RunImpl() { parsed_args_ = Remove::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); @@ -459,14 +458,14 @@ bool CookiesRemoveFunction::RunImpl() { // Pass the work off to the IO thread. bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&CookiesRemoveFunction::RemoveCookieOnIOThread, this)); + base::Bind(&RemoveCookieFunction::RemoveCookieOnIOThread, this)); DCHECK(rv); // Will return asynchronously. return true; } -void CookiesRemoveFunction::RemoveCookieOnIOThread() { +void RemoveCookieFunction::RemoveCookieOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); // Remove the cookie @@ -474,10 +473,10 @@ void CookiesRemoveFunction::RemoveCookieOnIOThread() { store_context_->GetURLRequestContext()->cookie_store(); cookie_store->DeleteCookieAsync( url_, parsed_args_->details.name, - base::Bind(&CookiesRemoveFunction::RemoveCookieCallback, this)); + base::Bind(&RemoveCookieFunction::RemoveCookieCallback, this)); } -void CookiesRemoveFunction::RemoveCookieCallback() { +void RemoveCookieFunction::RemoveCookieCallback() { // Build the callback result Remove::Results::Details details; details.name = parsed_args_->details.name; @@ -488,16 +487,16 @@ void CookiesRemoveFunction::RemoveCookieCallback() { // Return to UI thread bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CookiesRemoveFunction::RespondOnUIThread, this)); + base::Bind(&RemoveCookieFunction::RespondOnUIThread, this)); DCHECK(rv); } -void CookiesRemoveFunction::RespondOnUIThread() { +void RemoveCookieFunction::RespondOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); SendResponse(true); } -bool CookiesGetAllCookieStoresFunction::RunImpl() { +bool GetAllCookieStoresFunction::RunImpl() { Profile* original_profile = profile(); DCHECK(original_profile); scoped_ptr<ListValue> original_tab_ids(new ListValue()); @@ -540,7 +539,7 @@ bool CookiesGetAllCookieStoresFunction::RunImpl() { return true; } -void CookiesGetAllCookieStoresFunction::Run() { +void GetAllCookieStoresFunction::Run() { SendResponse(RunImpl()); } diff --git a/chrome/browser/extensions/api/cookies/cookies_api.h b/chrome/browser/extensions/api/cookies/cookies_api.h index 7c1b377..5eddcd2 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.h +++ b/chrome/browser/extensions/api/cookies/cookies_api.h @@ -87,14 +87,14 @@ class CookiesFunction : public AsyncExtensionFunction { }; // Implements the cookies.get() extension function. -class CookiesGetFunction : public CookiesFunction { +class GetCookieFunction : public CookiesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") - CookiesGetFunction(); + GetCookieFunction(); protected: - virtual ~CookiesGetFunction(); + virtual ~GetCookieFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -110,14 +110,14 @@ class CookiesGetFunction : public CookiesFunction { }; // Implements the cookies.getAll() extension function. -class CookiesGetAllFunction : public CookiesFunction { +class GetAllCookiesFunction : public CookiesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll") - CookiesGetAllFunction(); + GetAllCookiesFunction(); protected: - virtual ~CookiesGetAllFunction(); + virtual ~GetAllCookiesFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -133,14 +133,14 @@ class CookiesGetAllFunction : public CookiesFunction { }; // Implements the cookies.set() extension function. -class CookiesSetFunction : public CookiesFunction { +class SetCookieFunction : public CookiesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cookies.set") - CookiesSetFunction(); + SetCookieFunction(); protected: - virtual ~CookiesSetFunction(); + virtual ~SetCookieFunction(); virtual bool RunImpl() OVERRIDE; private: @@ -156,14 +156,14 @@ class CookiesSetFunction : public CookiesFunction { }; // Implements the cookies.remove() extension function. -class CookiesRemoveFunction : public CookiesFunction { +class RemoveCookieFunction : public CookiesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove") - CookiesRemoveFunction(); + RemoveCookieFunction(); protected: - virtual ~CookiesRemoveFunction(); + virtual ~RemoveCookieFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -179,15 +179,15 @@ class CookiesRemoveFunction : public CookiesFunction { }; // Implements the cookies.getAllCookieStores() extension function. -class CookiesGetAllCookieStoresFunction : public CookiesFunction { +class GetAllCookieStoresFunction : public CookiesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") protected: - virtual ~CookiesGetAllCookieStoresFunction() {} + virtual ~GetAllCookieStoresFunction() {} // ExtensionFunction: - // CookiesGetAllCookieStoresFunction is sync. + // GetAllCookieStoresFunction is sync. virtual void Run() OVERRIDE; virtual bool RunImpl() OVERRIDE; }; diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index d672af7..79b28b7 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -104,7 +104,7 @@ class ExtensionDevToolsClientHost : public DevToolsClientHost, bool MatchesContentsAndExtensionId(WebContents* web_contents, const std::string& extension_id); void Close(); - void SendMessageToBackend(DebuggerSendCommandFunction* function, + void SendMessageToBackend(SendCommandDebuggerFunction* function, const std::string& method, SendCommand::Params::CommandParams* command_params); @@ -129,7 +129,7 @@ class ExtensionDevToolsClientHost : public DevToolsClientHost, int tab_id_; content::NotificationRegistrar registrar_; int last_request_id_; - typedef std::map<int, scoped_refptr<DebuggerSendCommandFunction> > + typedef std::map<int, scoped_refptr<SendCommandDebuggerFunction> > PendingRequests; PendingRequests pending_requests_; ExtensionDevToolsInfoBarDelegate* infobar_delegate_; @@ -249,7 +249,7 @@ void ExtensionDevToolsClientHost::Close() { } void ExtensionDevToolsClientHost::SendMessageToBackend( - DebuggerSendCommandFunction* function, + SendCommandDebuggerFunction* function, const std::string& method, SendCommand::Params::CommandParams* command_params) { DictionaryValue protocol_request; @@ -343,7 +343,7 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( extensions::ExtensionSystem::Get(profile)->event_router()-> DispatchEventToExtension(extension_id_, event.Pass()); } else { - DebuggerSendCommandFunction* function = pending_requests_[id]; + SendCommandDebuggerFunction* function = pending_requests_[id]; if (!function) return; @@ -457,11 +457,11 @@ bool DebuggerFunction::InitClientHost() { return true; } -DebuggerAttachFunction::DebuggerAttachFunction() {} +AttachDebuggerFunction::AttachDebuggerFunction() {} -DebuggerAttachFunction::~DebuggerAttachFunction() {} +AttachDebuggerFunction::~AttachDebuggerFunction() {} -bool DebuggerAttachFunction::RunImpl() { +bool AttachDebuggerFunction::RunImpl() { scoped_ptr<Attach::Params> params(Attach::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -497,11 +497,11 @@ bool DebuggerAttachFunction::RunImpl() { return true; } -DebuggerDetachFunction::DebuggerDetachFunction() {} +DetachDebuggerFunction::DetachDebuggerFunction() {} -DebuggerDetachFunction::~DebuggerDetachFunction() {} +DetachDebuggerFunction::~DetachDebuggerFunction() {} -bool DebuggerDetachFunction::RunImpl() { +bool DetachDebuggerFunction::RunImpl() { scoped_ptr<Detach::Params> params(Detach::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -514,11 +514,11 @@ bool DebuggerDetachFunction::RunImpl() { return true; } -DebuggerSendCommandFunction::DebuggerSendCommandFunction() {} +SendCommandDebuggerFunction::SendCommandDebuggerFunction() {} -DebuggerSendCommandFunction::~DebuggerSendCommandFunction() {} +SendCommandDebuggerFunction::~SendCommandDebuggerFunction() {} -bool DebuggerSendCommandFunction::RunImpl() { +bool SendCommandDebuggerFunction::RunImpl() { scoped_ptr<SendCommand::Params> params(SendCommand::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -531,7 +531,7 @@ bool DebuggerSendCommandFunction::RunImpl() { return true; } -void DebuggerSendCommandFunction::SendResponseBody( +void SendCommandDebuggerFunction::SendResponseBody( DictionaryValue* response) { Value* error_body; if (response->Get("error", &error_body)) { diff --git a/chrome/browser/extensions/api/debugger/debugger_api.h b/chrome/browser/extensions/api/debugger/debugger_api.h index 44243d9..36b0cb5 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.h +++ b/chrome/browser/extensions/api/debugger/debugger_api.h @@ -39,43 +39,43 @@ class DebuggerFunction : public AsyncExtensionFunction { }; // Implements the debugger.attach() extension function. -class DebuggerAttachFunction : public DebuggerFunction { +class AttachDebuggerFunction : public DebuggerFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("debugger.attach") - DebuggerAttachFunction(); + AttachDebuggerFunction(); protected: - virtual ~DebuggerAttachFunction(); + virtual ~AttachDebuggerFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // Implements the debugger.detach() extension function. -class DebuggerDetachFunction : public DebuggerFunction { +class DetachDebuggerFunction : public DebuggerFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("debugger.detach") - DebuggerDetachFunction(); + DetachDebuggerFunction(); protected: - virtual ~DebuggerDetachFunction(); + virtual ~DetachDebuggerFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // Implements the debugger.sendCommand() extension function. -class DebuggerSendCommandFunction : public DebuggerFunction { +class SendCommandDebuggerFunction : public DebuggerFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("debugger.sendCommand") - DebuggerSendCommandFunction(); + SendCommandDebuggerFunction(); void SendResponseBody(base::DictionaryValue* result); protected: - virtual ~DebuggerSendCommandFunction(); + virtual ~SendCommandDebuggerFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc index 8c57352..57cd0e8 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/chrome/browser/extensions/api/declarative/declarative_api.cc @@ -61,7 +61,7 @@ bool RulesFunction::RunImpl() { return true; } -bool EventsAddRulesFunction::RunImplOnCorrectThread() { +bool AddRulesFunction::RunImplOnCorrectThread() { scoped_ptr<AddRules::Params> params(AddRules::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -73,7 +73,7 @@ bool EventsAddRulesFunction::RunImplOnCorrectThread() { return error_.empty(); } -bool EventsRemoveRulesFunction::RunImplOnCorrectThread() { +bool RemoveRulesFunction::RunImplOnCorrectThread() { scoped_ptr<RemoveRules::Params> params(RemoveRules::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -87,7 +87,7 @@ bool EventsRemoveRulesFunction::RunImplOnCorrectThread() { return error_.empty(); } -bool EventsGetRulesFunction::RunImplOnCorrectThread() { +bool GetRulesFunction::RunImplOnCorrectThread() { scoped_ptr<GetRules::Params> params(GetRules::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); diff --git a/chrome/browser/extensions/api/declarative/declarative_api.h b/chrome/browser/extensions/api/declarative/declarative_api.h index 5caf4ac..5f7acc0 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.h +++ b/chrome/browser/extensions/api/declarative/declarative_api.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ +#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" @@ -31,34 +31,34 @@ class RulesFunction : public AsyncExtensionFunction { scoped_refptr<RulesRegistry> rules_registry_; }; -class EventsAddRulesFunction : public RulesFunction { +class AddRulesFunction : public RulesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("events.addRules"); protected: - virtual ~EventsAddRulesFunction() {} + virtual ~AddRulesFunction() {} // RulesFunction: virtual bool RunImplOnCorrectThread() OVERRIDE; }; -class EventsRemoveRulesFunction : public RulesFunction { +class RemoveRulesFunction : public RulesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("events.removeRules"); protected: - virtual ~EventsRemoveRulesFunction() {} + virtual ~RemoveRulesFunction() {} // RulesFunction: virtual bool RunImplOnCorrectThread() OVERRIDE; }; -class EventsGetRulesFunction : public RulesFunction { +class GetRulesFunction : public RulesFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("events.getRules"); protected: - virtual ~EventsGetRulesFunction() {} + virtual ~GetRulesFunction() {} // RulesFunction: virtual bool RunImplOnCorrectThread() OVERRIDE; @@ -66,4 +66,4 @@ class EventsGetRulesFunction : public RulesFunction { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ diff --git a/chrome/browser/extensions/api/font_settings/font_settings_api.cc b/chrome/browser/extensions/api/font_settings/font_settings_api.cc index 7aeec6f..802c625 100644 --- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc +++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc @@ -217,7 +217,7 @@ FontSettingsAPI::FontSettingsAPI(Profile* profile) FontSettingsAPI::~FontSettingsAPI() { } -bool FontSettingsClearFontFunction::RunImpl() { +bool ClearFontFunction::RunImpl() { if (profile_->IsOffTheRecord()) { error_ = kSetFromIncognitoError; return false; @@ -242,7 +242,7 @@ bool FontSettingsClearFontFunction::RunImpl() { return true; } -bool FontSettingsGetFontFunction::RunImpl() { +bool GetFontFunction::RunImpl() { scoped_ptr<fonts::GetFont::Params> params( fonts::GetFont::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -275,7 +275,7 @@ bool FontSettingsGetFontFunction::RunImpl() { return true; } -bool FontSettingsSetFontFunction::RunImpl() { +bool SetFontFunction::RunImpl() { if (profile_->IsOffTheRecord()) { error_ = kSetFromIncognitoError; return false; @@ -302,19 +302,18 @@ bool FontSettingsSetFontFunction::RunImpl() { return true; } -bool FontSettingsGetFontListFunction::RunImpl() { +bool GetFontListFunction::RunImpl() { content::GetFontListAsync( - Bind(&FontSettingsGetFontListFunction::FontListHasLoaded, this)); + Bind(&GetFontListFunction::FontListHasLoaded, this)); return true; } -void FontSettingsGetFontListFunction::FontListHasLoaded( - scoped_ptr<ListValue> list) { +void GetFontListFunction::FontListHasLoaded(scoped_ptr<ListValue> list) { bool success = CopyFontsToResult(list.get()); SendResponse(success); } -bool FontSettingsGetFontListFunction::CopyFontsToResult(ListValue* fonts) { +bool GetFontListFunction::CopyFontsToResult(ListValue* fonts) { scoped_ptr<ListValue> result(new ListValue()); for (ListValue::iterator it = fonts->begin(); it != fonts->end(); ++it) { ListValue* font_list_value; @@ -402,63 +401,63 @@ bool SetFontPrefExtensionFunction::RunImpl() { return true; } -const char* FontSettingsClearDefaultFontSizeFunction::GetPrefName() { +const char* ClearDefaultFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFontSize; } -const char* FontSettingsGetDefaultFontSizeFunction::GetPrefName() { +const char* GetDefaultFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFontSize; } -const char* FontSettingsGetDefaultFontSizeFunction::GetKey() { +const char* GetDefaultFontSizeFunction::GetKey() { return kPixelSizeKey; } -const char* FontSettingsSetDefaultFontSizeFunction::GetPrefName() { +const char* SetDefaultFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFontSize; } -const char* FontSettingsSetDefaultFontSizeFunction::GetKey() { +const char* SetDefaultFontSizeFunction::GetKey() { return kPixelSizeKey; } -const char* FontSettingsClearDefaultFixedFontSizeFunction::GetPrefName() { +const char* ClearDefaultFixedFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFixedFontSize; } -const char* FontSettingsGetDefaultFixedFontSizeFunction::GetPrefName() { +const char* GetDefaultFixedFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFixedFontSize; } -const char* FontSettingsGetDefaultFixedFontSizeFunction::GetKey() { +const char* GetDefaultFixedFontSizeFunction::GetKey() { return kPixelSizeKey; } -const char* FontSettingsSetDefaultFixedFontSizeFunction::GetPrefName() { +const char* SetDefaultFixedFontSizeFunction::GetPrefName() { return prefs::kWebKitDefaultFixedFontSize; } -const char* FontSettingsSetDefaultFixedFontSizeFunction::GetKey() { +const char* SetDefaultFixedFontSizeFunction::GetKey() { return kPixelSizeKey; } -const char* FontSettingsClearMinimumFontSizeFunction::GetPrefName() { +const char* ClearMinimumFontSizeFunction::GetPrefName() { return prefs::kWebKitMinimumFontSize; } -const char* FontSettingsGetMinimumFontSizeFunction::GetPrefName() { +const char* GetMinimumFontSizeFunction::GetPrefName() { return prefs::kWebKitMinimumFontSize; } -const char* FontSettingsGetMinimumFontSizeFunction::GetKey() { +const char* GetMinimumFontSizeFunction::GetKey() { return kPixelSizeKey; } -const char* FontSettingsSetMinimumFontSizeFunction::GetPrefName() { +const char* SetMinimumFontSizeFunction::GetPrefName() { return prefs::kWebKitMinimumFontSize; } -const char* FontSettingsSetMinimumFontSizeFunction::GetKey() { +const char* SetMinimumFontSizeFunction::GetKey() { return kPixelSizeKey; } diff --git a/chrome/browser/extensions/api/font_settings/font_settings_api.h b/chrome/browser/extensions/api/font_settings/font_settings_api.h index 3920ca8..e4d2cb0 100644 --- a/chrome/browser/extensions/api/font_settings/font_settings_api.h +++ b/chrome/browser/extensions/api/font_settings/font_settings_api.h @@ -5,8 +5,8 @@ // Defines the classes to realize the Font Settings Extension API as specified // in the extension API JSON. -#ifndef CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__ +#define CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__ #include <string> @@ -80,50 +80,50 @@ class FontSettingsAPI : public ProfileKeyedService { }; // fontSettings.clearFont API function. -class FontSettingsClearFontFunction : public SyncExtensionFunction { +class ClearFontFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont") protected: // RefCounted types have non-public destructors, as with all extension // functions in this file. - virtual ~FontSettingsClearFontFunction() {} + virtual ~ClearFontFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // fontSettings.getFont API function. -class FontSettingsGetFontFunction : public SyncExtensionFunction { +class GetFontFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFont") protected: - virtual ~FontSettingsGetFontFunction() {} + virtual ~GetFontFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // fontSettings.setFont API function. -class FontSettingsSetFontFunction : public SyncExtensionFunction { +class SetFontFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setFont") protected: - virtual ~FontSettingsSetFontFunction() {} + virtual ~SetFontFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // fontSettings.getFontList API function. -class FontSettingsGetFontListFunction : public AsyncExtensionFunction { +class GetFontListFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFontList") protected: - virtual ~FontSettingsGetFontListFunction() {} + virtual ~GetFontListFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -183,114 +183,106 @@ class SetFontPrefExtensionFunction : public SyncExtensionFunction { // The following are get/set/clear API functions that act on a browser font // pref. -class FontSettingsClearDefaultFontSizeFunction - : public ClearFontPrefExtensionFunction { +class ClearDefaultFontSizeFunction : public ClearFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFontSize") protected: - virtual ~FontSettingsClearDefaultFontSizeFunction() {} + virtual ~ClearDefaultFontSizeFunction() {} // ClearFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; }; -class FontSettingsGetDefaultFontSizeFunction - : public GetFontPrefExtensionFunction { +class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFontSize") protected: - virtual ~FontSettingsGetDefaultFontSizeFunction() {} + virtual ~GetDefaultFontSizeFunction() {} // GetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; virtual const char* GetKey() OVERRIDE; }; -class FontSettingsSetDefaultFontSizeFunction - : public SetFontPrefExtensionFunction { +class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFontSize") protected: - virtual ~FontSettingsSetDefaultFontSizeFunction() {} + virtual ~SetDefaultFontSizeFunction() {} // SetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; virtual const char* GetKey() OVERRIDE; }; -class FontSettingsClearDefaultFixedFontSizeFunction +class ClearDefaultFixedFontSizeFunction : public ClearFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFixedFontSize") protected: - virtual ~FontSettingsClearDefaultFixedFontSizeFunction() {} + virtual ~ClearDefaultFixedFontSizeFunction() {} // ClearFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; }; -class FontSettingsGetDefaultFixedFontSizeFunction - : public GetFontPrefExtensionFunction { +class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFixedFontSize") protected: - virtual ~FontSettingsGetDefaultFixedFontSizeFunction() {} + virtual ~GetDefaultFixedFontSizeFunction() {} // GetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; virtual const char* GetKey() OVERRIDE; }; -class FontSettingsSetDefaultFixedFontSizeFunction - : public SetFontPrefExtensionFunction { +class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFixedFontSize") protected: - virtual ~FontSettingsSetDefaultFixedFontSizeFunction() {} + virtual ~SetDefaultFixedFontSizeFunction() {} // SetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; virtual const char* GetKey() OVERRIDE; }; -class FontSettingsClearMinimumFontSizeFunction - : public ClearFontPrefExtensionFunction { +class ClearMinimumFontSizeFunction : public ClearFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearMinimumFontSize") protected: - virtual ~FontSettingsClearMinimumFontSizeFunction() {} + virtual ~ClearMinimumFontSizeFunction() {} // ClearFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; }; -class FontSettingsGetMinimumFontSizeFunction - : public GetFontPrefExtensionFunction { +class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getMinimumFontSize") protected: - virtual ~FontSettingsGetMinimumFontSizeFunction() {} + virtual ~GetMinimumFontSizeFunction() {} // GetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; virtual const char* GetKey() OVERRIDE; }; -class FontSettingsSetMinimumFontSizeFunction - : public SetFontPrefExtensionFunction { +class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setMinimumFontSize") protected: - virtual ~FontSettingsSetMinimumFontSizeFunction() {} + virtual ~SetMinimumFontSizeFunction() {} // SetFontPrefExtensionFunction: virtual const char* GetPrefName() OVERRIDE; @@ -299,4 +291,4 @@ class FontSettingsSetMinimumFontSizeFunction } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__ diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc index 06b5fcc..00af52c 100644 --- a/chrome/browser/extensions/api/history/history_api.cc +++ b/chrome/browser/extensions/api/history/history_api.cc @@ -268,7 +268,7 @@ void HistoryFunctionWithCallback::SendResponseToCallback() { Release(); // Balanced in RunImpl(). } -bool HistoryGetMostVisitedFunction::RunAsyncImpl() { +bool GetMostVisitedHistoryFunction::RunAsyncImpl() { scoped_ptr<GetMostVisited::Params> params = GetMostVisited::Params::Create(*args_); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -288,12 +288,12 @@ bool HistoryGetMostVisitedFunction::RunAsyncImpl() { HistoryService* hs = HistoryServiceFactory::GetForProfile(profile(), Profile::EXPLICIT_ACCESS); hs->QueryFilteredURLs(max_results, filter, false, &cancelable_consumer_, - base::Bind(&HistoryGetMostVisitedFunction::QueryComplete, + base::Bind(&GetMostVisitedHistoryFunction::QueryComplete, base::Unretained(this))); return true; } -void HistoryGetMostVisitedFunction::QueryComplete( +void GetMostVisitedHistoryFunction::QueryComplete( CancelableRequestProvider::Handle handle, const history::FilteredURLList& data) { std::vector<linked_ptr<MostVisitedItem> > results; @@ -308,7 +308,7 @@ void HistoryGetMostVisitedFunction::QueryComplete( SendAsyncResponse(); } -bool HistoryGetVisitsFunction::RunAsyncImpl() { +bool GetVisitsHistoryFunction::RunAsyncImpl() { scoped_ptr<GetVisits::Params> params(GetVisits::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -322,13 +322,13 @@ bool HistoryGetVisitsFunction::RunAsyncImpl() { hs->QueryURL(url, true, // Retrieve full history of a URL. &cancelable_consumer_, - base::Bind(&HistoryGetVisitsFunction::QueryComplete, + base::Bind(&GetVisitsHistoryFunction::QueryComplete, base::Unretained(this))); return true; } -void HistoryGetVisitsFunction::QueryComplete( +void GetVisitsHistoryFunction::QueryComplete( HistoryService::Handle request_service, bool success, const history::URLRow* url_row, @@ -347,7 +347,7 @@ void HistoryGetVisitsFunction::QueryComplete( SendAsyncResponse(); } -bool HistorySearchFunction::RunAsyncImpl() { +bool SearchHistoryFunction::RunAsyncImpl() { scoped_ptr<Search::Params> params(Search::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -368,13 +368,13 @@ bool HistorySearchFunction::RunAsyncImpl() { HistoryServiceFactory::GetForProfile(profile(), Profile::EXPLICIT_ACCESS); hs->QueryHistory(search_text, options, &cancelable_consumer_, - base::Bind(&HistorySearchFunction::SearchComplete, + base::Bind(&SearchHistoryFunction::SearchComplete, base::Unretained(this))); return true; } -void HistorySearchFunction::SearchComplete( +void SearchHistoryFunction::SearchComplete( HistoryService::Handle request_handle, history::QueryResults* results) { HistoryItemList history_item_vec; @@ -391,7 +391,7 @@ void HistorySearchFunction::SearchComplete( SendAsyncResponse(); } -bool HistoryAddUrlFunction::RunImpl() { +bool AddUrlHistoryFunction::RunImpl() { scoped_ptr<AddUrl::Params> params(AddUrl::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -408,7 +408,7 @@ bool HistoryAddUrlFunction::RunImpl() { return true; } -bool HistoryDeleteUrlFunction::RunImpl() { +bool DeleteUrlHistoryFunction::RunImpl() { scoped_ptr<DeleteUrl::Params> params(DeleteUrl::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -425,7 +425,7 @@ bool HistoryDeleteUrlFunction::RunImpl() { return true; } -bool HistoryDeleteRangeFunction::RunAsyncImpl() { +bool DeleteRangeHistoryFunction::RunAsyncImpl() { scoped_ptr<DeleteRange::Params> params(DeleteRange::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -440,18 +440,18 @@ bool HistoryDeleteRangeFunction::RunAsyncImpl() { restrict_urls, start_time, end_time, - base::Bind(&HistoryDeleteRangeFunction::DeleteComplete, + base::Bind(&DeleteRangeHistoryFunction::DeleteComplete, base::Unretained(this)), &task_tracker_); return true; } -void HistoryDeleteRangeFunction::DeleteComplete() { +void DeleteRangeHistoryFunction::DeleteComplete() { SendAsyncResponse(); } -bool HistoryDeleteAllFunction::RunAsyncImpl() { +bool DeleteAllHistoryFunction::RunAsyncImpl() { std::set<GURL> restrict_urls; HistoryService* hs = HistoryServiceFactory::GetForProfile(profile(), @@ -460,14 +460,14 @@ bool HistoryDeleteAllFunction::RunAsyncImpl() { restrict_urls, base::Time::UnixEpoch(), // From the beginning of the epoch. base::Time::Now(), // To the current time. - base::Bind(&HistoryDeleteAllFunction::DeleteComplete, + base::Bind(&DeleteAllHistoryFunction::DeleteComplete, base::Unretained(this)), &task_tracker_); return true; } -void HistoryDeleteAllFunction::DeleteComplete() { +void DeleteAllHistoryFunction::DeleteComplete() { SendAsyncResponse(); } diff --git a/chrome/browser/extensions/api/history/history_api.h b/chrome/browser/extensions/api/history/history_api.h index 9700b18..83860eb 100644 --- a/chrome/browser/extensions/api/history/history_api.h +++ b/chrome/browser/extensions/api/history/history_api.h @@ -112,12 +112,12 @@ class HistoryFunctionWithCallback : public HistoryFunction { void SendResponseToCallback(); }; -class HistoryGetMostVisitedFunction : public HistoryFunctionWithCallback { +class GetMostVisitedHistoryFunction : public HistoryFunctionWithCallback { public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.history.getMostVisited"); protected: - virtual ~HistoryGetMostVisitedFunction() {} + virtual ~GetMostVisitedHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunAsyncImpl() OVERRIDE; @@ -127,12 +127,12 @@ class HistoryGetMostVisitedFunction : public HistoryFunctionWithCallback { const history::FilteredURLList& data); }; -class HistoryGetVisitsFunction : public HistoryFunctionWithCallback { +class GetVisitsHistoryFunction : public HistoryFunctionWithCallback { public: DECLARE_EXTENSION_FUNCTION_NAME("history.getVisits"); protected: - virtual ~HistoryGetVisitsFunction() {} + virtual ~GetVisitsHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunAsyncImpl() OVERRIDE; @@ -144,12 +144,12 @@ class HistoryGetVisitsFunction : public HistoryFunctionWithCallback { history::VisitVector* visits); }; -class HistorySearchFunction : public HistoryFunctionWithCallback { +class SearchHistoryFunction : public HistoryFunctionWithCallback { public: DECLARE_EXTENSION_FUNCTION_NAME("history.search"); protected: - virtual ~HistorySearchFunction() {} + virtual ~SearchHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunAsyncImpl() OVERRIDE; @@ -159,23 +159,23 @@ class HistorySearchFunction : public HistoryFunctionWithCallback { history::QueryResults* results); }; -class HistoryAddUrlFunction : public HistoryFunction { +class AddUrlHistoryFunction : public HistoryFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("history.addUrl"); protected: - virtual ~HistoryAddUrlFunction() {} + virtual ~AddUrlHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunImpl() OVERRIDE; }; -class HistoryDeleteAllFunction : public HistoryFunctionWithCallback { +class DeleteAllHistoryFunction : public HistoryFunctionWithCallback { public: DECLARE_EXTENSION_FUNCTION_NAME("history.deleteAll"); protected: - virtual ~HistoryDeleteAllFunction() {} + virtual ~DeleteAllHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunAsyncImpl() OVERRIDE; @@ -185,23 +185,23 @@ class HistoryDeleteAllFunction : public HistoryFunctionWithCallback { }; -class HistoryDeleteUrlFunction : public HistoryFunction { +class DeleteUrlHistoryFunction : public HistoryFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("history.deleteUrl"); protected: - virtual ~HistoryDeleteUrlFunction() {} + virtual ~DeleteUrlHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunImpl() OVERRIDE; }; -class HistoryDeleteRangeFunction : public HistoryFunctionWithCallback { +class DeleteRangeHistoryFunction : public HistoryFunctionWithCallback { public: DECLARE_EXTENSION_FUNCTION_NAME("history.deleteRange"); protected: - virtual ~HistoryDeleteRangeFunction() {} + virtual ~DeleteRangeHistoryFunction() {} // HistoryFunctionWithCallback: virtual bool RunAsyncImpl() OVERRIDE; diff --git a/chrome/browser/extensions/api/i18n/i18n_api.cc b/chrome/browser/extensions/api/i18n/i18n_api.cc index ad2ef32..51897da 100644 --- a/chrome/browser/extensions/api/i18n/i18n_api.cc +++ b/chrome/browser/extensions/api/i18n/i18n_api.cc @@ -12,15 +12,15 @@ #include "base/string_split.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/extensions/api/i18n.h" #include "chrome/common/pref_names.h" +#include "chrome/common/extensions/api/i18n.h" namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages; // Errors. static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; -bool I18nGetAcceptLanguagesFunction::RunImpl() { +bool GetAcceptLanguagesFunction::RunImpl() { std::string accept_languages = profile()->GetPrefs()->GetString(prefs::kAcceptLanguages); // Currently, there are 2 ways to set browser's accept-languages: through UI diff --git a/chrome/browser/extensions/api/i18n/i18n_api.h b/chrome/browser/extensions/api/i18n/i18n_api.h index 1975f17..d69bd9b 100644 --- a/chrome/browser/extensions/api/i18n/i18n_api.h +++ b/chrome/browser/extensions/api/i18n/i18n_api.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H__ +#define CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H__ #include "chrome/browser/extensions/extension_function.h" -class I18nGetAcceptLanguagesFunction : public SyncExtensionFunction { - virtual ~I18nGetAcceptLanguagesFunction() {} +class GetAcceptLanguagesFunction : public SyncExtensionFunction { + virtual ~GetAcceptLanguagesFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("i18n.getAcceptLanguages") }; -#endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_I18N_I18N_API_H__ diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc index 04914f0..140517a 100644 --- a/chrome/browser/extensions/api/management/management_api.cc +++ b/chrome/browser/extensions/api/management/management_api.cc @@ -219,7 +219,7 @@ ExtensionService* AsyncManagementFunction::service() { return profile()->GetExtensionService(); } -bool ManagementGetAllFunction::RunImpl() { +bool GetAllExtensionsFunction::RunImpl() { ExtensionInfoList extensions; ExtensionSystem* system = ExtensionSystem::Get(profile()); @@ -231,7 +231,7 @@ bool ManagementGetAllFunction::RunImpl() { return true; } -bool ManagementGetFunction::RunImpl() { +bool GetExtensionByIdFunction::RunImpl() { scoped_ptr<management::Get::Params> params( management::Get::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -250,7 +250,7 @@ bool ManagementGetFunction::RunImpl() { return true; } -bool ManagementGetPermissionWarningsByIdFunction::RunImpl() { +bool GetPermissionWarningsByIdFunction::RunImpl() { scoped_ptr<management::GetPermissionWarningsById::Params> params( management::GetPermissionWarningsById::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -269,13 +269,12 @@ bool ManagementGetPermissionWarningsByIdFunction::RunImpl() { namespace { -// This class helps ManagementGetPermissionWarningsByManifestFunction manage +// This class helps GetPermissionWarningsByManifestFunction manage // sending manifest JSON strings to the utility process for parsing. class SafeManifestJSONParser : public UtilityProcessHostClient { public: - SafeManifestJSONParser( - ManagementGetPermissionWarningsByManifestFunction* client, - const std::string& manifest) + SafeManifestJSONParser(GetPermissionWarningsByManifestFunction* client, + const std::string& manifest) : client_(client), manifest_(manifest) {} @@ -346,7 +345,7 @@ class SafeManifestJSONParser : public UtilityProcessHostClient { ~SafeManifestJSONParser() {} // The client who we'll report results back to. - ManagementGetPermissionWarningsByManifestFunction* client_; + GetPermissionWarningsByManifestFunction* client_; // Data to parse. std::string manifest_; @@ -359,7 +358,7 @@ class SafeManifestJSONParser : public UtilityProcessHostClient { } // namespace -bool ManagementGetPermissionWarningsByManifestFunction::RunImpl() { +bool GetPermissionWarningsByManifestFunction::RunImpl() { scoped_ptr<management::GetPermissionWarningsByManifest::Params> params( management::GetPermissionWarningsByManifest::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -375,7 +374,7 @@ bool ManagementGetPermissionWarningsByManifestFunction::RunImpl() { return true; } -void ManagementGetPermissionWarningsByManifestFunction::OnParseSuccess( +void GetPermissionWarningsByManifestFunction::OnParseSuccess( DictionaryValue* parsed_manifest) { CHECK(parsed_manifest); @@ -396,7 +395,7 @@ void ManagementGetPermissionWarningsByManifestFunction::OnParseSuccess( Release(); } -void ManagementGetPermissionWarningsByManifestFunction::OnParseFailure( +void GetPermissionWarningsByManifestFunction::OnParseFailure( const std::string& error) { error_ = error; SendResponse(false); @@ -405,7 +404,7 @@ void ManagementGetPermissionWarningsByManifestFunction::OnParseFailure( Release(); } -bool ManagementLaunchAppFunction::RunImpl() { +bool LaunchAppFunction::RunImpl() { scoped_ptr<management::LaunchApp::Params> params( management::LaunchApp::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -437,13 +436,13 @@ bool ManagementLaunchAppFunction::RunImpl() { return true; } -ManagementSetEnabledFunction::ManagementSetEnabledFunction() { +SetEnabledFunction::SetEnabledFunction() { } -ManagementSetEnabledFunction::~ManagementSetEnabledFunction() { +SetEnabledFunction::~SetEnabledFunction() { } -bool ManagementSetEnabledFunction::RunImpl() { +bool SetEnabledFunction::RunImpl() { scoped_ptr<management::SetEnabled::Params> params( management::SetEnabled::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -488,30 +487,30 @@ bool ManagementSetEnabledFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&ManagementSetEnabledFunction::SendResponse, this, true)); + base::Bind(&SetEnabledFunction::SendResponse, this, true)); return true; } -void ManagementSetEnabledFunction::InstallUIProceed() { +void SetEnabledFunction::InstallUIProceed() { service()->EnableExtension(extension_id_); SendResponse(true); Release(); } -void ManagementSetEnabledFunction::InstallUIAbort(bool user_initiated) { +void SetEnabledFunction::InstallUIAbort(bool user_initiated) { error_ = keys::kUserDidNotReEnableError; SendResponse(false); Release(); } -ManagementUninstallFunction::ManagementUninstallFunction() { +UninstallFunction::UninstallFunction() { } -ManagementUninstallFunction::~ManagementUninstallFunction() { +UninstallFunction::~UninstallFunction() { } -bool ManagementUninstallFunction::RunImpl() { +bool UninstallFunction::RunImpl() { scoped_ptr<management::Uninstall::Params> params( management::Uninstall::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -553,11 +552,11 @@ bool ManagementUninstallFunction::RunImpl() { } // static -void ManagementUninstallFunction::SetAutoConfirmForTest(bool should_proceed) { +void UninstallFunction::SetAutoConfirmForTest(bool should_proceed) { auto_confirm_for_test = should_proceed ? PROCEED : ABORT; } -void ManagementUninstallFunction::Finish(bool should_uninstall) { +void UninstallFunction::Finish(bool should_uninstall) { if (should_uninstall) { bool success = service()->UninstallExtension( extension_id_, @@ -574,12 +573,12 @@ void ManagementUninstallFunction::Finish(bool should_uninstall) { } -void ManagementUninstallFunction::ExtensionUninstallAccepted() { +void UninstallFunction::ExtensionUninstallAccepted() { Finish(true); Release(); } -void ManagementUninstallFunction::ExtensionUninstallCanceled() { +void UninstallFunction::ExtensionUninstallCanceled() { Finish(false); Release(); } diff --git a/chrome/browser/extensions/api/management/management_api.h b/chrome/browser/extensions/api/management/management_api.h index 07553c8..1bb39ee 100644 --- a/chrome/browser/extensions/api/management/management_api.h +++ b/chrome/browser/extensions/api/management/management_api.h @@ -34,41 +34,40 @@ class AsyncManagementFunction : public AsyncExtensionFunction { ExtensionService* service(); }; -class ManagementGetAllFunction : public ManagementFunction { +class GetAllExtensionsFunction : public ManagementFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); protected: - virtual ~ManagementGetAllFunction() {} + virtual ~GetAllExtensionsFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ManagementGetFunction : public ManagementFunction { +class GetExtensionByIdFunction : public ManagementFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("management.get"); protected: - virtual ~ManagementGetFunction() {} + virtual ~GetExtensionByIdFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction { +class GetPermissionWarningsByIdFunction : public ManagementFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); protected: - virtual ~ManagementGetPermissionWarningsByIdFunction() {} + virtual ~GetPermissionWarningsByIdFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ManagementGetPermissionWarningsByManifestFunction - : public AsyncExtensionFunction { +class GetPermissionWarningsByManifestFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME( "management.getPermissionWarningsByManifest"); @@ -78,32 +77,32 @@ class ManagementGetPermissionWarningsByManifestFunction void OnParseFailure(const std::string& error); protected: - virtual ~ManagementGetPermissionWarningsByManifestFunction() {} + virtual ~GetPermissionWarningsByManifestFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ManagementLaunchAppFunction : public ManagementFunction { +class LaunchAppFunction : public ManagementFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); protected: - virtual ~ManagementLaunchAppFunction() {} + virtual ~LaunchAppFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; -class ManagementSetEnabledFunction : public AsyncManagementFunction, +class SetEnabledFunction : public AsyncManagementFunction, public ExtensionInstallPrompt::Delegate { public: DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); - ManagementSetEnabledFunction(); + SetEnabledFunction(); protected: - virtual ~ManagementSetEnabledFunction(); + virtual ~SetEnabledFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; @@ -119,12 +118,12 @@ class ManagementSetEnabledFunction : public AsyncManagementFunction, scoped_ptr<ExtensionInstallPrompt> install_prompt_; }; -class ManagementUninstallFunction : public AsyncManagementFunction, +class UninstallFunction : public AsyncManagementFunction, public ExtensionUninstallDialog::Delegate { public: DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); - ManagementUninstallFunction(); + UninstallFunction(); static void SetAutoConfirmForTest(bool should_proceed); // ExtensionUninstallDialog::Delegate implementation. @@ -132,7 +131,7 @@ class ManagementUninstallFunction : public AsyncManagementFunction, virtual void ExtensionUninstallCanceled() OVERRIDE; private: - virtual ~ManagementUninstallFunction(); + virtual ~UninstallFunction(); virtual bool RunImpl() OVERRIDE; diff --git a/chrome/browser/extensions/api/management/management_api_browsertest.cc b/chrome/browser/extensions/api/management/management_api_browsertest.cc index 3250a3b..5ca8f4c6 100644 --- a/chrome/browser/extensions/api/management/management_api_browsertest.cc +++ b/chrome/browser/extensions/api/management/management_api_browsertest.cc @@ -106,9 +106,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, const std::string id = extension->id(); // Uninstall, then cancel via the confirm dialog. - scoped_refptr<ManagementUninstallFunction> uninstall_function( - new ManagementUninstallFunction()); - ManagementUninstallFunction::SetAutoConfirmForTest(false); + scoped_refptr<UninstallFunction> uninstall_function(new UninstallFunction()); + UninstallFunction::SetAutoConfirmForTest(false); EXPECT_TRUE(MatchPattern( util::RunFunctionAndReturnError( @@ -122,8 +121,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, EXPECT_TRUE(service->GetExtensionById(id, false) != NULL); // Uninstall, then accept via the confirm dialog. - uninstall_function = new ManagementUninstallFunction(); - ManagementUninstallFunction::SetAutoConfirmForTest(true); + uninstall_function = new UninstallFunction(); + UninstallFunction::SetAutoConfirmForTest(true); util::RunFunctionAndReturnSingleResult( uninstall_function, @@ -145,8 +144,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, ASSERT_TRUE(listener.WaitUntilSatisfied()); // The management API should list this extension. - scoped_refptr<ManagementGetAllFunction> function = - new ManagementGetAllFunction(); + scoped_refptr<GetAllExtensionsFunction> function = + new GetAllExtensionsFunction(); scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( function.get(), "[]", browser())); base::ListValue* list; @@ -156,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, // And it should continue to do so even after it crashes. ASSERT_TRUE(CrashEnabledExtension(extension->id())); - function = new ManagementGetAllFunction(); + function = new GetAllExtensionsFunction(); result.reset(util::RunFunctionAndReturnSingleResult( function.get(), "[]", browser())); ASSERT_TRUE(result->GetAsList(&list)); @@ -201,8 +200,7 @@ class ExtensionManagementApiEscalationTest : void SetEnabled(bool enabled, bool user_gesture, const std::string& expected_error) { - scoped_refptr<ManagementSetEnabledFunction> function( - new ManagementSetEnabledFunction); + scoped_refptr<SetEnabledFunction> function(new SetEnabledFunction); const char* enabled_string = enabled ? "true" : "false"; if (user_gesture) function->set_user_gesture(true); @@ -229,8 +227,8 @@ const char ExtensionManagementApiEscalationTest::kId[] = IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, DisabledReason) { - scoped_refptr<ManagementGetFunction> function = - new ManagementGetFunction(); + scoped_refptr<GetExtensionByIdFunction> function = + new GetExtensionByIdFunction(); scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( function.get(), base::StringPrintf("[\"%s\"]", kId), diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc index ba71c9c..c395b9d 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api.cc @@ -52,7 +52,7 @@ bool ignore_user_gesture_for_tests = false; } // namespace -bool PermissionsContainsFunction::RunImpl() { +bool ContainsPermissionsFunction::RunImpl() { scoped_ptr<Contains::Params> params(Contains::Params::Create(*args_)); scoped_refptr<PermissionSet> permissions = @@ -65,14 +65,14 @@ bool PermissionsContainsFunction::RunImpl() { return true; } -bool PermissionsGetAllFunction::RunImpl() { +bool GetAllPermissionsFunction::RunImpl() { scoped_ptr<Permissions> permissions = helpers::PackPermissionSet(GetExtension()->GetActivePermissions()); results_ = GetAll::Results::Create(*permissions); return true; } -bool PermissionsRemoveFunction::RunImpl() { +bool RemovePermissionsFunction::RunImpl() { scoped_ptr<Remove::Params> params(Remove::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -110,19 +110,19 @@ bool PermissionsRemoveFunction::RunImpl() { } // static -void PermissionsRequestFunction::SetAutoConfirmForTests(bool should_proceed) { +void RequestPermissionsFunction::SetAutoConfirmForTests(bool should_proceed) { auto_confirm_for_tests = should_proceed ? PROCEED : ABORT; } // static -void PermissionsRequestFunction::SetIgnoreUserGestureForTests( +void RequestPermissionsFunction::SetIgnoreUserGestureForTests( bool ignore) { ignore_user_gesture_for_tests = ignore; } -PermissionsRequestFunction::PermissionsRequestFunction() {} +RequestPermissionsFunction::RequestPermissionsFunction() {} -void PermissionsRequestFunction::InstallUIProceed() { +void RequestPermissionsFunction::InstallUIProceed() { PermissionsUpdater perms_updater(profile()); perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); @@ -132,16 +132,16 @@ void PermissionsRequestFunction::InstallUIProceed() { Release(); // Balanced in RunImpl(). } -void PermissionsRequestFunction::InstallUIAbort(bool user_initiated) { +void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) { results_ = Request::Results::Create(false); SendResponse(true); Release(); // Balanced in RunImpl(). } -PermissionsRequestFunction::~PermissionsRequestFunction() {} +RequestPermissionsFunction::~RequestPermissionsFunction() {} -bool PermissionsRequestFunction::RunImpl() { +bool RequestPermissionsFunction::RunImpl() { if (!user_gesture() && !ignore_user_gesture_for_tests) { error_ = kUserGestureRequiredError; return false; diff --git a/chrome/browser/extensions/api/permissions/permissions_api.h b/chrome/browser/extensions/api/permissions/permissions_api.h index 21281e2..9801ea1 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.h +++ b/chrome/browser/extensions/api/permissions/permissions_api.h @@ -15,48 +15,48 @@ class ExtensionService; // chrome.permissions.contains -class PermissionsContainsFunction : public SyncExtensionFunction { +class ContainsPermissionsFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("permissions.contains") protected: - virtual ~PermissionsContainsFunction() {} + virtual ~ContainsPermissionsFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // chrome.permissions.getAll -class PermissionsGetAllFunction : public SyncExtensionFunction { +class GetAllPermissionsFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("permissions.getAll") protected: - virtual ~PermissionsGetAllFunction() {} + virtual ~GetAllPermissionsFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // chrome.permissions.remove -class PermissionsRemoveFunction : public SyncExtensionFunction { +class RemovePermissionsFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("permissions.remove") protected: - virtual ~PermissionsRemoveFunction() {} + virtual ~RemovePermissionsFunction() {} // ExtensionFunction: virtual bool RunImpl() OVERRIDE; }; // chrome.permissions.request -class PermissionsRequestFunction : public AsyncExtensionFunction, +class RequestPermissionsFunction : public AsyncExtensionFunction, public ExtensionInstallPrompt::Delegate { public: DECLARE_EXTENSION_FUNCTION_NAME("permissions.request") - PermissionsRequestFunction(); + RequestPermissionsFunction(); // FOR TESTS ONLY to bypass the confirmation UI. static void SetAutoConfirmForTests(bool should_proceed); @@ -67,7 +67,7 @@ class PermissionsRequestFunction : public AsyncExtensionFunction, virtual void InstallUIAbort(bool user_initiated) OVERRIDE; protected: - virtual ~PermissionsRequestFunction(); + virtual ~RequestPermissionsFunction(); // ExtensionFunction: virtual bool RunImpl() OVERRIDE; diff --git a/chrome/browser/extensions/api/permissions/permissions_apitest.cc b/chrome/browser/extensions/api/permissions/permissions_apitest.cc index a3944b5..4006d9b 100644 --- a/chrome/browser/extensions/api/permissions/permissions_apitest.cc +++ b/chrome/browser/extensions/api/permissions/permissions_apitest.cc @@ -85,7 +85,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", granted_permissions); - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); host_resolver()->AddRule("*.com", "127.0.0.1"); ASSERT_TRUE(StartTestServer()); EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; @@ -95,8 +95,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) { // Rather than setting the granted permissions, set the UI autoconfirm flag // and run the same tests. - PermissionsRequestFunction::SetAutoConfirmForTests(true); - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetAutoConfirmForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); host_resolver()->AddRule("*.com", "127.0.0.1"); ASSERT_TRUE(StartTestServer()); EXPECT_TRUE(RunExtensionTest("permissions/optional")) << message_; @@ -107,15 +107,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsAutoConfirm) { IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ComplexOptionalPermissions) { // Rather than setting the granted permissions, set the UI autoconfirm flag // and run the same tests. - PermissionsRequestFunction::SetAutoConfirmForTests(true); - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetAutoConfirmForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); EXPECT_TRUE(RunExtensionTest("permissions/complex_optional")) << message_; } // Test that denying the optional permissions confirmation dialog works. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsDeny) { - PermissionsRequestFunction::SetAutoConfirmForTests(false); - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetAutoConfirmForTests(false); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); host_resolver()->AddRule("*.com", "127.0.0.1"); ASSERT_TRUE(StartTestServer()); EXPECT_TRUE(RunExtensionTest("permissions/optional_deny")) << message_; @@ -124,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsDeny) { // Tests that the permissions.request function must be called from within a // user gesture. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGesture) { - PermissionsRequestFunction::SetIgnoreUserGestureForTests(false); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(false); host_resolver()->AddRule("*.com", "127.0.0.1"); ASSERT_TRUE(StartTestServer()); EXPECT_TRUE(RunExtensionTest("permissions/optional_gesture")) << message_; diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc index eb20dac..3042051 100644 --- a/chrome/browser/extensions/api/processes/processes_api.cc +++ b/chrome/browser/extensions/api/processes/processes_api.cc @@ -12,6 +12,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" + #include "chrome/browser/extensions/api/processes/processes_api_constants.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/event_router.h" diff --git a/chrome/browser/extensions/api/record/record_api.cc b/chrome/browser/extensions/api/record/record_api.cc index a16b755..ff60cb3 100644 --- a/chrome/browser/extensions/api/record/record_api.cc +++ b/chrome/browser/extensions/api/record/record_api.cc @@ -152,16 +152,16 @@ const ProcessStrategy &RunPageCyclerFunction::GetProcessStrategy() { return *process_strategy_; } -// RecordCaptureURLsFunction ------------------------------------------------ +// CaptureURLsFunction ------------------------------------------------ -RecordCaptureURLsFunction::RecordCaptureURLsFunction() +CaptureURLsFunction::CaptureURLsFunction() : RunPageCyclerFunction(new ProductionProcessStrategy()) {} -RecordCaptureURLsFunction::RecordCaptureURLsFunction(ProcessStrategy* strategy) +CaptureURLsFunction::CaptureURLsFunction(ProcessStrategy* strategy) : RunPageCyclerFunction(strategy) {} // Fetch data for possible optional switch for an extension to load. -bool RecordCaptureURLsFunction::ParseJSParameters() { +bool CaptureURLsFunction::ParseJSParameters() { scoped_ptr<record::CaptureURLs::Params> params( record::CaptureURLs::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -174,34 +174,34 @@ bool RecordCaptureURLsFunction::ParseJSParameters() { return true; } -// RecordCaptureURLsFunction adds "record-mode" to sub-browser call, and returns +// CaptureURLsFunction adds "record-mode" to sub-browser call, and returns // just the (possibly empty) error list. -void RecordCaptureURLsFunction::AddSwitches(CommandLine* line) { +void CaptureURLsFunction::AddSwitches(CommandLine* line) { if (!line->HasSwitch(switches::kRecordMode)) line->AppendSwitch(switches::kRecordMode); } -void RecordCaptureURLsFunction::Finish() { +void CaptureURLsFunction::Finish() { results_ = record::CaptureURLs::Results::Create(errors_); SendResponse(true); } -// RecordReplayURLsFunction ------------------------------------------------ +// ReplayURLsFunction ------------------------------------------------ -RecordReplayURLsFunction::RecordReplayURLsFunction() +ReplayURLsFunction::ReplayURLsFunction() : RunPageCyclerFunction(new ProductionProcessStrategy()), run_time_ms_(0.0) { } -RecordReplayURLsFunction::RecordReplayURLsFunction(ProcessStrategy* strategy) +ReplayURLsFunction::ReplayURLsFunction(ProcessStrategy* strategy) : RunPageCyclerFunction(strategy), run_time_ms_(0.0) { } -RecordReplayURLsFunction::~RecordReplayURLsFunction() {} +ReplayURLsFunction::~ReplayURLsFunction() {} // Fetch data for possible optional switches for a repeat count and an // extension to load. -bool RecordReplayURLsFunction::ParseJSParameters() { +bool ReplayURLsFunction::ParseJSParameters() { scoped_ptr<record::ReplayURLs::Params> params( record::ReplayURLs::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -228,7 +228,7 @@ bool RecordReplayURLsFunction::ParseJSParameters() { // plus temp file into which to place stats. (Can't do this in // ParseJSParameters because file creation can't go on the UI thread.) // Plus, initialize time to create run time statistic. -void RecordReplayURLsFunction::AddSwitches(CommandLine* line) { +void ReplayURLsFunction::AddSwitches(CommandLine* line) { file_util::CreateTemporaryFile(&stats_file_path_); if (!extension_path_.empty()) @@ -240,13 +240,13 @@ void RecordReplayURLsFunction::AddSwitches(CommandLine* line) { } // Read stats file, and get run time. -void RecordReplayURLsFunction::ReadReplyFiles() { +void ReplayURLsFunction::ReadReplyFiles() { file_util::ReadFileToString(stats_file_path_, &stats_); run_time_ms_ = (base::Time::NowFromSystemTime() - timer_).InMillisecondsF(); } -void RecordReplayURLsFunction::Finish() { +void ReplayURLsFunction::Finish() { record::ReplayURLsResult result; result.run_time = run_time_ms_; diff --git a/chrome/browser/extensions/api/record/record_api.h b/chrome/browser/extensions/api/record/record_api.h index 69974ac..4f5559a 100644 --- a/chrome/browser/extensions/api/record/record_api.h +++ b/chrome/browser/extensions/api/record/record_api.h @@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_EXTENSIONS_API_RECORD_RECORD_API_H_ #define CHROME_BROWSER_EXTENSIONS_API_RECORD_RECORD_API_H_ +#include "chrome/browser/extensions/extension_function.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/time.h" -#include "chrome/browser/extensions/extension_function.h" namespace { @@ -105,15 +105,15 @@ class RunPageCyclerFunction : public AsyncExtensionFunction { scoped_ptr<ProcessStrategy> process_strategy_; }; -class RecordCaptureURLsFunction : public RunPageCyclerFunction { +class CaptureURLsFunction : public RunPageCyclerFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.record.captureURLs"); - RecordCaptureURLsFunction(); - explicit RecordCaptureURLsFunction(ProcessStrategy* strategy); + CaptureURLsFunction(); + explicit CaptureURLsFunction(ProcessStrategy* strategy); private: - virtual ~RecordCaptureURLsFunction() {} + virtual ~CaptureURLsFunction() {} // Read the ReplayDetails parameter if it exists. virtual bool ParseJSParameters() OVERRIDE; @@ -125,15 +125,15 @@ class RecordCaptureURLsFunction : public RunPageCyclerFunction { virtual void Finish() OVERRIDE; }; -class RecordReplayURLsFunction : public RunPageCyclerFunction { +class ReplayURLsFunction : public RunPageCyclerFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("experimental.record.replayURLs"); - RecordReplayURLsFunction(); - explicit RecordReplayURLsFunction(ProcessStrategy* strategy); + ReplayURLsFunction(); + explicit ReplayURLsFunction(ProcessStrategy* strategy); private: - virtual ~RecordReplayURLsFunction(); + virtual ~ReplayURLsFunction(); // Read the ReplayDetails parameter if it exists. virtual bool ParseJSParameters() OVERRIDE; diff --git a/chrome/browser/extensions/api/record/record_api_test.cc b/chrome/browser/extensions/api/record/record_api_test.cc index 50de96a..c81dbe1 100644 --- a/chrome/browser/extensions/api/record/record_api_test.cc +++ b/chrome/browser/extensions/api/record/record_api_test.cc @@ -217,14 +217,13 @@ class RecordApiTest : public InProcessBrowserTest { // Run a capture, using standard URL test list and the specified // user data dir. Return via |out_list| the list of error URLs, // if any, resulting from the capture. And return directly the - // RecordCaptureURLsFunction that was used, so that its state may be + // CaptureURLsFunction that was used, so that its state may be // queried. - scoped_refptr<RecordCaptureURLsFunction> RunCapture( - const FilePath& user_data_dir, + scoped_refptr<CaptureURLsFunction> RunCapture(const FilePath& user_data_dir, scoped_ptr<base::ListValue>* out_list) { - scoped_refptr<RecordCaptureURLsFunction> capture_function( - new RecordCaptureURLsFunction(new TestProcessStrategy(&temp_files_))); + scoped_refptr<CaptureURLsFunction> capture_function( + new CaptureURLsFunction(new TestProcessStrategy(&temp_files_))); std::string escaped_user_data_dir; ReplaceChars(user_data_dir.AsUTF8Unsafe(), "\\", "\\\\", @@ -278,7 +277,7 @@ IN_PROC_BROWSER_TEST_F(RecordApiTest, DISABLED_CheckCapture) { scoped_ptr<base::ListValue> result; EXPECT_TRUE(user_data_dir.CreateUniqueTempDir()); - scoped_refptr<RecordCaptureURLsFunction> capture_URLs_function = + scoped_refptr<CaptureURLsFunction> capture_URLs_function = RunCapture(user_data_dir.path(), &result); // Check that user-data-dir switch has been properly overridden. @@ -315,8 +314,7 @@ IN_PROC_BROWSER_TEST_F(RecordApiTest, MAYBE_CheckPlayback) { ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\", &escaped_user_data_dir); - scoped_refptr<RecordReplayURLsFunction> playback_function( - new RecordReplayURLsFunction( + scoped_refptr<ReplayURLsFunction> playback_function(new ReplayURLsFunction( new TestProcessStrategy(&temp_files_))); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult(playback_function, diff --git a/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc new file mode 100644 index 0000000..29a57d9 --- /dev/null +++ b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc @@ -0,0 +1,277 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h" + +#include "base/bind.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" +#include "chrome/browser/extensions/api/tabs/tabs_constants.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_tab_util.h" +#include "chrome/browser/extensions/file_reader.h" +#include "chrome/browser/extensions/script_executor.h" +#include "chrome/browser/extensions/tab_helper.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/common/extensions/api/tabs.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_constants.h" +#include "chrome/common/extensions/extension_file_util.h" +#include "chrome/common/extensions/extension_l10n_util.h" +#include "chrome/common/extensions/extension_manifest_constants.h" +#include "chrome/common/extensions/extension_messages.h" +#include "chrome/common/extensions/message_bundle.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "extensions/common/error_utils.h" + +using content::BrowserThread; +using extensions::api::tabs::InjectDetails; +using extensions::ErrorUtils; +using extensions::ScriptExecutor; +using extensions::UserScript; + +namespace keys = extensions::tabs_constants; + +ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() + : execute_tab_id_(-1) { +} + +ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} + +bool ExecuteCodeInTabFunction::HasPermission() { + if (Init() && + extension_->HasAPIPermissionForTab(execute_tab_id_, + extensions::APIPermission::kTab)) { + return true; + } + return ExtensionFunction::HasPermission(); +} + +bool ExecuteCodeInTabFunction::RunImpl() { + EXTENSION_FUNCTION_VALIDATE(Init()); + + if (!details_->code.get() && !details_->file.get()) { + error_ = keys::kNoCodeOrFileToExecuteError; + return false; + } + if (details_->code.get() && details_->file.get()) { + error_ = keys::kMoreThanOneValuesError; + return false; + } + + content::WebContents* contents = NULL; + + // If |tab_id| is specified, look for the tab. Otherwise default to selected + // tab in the current window. + CHECK_GE(execute_tab_id_, 0); + if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), + include_incognito(), + NULL, NULL, &contents, NULL)) { + return false; + } + + // NOTE: This can give the wrong answer due to race conditions, but it is OK, + // we check again in the renderer. + CHECK(contents); + if (!GetExtension()->CanExecuteScriptOnPage(contents->GetURL(), + contents->GetURL(), + execute_tab_id_, + NULL, + &error_)) { + return false; + } + + if (details_->code.get()) + return Execute(*details_->code); + + CHECK(details_->file.get()); + resource_ = GetExtension()->GetResource(*details_->file); + + if (resource_.extension_root().empty() || resource_.relative_path().empty()) { + error_ = keys::kNoCodeOrFileToExecuteError; + return false; + } + + scoped_refptr<FileReader> file_reader(new FileReader( + resource_, base::Bind(&ExecuteCodeInTabFunction::DidLoadFile, this))); + file_reader->Start(); + + return true; +} + +void ExecuteCodeInTabFunction::OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const ListValue& result) { + if (!error.empty()) + SetError(error); + + SendResponse(error.empty()); +} + +void TabsExecuteScriptFunction::OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const ListValue& result) { + if (error.empty()) + SetResult(result.DeepCopy()); + ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_page_id, on_url, + result); +} + +bool ExecuteCodeInTabFunction::Init() { + if (details_.get()) + return true; + + // |tab_id| is optional so it's ok if it's not there. + int tab_id = -1; + args_->GetInteger(0, &tab_id); + + // |details| are not optional. + DictionaryValue* details_value = NULL; + if (!args_->GetDictionary(1, &details_value)) + return false; + scoped_ptr<InjectDetails> details(new InjectDetails()); + if (!InjectDetails::Populate(*details_value, details.get())) + return false; + + // If the tab ID is -1 then it needs to be converted to the currently active + // tab's ID. + if (tab_id == -1) { + Browser* browser = GetCurrentBrowser(); + if (!browser) + return false; + content::WebContents* web_contents = NULL; + if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, &tab_id)) + return false; + } + + execute_tab_id_ = tab_id; + details_ = details.Pass(); + return true; +} + +void ExecuteCodeInTabFunction::DidLoadFile(bool success, + const std::string& data) { + std::string function_name = name(); + const extensions::Extension* extension = GetExtension(); + + // Check if the file is CSS and needs localization. + if (success && + function_name == TabsInsertCSSFunction::function_name() && + extension != NULL && + data.find( + extensions::MessageBundle::kMessageBegin) != std::string::npos) { + BrowserThread::PostTask( + BrowserThread::FILE, FROM_HERE, + base::Bind(&ExecuteCodeInTabFunction::LocalizeCSS, this, + data, + extension->id(), + extension->path(), + extension->default_locale())); + } else { + DidLoadAndLocalizeFile(success, data); + } +} + +void ExecuteCodeInTabFunction::LocalizeCSS( + const std::string& data, + const std::string& extension_id, + const FilePath& extension_path, + const std::string& extension_default_locale) { + scoped_ptr<SubstitutionMap> localization_messages( + extension_file_util::LoadMessageBundleSubstitutionMap( + extension_path, extension_id, extension_default_locale)); + + // We need to do message replacement on the data, so it has to be mutable. + std::string css_data = data; + std::string error; + extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( + *localization_messages, &css_data, &error); + + // Call back DidLoadAndLocalizeFile on the UI thread. The success parameter + // is always true, because if loading had failed, we wouldn't have had + // anything to localize. + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&ExecuteCodeInTabFunction::DidLoadAndLocalizeFile, this, + true, css_data)); +} + +void ExecuteCodeInTabFunction::DidLoadAndLocalizeFile(bool success, + const std::string& data) { + if (success) { + if (!Execute(data)) + SendResponse(false); + } else { +#if defined(OS_POSIX) + // TODO(viettrungluu): bug: there's no particular reason the path should be + // UTF-8, in which case this may fail. + error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError, + resource_.relative_path().value()); +#elif defined(OS_WIN) + error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError, + WideToUTF8(resource_.relative_path().value())); +#endif // OS_WIN + SendResponse(false); + } +} + +bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { + content::WebContents* contents = NULL; + Browser* browser = NULL; + + bool success = ExtensionTabUtil::GetTabById( + execute_tab_id_, profile(), include_incognito(), &browser, NULL, + &contents, NULL) && contents && browser; + + if (!success) + return false; + + const extensions::Extension* extension = GetExtension(); + if (!extension) + return false; + + ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; + std::string function_name = name(); + if (function_name == TabsInsertCSSFunction::function_name()) { + script_type = ScriptExecutor::CSS; + } else if (function_name != TabsExecuteScriptFunction::function_name()) { + NOTREACHED(); + } + + ScriptExecutor::FrameScope frame_scope = + details_->all_frames.get() && *details_->all_frames ? + ScriptExecutor::ALL_FRAMES : + ScriptExecutor::TOP_FRAME; + + UserScript::RunLocation run_at = UserScript::UNDEFINED; + switch (details_->run_at) { + case InjectDetails::RUN_AT_NONE: + case InjectDetails::RUN_AT_DOCUMENT_IDLE: + run_at = UserScript::DOCUMENT_IDLE; + break; + case InjectDetails::RUN_AT_DOCUMENT_START: + run_at = UserScript::DOCUMENT_START; + break; + case InjectDetails::RUN_AT_DOCUMENT_END: + run_at = UserScript::DOCUMENT_END; + break; + } + CHECK_NE(UserScript::UNDEFINED, run_at); + + extensions::TabHelper::FromWebContents(contents)-> + script_executor()->ExecuteScript( + extension->id(), + script_type, + code_string, + frame_scope, + run_at, + ScriptExecutor::ISOLATED_WORLD, + base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); + return true; +} diff --git a/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h new file mode 100644 index 0000000..7ce5ec1 --- /dev/null +++ b/chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h @@ -0,0 +1,94 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ +#define CHROME_BROWSER_EXTENSIONS_API_TABS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ + +#include <string> + +#include "chrome/browser/extensions/extension_function.h" +#include "chrome/common/extensions/extension_resource.h" +#include "chrome/common/extensions/user_script.h" + +namespace extensions { +namespace api { +namespace tabs { +struct InjectDetails; +} // namespace tabs +} // namespace api +} // namespace extensions + +// Implement API call tabs.executeScript and tabs.insertCSS. +class ExecuteCodeInTabFunction : public AsyncExtensionFunction { + public: + ExecuteCodeInTabFunction(); + + protected: + virtual ~ExecuteCodeInTabFunction(); + + // ExtensionFunction: + virtual bool HasPermission() OVERRIDE; + virtual bool RunImpl() OVERRIDE; + + // Message handler. + virtual void OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const ListValue& script_result); + + private: + // Initialize the |execute_tab_id_| and |details_| if they haven't already + // been. Returns whether initialization was successful. + bool Init(); + + // Called when contents from the file whose path is specified in JSON + // arguments has been loaded. + void DidLoadFile(bool success, const std::string& data); + + // Runs on FILE thread. Loads message bundles for the extension and + // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. + void LocalizeCSS( + const std::string& data, + const std::string& extension_id, + const FilePath& extension_path, + const std::string& extension_default_locale); + + // Called when contents from the loaded file have been localized. + void DidLoadAndLocalizeFile(bool success, const std::string& data); + + // Run in UI thread. Code string contains the code to be executed. Returns + // true on success. If true is returned, this does an AddRef. + bool Execute(const std::string& code_string); + + // Id of tab which executes code. + int execute_tab_id_; + + // The injection details. + scoped_ptr<extensions::api::tabs::InjectDetails> details_; + + // Contains extension resource built from path of file which is + // specified in JSON arguments. + ExtensionResource resource_; +}; + +class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { + private: + virtual ~TabsExecuteScriptFunction() {} + + virtual void OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const ListValue& script_result) OVERRIDE; + + DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") +}; + +class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { + private: + virtual ~TabsInsertCSSFunction() {} + + DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") +}; + +#endif // CHROME_BROWSER_EXTENSIONS_API_TABS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs.cc index 441f422..342b630 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/tabs/tabs_api.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include <algorithm> #include <limits> @@ -26,7 +26,6 @@ #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/extensions/file_reader.h" #include "chrome/browser/extensions/script_executor.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/window_controller.h" @@ -51,15 +50,10 @@ #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/api/tabs.h" #include "chrome/common/extensions/api/windows.h" #include "chrome/common/extensions/extension.h" -#include "chrome/common/extensions/extension_constants.h" -#include "chrome/common/extensions/extension_file_util.h" -#include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/extensions/extension_manifest_constants.h" #include "chrome/common/extensions/extension_messages.h" -#include "chrome/common/extensions/message_bundle.h" #include "chrome/common/extensions/user_script.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -93,7 +87,6 @@ namespace GetLastFocused = extensions::api::windows::GetLastFocused; namespace errors = extension_manifest_errors; namespace keys = extensions::tabs_constants; -using content::BrowserThread; using content::NavigationController; using content::NavigationEntry; using content::OpenURLParams; @@ -102,12 +95,10 @@ using content::RenderViewHost; using content::WebContents; using extensions::ErrorUtils; using extensions::ScriptExecutor; -using extensions::UserScript; using extensions::WindowController; using extensions::WindowControllerList; -using extensions::api::tabs::InjectDetails; -const int TabsCaptureVisibleTabFunction::kDefaultQuality = 90; +const int CaptureVisibleTabFunction::kDefaultQuality = 90; namespace { @@ -258,7 +249,7 @@ Browser* CreateBrowserWindow(const Browser::CreateParams& params, // Windows --------------------------------------------------------------------- -bool WindowsGetFunction::RunImpl() { +bool GetWindowFunction::RunImpl() { scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -277,7 +268,7 @@ bool WindowsGetFunction::RunImpl() { return true; } -bool WindowsGetCurrentFunction::RunImpl() { +bool GetCurrentWindowFunction::RunImpl() { scoped_ptr<GetCurrent::Params> params(GetCurrent::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -298,7 +289,7 @@ bool WindowsGetCurrentFunction::RunImpl() { return true; } -bool WindowsGetLastFocusedFunction::RunImpl() { +bool GetLastFocusedWindowFunction::RunImpl() { scoped_ptr<GetLastFocused::Params> params( GetLastFocused::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -325,7 +316,7 @@ bool WindowsGetLastFocusedFunction::RunImpl() { return true; } -bool WindowsGetAllFunction::RunImpl() { +bool GetAllWindowsFunction::RunImpl() { scoped_ptr<GetAll::Params> params(GetAll::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -350,7 +341,7 @@ bool WindowsGetAllFunction::RunImpl() { return true; } -bool WindowsCreateFunction::ShouldOpenIncognitoWindow( +bool CreateWindowFunction::ShouldOpenIncognitoWindow( const base::DictionaryValue* args, std::vector<GURL>* urls, bool* is_error) { @@ -400,7 +391,7 @@ bool WindowsCreateFunction::ShouldOpenIncognitoWindow( return incognito; } -bool WindowsCreateFunction::RunImpl() { +bool CreateWindowFunction::RunImpl() { DictionaryValue* args = NULL; std::vector<GURL> urls; WebContents* contents = NULL; @@ -669,7 +660,7 @@ bool WindowsCreateFunction::RunImpl() { return true; } -bool WindowsUpdateFunction::RunImpl() { +bool UpdateWindowFunction::RunImpl() { int window_id = extension_misc::kUnknownWindowId; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); DictionaryValue* update_props; @@ -813,7 +804,7 @@ bool WindowsUpdateFunction::RunImpl() { return true; } -bool WindowsRemoveFunction::RunImpl() { +bool RemoveWindowFunction::RunImpl() { int window_id = -1; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &window_id)); @@ -840,7 +831,7 @@ bool WindowsRemoveFunction::RunImpl() { // Tabs ------------------------------------------------------------------------ -bool TabsGetSelectedFunction::RunImpl() { +bool GetSelectedTabFunction::RunImpl() { // windowId defaults to "current" window. int window_id = extension_misc::kCurrentWindowId; @@ -864,7 +855,7 @@ bool TabsGetSelectedFunction::RunImpl() { return true; } -bool TabsGetAllInWindowFunction::RunImpl() { +bool GetAllTabsInWindowFunction::RunImpl() { // windowId defaults to "current" window. int window_id = extension_misc::kCurrentWindowId; if (HasOptionalArgument(0)) @@ -879,7 +870,7 @@ bool TabsGetAllInWindowFunction::RunImpl() { return true; } -bool TabsQueryFunction::RunImpl() { +bool QueryTabsFunction::RunImpl() { DictionaryValue* query = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query)); @@ -992,7 +983,7 @@ bool TabsQueryFunction::RunImpl() { return true; } -bool TabsCreateFunction::RunImpl() { +bool CreateTabFunction::RunImpl() { DictionaryValue* args = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); @@ -1126,7 +1117,7 @@ bool TabsCreateFunction::RunImpl() { return true; } -bool TabsDuplicateFunction::RunImpl() { +bool DuplicateTabFunction::RunImpl() { int tab_id = -1; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); @@ -1152,7 +1143,7 @@ bool TabsDuplicateFunction::RunImpl() { return true; } -bool TabsGetFunction::RunImpl() { +bool GetTabFunction::RunImpl() { int tab_id = -1; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); @@ -1170,7 +1161,7 @@ bool TabsGetFunction::RunImpl() { return true; } -bool TabsGetCurrentFunction::RunImpl() { +bool GetCurrentTabFunction::RunImpl() { DCHECK(dispatcher()); WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); @@ -1180,7 +1171,7 @@ bool TabsGetCurrentFunction::RunImpl() { return true; } -bool TabsHighlightFunction::RunImpl() { +bool HighlightTabsFunction::RunImpl() { DictionaryValue* info = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &info)); @@ -1237,10 +1228,10 @@ bool TabsHighlightFunction::RunImpl() { return true; } -TabsUpdateFunction::TabsUpdateFunction() : web_contents_(NULL) { +UpdateTabFunction::UpdateTabFunction() : web_contents_(NULL) { } -bool TabsUpdateFunction::RunImpl() { +bool UpdateTabFunction::RunImpl() { DictionaryValue* update_props = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); @@ -1344,7 +1335,7 @@ bool TabsUpdateFunction::RunImpl() { return true; } -bool TabsUpdateFunction::UpdateURLIfPresent(DictionaryValue* update_props, +bool UpdateTabFunction::UpdateURLIfPresent(DictionaryValue* update_props, int tab_id, bool* is_async) { if (!update_props->HasKey(keys::kUrlKey)) @@ -1388,7 +1379,7 @@ bool TabsUpdateFunction::UpdateURLIfPresent(DictionaryValue* update_props, ScriptExecutor::TOP_FRAME, extensions::UserScript::DOCUMENT_IDLE, ScriptExecutor::MAIN_WORLD, - base::Bind(&TabsUpdateFunction::OnExecuteCodeFinished, this)); + base::Bind(&UpdateTabFunction::OnExecuteCodeFinished, this)); *is_async = true; return true; @@ -1405,14 +1396,14 @@ bool TabsUpdateFunction::UpdateURLIfPresent(DictionaryValue* update_props, return true; } -void TabsUpdateFunction::PopulateResult() { +void UpdateTabFunction::PopulateResult() { if (!has_callback()) return; SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension())); } -void TabsUpdateFunction::OnExecuteCodeFinished(const std::string& error, +void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error, int32 on_page_id, const GURL& url, const ListValue& script_result) { @@ -1423,7 +1414,7 @@ void TabsUpdateFunction::OnExecuteCodeFinished(const std::string& error, SendResponse(error.empty()); } -bool TabsMoveFunction::RunImpl() { +bool MoveTabsFunction::RunImpl() { Value* tab_value = NULL; EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value)); @@ -1544,7 +1535,7 @@ bool TabsMoveFunction::RunImpl() { return true; } -bool TabsReloadFunction::RunImpl() { +bool ReloadTabFunction::RunImpl() { bool bypass_cache = false; if (HasOptionalArgument(1)) { DictionaryValue* reload_props = NULL; @@ -1599,7 +1590,7 @@ bool TabsReloadFunction::RunImpl() { return true; } -bool TabsRemoveFunction::RunImpl() { +bool RemoveTabsFunction::RunImpl() { Value* tab_value = NULL; EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value)); @@ -1629,8 +1620,7 @@ bool TabsRemoveFunction::RunImpl() { return true; } -bool TabsCaptureVisibleTabFunction::GetTabToCapture( - WebContents** web_contents) { +bool CaptureVisibleTabFunction::GetTabToCapture(WebContents** web_contents) { Browser* browser = NULL; // windowId defaults to "current" window. int window_id = extension_misc::kCurrentWindowId; @@ -1650,7 +1640,7 @@ bool TabsCaptureVisibleTabFunction::GetTabToCapture( return true; }; -bool TabsCaptureVisibleTabFunction::RunImpl() { +bool CaptureVisibleTabFunction::RunImpl() { PrefServiceBase* service = profile()->GetPrefs(); if (service->GetBoolean(prefs::kDisableScreenshots)) { error_ = keys::kScreenshotsDisabled; @@ -1709,14 +1699,14 @@ bool TabsCaptureVisibleTabFunction::RunImpl() { render_view_host->CopyFromBackingStore( gfx::Rect(), view->GetViewBounds().size(), - base::Bind(&TabsCaptureVisibleTabFunction::CopyFromBackingStoreComplete, + base::Bind(&CaptureVisibleTabFunction::CopyFromBackingStoreComplete, this, base::Owned(temp_bitmap)), temp_bitmap); return true; } -void TabsCaptureVisibleTabFunction::CopyFromBackingStoreComplete( +void CaptureVisibleTabFunction::CopyFromBackingStoreComplete( skia::PlatformBitmap* bitmap, bool succeeded) { if (succeeded) { @@ -1736,14 +1726,14 @@ void TabsCaptureVisibleTabFunction::CopyFromBackingStoreComplete( registrar_.Add(this, chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, content::Source<WebContents>(web_contents)); - AddRef(); // Balanced in TabsCaptureVisibleTabFunction::Observe(). + AddRef(); // Balanced in CaptureVisibleTabFunction::Observe(). SnapshotTabHelper::FromWebContents(web_contents)->CaptureSnapshot(); } -// If a backing store was not available in -// TabsCaptureVisibleTabFunction::RunImpl, than the renderer was asked for a -// snapshot. Listen for a notification that the snapshot is available. -void TabsCaptureVisibleTabFunction::Observe( +// If a backing store was not available in CaptureVisibleTabFunction::RunImpl, +// than the renderer was asked for a snapshot. Listen for a notification +// that the snapshot is available. +void CaptureVisibleTabFunction::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -1761,12 +1751,12 @@ void TabsCaptureVisibleTabFunction::Observe( SendResultFromBitmap(*screen_capture); } - Release(); // Balanced in TabsCaptureVisibleTabFunction::RunImpl(). + Release(); // Balanced in CaptureVisibleTabFunction::RunImpl(). } // Turn a bitmap of the screen into an image, set that image as the result, // and call SendResponse(). -void TabsCaptureVisibleTabFunction::SendResultFromBitmap( +void CaptureVisibleTabFunction::SendResultFromBitmap( const SkBitmap& screen_capture) { std::vector<unsigned char> data; SkAutoLockPixels screen_capture_lock(screen_capture); @@ -1812,13 +1802,13 @@ void TabsCaptureVisibleTabFunction::SendResultFromBitmap( SendResponse(true); } -void TabsCaptureVisibleTabFunction::RegisterUserPrefs( +void CaptureVisibleTabFunction::RegisterUserPrefs( PrefServiceSyncable* service) { service->RegisterBooleanPref(prefs::kDisableScreenshots, false, PrefServiceSyncable::UNSYNCABLE_PREF); } -bool TabsDetectLanguageFunction::RunImpl() { +bool DetectTabLanguageFunction::RunImpl() { int tab_id = 0; Browser* browser = NULL; WebContents* contents = NULL; @@ -1856,7 +1846,7 @@ bool TabsDetectLanguageFunction::RunImpl() { // Delay the callback invocation until after the current JS call has // returned. MessageLoop::current()->PostTask(FROM_HERE, base::Bind( - &TabsDetectLanguageFunction::GotLanguage, this, + &DetectTabLanguageFunction::GotLanguage, this, translate_tab_helper->language_state().original_language())); return true; } @@ -1873,7 +1863,7 @@ bool TabsDetectLanguageFunction::RunImpl() { return true; } -void TabsDetectLanguageFunction::Observe( +void DetectTabLanguageFunction::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -1888,249 +1878,9 @@ void TabsDetectLanguageFunction::Observe( GotLanguage(language); } -void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { +void DetectTabLanguageFunction::GotLanguage(const std::string& language) { SetResult(Value::CreateStringValue(language.c_str())); SendResponse(true); Release(); // Balanced in Run() } - -ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() - : execute_tab_id_(-1) { -} - -ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} - -bool ExecuteCodeInTabFunction::HasPermission() { - if (Init() && - extension_->HasAPIPermissionForTab(execute_tab_id_, - extensions::APIPermission::kTab)) { - return true; - } - return ExtensionFunction::HasPermission(); -} - -bool ExecuteCodeInTabFunction::RunImpl() { - EXTENSION_FUNCTION_VALIDATE(Init()); - - if (!details_->code.get() && !details_->file.get()) { - error_ = keys::kNoCodeOrFileToExecuteError; - return false; - } - if (details_->code.get() && details_->file.get()) { - error_ = keys::kMoreThanOneValuesError; - return false; - } - - content::WebContents* contents = NULL; - - // If |tab_id| is specified, look for the tab. Otherwise default to selected - // tab in the current window. - CHECK_GE(execute_tab_id_, 0); - if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), - include_incognito(), - NULL, NULL, &contents, NULL)) { - return false; - } - - // NOTE: This can give the wrong answer due to race conditions, but it is OK, - // we check again in the renderer. - CHECK(contents); - if (!GetExtension()->CanExecuteScriptOnPage(contents->GetURL(), - contents->GetURL(), - execute_tab_id_, - NULL, - &error_)) { - return false; - } - - if (details_->code.get()) - return Execute(*details_->code); - - CHECK(details_->file.get()); - resource_ = GetExtension()->GetResource(*details_->file); - - if (resource_.extension_root().empty() || resource_.relative_path().empty()) { - error_ = keys::kNoCodeOrFileToExecuteError; - return false; - } - - scoped_refptr<FileReader> file_reader(new FileReader( - resource_, base::Bind(&ExecuteCodeInTabFunction::DidLoadFile, this))); - file_reader->Start(); - - return true; -} - -void ExecuteCodeInTabFunction::OnExecuteCodeFinished(const std::string& error, - int32 on_page_id, - const GURL& on_url, - const ListValue& result) { - if (!error.empty()) - SetError(error); - - SendResponse(error.empty()); -} - -void TabsExecuteScriptFunction::OnExecuteCodeFinished(const std::string& error, - int32 on_page_id, - const GURL& on_url, - const ListValue& result) { - if (error.empty()) - SetResult(result.DeepCopy()); - ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_page_id, on_url, - result); -} - -bool ExecuteCodeInTabFunction::Init() { - if (details_.get()) - return true; - - // |tab_id| is optional so it's ok if it's not there. - int tab_id = -1; - args_->GetInteger(0, &tab_id); - - // |details| are not optional. - DictionaryValue* details_value = NULL; - if (!args_->GetDictionary(1, &details_value)) - return false; - scoped_ptr<InjectDetails> details(new InjectDetails()); - if (!InjectDetails::Populate(*details_value, details.get())) - return false; - - // If the tab ID is -1 then it needs to be converted to the currently active - // tab's ID. - if (tab_id == -1) { - Browser* browser = GetCurrentBrowser(); - if (!browser) - return false; - content::WebContents* web_contents = NULL; - if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, &tab_id)) - return false; - } - - execute_tab_id_ = tab_id; - details_ = details.Pass(); - return true; -} - -void ExecuteCodeInTabFunction::DidLoadFile(bool success, - const std::string& data) { - std::string function_name = name(); - const extensions::Extension* extension = GetExtension(); - - // Check if the file is CSS and needs localization. - if (success && - function_name == TabsInsertCSSFunction::function_name() && - extension != NULL && - data.find( - extensions::MessageBundle::kMessageBegin) != std::string::npos) { - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, - base::Bind(&ExecuteCodeInTabFunction::LocalizeCSS, this, - data, - extension->id(), - extension->path(), - extension->default_locale())); - } else { - DidLoadAndLocalizeFile(success, data); - } -} - -void ExecuteCodeInTabFunction::LocalizeCSS( - const std::string& data, - const std::string& extension_id, - const FilePath& extension_path, - const std::string& extension_default_locale) { - scoped_ptr<SubstitutionMap> localization_messages( - extension_file_util::LoadMessageBundleSubstitutionMap( - extension_path, extension_id, extension_default_locale)); - - // We need to do message replacement on the data, so it has to be mutable. - std::string css_data = data; - std::string error; - extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( - *localization_messages, &css_data, &error); - - // Call back DidLoadAndLocalizeFile on the UI thread. The success parameter - // is always true, because if loading had failed, we wouldn't have had - // anything to localize. - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&ExecuteCodeInTabFunction::DidLoadAndLocalizeFile, this, - true, css_data)); -} - -void ExecuteCodeInTabFunction::DidLoadAndLocalizeFile(bool success, - const std::string& data) { - if (success) { - if (!Execute(data)) - SendResponse(false); - } else { -#if defined(OS_POSIX) - // TODO(viettrungluu): bug: there's no particular reason the path should be - // UTF-8, in which case this may fail. - error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError, - resource_.relative_path().value()); -#elif defined(OS_WIN) - error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError, - WideToUTF8(resource_.relative_path().value())); -#endif // OS_WIN - SendResponse(false); - } -} - -bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { - content::WebContents* contents = NULL; - Browser* browser = NULL; - - bool success = ExtensionTabUtil::GetTabById( - execute_tab_id_, profile(), include_incognito(), &browser, NULL, - &contents, NULL) && contents && browser; - - if (!success) - return false; - - const extensions::Extension* extension = GetExtension(); - if (!extension) - return false; - - ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; - std::string function_name = name(); - if (function_name == TabsInsertCSSFunction::function_name()) { - script_type = ScriptExecutor::CSS; - } else if (function_name != TabsExecuteScriptFunction::function_name()) { - NOTREACHED(); - } - - ScriptExecutor::FrameScope frame_scope = - details_->all_frames.get() && *details_->all_frames ? - ScriptExecutor::ALL_FRAMES : - ScriptExecutor::TOP_FRAME; - - UserScript::RunLocation run_at = UserScript::UNDEFINED; - switch (details_->run_at) { - case InjectDetails::RUN_AT_NONE: - case InjectDetails::RUN_AT_DOCUMENT_IDLE: - run_at = UserScript::DOCUMENT_IDLE; - break; - case InjectDetails::RUN_AT_DOCUMENT_START: - run_at = UserScript::DOCUMENT_START; - break; - case InjectDetails::RUN_AT_DOCUMENT_END: - run_at = UserScript::DOCUMENT_END; - break; - } - CHECK_NE(UserScript::UNDEFINED, run_at); - - extensions::TabHelper::FromWebContents(contents)-> - script_executor()->ExecuteScript( - extension->id(), - script_type, - code_string, - frame_scope, - run_at, - ScriptExecutor::ISOLATED_WORLD, - base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); - return true; -} diff --git a/chrome/browser/extensions/api/tabs/tabs_api.h b/chrome/browser/extensions/api/tabs/tabs.h index db362cc..5011c3f 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.h +++ b/chrome/browser/extensions/api/tabs/tabs.h @@ -2,16 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_H__ +#define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_H__ #include <string> #include <vector> #include "base/compiler_specific.h" #include "chrome/browser/extensions/extension_function.h" -#include "chrome/common/extensions/extension_resource.h" -#include "chrome/common/extensions/user_script.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "googleurl/src/gurl.h" @@ -29,41 +27,33 @@ namespace content { class WebContents; } -namespace extensions { -namespace api { -namespace tabs { -struct InjectDetails; -} // namespace tabs -} // namespace api -} // namespace extensions - namespace skia { class PlatformBitmap; } // Windows -class WindowsGetFunction : public SyncExtensionFunction { - virtual ~WindowsGetFunction() {} +class GetWindowFunction : public SyncExtensionFunction { + virtual ~GetWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.get") }; -class WindowsGetCurrentFunction : public SyncExtensionFunction { - virtual ~WindowsGetCurrentFunction() {} +class GetCurrentWindowFunction : public SyncExtensionFunction { + virtual ~GetCurrentWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.getCurrent") }; -class WindowsGetLastFocusedFunction : public SyncExtensionFunction { - virtual ~WindowsGetLastFocusedFunction() {} +class GetLastFocusedWindowFunction : public SyncExtensionFunction { + virtual ~GetLastFocusedWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.getLastFocused") }; -class WindowsGetAllFunction : public SyncExtensionFunction { - virtual ~WindowsGetAllFunction() {} +class GetAllWindowsFunction : public SyncExtensionFunction { + virtual ~GetAllWindowsFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.getAll") }; -class WindowsCreateFunction : public SyncExtensionFunction { - virtual ~WindowsCreateFunction() {} +class CreateWindowFunction : public SyncExtensionFunction { + virtual ~CreateWindowFunction() {} virtual bool RunImpl() OVERRIDE; // Returns whether the window should be created in incognito mode. // |urls| is the list of urls to open. If we are creating an incognito window, @@ -76,64 +66,64 @@ class WindowsCreateFunction : public SyncExtensionFunction { bool* is_error); DECLARE_EXTENSION_FUNCTION_NAME("windows.create") }; -class WindowsUpdateFunction : public SyncExtensionFunction { - virtual ~WindowsUpdateFunction() {} +class UpdateWindowFunction : public SyncExtensionFunction { + virtual ~UpdateWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.update") }; -class WindowsRemoveFunction : public SyncExtensionFunction { - virtual ~WindowsRemoveFunction() {} +class RemoveWindowFunction : public SyncExtensionFunction { + virtual ~RemoveWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("windows.remove") }; // Tabs -class TabsGetFunction : public SyncExtensionFunction { - virtual ~TabsGetFunction() {} +class GetTabFunction : public SyncExtensionFunction { + virtual ~GetTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.get") }; -class TabsGetCurrentFunction : public SyncExtensionFunction { - virtual ~TabsGetCurrentFunction() {} +class GetCurrentTabFunction : public SyncExtensionFunction { + virtual ~GetCurrentTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.getCurrent") }; -class TabsGetSelectedFunction : public SyncExtensionFunction { - virtual ~TabsGetSelectedFunction() {} +class GetSelectedTabFunction : public SyncExtensionFunction { + virtual ~GetSelectedTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.getSelected") }; -class TabsGetAllInWindowFunction : public SyncExtensionFunction { - virtual ~TabsGetAllInWindowFunction() {} +class GetAllTabsInWindowFunction : public SyncExtensionFunction { + virtual ~GetAllTabsInWindowFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.getAllInWindow") }; -class TabsQueryFunction : public SyncExtensionFunction { - virtual ~TabsQueryFunction() {} +class QueryTabsFunction : public SyncExtensionFunction { + virtual ~QueryTabsFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.query") }; -class TabsCreateFunction : public SyncExtensionFunction { - virtual ~TabsCreateFunction() {} +class CreateTabFunction : public SyncExtensionFunction { + virtual ~CreateTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.create") }; -class TabsDuplicateFunction : public SyncExtensionFunction { - virtual ~TabsDuplicateFunction() {} +class DuplicateTabFunction : public SyncExtensionFunction { + virtual ~DuplicateTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.duplicate") }; -class TabsHighlightFunction : public SyncExtensionFunction { - virtual ~TabsHighlightFunction() {} +class HighlightTabsFunction : public SyncExtensionFunction { + virtual ~HighlightTabsFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight") }; -class TabsUpdateFunction : public AsyncExtensionFunction { +class UpdateTabFunction : public AsyncExtensionFunction { public: - TabsUpdateFunction(); + UpdateTabFunction(); protected: - virtual ~TabsUpdateFunction() {} + virtual ~UpdateTabFunction() {} virtual bool UpdateURLIfPresent(base::DictionaryValue* update_props, int tab_id, bool* is_async); @@ -150,25 +140,25 @@ class TabsUpdateFunction : public AsyncExtensionFunction { DECLARE_EXTENSION_FUNCTION_NAME("tabs.update") }; -class TabsMoveFunction : public SyncExtensionFunction { - virtual ~TabsMoveFunction() {} +class MoveTabsFunction : public SyncExtensionFunction { + virtual ~MoveTabsFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.move") }; -class TabsReloadFunction : public SyncExtensionFunction { - virtual ~TabsReloadFunction() {} +class ReloadTabFunction : public SyncExtensionFunction { + virtual ~ReloadTabFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.reload") }; -class TabsRemoveFunction : public SyncExtensionFunction { - virtual ~TabsRemoveFunction() {} +class RemoveTabsFunction : public SyncExtensionFunction { + virtual ~RemoveTabsFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("tabs.remove") }; -class TabsDetectLanguageFunction : public AsyncExtensionFunction, +class DetectTabLanguageFunction : public AsyncExtensionFunction, public content::NotificationObserver { private: - virtual ~TabsDetectLanguageFunction() {} + virtual ~DetectTabLanguageFunction() {} virtual bool RunImpl() OVERRIDE; virtual void Observe(int type, @@ -178,7 +168,7 @@ class TabsDetectLanguageFunction : public AsyncExtensionFunction, content::NotificationRegistrar registrar_; DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage") }; -class TabsCaptureVisibleTabFunction : public AsyncExtensionFunction, +class CaptureVisibleTabFunction : public AsyncExtensionFunction, public content::NotificationObserver { public: static void RegisterUserPrefs(PrefServiceSyncable* service); @@ -192,7 +182,7 @@ class TabsCaptureVisibleTabFunction : public AsyncExtensionFunction, // The default quality setting used when encoding jpegs. static const int kDefaultQuality; - virtual ~TabsCaptureVisibleTabFunction() {} + virtual ~CaptureVisibleTabFunction() {} virtual bool RunImpl() OVERRIDE; virtual bool GetTabToCapture(content::WebContents** web_contents); virtual void Observe(int type, @@ -215,76 +205,4 @@ class TabsCaptureVisibleTabFunction : public AsyncExtensionFunction, DECLARE_EXTENSION_FUNCTION_NAME("tabs.captureVisibleTab") }; -// Implement API call tabs.executeScript and tabs.insertCSS. -class ExecuteCodeInTabFunction : public AsyncExtensionFunction { - public: - ExecuteCodeInTabFunction(); - - protected: - virtual ~ExecuteCodeInTabFunction(); - - // ExtensionFunction: - virtual bool HasPermission() OVERRIDE; - virtual bool RunImpl() OVERRIDE; - - // Message handler. - virtual void OnExecuteCodeFinished(const std::string& error, - int32 on_page_id, - const GURL& on_url, - const ListValue& script_result); - - private: - // Initialize the |execute_tab_id_| and |details_| if they haven't already - // been. Returns whether initialization was successful. - bool Init(); - - // Called when contents from the file whose path is specified in JSON - // arguments has been loaded. - void DidLoadFile(bool success, const std::string& data); - - // Runs on FILE thread. Loads message bundles for the extension and - // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. - void LocalizeCSS( - const std::string& data, - const std::string& extension_id, - const FilePath& extension_path, - const std::string& extension_default_locale); - - // Called when contents from the loaded file have been localized. - void DidLoadAndLocalizeFile(bool success, const std::string& data); - - // Run in UI thread. Code string contains the code to be executed. Returns - // true on success. If true is returned, this does an AddRef. - bool Execute(const std::string& code_string); - - // Id of tab which executes code. - int execute_tab_id_; - - // The injection details. - scoped_ptr<extensions::api::tabs::InjectDetails> details_; - - // Contains extension resource built from path of file which is - // specified in JSON arguments. - ExtensionResource resource_; -}; - -class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { - private: - virtual ~TabsExecuteScriptFunction() {} - - virtual void OnExecuteCodeFinished(const std::string& error, - int32 on_page_id, - const GURL& on_url, - const ListValue& script_result) OVERRIDE; - - DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") -}; - -class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { - private: - virtual ~TabsInsertCSSFunction() {} - - DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") -}; - -#endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_H__ diff --git a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc index c18a161..c5a0dd5 100644 --- a/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_interactive_test.cc @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/extensions/api/tabs/tabs.h" + #include "base/values.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/interactive_test_utils.h" +#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" namespace keys = extensions::tabs_constants; @@ -31,8 +32,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_GetLastFocusedWindow) { Browser* new_browser = CreateBrowser(browser()->profile()); int focused_window_id = ExtensionTabUtil::GetWindowId(new_browser); - scoped_refptr<WindowsGetLastFocusedFunction> function = - new WindowsGetLastFocusedFunction(); + scoped_refptr<GetLastFocusedWindowFunction> function = + new GetLastFocusedWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( @@ -46,7 +47,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_GetLastFocusedWindow) { ListValue* tabs = NULL; EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); - function = new WindowsGetLastFocusedFunction(); + function = new GetLastFocusedWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -82,7 +83,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { int focused_window_id = ExtensionTabUtil::GetWindowId(focused_window); // Get tabs in the 'last focused' window called from non-focused browser. - scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); + scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction(); scoped_ptr<base::ListValue> result(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), "[{\"lastFocusedWindow\":true}]", @@ -99,7 +100,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { } // Get tabs NOT in the 'last focused' window called from the focused browser. - function = new TabsQueryFunction(); + function = new QueryTabsFunction(); result.reset(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), "[{\"lastFocusedWindow\":false}]", diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc index ec96b6a..30f192c 100644 --- a/chrome/browser/extensions/api/tabs/tabs_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/extensions/api/tabs/tabs.h" #include <string> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/string_util.h" #include "base/stringprintf.h" +#include "base/string_util.h" #include "base/values.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" #include "chrome/browser/extensions/api/tabs/tabs_constants.h" #include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_tab_util.h" @@ -38,7 +38,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { int window_id = ExtensionTabUtil::GetWindowId(browser()); // Invalid window ID error. - scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); + scoped_refptr<GetWindowFunction> function = new GetWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( @@ -55,7 +55,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { else bounds = browser()->window()->GetBounds(); - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -71,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { EXPECT_EQ(bounds.height(), utils::GetInteger(result.get(), "height")); // With "populate" enabled. - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -96,7 +96,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // Popup. Browser* popup_browser = new Browser( Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -109,7 +109,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // Panel. Browser* panel_browser = new Browser( Browser::CreateParams(Browser::TYPE_PANEL, browser()->profile())); - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -124,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { int incognito_window_id = ExtensionTabUtil::GetWindowId(incognito_browser); // Without "include_incognito". - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError( @@ -134,7 +134,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { keys::kWindowNotFoundError)); // With "include_incognito". - function = new WindowsGetFunction(); + function = new GetWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -151,8 +151,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { int new_id = ExtensionTabUtil::GetWindowId(new_browser); // Get the current window using new_browser. - scoped_refptr<WindowsGetCurrentFunction> function = - new WindowsGetCurrentFunction(); + scoped_refptr<GetCurrentWindowFunction> function = + new GetCurrentWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( @@ -167,7 +167,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); // Get the current window using the old window and make the tabs populated. - function = new WindowsGetCurrentFunction(); + function = new GetCurrentWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -192,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { window_ids.insert(ExtensionTabUtil::GetWindowId(new_browser)); } - scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); + scoped_refptr<GetAllWindowsFunction> function = new GetAllWindowsFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); scoped_ptr<base::ListValue> result(utils::ToList( @@ -215,7 +215,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { EXPECT_EQ(window_ids, result_ids); result_ids.clear(); - function = new WindowsGetAllFunction(); + function = new GetAllWindowsFunction(); function->set_extension(extension.get()); result.reset(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -240,8 +240,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { // The test empty extension has no permissions, therefore it should not get // tab data in the function result. - scoped_refptr<TabsUpdateFunction> update_tab_function( - new TabsUpdateFunction()); + scoped_refptr<UpdateTabFunction> update_tab_function(new UpdateTabFunction()); scoped_refptr<extensions::Extension> empty_extension( utils::CreateEmptyExtension()); update_tab_function->set_extension(empty_extension.get()); @@ -266,7 +265,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. - scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); + scoped_refptr<CreateWindowFunction> function(new CreateWindowFunction()); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( @@ -285,7 +284,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, // Now try creating a window from incognito window. Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. - function = new WindowsCreateFunction(); + function = new CreateWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult( @@ -307,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( @@ -325,7 +324,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, // Now try creating a window from incognito window. Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. - function = new WindowsCreateFunction(); + function = new CreateWindowFunction(); function->set_extension(extension.get()); result.reset(utils::ToDictionary( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -348,7 +347,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::FORCED); // Run with an explicit "incognito" param. - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( @@ -360,7 +359,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, // Now try opening a normal window from incognito window. Browser* incognito_browser = CreateIncognitoBrowser(); // Run with an explicit "incognito" param. - function = new WindowsCreateFunction(); + function = new CreateWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError(function.get(), @@ -379,7 +378,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), IncognitoModePrefs::DISABLED); // Run in normal window. - scoped_refptr<WindowsCreateFunction> function = new WindowsCreateFunction(); + scoped_refptr<CreateWindowFunction> function = new CreateWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( @@ -389,7 +388,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, keys::kIncognitoModeIsDisabled)); // Run in incognito window. - function = new WindowsCreateFunction(); + function = new CreateWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError(function.get(), @@ -408,7 +407,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { int window_id = ExtensionTabUtil::GetWindowId(browser()); // Get tabs in the 'current' window called from non-focused browser. - scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); + scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction(); function->set_extension(utils::CreateEmptyExtension().get()); scoped_ptr<base::ListValue> result(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -425,7 +424,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { } // Get tabs NOT in the 'current' window called from non-focused browser. - function = new TabsQueryFunction(); + function = new QueryTabsFunction(); function->set_extension(utils::CreateEmptyExtension().get()); result.reset(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -451,8 +450,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { int window_id = ExtensionTabUtil::GetWindowId(popup_browser); chrome::CloseWindow(popup_browser); - scoped_refptr<TabsCreateFunction> create_tab_function( - new TabsCreateFunction()); + scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction()); create_tab_function->set_extension(utils::CreateEmptyExtension().get()); // Without a callback the function will not generate a result. create_tab_function->set_has_callback(true); @@ -474,7 +472,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMinimizedWithFocus[] = "[%u, {\"state\": \"minimized\", \"focused\": true}]"; - scoped_refptr<WindowsUpdateFunction> function = new WindowsUpdateFunction(); + scoped_refptr<UpdateWindowFunction> function = new UpdateWindowFunction(); scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( @@ -486,7 +484,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMaximizedWithoutFocus[] = "[%u, {\"state\": \"maximized\", \"focused\": false}]"; - function = new WindowsUpdateFunction(); + function = new UpdateWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError( @@ -497,7 +495,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMinimizedWithBounds[] = "[%u, {\"state\": \"minimized\", \"width\": 500}]"; - function = new WindowsUpdateFunction(); + function = new UpdateWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError( @@ -508,7 +506,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, InvalidUpdateWindowState) { static const char kArgsMaximizedWithBounds[] = "[%u, {\"state\": \"maximized\", \"width\": 500}]"; - function = new WindowsUpdateFunction(); + function = new UpdateWindowFunction(); function->set_extension(extension.get()); EXPECT_TRUE(MatchPattern( utils::RunFunctionAndReturnError( @@ -531,8 +529,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { TabStripModel* tab_strip; ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); - scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( - new TabsDuplicateFunction()); + scoped_refptr<DuplicateTabFunction> duplicate_tab_function( + new DuplicateTabFunction()); scoped_ptr<base::DictionaryValue> test_extension_value( utils::ParseDictionary( "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": [\"tabs\"]}" @@ -575,8 +573,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { TabStripModel* tab_strip; ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); - scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( - new TabsDuplicateFunction()); + scoped_refptr<DuplicateTabFunction> duplicate_tab_function( + new DuplicateTabFunction()); scoped_refptr<extensions::Extension> empty_extension( utils::CreateEmptyExtension()); duplicate_tab_function->set_extension(empty_extension.get()); diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc index 713fff5..841a7fc 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc @@ -19,12 +19,12 @@ #include "chrome/browser/view_type_utils.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/api/web_navigation.h" +#include "content/public/browser/resource_request_details.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/resource_request_details.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" #include "net/base/net_errors.h" @@ -664,7 +664,7 @@ bool WebNavigationTabObserver::IsReferenceFragmentNavigation( url.ReplaceComponents(replacements); } -bool WebNavigationGetFrameFunction::RunImpl() { +bool GetFrameFunction::RunImpl() { scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); int tab_id = params->details.tab_id; @@ -720,7 +720,7 @@ bool WebNavigationGetFrameFunction::RunImpl() { return true; } -bool WebNavigationGetAllFramesFunction::RunImpl() { +bool GetAllFramesFunction::RunImpl() { scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); int tab_id = params->details.tab_id; diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.h b/chrome/browser/extensions/api/web_navigation/web_navigation_api.h index 8270307..58e4308 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.h +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.h @@ -201,15 +201,15 @@ class WebNavigationEventRouter : public TabStripModelObserver, }; // API function that returns the state of a given frame. -class WebNavigationGetFrameFunction : public SyncExtensionFunction { - virtual ~WebNavigationGetFrameFunction() {} +class GetFrameFunction : public SyncExtensionFunction { + virtual ~GetFrameFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getFrame") }; // API function that returns the states of all frames in a given tab. -class WebNavigationGetAllFramesFunction : public SyncExtensionFunction { - virtual ~WebNavigationGetAllFramesFunction() {} +class GetAllFramesFunction : public SyncExtensionFunction { + virtual ~GetAllFramesFunction() {} virtual bool RunImpl() OVERRIDE; DECLARE_EXTENSION_FUNCTION_NAME("webNavigation.getAllFrames") }; diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index b53ef97..f907d43 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -1706,7 +1706,7 @@ void ExtensionWebRequestEventRouter::ClearSignaled(uint64 request_id, iter->second &= ~event_type; } -// Special QuotaLimitHeuristic for WebRequestHandlerBehaviorChangedFunction. +// Special QuotaLimitHeuristic for WebRequestHandlerBehaviorChanged. // // Each call of webRequest.handlerBehaviorChanged() clears the in-memory cache // of WebKit at the time of the next page load (top level navigation event). @@ -1955,7 +1955,7 @@ bool WebRequestEventHandled::RunImpl() { return true; } -void WebRequestHandlerBehaviorChangedFunction::GetQuotaLimitHeuristics( +void WebRequestHandlerBehaviorChanged::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { QuotaLimitHeuristic::Config config = { // See web_request.json for current value. @@ -1969,7 +1969,7 @@ void WebRequestHandlerBehaviorChangedFunction::GetQuotaLimitHeuristics( heuristics->push_back(heuristic); } -void WebRequestHandlerBehaviorChangedFunction::OnQuotaExceeded( +void WebRequestHandlerBehaviorChanged::OnQuotaExceeded( const std::string& violation_error) { // Post warning message. ExtensionWarningSet warnings; @@ -1985,7 +1985,7 @@ void WebRequestHandlerBehaviorChangedFunction::OnQuotaExceeded( Run(); } -bool WebRequestHandlerBehaviorChangedFunction::RunImpl() { +bool WebRequestHandlerBehaviorChanged::RunImpl() { helpers::ClearCacheOnNavigation(); return true; } diff --git a/chrome/browser/extensions/api/web_request/web_request_api.h b/chrome/browser/extensions/api/web_request/web_request_api.h index c7e567a..d0fb338 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.h +++ b/chrome/browser/extensions/api/web_request/web_request_api.h @@ -433,13 +433,12 @@ class WebRequestEventHandled : public SyncIOThreadExtensionFunction { virtual bool RunImpl() OVERRIDE; }; -class WebRequestHandlerBehaviorChangedFunction - : public SyncIOThreadExtensionFunction { +class WebRequestHandlerBehaviorChanged : public SyncIOThreadExtensionFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("webRequest.handlerBehaviorChanged"); protected: - virtual ~WebRequestHandlerBehaviorChangedFunction() {} + virtual ~WebRequestHandlerBehaviorChanged() {} // ExtensionFunction: virtual void GetQuotaLimitHeuristics( diff --git a/chrome/browser/extensions/browser_event_router.h b/chrome/browser/extensions/browser_event_router.h index 0f40c36..0ef7a0c 100644 --- a/chrome/browser/extensions/browser_event_router.h +++ b/chrome/browser/extensions/browser_event_router.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_toolbar_model.h" #include "chrome/browser/ui/browser_list_observer.h" diff --git a/chrome/browser/extensions/content_script_apitest.cc b/chrome/browser/extensions/content_script_apitest.cc index d1a71f3..b675403 100644 --- a/chrome/browser/extensions/content_script_apitest.cc +++ b/chrome/browser/extensions/content_script_apitest.cc @@ -163,8 +163,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionAPIs) { } IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptPermissionsApi) { - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); - PermissionsRequestFunction::SetAutoConfirmForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetAutoConfirmForTests(true); host_resolver()->AddRule("*.com", "127.0.0.1"); ASSERT_TRUE(StartTestServer()); ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc index a5c645a..a164df0 100644 --- a/chrome/browser/extensions/data_deleter.cc +++ b/chrome/browser/extensions/data_deleter.cc @@ -4,8 +4,8 @@ #include "chrome/browser/extensions/data_deleter.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/browser_context.h" diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc index 7657dc9..5b63968 100644 --- a/chrome/browser/extensions/extension_function_registry.cc +++ b/chrome/browser/extensions/extension_function_registry.cc @@ -7,23 +7,44 @@ #include "chrome/browser/accessibility/accessibility_extension_api.h" #include "chrome/browser/extensions/api/app/app_api.h" #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" +#include "chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h" #include "chrome/browser/extensions/api/commands/commands.h" +#include "chrome/browser/extensions/api/content_settings/content_settings_api.h" +#include "chrome/browser/extensions/api/context_menu/context_menu_api.h" +#include "chrome/browser/extensions/api/cookies/cookies_api.h" +#include "chrome/browser/extensions/api/debugger/debugger_api.h" +#include "chrome/browser/extensions/api/declarative/declarative_api.h" #include "chrome/browser/extensions/api/extension_action/extension_browser_actions_api.h" #include "chrome/browser/extensions/api/extension_action/extension_page_actions_api.h" #include "chrome/browser/extensions/api/extension_action/extension_script_badge_api.h" +#include "chrome/browser/extensions/api/font_settings/font_settings_api.h" +#include "chrome/browser/extensions/api/history/history_api.h" +#include "chrome/browser/extensions/api/identity/identity_api.h" +#include "chrome/browser/extensions/api/i18n/i18n_api.h" #include "chrome/browser/extensions/api/idle/idle_api.h" #include "chrome/browser/extensions/api/managed_mode/managed_mode_api.h" +#include "chrome/browser/extensions/api/management/management_api.h" #include "chrome/browser/extensions/api/metrics/metrics.h" #include "chrome/browser/extensions/api/module/module.h" #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" +#include "chrome/browser/extensions/api/page_capture/page_capture_api.h" +#include "chrome/browser/extensions/api/permissions/permissions_api.h" #include "chrome/browser/extensions/api/preference/preference_api.h" +#include "chrome/browser/extensions/api/record/record_api.h" #include "chrome/browser/extensions/api/runtime/runtime_api.h" +#include "chrome/browser/extensions/api/serial/serial_api.h" +#include "chrome/browser/extensions/api/socket/socket_api.h" +#include "chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include "chrome/browser/extensions/api/test/test_api.h" #include "chrome/browser/extensions/api/top_sites/top_sites_api.h" +#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" #include "chrome/browser/extensions/api/web_request/web_request_api.h" #include "chrome/browser/extensions/api/web_socket_proxy_private/web_socket_proxy_private_api.h" #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" +#include "chrome/browser/extensions/settings/settings_api.h" #include "chrome/browser/extensions/system/system_api.h" #include "chrome/browser/infobars/infobar_extension_api.h" #include "chrome/browser/rlz/rlz_extension_api.h" @@ -32,17 +53,18 @@ #if defined(TOOLKIT_VIEWS) #include "chrome/browser/extensions/api/input/input.h" -#endif // defined(TOOLKIT_VIEWS) +#endif #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/extensions/echo_private_api.h" +#include "chrome/browser/chromeos/extensions/file_browser_handler_api.h" #include "chrome/browser/chromeos/extensions/info_private_api.h" #include "chrome/browser/chromeos/extensions/input_method_api.h" #include "chrome/browser/chromeos/extensions/media_player_api.h" #include "chrome/browser/chromeos/extensions/power/power_api.h" #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" #include "chrome/browser/extensions/api/terminal/terminal_private_api.h" -#endif // defined(OS_CHROMEOS) +#endif // static ExtensionFunctionRegistry* ExtensionFunctionRegistry::GetInstance() { @@ -61,6 +83,33 @@ void ExtensionFunctionRegistry::ResetFunctions() { // Register all functions here. + // Windows + RegisterFunction<GetWindowFunction>(); + RegisterFunction<GetCurrentWindowFunction>(); + RegisterFunction<GetLastFocusedWindowFunction>(); + RegisterFunction<GetAllWindowsFunction>(); + RegisterFunction<CreateWindowFunction>(); + RegisterFunction<UpdateWindowFunction>(); + RegisterFunction<RemoveWindowFunction>(); + + // Tabs + RegisterFunction<CaptureVisibleTabFunction>(); + RegisterFunction<CreateTabFunction>(); + RegisterFunction<DetectTabLanguageFunction>(); + RegisterFunction<DuplicateTabFunction>(); + RegisterFunction<GetAllTabsInWindowFunction>(); + RegisterFunction<GetCurrentTabFunction>(); + RegisterFunction<GetSelectedTabFunction>(); + RegisterFunction<GetTabFunction>(); + RegisterFunction<HighlightTabsFunction>(); + RegisterFunction<MoveTabsFunction>(); + RegisterFunction<QueryTabsFunction>(); + RegisterFunction<ReloadTabFunction>(); + RegisterFunction<RemoveTabsFunction>(); + RegisterFunction<TabsExecuteScriptFunction>(); + RegisterFunction<TabsInsertCSSFunction>(); + RegisterFunction<UpdateTabFunction>(); + // Page Actions. RegisterFunction<EnablePageActionsFunction>(); RegisterFunction<DisablePageActionsFunction>(); @@ -105,6 +154,21 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<RemovePasswordsFunction>(); RegisterFunction<RemoveWebSQLFunction>(); + // Bookmarks. + RegisterFunction<extensions::GetBookmarksFunction>(); + RegisterFunction<extensions::GetBookmarkChildrenFunction>(); + RegisterFunction<extensions::GetBookmarkRecentFunction>(); + RegisterFunction<extensions::GetBookmarkTreeFunction>(); + RegisterFunction<extensions::GetBookmarkSubTreeFunction>(); + RegisterFunction<extensions::ImportBookmarksFunction>(); + RegisterFunction<extensions::ExportBookmarksFunction>(); + RegisterFunction<extensions::SearchBookmarksFunction>(); + RegisterFunction<extensions::RemoveBookmarkFunction>(); + RegisterFunction<extensions::RemoveTreeBookmarkFunction>(); + RegisterFunction<extensions::CreateBookmarkFunction>(); + RegisterFunction<extensions::MoveBookmarkFunction>(); + RegisterFunction<extensions::UpdateBookmarkFunction>(); + // Infobars. RegisterFunction<ShowInfoBarFunction>(); @@ -121,10 +185,22 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<extensions::CanEditBookmarkManagerFunction>(); RegisterFunction<extensions::CanOpenNewWindowsBookmarkFunction>(); + // History + RegisterFunction<extensions::AddUrlHistoryFunction>(); + RegisterFunction<extensions::DeleteAllHistoryFunction>(); + RegisterFunction<extensions::DeleteRangeHistoryFunction>(); + RegisterFunction<extensions::DeleteUrlHistoryFunction>(); + RegisterFunction<extensions::GetMostVisitedHistoryFunction>(); + RegisterFunction<extensions::GetVisitsHistoryFunction>(); + RegisterFunction<extensions::SearchHistoryFunction>(); + // Idle RegisterFunction<extensions::IdleQueryStateFunction>(); RegisterFunction<extensions::IdleSetDetectionIntervalFunction>(); + // I18N. + RegisterFunction<GetAcceptLanguagesFunction>(); + // Metrics. RegisterFunction<extensions::MetricsRecordUserActionFunction>(); RegisterFunction<extensions::MetricsRecordValueFunction>(); @@ -144,6 +220,13 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<RlzClearProductStateFunction>(); #endif + // Cookies. + RegisterFunction<extensions::GetCookieFunction>(); + RegisterFunction<extensions::GetAllCookiesFunction>(); + RegisterFunction<extensions::SetCookieFunction>(); + RegisterFunction<extensions::RemoveCookieFunction>(); + RegisterFunction<extensions::GetAllCookieStoresFunction>(); + // Test. RegisterFunction<extensions::TestNotifyPassFunction>(); RegisterFunction<extensions::TestFailFunction>(); @@ -153,6 +236,10 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<extensions::TestSendMessageFunction>(); RegisterFunction<extensions::TestGetConfigFunction>(); + // Record. + RegisterFunction<extensions::CaptureURLsFunction>(); + RegisterFunction<extensions::ReplayURLsFunction>(); + // Accessibility. RegisterFunction<GetFocusedControlFunction>(); RegisterFunction<SetAccessibilityEnabledFunction>(); @@ -161,6 +248,12 @@ void ExtensionFunctionRegistry::ResetFunctions() { // Commands. RegisterFunction<GetAllCommandsFunction>(); + // Context Menus. + RegisterFunction<extensions::CreateContextMenuFunction>(); + RegisterFunction<extensions::UpdateContextMenuFunction>(); + RegisterFunction<extensions::RemoveContextMenuFunction>(); + RegisterFunction<extensions::RemoveAllContextMenusFunction>(); + // Omnibox. RegisterFunction<extensions::OmniboxSendSuggestionsFunction>(); RegisterFunction<extensions::OmniboxSetDefaultSuggestionFunction>(); @@ -189,6 +282,15 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<extensions::GetPolicyFunction>(); RegisterFunction<extensions::SetPolicyFunction>(); + // Management. + RegisterFunction<extensions::GetAllExtensionsFunction>(); + RegisterFunction<extensions::GetExtensionByIdFunction>(); + RegisterFunction<extensions::GetPermissionWarningsByIdFunction>(); + RegisterFunction<extensions::GetPermissionWarningsByManifestFunction>(); + RegisterFunction<extensions::LaunchAppFunction>(); + RegisterFunction<extensions::SetEnabledFunction>(); + RegisterFunction<extensions::UninstallFunction>(); + // Extension module. RegisterFunction<extensions::SetUpdateUrlDataFunction>(); RegisterFunction<extensions::IsAllowedIncognitoAccessFunction>(); @@ -203,9 +305,14 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<extensions::CompleteInstallFunction>(); RegisterFunction<extensions::GetWebGLStatusFunction>(); + // WebNavigation. + RegisterFunction<extensions::GetFrameFunction>(); + RegisterFunction<extensions::GetAllFramesFunction>(); + // WebRequest. RegisterFunction<WebRequestAddEventListener>(); RegisterFunction<WebRequestEventHandled>(); + RegisterFunction<WebRequestHandlerBehaviorChanged>(); // Preferences. RegisterFunction<extensions::GetPreferenceFunction>(); @@ -217,6 +324,9 @@ void ExtensionFunctionRegistry::ResetFunctions() { // Device Customization. RegisterFunction<extensions::GetChromeosInfoFunction>(); + // FileBrowserHandlerInternal. + RegisterFunction<FileHandlerSelectFileFunction>(); + // Mediaplayer RegisterFunction<extensions::PlayMediaplayerFunction>(); RegisterFunction<extensions::GetPlaylistMediaplayerFunction>(); @@ -252,17 +362,83 @@ void ExtensionFunctionRegistry::ResetFunctions() { extensions::WebSocketProxyPrivateGetPassportForTCPFunction>(); RegisterFunction<extensions::WebSocketProxyPrivateGetURLForTCPFunction>(); + // Debugger + RegisterFunction<AttachDebuggerFunction>(); + RegisterFunction<DetachDebuggerFunction>(); + RegisterFunction<SendCommandDebuggerFunction>(); + + // Settings + RegisterFunction<extensions::GetSettingsFunction>(); + RegisterFunction<extensions::SetSettingsFunction>(); + RegisterFunction<extensions::RemoveSettingsFunction>(); + RegisterFunction<extensions::ClearSettingsFunction>(); + RegisterFunction<extensions::GetBytesInUseSettingsFunction>(); + + // Content settings. + RegisterFunction<extensions::GetResourceIdentifiersFunction>(); + RegisterFunction<extensions::ClearContentSettingsFunction>(); + RegisterFunction<extensions::GetContentSettingFunction>(); + RegisterFunction<extensions::SetContentSettingFunction>(); + + // Font settings. + RegisterFunction<extensions::GetFontListFunction>(); + RegisterFunction<extensions::ClearFontFunction>(); + RegisterFunction<extensions::GetFontFunction>(); + RegisterFunction<extensions::SetFontFunction>(); + RegisterFunction<extensions::ClearDefaultFontSizeFunction>(); + RegisterFunction<extensions::GetDefaultFontSizeFunction>(); + RegisterFunction<extensions::SetDefaultFontSizeFunction>(); + RegisterFunction<extensions::ClearDefaultFixedFontSizeFunction>(); + RegisterFunction<extensions::GetDefaultFixedFontSizeFunction>(); + RegisterFunction<extensions::SetDefaultFixedFontSizeFunction>(); + RegisterFunction<extensions::ClearMinimumFontSizeFunction>(); + RegisterFunction<extensions::GetMinimumFontSizeFunction>(); + RegisterFunction<extensions::SetMinimumFontSizeFunction>(); + + // CloudPrint settings. + RegisterFunction<extensions::CloudPrintSetupConnectorFunction>(); + RegisterFunction<extensions::CloudPrintGetHostNameFunction>(); + RegisterFunction<extensions::CloudPrintGetPrintersFunction>(); + // Experimental App API. RegisterFunction<extensions::AppNotifyFunction>(); RegisterFunction<extensions::AppClearAllNotificationsFunction>(); + // Permissions + RegisterFunction<ContainsPermissionsFunction>(); + RegisterFunction<GetAllPermissionsFunction>(); + RegisterFunction<RemovePermissionsFunction>(); + RegisterFunction<RequestPermissionsFunction>(); + + // PageCapture + RegisterFunction<extensions::PageCaptureSaveAsMHTMLFunction>(); + // TopSites RegisterFunction<extensions::GetTopSitesFunction>(); + // Serial + RegisterFunction<extensions::SerialOpenFunction>(); + RegisterFunction<extensions::SerialCloseFunction>(); + RegisterFunction<extensions::SerialReadFunction>(); + RegisterFunction<extensions::SerialWriteFunction>(); + + // Sockets + RegisterFunction<extensions::SocketCreateFunction>(); + RegisterFunction<extensions::SocketDestroyFunction>(); + RegisterFunction<extensions::SocketConnectFunction>(); + RegisterFunction<extensions::SocketDisconnectFunction>(); + RegisterFunction<extensions::SocketReadFunction>(); + RegisterFunction<extensions::SocketWriteFunction>(); + // System RegisterFunction<extensions::GetIncognitoModeAvailabilityFunction>(); RegisterFunction<extensions::GetUpdateStatusFunction>(); + // Net + RegisterFunction<extensions::AddRulesFunction>(); + RegisterFunction<extensions::RemoveRulesFunction>(); + RegisterFunction<extensions::GetRulesFunction>(); + // Runtime RegisterFunction<extensions::RuntimeGetBackgroundPageFunction>(); RegisterFunction<extensions::RuntimeReloadFunction>(); diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 726959e..4917d5f 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -36,7 +36,6 @@ #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" #include "chrome/browser/extensions/api/runtime/runtime_api.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" #include "chrome/browser/extensions/app_notification_manager.h" #include "chrome/browser/extensions/app_sync_data.h" #include "chrome/browser/extensions/browser_event_router.h" @@ -63,6 +62,7 @@ #include "chrome/browser/extensions/pending_extension_manager.h" #include "chrome/browser/extensions/permissions_updater.h" #include "chrome/browser/extensions/platform_app_launcher.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include "chrome/browser/extensions/shell_window_registry.h" #include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/extensions/updater/extension_updater.h" diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc index 718d2bd..d2715bd 100644 --- a/chrome/browser/extensions/platform_app_browsertest.cc +++ b/chrome/browser/extensions/platform_app_browsertest.cc @@ -10,8 +10,8 @@ #include "chrome/browser/automation/automation_util.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/extensions/api/permissions/permissions_api.h" -#include "chrome/browser/extensions/app_restore_service.h" #include "chrome/browser/extensions/app_restore_service_factory.h" +#include "chrome/browser/extensions/app_restore_service.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_service.h" @@ -761,7 +761,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithURL) { #endif IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) { - PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); + RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); const Extension* extension = LoadAndLaunchPlatformApp("optional_permission_request"); ASSERT_TRUE(extension) << "Failed to load extension."; diff --git a/chrome/browser/extensions/platform_app_browsertest_util.cc b/chrome/browser/extensions/platform_app_browsertest_util.cc index f1b78a4..4611c0a 100644 --- a/chrome/browser/extensions/platform_app_browsertest_util.cc +++ b/chrome/browser/extensions/platform_app_browsertest_util.cc @@ -6,7 +6,7 @@ #include "base/command_line.h" #include "base/stringprintf.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/shell_window_registry.h" #include "chrome/browser/ui/browser.h" @@ -93,7 +93,7 @@ ShellWindow* PlatformAppBrowserTest::GetFirstShellWindow() { size_t PlatformAppBrowserTest::RunGetWindowsFunctionForExtension( const Extension* extension) { - scoped_refptr<WindowsGetAllFunction> function = new WindowsGetAllFunction(); + scoped_refptr<GetAllWindowsFunction> function = new GetAllWindowsFunction(); function->set_extension(extension); scoped_ptr<base::ListValue> result(utils::ToList( utils::RunFunctionAndReturnSingleResult(function.get(), @@ -105,7 +105,7 @@ size_t PlatformAppBrowserTest::RunGetWindowsFunctionForExtension( bool PlatformAppBrowserTest::RunGetWindowFunctionForExtension( int window_id, const Extension* extension) { - scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); + scoped_refptr<GetWindowFunction> function = new GetWindowFunction(); function->set_extension(extension); utils::RunFunction( function.get(), diff --git a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc b/chrome/browser/extensions/settings/leveldb_settings_storage_factory.cc index 6fbffbf..d057529 100644 --- a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc +++ b/chrome/browser/extensions/settings/leveldb_settings_storage_factory.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h" +#include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" #include "base/logging.h" #include "chrome/browser/value_store/leveldb_value_store.h" diff --git a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h b/chrome/browser/extensions/settings/leveldb_settings_storage_factory.h index 395fcfc..8a88f0d 100644 --- a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h +++ b/chrome/browser/extensions/settings/leveldb_settings_storage_factory.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" namespace extensions { @@ -22,4 +22,4 @@ class LeveldbSettingsStorageFactory : public SettingsStorageFactory { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_LEVELDB_SETTINGS_STORAGE_FACTORY_H_ diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/settings/managed_value_store_cache.cc index e71d9bf..62eb094 100644 --- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc +++ b/chrome/browser/extensions/settings/managed_value_store_cache.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/managed_value_store_cache.h" +#include "chrome/browser/extensions/settings/managed_value_store_cache.h" #include <set> @@ -12,10 +12,10 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/message_loop_proxy.h" -#include "chrome/browser/extensions/api/storage/policy_value_store.h" -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" #include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/settings/policy_value_store.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" #include "chrome/browser/value_store/value_store_change.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.h b/chrome/browser/extensions/settings/managed_value_store_cache.h index 2862732..9a1ea7b 100644 --- a/chrome/browser/extensions/api/storage/managed_value_store_cache.h +++ b/chrome/browser/extensions/settings/managed_value_store_cache.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_MANAGED_VALUE_STORE_CACHE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_MANAGED_VALUE_STORE_CACHE_H_ #include <map> #include <string> @@ -16,9 +16,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" -#include "chrome/browser/extensions/api/storage/value_store_cache.h" #include "chrome/browser/extensions/event_router.h" +#include "chrome/browser/extensions/settings/settings_observer.h" +#include "chrome/browser/extensions/settings/value_store_cache.h" #include "chrome/browser/policy/policy_service.h" namespace policy { @@ -151,4 +151,4 @@ class ManagedValueStoreCache : public ValueStoreCache, } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_MANAGED_VALUE_STORE_CACHE_H_ diff --git a/chrome/browser/extensions/api/storage/policy_value_store.cc b/chrome/browser/extensions/settings/policy_value_store.cc index 8e84994..88e2de8 100644 --- a/chrome/browser/extensions/api/storage/policy_value_store.cc +++ b/chrome/browser/extensions/settings/policy_value_store.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/policy_value_store.h" +#include "chrome/browser/extensions/settings/policy_value_store.h" #include "base/logging.h" #include "base/values.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" #include "chrome/browser/policy/policy_map.h" #include "chrome/browser/policy/policy_types.h" #include "chrome/browser/value_store/value_store_change.h" diff --git a/chrome/browser/extensions/api/storage/policy_value_store.h b/chrome/browser/extensions/settings/policy_value_store.h index ea4f4da..adf5129 100644 --- a/chrome/browser/extensions/api/storage/policy_value_store.h +++ b/chrome/browser/extensions/settings/policy_value_store.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_POLICY_VALUE_STORE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_POLICY_VALUE_STORE_H_ #include <string> #include <vector> @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" +#include "chrome/browser/extensions/settings/settings_observer.h" #include "chrome/browser/value_store/value_store.h" namespace policy { @@ -72,4 +72,4 @@ class PolicyValueStore : public ValueStore { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_POLICY_VALUE_STORE_H_ diff --git a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc b/chrome/browser/extensions/settings/policy_value_store_unittest.cc index 06f1ad9..0d7fa45 100644 --- a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc +++ b/chrome/browser/extensions/settings/policy_value_store_unittest.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/policy_value_store.h" +#include "chrome/browser/extensions/settings/policy_value_store.h" #include "base/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" +#include "chrome/browser/extensions/settings/settings_observer.h" #include "chrome/browser/policy/policy_map.h" #include "chrome/browser/value_store/leveldb_value_store.h" #include "chrome/browser/value_store/value_store_unittest.h" diff --git a/chrome/browser/extensions/api/storage/setting_sync_data.cc b/chrome/browser/extensions/settings/setting_sync_data.cc index cb4fe79..4baf04c 100644 --- a/chrome/browser/extensions/api/storage/setting_sync_data.cc +++ b/chrome/browser/extensions/settings/setting_sync_data.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/setting_sync_data.h" +#include "chrome/browser/extensions/settings/setting_sync_data.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" diff --git a/chrome/browser/extensions/api/storage/setting_sync_data.h b/chrome/browser/extensions/settings/setting_sync_data.h index 4cecb23..fc9d1d4 100644 --- a/chrome/browser/extensions/api/storage/setting_sync_data.h +++ b/chrome/browser/extensions/settings/setting_sync_data.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTING_SYNC_DATA_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTING_SYNC_DATA_H_ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -88,4 +88,4 @@ typedef std::vector<SettingSyncData> SettingSyncDataList; } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTING_SYNC_DATA_H_ diff --git a/chrome/browser/extensions/api/storage/storage_api.cc b/chrome/browser/extensions/settings/settings_api.cc index 8be3087..35f4eaf 100644 --- a/chrome/browser/extensions/api/storage/storage_api.cc +++ b/chrome/browser/extensions/settings/settings_api.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/storage_api.h" +#include "chrome/browser/extensions/settings/settings_api.h" #include <string> #include <vector> @@ -10,9 +10,9 @@ #include "base/bind.h" #include "base/stringprintf.h" #include "base/values.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extensions_quota_service.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/storage.h" #include "content/public/browser/browser_thread.h" @@ -162,7 +162,7 @@ void GetModificationQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) { } // namespace -bool StorageGetFunction::RunWithStorage(ValueStore* storage) { +bool GetSettingsFunction::RunWithStorage(ValueStore* storage) { Value* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); @@ -201,7 +201,7 @@ bool StorageGetFunction::RunWithStorage(ValueStore* storage) { } } -bool StorageGetBytesInUseFunction::RunWithStorage(ValueStore* storage) { +bool GetBytesInUseSettingsFunction::RunWithStorage(ValueStore* storage) { Value* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); @@ -235,18 +235,18 @@ bool StorageGetBytesInUseFunction::RunWithStorage(ValueStore* storage) { return true; } -bool StorageSetFunction::RunWithStorage(ValueStore* storage) { +bool SetSettingsFunction::RunWithStorage(ValueStore* storage) { DictionaryValue* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input)); } -void StorageSetFunction::GetQuotaLimitHeuristics( +void SetSettingsFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { GetModificationQuotaLimitHeuristics(heuristics); } -bool StorageRemoveFunction::RunWithStorage(ValueStore* storage) { +bool RemoveSettingsFunction::RunWithStorage(ValueStore* storage) { Value* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); @@ -269,16 +269,16 @@ bool StorageRemoveFunction::RunWithStorage(ValueStore* storage) { }; } -void StorageRemoveFunction::GetQuotaLimitHeuristics( +void RemoveSettingsFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { GetModificationQuotaLimitHeuristics(heuristics); } -bool StorageClearFunction::RunWithStorage(ValueStore* storage) { +bool ClearSettingsFunction::RunWithStorage(ValueStore* storage) { return UseWriteResult(storage->Clear()); } -void StorageClearFunction::GetQuotaLimitHeuristics( +void ClearSettingsFunction::GetQuotaLimitHeuristics( QuotaLimitHeuristics* heuristics) const { GetModificationQuotaLimitHeuristics(heuristics); } diff --git a/chrome/browser/extensions/api/storage/storage_api.h b/chrome/browser/extensions/settings/settings_api.h index b217f6d..38a18d5 100644 --- a/chrome/browser/extensions/api/storage/storage_api.h +++ b/chrome/browser/extensions/settings/settings_api.h @@ -2,19 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_STORAGE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_STORAGE_API_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_API_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_API_H_ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" #include "chrome/browser/extensions/extension_function.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_observer.h" #include "chrome/browser/value_store/value_store.h" namespace extensions { // Superclass of all settings functions. +// +// NOTE: these all have "*SettingsFunction" names left over from when the API +// was called the "Settings API" (now "Storage API"). +// TODO(kalman): Rename these functions, and all files under +// chrome/browser/extensions/settings. class SettingsFunction : public AsyncExtensionFunction { protected: SettingsFunction(); @@ -52,23 +57,23 @@ class SettingsFunction : public AsyncExtensionFunction { scoped_refptr<SettingsObserverList> observers_; }; -class StorageGetFunction : public SettingsFunction { +class GetSettingsFunction : public SettingsFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("storage.get"); protected: - virtual ~StorageGetFunction() {} + virtual ~GetSettingsFunction() {} // SettingsFunction: virtual bool RunWithStorage(ValueStore* storage) OVERRIDE; }; -class StorageSetFunction : public SettingsFunction { +class SetSettingsFunction : public SettingsFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("storage.set"); protected: - virtual ~StorageSetFunction() {} + virtual ~SetSettingsFunction() {} // SettingsFunction: virtual bool RunWithStorage(ValueStore* storage) OVERRIDE; @@ -78,12 +83,12 @@ class StorageSetFunction : public SettingsFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; }; -class StorageRemoveFunction : public SettingsFunction { +class RemoveSettingsFunction : public SettingsFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("storage.remove"); protected: - virtual ~StorageRemoveFunction() {} + virtual ~RemoveSettingsFunction() {} // SettingsFunction: virtual bool RunWithStorage(ValueStore* storage) OVERRIDE; @@ -93,12 +98,12 @@ class StorageRemoveFunction : public SettingsFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; }; -class StorageClearFunction : public SettingsFunction { +class ClearSettingsFunction : public SettingsFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("storage.clear"); protected: - virtual ~StorageClearFunction() {} + virtual ~ClearSettingsFunction() {} // SettingsFunction: virtual bool RunWithStorage(ValueStore* storage) OVERRIDE; @@ -108,12 +113,12 @@ class StorageClearFunction : public SettingsFunction { QuotaLimitHeuristics* heuristics) const OVERRIDE; }; -class StorageGetBytesInUseFunction : public SettingsFunction { +class GetBytesInUseSettingsFunction : public SettingsFunction { public: DECLARE_EXTENSION_FUNCTION_NAME("storage.getBytesInUse"); protected: - virtual ~StorageGetBytesInUseFunction() {} + virtual ~GetBytesInUseSettingsFunction() {} // SettingsFunction: virtual bool RunWithStorage(ValueStore* storage) OVERRIDE; @@ -121,4 +126,4 @@ class StorageGetBytesInUseFunction : public SettingsFunction { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_STORAGE_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_API_H_ diff --git a/chrome/browser/extensions/api/storage/settings_apitest.cc b/chrome/browser/extensions/settings/settings_apitest.cc index a5646eb..acfa22d 100644 --- a/chrome/browser/extensions/api/storage/settings_apitest.cc +++ b/chrome/browser/extensions/settings/settings_apitest.cc @@ -4,12 +4,12 @@ #include "base/bind.h" #include "base/json/json_writer.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_test_message_listener.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/extensions/value_builder.h" diff --git a/chrome/browser/extensions/api/storage/settings_backend.cc b/chrome/browser/extensions/settings/settings_backend.cc index 1d8a5d5..99ca5e3 100644 --- a/chrome/browser/extensions/api/storage/settings_backend.cc +++ b/chrome/browser/extensions/settings/settings_backend.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_backend.h" +#include "chrome/browser/extensions/settings/settings_backend.h" #include "base/file_util.h" #include "base/logging.h" -#include "chrome/browser/extensions/api/storage/settings_sync_processor.h" -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" -#include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" +#include "chrome/browser/extensions/settings/settings_sync_processor.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" +#include "chrome/browser/extensions/settings/syncable_settings_storage.h" #include "content/public/browser/browser_thread.h" #include "sync/api/sync_error_factory.h" diff --git a/chrome/browser/extensions/api/storage/settings_backend.h b/chrome/browser/extensions/settings/settings_backend.h index 60073b2..9560c82 100644 --- a/chrome/browser/extensions/api/storage/settings_backend.h +++ b/chrome/browser/extensions/settings/settings_backend.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ #include <map> #include <set> @@ -14,9 +14,9 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/settings_observer.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" #include "sync/api/syncable_service.h" namespace syncer { @@ -113,4 +113,4 @@ class SettingsBackend : public syncer::SyncableService { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_BACKEND_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ diff --git a/chrome/browser/extensions/api/storage/settings_frontend.cc b/chrome/browser/extensions/settings/settings_frontend.cc index 240bc66..b616edd0 100644 --- a/chrome/browser/extensions/api/storage/settings_frontend.cc +++ b/chrome/browser/extensions/settings/settings_frontend.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_frontend.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include <limits> @@ -10,19 +10,19 @@ #include "base/bind_helpers.h" #include "base/file_path.h" #include "base/json/json_reader.h" -#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_backend.h" -#include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h" #include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" +#include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_backend.h" +#include "chrome/browser/extensions/settings/sync_or_local_value_store_cache.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/storage.h" #include "content/public/browser/browser_thread.h" #if defined(ENABLE_CONFIGURATION_POLICY) -#include "chrome/browser/extensions/api/storage/managed_value_store_cache.h" +#include "chrome/browser/extensions/settings/managed_value_store_cache.h" #endif using content::BrowserThread; diff --git a/chrome/browser/extensions/api/storage/settings_frontend.h b/chrome/browser/extensions/settings/settings_frontend.h index 6c655bf..1c53d51 100644 --- a/chrome/browser/extensions/api/storage/settings_frontend.h +++ b/chrome/browser/extensions/settings/settings_frontend.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ #include <map> #include <string> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" -#include "chrome/browser/extensions/api/storage/value_store_cache.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_observer.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/value_store_cache.h" #include "sync/api/syncable_service.h" class Profile; @@ -90,4 +90,4 @@ class SettingsFrontend { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_FRONTEND_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ diff --git a/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc b/chrome/browser/extensions/settings/settings_frontend_unittest.cc index 07a473d..34e2318 100644 --- a/chrome/browser/extensions/api/storage/settings_frontend_unittest.cc +++ b/chrome/browser/extensions/settings/settings_frontend_unittest.cc @@ -2,20 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "testing/gtest/include/gtest/gtest.h" + #include "base/bind.h" #include "base/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/stringprintf.h" -#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_test_util.h" +#include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_test_util.h" #include "chrome/browser/value_store/value_store.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/test/test_browser_thread.h" -#include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; diff --git a/chrome/browser/extensions/api/storage/settings_namespace.cc b/chrome/browser/extensions/settings/settings_namespace.cc index 0b7ee3c..82767ca 100644 --- a/chrome/browser/extensions/api/storage/settings_namespace.cc +++ b/chrome/browser/extensions/settings/settings_namespace.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" #include "base/logging.h" diff --git a/chrome/browser/extensions/api/storage/settings_namespace.h b/chrome/browser/extensions/settings/settings_namespace.h index 1047b45..c89658b 100644 --- a/chrome/browser/extensions/api/storage/settings_namespace.h +++ b/chrome/browser/extensions/settings/settings_namespace.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_NAMESPACE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_NAMESPACE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_NAMESPACE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_NAMESPACE_H_ #include <string> @@ -31,4 +31,4 @@ Namespace FromString(const std::string& ns_string); } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_NAMESPACE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_NAMESPACE_H_ diff --git a/chrome/browser/extensions/api/storage/settings_observer.h b/chrome/browser/extensions/settings/settings_observer.h index 030713e..f789b95 100644 --- a/chrome/browser/extensions/api/storage/settings_observer.h +++ b/chrome/browser/extensions/settings/settings_observer.h @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_OBSERVER_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_OBSERVER_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_OBSERVER_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_OBSERVER_H_ #include "base/observer_list_threadsafe.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" namespace extensions { @@ -27,4 +27,4 @@ typedef ObserverListThreadSafe<SettingsObserver> } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_OBSERVER_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_OBSERVER_H_ diff --git a/chrome/browser/extensions/api/storage/settings_quota_unittest.cc b/chrome/browser/extensions/settings/settings_quota_unittest.cc index 8ed71e8..c8b66c6 100644 --- a/chrome/browser/extensions/api/storage/settings_quota_unittest.cc +++ b/chrome/browser/extensions/settings/settings_quota_unittest.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "testing/gtest/include/gtest/gtest.h" + #include "base/json/json_writer.h" +#include "base/values.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "chrome/browser/extensions/api/storage/settings_backend.h" -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/settings_backend.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" #include "chrome/browser/value_store/testing_value_store.h" -#include "testing/gtest/include/gtest/gtest.h" namespace extensions { diff --git a/chrome/browser/extensions/api/storage/settings_storage_factory.h b/chrome/browser/extensions/settings/settings_storage_factory.h index 4fce4f6..844e80d 100644 --- a/chrome/browser/extensions/api/storage/settings_storage_factory.h +++ b/chrome/browser/extensions/settings/settings_storage_factory.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_FACTORY_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_FACTORY_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_FACTORY_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_FACTORY_H_ #include <string> @@ -33,4 +33,4 @@ class SettingsStorageFactory } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_FACTORY_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_FACTORY_H_ diff --git a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc index cc48ec7..a4c81ef 100644 --- a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc +++ b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" #include "base/bind.h" #include "base/json/json_writer.h" diff --git a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.h index 537ee33..2b71ff9 100644 --- a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h +++ b/chrome/browser/extensions/settings/settings_storage_quota_enforcer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" @@ -66,4 +66,4 @@ class SettingsStorageQuotaEnforcer : public ValueStore { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ diff --git a/chrome/browser/extensions/api/storage/settings_sync_processor.cc b/chrome/browser/extensions/settings/settings_sync_processor.cc index 94de1b6..18c4f07 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_processor.cc +++ b/chrome/browser/extensions/settings/settings_sync_processor.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_sync_processor.h" -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_sync_processor.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" #include "content/public/browser/browser_thread.h" #include "sync/api/sync_change_processor.h" #include "sync/api/sync_data.h" diff --git a/chrome/browser/extensions/api/storage/settings_sync_processor.h b/chrome/browser/extensions/settings/settings_sync_processor.h index 834e026..cd39815 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_processor.h +++ b/chrome/browser/extensions/settings/settings_sync_processor.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_PROCESSOR_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_PROCESSOR_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_PROCESSOR_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_PROCESSOR_H_ #include <set> #include <string> @@ -64,4 +64,4 @@ class SettingsSyncProcessor { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_PROCESSOR_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_PROCESSOR_H_ diff --git a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc b/chrome/browser/extensions/settings/settings_sync_unittest.cc index f8d65f0..1386244 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc +++ b/chrome/browser/extensions/settings/settings_sync_unittest.cc @@ -2,26 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "testing/gtest/include/gtest/gtest.h" + #include "base/bind.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" -#include "chrome/browser/extensions/api/storage/settings_test_util.h" -#include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" #include "chrome/browser/extensions/extension_system.h" +#include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" +#include "chrome/browser/extensions/settings/settings_test_util.h" +#include "chrome/browser/extensions/settings/syncable_settings_storage.h" #include "chrome/browser/extensions/test_extension_service.h" #include "chrome/browser/value_store/testing_value_store.h" #include "content/public/test/test_browser_thread.h" #include "sync/api/sync_change_processor.h" #include "sync/api/sync_error_factory.h" #include "sync/api/sync_error_factory_mock.h" -#include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; diff --git a/chrome/browser/extensions/api/storage/settings_sync_util.cc b/chrome/browser/extensions/settings/settings_sync_util.cc index b9246e0..5c6c28a 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_util.cc +++ b/chrome/browser/extensions/settings/settings_sync_util.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" #include "base/json/json_writer.h" #include "base/values.h" diff --git a/chrome/browser/extensions/api/storage/settings_sync_util.h b/chrome/browser/extensions/settings/settings_sync_util.h index 0c6df046..08769a3 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_util.h +++ b/chrome/browser/extensions/settings/settings_sync_util.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_UTIL_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_UTIL_H_ #include "sync/api/sync_change.h" @@ -48,4 +48,4 @@ syncer::SyncChange CreateDelete( } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_SYNC_UTIL_H_ diff --git a/chrome/browser/extensions/api/storage/settings_test_util.cc b/chrome/browser/extensions/settings/settings_test_util.cc index bd90ae9..7f92850 100644 --- a/chrome/browser/extensions/api/storage/settings_test_util.cc +++ b/chrome/browser/extensions/settings/settings_test_util.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/settings_test_util.h" +#include "chrome/browser/extensions/settings/settings_test_util.h" #include "base/file_path.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" -#include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/common/extensions/extension.h" +#include "chrome/browser/extensions/extension_system_factory.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" namespace extensions { diff --git a/chrome/browser/extensions/api/storage/settings_test_util.h b/chrome/browser/extensions/settings/settings_test_util.h index ee85b4e..d1f3e44 100644 --- a/chrome/browser/extensions/api/storage/settings_test_util.h +++ b/chrome/browser/extensions/settings/settings_test_util.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_TEST_UTIL_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_TEST_UTIL_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ #include <set> #include <string> @@ -12,10 +12,10 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_storage_factory.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_storage_factory.h" #include "chrome/browser/extensions/test_extension_service.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/common/extensions/extension.h" @@ -114,4 +114,4 @@ class ScopedSettingsStorageFactory : public SettingsStorageFactory { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_TEST_UTIL_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_TEST_UTIL_H_ diff --git a/chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.cc b/chrome/browser/extensions/settings/sync_or_local_value_store_cache.cc index 7855b46..e3d951f 100644 --- a/chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.cc +++ b/chrome/browser/extensions/settings/sync_or_local_value_store_cache.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h" +#include "chrome/browser/extensions/settings/sync_or_local_value_store_cache.h" #include "base/bind.h" #include "base/callback.h" #include "base/file_path.h" #include "base/sequenced_task_runner.h" -#include "chrome/browser/extensions/api/storage/settings_backend.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" -#include "chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/settings/settings_backend.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/weak_unlimited_settings_storage.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/permissions/api_permission.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h b/chrome/browser/extensions/settings/sync_or_local_value_store_cache.h index 8438b45..05cd59e 100644 --- a/chrome/browser/extensions/api/storage/sync_or_local_value_store_cache.h +++ b/chrome/browser/extensions/settings/sync_or_local_value_store_cache.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" -#include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.h" -#include "chrome/browser/extensions/api/storage/value_store_cache.h" +#include "chrome/browser/extensions/settings/settings_observer.h" +#include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" +#include "chrome/browser/extensions/settings/value_store_cache.h" class FilePath; @@ -59,4 +59,4 @@ class SyncOrLocalValueStoreCache : public ValueStoreCache { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNC_OR_LOCAL_VALUE_STORE_CACHE_H_ diff --git a/chrome/browser/extensions/api/storage/syncable_settings_storage.cc b/chrome/browser/extensions/settings/syncable_settings_storage.cc index 8f413a8..c4edd9c 100644 --- a/chrome/browser/extensions/api/storage/syncable_settings_storage.cc +++ b/chrome/browser/extensions/settings/syncable_settings_storage.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" +#include "chrome/browser/extensions/settings/syncable_settings_storage.h" -#include "chrome/browser/extensions/api/storage/settings_namespace.h" -#include "chrome/browser/extensions/api/storage/settings_sync_processor.h" -#include "chrome/browser/extensions/api/storage/settings_sync_util.h" +#include "chrome/browser/extensions/settings/settings_namespace.h" +#include "chrome/browser/extensions/settings/settings_sync_processor.h" +#include "chrome/browser/extensions/settings/settings_sync_util.h" #include "content/public/browser/browser_thread.h" #include "sync/api/sync_data.h" #include "sync/protocol/extension_setting_specifics.pb.h" diff --git a/chrome/browser/extensions/api/storage/syncable_settings_storage.h b/chrome/browser/extensions/settings/syncable_settings_storage.h index ec57f83..993a226 100644 --- a/chrome/browser/extensions/api/storage/syncable_settings_storage.h +++ b/chrome/browser/extensions/settings/syncable_settings_storage.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list_threadsafe.h" #include "base/values.h" -#include "chrome/browser/extensions/api/storage/setting_sync_data.h" -#include "chrome/browser/extensions/api/storage/settings_observer.h" +#include "chrome/browser/extensions/settings/setting_sync_data.h" +#include "chrome/browser/extensions/settings/settings_observer.h" #include "chrome/browser/value_store/value_store.h" #include "sync/api/sync_change.h" #include "sync/api/syncable_service.h" @@ -108,4 +108,4 @@ class SyncableSettingsStorage : public ValueStore { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SYNCABLE_SETTINGS_STORAGE_H_ diff --git a/chrome/browser/extensions/api/storage/value_store_cache.cc b/chrome/browser/extensions/settings/value_store_cache.cc index bf68f7f..4d3fd70 100644 --- a/chrome/browser/extensions/api/storage/value_store_cache.cc +++ b/chrome/browser/extensions/settings/value_store_cache.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/value_store_cache.h" +#include "chrome/browser/extensions/settings/value_store_cache.h" namespace extensions { diff --git a/chrome/browser/extensions/api/storage/value_store_cache.h b/chrome/browser/extensions/settings/value_store_cache.h index 9aacc76..b3322f8 100644 --- a/chrome/browser/extensions/api/storage/value_store_cache.h +++ b/chrome/browser/extensions/settings/value_store_cache.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_VALUE_STORE_CACHE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_VALUE_STORE_CACHE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ #include <string> @@ -54,4 +54,4 @@ class ValueStoreCache { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_VALUE_STORE_CACHE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_VALUE_STORE_CACHE_H_ diff --git a/chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.cc b/chrome/browser/extensions/settings/weak_unlimited_settings_storage.cc index 7adf5f4..7afbc2c 100644 --- a/chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.cc +++ b/chrome/browser/extensions/settings/weak_unlimited_settings_storage.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.h" +#include "chrome/browser/extensions/settings/weak_unlimited_settings_storage.h" namespace extensions { diff --git a/chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.h b/chrome/browser/extensions/settings/weak_unlimited_settings_storage.h index c74d57c..c9e6014 100644 --- a/chrome/browser/extensions/api/storage/weak_unlimited_settings_storage.h +++ b/chrome/browser/extensions/settings/weak_unlimited_settings_storage.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ -#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ +#ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ +#define CHROME_BROWSER_EXTENSIONS_SETTINGS_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ #include "base/compiler_specific.h" #include "chrome/browser/value_store/value_store.h" @@ -46,4 +46,4 @@ class WeakUnlimitedSettingsStorage : public ValueStore { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ +#endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ diff --git a/chrome/browser/performance_monitor/performance_monitor.gyp b/chrome/browser/performance_monitor/performance_monitor.gyp index e3587f4..08fe90e 100644 --- a/chrome/browser/performance_monitor/performance_monitor.gyp +++ b/chrome/browser/performance_monitor/performance_monitor.gyp @@ -8,14 +8,14 @@ 'target_name': 'performance_monitor', 'type': 'static_library', 'sources': [ - '<@(schema_files)', + '<@(json_schema_files)', ], 'includes': [ '../../../build/json_schema_compile.gypi', ], 'variables': { 'chromium_code': 1, - 'schema_files': [ + 'json_schema_files': [ 'events.json', ], 'cc_dir': 'chrome/browser/performance_monitor', diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index c888a88..ff03982 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -17,7 +17,7 @@ #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/extensions/api/commands/command_service.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include "chrome/browser/extensions/component_loader.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_web_ui.h" @@ -278,7 +278,7 @@ void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { #endif #if !defined(OS_ANDROID) - TabsCaptureVisibleTabFunction::RegisterUserPrefs(user_prefs); + CaptureVisibleTabFunction::RegisterUserPrefs(user_prefs); ChromeToMobileService::RegisterUserPrefs(user_prefs); DevToolsWindow::RegisterUserPrefs(user_prefs); extensions::CommandService::RegisterUserPrefs(user_prefs); diff --git a/chrome/browser/sync/glue/chrome_extensions_activity_monitor.cc b/chrome/browser/sync/glue/chrome_extensions_activity_monitor.cc index 7518a83..1c6d472 100644 --- a/chrome/browser/sync/glue/chrome_extensions_activity_monitor.cc +++ b/chrome/browser/sync/glue/chrome_extensions_activity_monitor.cc @@ -5,7 +5,7 @@ #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h" #include "base/bind.h" -#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc b/chrome/browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc index 37ddfd6..f03e231 100644 --- a/chrome/browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc +++ b/chrome/browser/sync/glue/chrome_extensions_activity_monitor_unittest.cc @@ -8,7 +8,7 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/values.h" -#include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" +#include "chrome/browser/extensions/api/bookmarks/bookmark_api.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension.h" @@ -86,20 +86,18 @@ class SyncChromeExtensionsActivityMonitorTest : public testing::Test { // 2. Only the mutating events should be recorded by the // syncer::ExtensionsActivityMonitor. TEST_F(SyncChromeExtensionsActivityMonitorTest, Basic) { - FireBookmarksApiEvent<extensions::BookmarksRemoveFunction>(extension1_, 1); - FireBookmarksApiEvent<extensions::BookmarksMoveFunction>(extension1_, 1); - FireBookmarksApiEvent<extensions::BookmarksUpdateFunction>(extension1_, 2); - FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3); - FireBookmarksApiEvent<extensions::BookmarksSearchFunction>(extension1_, 5); + FireBookmarksApiEvent<extensions::RemoveBookmarkFunction>(extension1_, 1); + FireBookmarksApiEvent<extensions::MoveBookmarkFunction>(extension1_, 1); + FireBookmarksApiEvent<extensions::UpdateBookmarkFunction>(extension1_, 2); + FireBookmarksApiEvent<extensions::CreateBookmarkFunction>(extension1_, 3); + FireBookmarksApiEvent<extensions::SearchBookmarksFunction>(extension1_, 5); const uint32 writes_by_extension1 = 1 + 1 + 2 + 3; - FireBookmarksApiEvent<extensions::BookmarksRemoveTreeFunction>( - extension2_, 8); - FireBookmarksApiEvent<extensions::BookmarksGetSubTreeFunction>( - extension2_, 13); - FireBookmarksApiEvent<extensions::BookmarksGetChildrenFunction>( + FireBookmarksApiEvent<extensions::RemoveTreeBookmarkFunction>(extension2_, 8); + FireBookmarksApiEvent<extensions::GetBookmarkTreeFunction>(extension2_, 13); + FireBookmarksApiEvent<extensions::GetBookmarkChildrenFunction>( extension2_, 21); - FireBookmarksApiEvent<extensions::BookmarksGetTreeFunction>(extension2_, 33); + FireBookmarksApiEvent<extensions::GetBookmarksFunction>(extension2_, 33); const uint32 writes_by_extension2 = 8; syncer::ExtensionsActivityMonitor::Records results; @@ -117,8 +115,8 @@ TEST_F(SyncChromeExtensionsActivityMonitorTest, Basic) { // and put the old records back. Those should be merged with the new // records correctly. TEST_F(SyncChromeExtensionsActivityMonitorTest, Put) { - FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 5); - FireBookmarksApiEvent<extensions::BookmarksMoveFunction>(extension2_, 8); + FireBookmarksApiEvent<extensions::CreateBookmarkFunction>(extension1_, 5); + FireBookmarksApiEvent<extensions::MoveBookmarkFunction>(extension2_, 8); syncer::ExtensionsActivityMonitor::Records results; monitor_.GetAndClearRecords(&results); @@ -127,8 +125,8 @@ TEST_F(SyncChromeExtensionsActivityMonitorTest, Put) { EXPECT_EQ(5U, results[id1_].bookmark_write_count); EXPECT_EQ(8U, results[id2_].bookmark_write_count); - FireBookmarksApiEvent<extensions::BookmarksGetTreeFunction>(extension2_, 3); - FireBookmarksApiEvent<extensions::BookmarksUpdateFunction>(extension2_, 2); + FireBookmarksApiEvent<extensions::GetBookmarksFunction>(extension2_, 3); + FireBookmarksApiEvent<extensions::UpdateBookmarkFunction>(extension2_, 2); // Simulate a commit failure, which augments the active record set with the // refugee records. @@ -147,7 +145,7 @@ TEST_F(SyncChromeExtensionsActivityMonitorTest, Put) { // times. The mintor should correctly clear its records every time // they're returned. TEST_F(SyncChromeExtensionsActivityMonitorTest, MultiGet) { - FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 5); + FireBookmarksApiEvent<extensions::CreateBookmarkFunction>(extension1_, 5); syncer::ExtensionsActivityMonitor::Records results; monitor_.GetAndClearRecords(&results); @@ -158,7 +156,7 @@ TEST_F(SyncChromeExtensionsActivityMonitorTest, MultiGet) { monitor_.GetAndClearRecords(&results); EXPECT_TRUE(results.empty()); - FireBookmarksApiEvent<extensions::BookmarksCreateFunction>(extension1_, 3); + FireBookmarksApiEvent<extensions::CreateBookmarkFunction>(extension1_, 3); monitor_.GetAndClearRecords(&results); EXPECT_EQ(1U, results.size()); diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index acdefba..a9d9a52 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -5,11 +5,11 @@ #include "base/command_line.h" #include "build/build_config.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" #include "chrome/browser/extensions/app_notification_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_system_factory.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/prefs/pref_model_associator.h" @@ -46,8 +46,8 @@ #include "chrome/browser/sync/glue/ui_data_type_controller.h" #include "chrome/browser/sync/profile_sync_components_factory_impl.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_syncable_service.h" #include "chrome/browser/webdata/autocomplete_syncable_service.h" #include "chrome/browser/webdata/autofill_profile_syncable_service.h" diff --git a/chrome/browser/sync/test/integration/extension_settings_helper.cc b/chrome/browser/sync/test/integration/extension_settings_helper.cc index be57a4a..5c42b95 100644 --- a/chrome/browser/sync/test/integration/extension_settings_helper.cc +++ b/chrome/browser/sync/test/integration/extension_settings_helper.cc @@ -6,12 +6,12 @@ #include "base/bind.h" #include "base/json/json_writer.h" -#include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/logging.h" #include "base/synchronization/waitable_event.h" #include "base/values.h" -#include "chrome/browser/extensions/api/storage/settings_frontend.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/settings/settings_frontend.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/test/integration/extensions_helper.h" #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm index ebdaa95..97894ed 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm @@ -17,7 +17,7 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" -#include "chrome/browser/extensions/api/tabs/tabs_api.h" +#include "chrome/browser/extensions/api/tabs/tabs.h" #include "chrome/browser/extensions/extension_action.h" #include "chrome/browser/extensions/location_bar_controller.h" #include "chrome/browser/extensions/tab_helper.h" diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 1765329..97b6e33 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -97,14 +97,14 @@ 'browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h', 'browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.cc', 'browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api_constants.h', + 'browser/extensions/api/bookmarks/bookmark_api.cc', + 'browser/extensions/api/bookmarks/bookmark_api.h', 'browser/extensions/api/bookmarks/bookmark_api_constants.cc', 'browser/extensions/api/bookmarks/bookmark_api_constants.h', 'browser/extensions/api/bookmarks/bookmark_api_factory.cc', 'browser/extensions/api/bookmarks/bookmark_api_factory.h', 'browser/extensions/api/bookmarks/bookmark_api_helpers.cc', 'browser/extensions/api/bookmarks/bookmark_api_helpers.h', - 'browser/extensions/api/bookmarks/bookmarks_api.cc', - 'browser/extensions/api/bookmarks/bookmarks_api.h', 'browser/extensions/api/browsing_data/browsing_data_api.cc', 'browser/extensions/api/browsing_data/browsing_data_api.h', 'browser/extensions/api/cloud_print_private/cloud_print_private_api.cc', @@ -123,8 +123,8 @@ 'browser/extensions/api/content_settings/content_settings_store.h', 'browser/extensions/api/commands/commands.cc', 'browser/extensions/api/commands/commands.h', - 'browser/extensions/api/context_menus/context_menus_api.cc', - 'browser/extensions/api/context_menus/context_menus_api.h', + 'browser/extensions/api/context_menu/context_menu_api.cc', + 'browser/extensions/api/context_menu/context_menu_api.h', 'browser/extensions/api/cookies/cookies_api.cc', 'browser/extensions/api/cookies/cookies_api.h', 'browser/extensions/api/cookies/cookies_api_constants.cc', @@ -324,38 +324,6 @@ 'browser/extensions/api/socket/tcp_socket.h', 'browser/extensions/api/socket/udp_socket.cc', 'browser/extensions/api/socket/udp_socket.h', - 'browser/extensions/api/storage/leveldb_settings_storage_factory.cc', - 'browser/extensions/api/storage/leveldb_settings_storage_factory.h', - 'browser/extensions/api/storage/managed_value_store_cache.cc', - 'browser/extensions/api/storage/managed_value_store_cache.h', - 'browser/extensions/api/storage/policy_value_store.cc', - 'browser/extensions/api/storage/policy_value_store.h', - 'browser/extensions/api/storage/setting_sync_data.cc', - 'browser/extensions/api/storage/setting_sync_data.h', - 'browser/extensions/api/storage/settings_backend.cc', - 'browser/extensions/api/storage/settings_backend.h', - 'browser/extensions/api/storage/settings_frontend.cc', - 'browser/extensions/api/storage/settings_frontend.h', - 'browser/extensions/api/storage/settings_namespace.cc', - 'browser/extensions/api/storage/settings_namespace.h', - 'browser/extensions/api/storage/settings_observer.h', - 'browser/extensions/api/storage/settings_storage_factory.h', - 'browser/extensions/api/storage/settings_storage_quota_enforcer.cc', - 'browser/extensions/api/storage/settings_storage_quota_enforcer.h', - 'browser/extensions/api/storage/settings_sync_processor.cc', - 'browser/extensions/api/storage/settings_sync_processor.h', - 'browser/extensions/api/storage/settings_sync_util.cc', - 'browser/extensions/api/storage/settings_sync_util.h', - 'browser/extensions/api/storage/storage_api.cc', - 'browser/extensions/api/storage/storage_api.h', - 'browser/extensions/api/storage/sync_or_local_value_store_cache.cc', - 'browser/extensions/api/storage/sync_or_local_value_store_cache.h', - 'browser/extensions/api/storage/syncable_settings_storage.cc', - 'browser/extensions/api/storage/syncable_settings_storage.h', - 'browser/extensions/api/storage/value_store_cache.cc', - 'browser/extensions/api/storage/value_store_cache.h', - 'browser/extensions/api/storage/weak_unlimited_settings_storage.cc', - 'browser/extensions/api/storage/weak_unlimited_settings_storage.h', 'browser/extensions/api/sync_file_system/extension_sync_event_observer_factory.cc', 'browser/extensions/api/sync_file_system/extension_sync_event_observer_factory.h', 'browser/extensions/api/sync_file_system/extension_sync_event_observer.cc', @@ -399,8 +367,10 @@ 'browser/extensions/api/tab_capture/tab_capture_registry.h', 'browser/extensions/api/tab_capture/tab_capture_registry_factory.cc', 'browser/extensions/api/tab_capture/tab_capture_registry_factory.h', - 'browser/extensions/api/tabs/tabs_api.cc', - 'browser/extensions/api/tabs/tabs_api.h', + 'browser/extensions/api/tabs/execute_code_in_tab_function.cc', + 'browser/extensions/api/tabs/execute_code_in_tab_function.h', + 'browser/extensions/api/tabs/tabs.cc', + 'browser/extensions/api/tabs/tabs.h', 'browser/extensions/api/tabs/tabs_windows_api.cc', 'browser/extensions/api/tabs/tabs_windows_api.h', 'browser/extensions/api/tabs/tabs_constants.cc', @@ -666,6 +636,38 @@ 'browser/extensions/script_bubble_controller.h', 'browser/extensions/script_executor.cc', 'browser/extensions/script_executor.h', + 'browser/extensions/settings/leveldb_settings_storage_factory.cc', + 'browser/extensions/settings/leveldb_settings_storage_factory.h', + 'browser/extensions/settings/managed_value_store_cache.cc', + 'browser/extensions/settings/managed_value_store_cache.h', + 'browser/extensions/settings/policy_value_store.cc', + 'browser/extensions/settings/policy_value_store.h', + 'browser/extensions/settings/setting_sync_data.cc', + 'browser/extensions/settings/setting_sync_data.h', + 'browser/extensions/settings/settings_api.cc', + 'browser/extensions/settings/settings_api.h', + 'browser/extensions/settings/settings_backend.cc', + 'browser/extensions/settings/settings_backend.h', + 'browser/extensions/settings/settings_frontend.cc', + 'browser/extensions/settings/settings_frontend.h', + 'browser/extensions/settings/settings_namespace.cc', + 'browser/extensions/settings/settings_namespace.h', + 'browser/extensions/settings/settings_observer.h', + 'browser/extensions/settings/settings_storage_factory.h', + 'browser/extensions/settings/settings_storage_quota_enforcer.cc', + 'browser/extensions/settings/settings_storage_quota_enforcer.h', + 'browser/extensions/settings/settings_sync_processor.cc', + 'browser/extensions/settings/settings_sync_processor.h', + 'browser/extensions/settings/settings_sync_util.cc', + 'browser/extensions/settings/settings_sync_util.h', + 'browser/extensions/settings/sync_or_local_value_store_cache.cc', + 'browser/extensions/settings/sync_or_local_value_store_cache.h', + 'browser/extensions/settings/syncable_settings_storage.cc', + 'browser/extensions/settings/syncable_settings_storage.h', + 'browser/extensions/settings/value_store_cache.cc', + 'browser/extensions/settings/value_store_cache.h', + 'browser/extensions/settings/weak_unlimited_settings_storage.cc', + 'browser/extensions/settings/weak_unlimited_settings_storage.h', 'browser/extensions/shell_window_geometry_cache.cc', 'browser/extensions/shell_window_geometry_cache.h', 'browser/extensions/shell_window_registry.cc', @@ -784,7 +786,6 @@ ['include', '^browser/extensions/api/proxy/proxy_api_constants.cc'], ['include', '^browser/extensions/api/push_messaging/push_messaging_api.cc'], ['include', '^browser/extensions/api/runtime/runtime_api.cc'], - ['include', '^browser/extensions/api/storage/.*\.cc'], ['include', '^browser/extensions/api/system_info_cpu/cpu_info_provider.cc'], ['include', '^browser/extensions/api/system_info_cpu/cpu_info_provider_android.cc'], ['include', '^browser/extensions/api/tabs/tabs_constants.cc'], @@ -831,10 +832,10 @@ ], }, { # configuration_policy==0 'sources!': [ - 'browser/extensions/api/storage/managed_value_store_cache.cc', - 'browser/extensions/api/storage/managed_value_store_cache.h', - 'browser/extensions/api/storage/policy_value_store.cc', - 'browser/extensions/api/storage/policy_value_store.h', + 'browser/extensions/settings/managed_value_store_cache.cc', + 'browser/extensions/settings/managed_value_store_cache.h', + 'browser/extensions/settings/policy_value_store.cc', + 'browser/extensions/settings/policy_value_store.h', ], }], ['OS=="win"', { diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 7449b3e..ad69e62 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -969,7 +969,7 @@ 'browser/extensions/api/browsing_data/browsing_data_test.cc', 'browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc', 'browser/extensions/api/content_settings/content_settings_apitest.cc', - 'browser/extensions/api/context_menus/context_menu_apitest.cc', + 'browser/extensions/api/context_menu/context_menu_apitest.cc', 'browser/extensions/api/cookies/cookies_apitest.cc', 'browser/extensions/api/debugger/debugger_apitest.cc', 'browser/extensions/api/declarative/declarative_apitest.cc', @@ -1088,7 +1088,7 @@ 'browser/extensions/process_management_browsertest.cc', 'browser/extensions/requirements_checker_browsertest.cc', 'browser/extensions/sandboxed_pages_apitest.cc', - 'browser/extensions/api/storage/settings_apitest.cc', + 'browser/extensions/settings/settings_apitest.cc', 'browser/extensions/stubs_apitest.cc', 'browser/extensions/subscribe_page_action_browsertest.cc', 'browser/extensions/system/system_apitest.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index e0240b7..16a90bd 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -735,12 +735,12 @@ 'browser/extensions/sandboxed_unpacker_unittest.cc', 'browser/extensions/script_badge_controller_unittest.cc', 'browser/extensions/script_bubble_controller_unittest.cc', - 'browser/extensions/api/storage/policy_value_store_unittest.cc', - 'browser/extensions/api/storage/settings_frontend_unittest.cc', - 'browser/extensions/api/storage/settings_quota_unittest.cc', - 'browser/extensions/api/storage/settings_sync_unittest.cc', - 'browser/extensions/api/storage/settings_test_util.cc', - 'browser/extensions/api/storage/settings_test_util.h', + 'browser/extensions/settings/policy_value_store_unittest.cc', + 'browser/extensions/settings/settings_frontend_unittest.cc', + 'browser/extensions/settings/settings_quota_unittest.cc', + 'browser/extensions/settings/settings_sync_unittest.cc', + 'browser/extensions/settings/settings_test_util.cc', + 'browser/extensions/settings/settings_test_util.h', 'browser/extensions/shell_window_geometry_cache_unittest.cc', 'browser/extensions/standard_management_policy_provider_unittest.cc', 'browser/extensions/updater/extension_updater_unittest.cc', @@ -1788,7 +1788,7 @@ }], ['configuration_policy==0', { 'sources!': [ - 'browser/extensions/api/storage/policy_value_store_unittest.cc', + 'browser/extensions/settings/policy_value_store_unittest.cc', 'browser/managed_mode/managed_mode_url_filter_unittest.cc', 'browser/prefs/proxy_policy_unittest.cc', 'browser/ui/webui/policy_ui_unittest.cc', diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp index fce4407..95af0dc 100644 --- a/chrome/common/extensions/api/api.gyp +++ b/chrome/common/extensions/api/api.gyp @@ -8,7 +8,8 @@ 'target_name': 'api', 'type': 'static_library', 'sources': [ - '<@(schema_files)', + '<@(idl_schema_files)', + '<@(json_schema_files)', ], 'includes': [ '../../../../build/json_schema_bundle_compile.gypi', @@ -16,71 +17,75 @@ ], 'variables': { 'chromium_code': 1, - 'schema_files': [ - 'alarms.idl', - 'app_current_window_internal.idl', - 'app_runtime.idl', - 'app_window.idl', - 'autotest_private.idl', - 'bluetooth.idl', + 'json_schema_files': [ 'bookmarks.json', 'cloud_print_private.json', 'content_settings.json', 'context_menus.json', 'cookies.json', 'debugger.json', + 'events.json', + 'experimental_history.json', + 'experimental_record.json', + 'file_browser_handler_internal.json', + 'i18n.json', + 'font_settings.json', + 'history.json', + 'management.json', + 'page_capture.json', + 'permissions.json', + 'storage.json', + 'tabs.json', + 'web_navigation.json', + 'web_request.json', + 'windows.json', + ], + 'idl_schema_files': [ + 'alarms.idl', + 'app_current_window_internal.idl', + 'app_runtime.idl', + 'app_window.idl', + 'autotest_private.idl', + 'bluetooth.idl', 'developer_private.idl', 'dial.idl', 'downloads.idl', - 'events.json', 'experimental_discovery.idl', 'experimental_dns.idl', - 'experimental_history.json', 'experimental_identity.idl', 'experimental_idltest.idl', 'experimental_media_galleries.idl', 'experimental_notification.idl', - 'experimental_record.json', 'experimental_system_info_cpu.idl', 'experimental_system_info_display.idl', 'experimental_system_info_memory.idl', 'experimental_system_info_storage.idl', - 'file_browser_handler_internal.json', 'file_system.idl', - 'font_settings.json', - 'history.json', - 'i18n.json', - 'management.json', 'media_galleries.idl', 'media_galleries_private.idl', - 'page_capture.json', - 'permissions.json', 'push_messaging.idl', 'rtc_private.idl', 'serial.idl', 'socket.idl', - 'storage.json', 'sync_file_system.idl', 'system_indicator.idl', 'tab_capture.idl', - 'tabs.json', 'usb.idl', - 'web_navigation.json', - 'web_request.json', - 'windows.json', ], 'cc_dir': 'chrome/common/extensions/api', 'root_namespace': 'extensions::api', }, 'conditions': [ ['OS=="android"', { - 'schema_files!': [ + 'idl_schema_files!': [ 'usb.idl', ], }], ['OS!="chromeos"', { - 'schema_files!': [ + 'json_schema_files!': [ 'file_browser_handler_internal.json', + ], + 'idl_schema_files!': [ 'rtc_private.idl', ], }], diff --git a/chrome/common/extensions/api/content_settings.json b/chrome/common/extensions/api/content_settings.json index 43643dd..3c04bac 100644 --- a/chrome/common/extensions/api/content_settings.json +++ b/chrome/common/extensions/api/content_settings.json @@ -5,9 +5,6 @@ [ { "namespace": "contentSettings", - "compiler_options": { - "generate_type_functions": true - }, "types": [ { "id": "ResourceIdentifier", diff --git a/chrome/common/extensions/api/events.json b/chrome/common/extensions/api/events.json index b003fb6..cacc8dc 100644 --- a/chrome/common/extensions/api/events.json +++ b/chrome/common/extensions/api/events.json @@ -5,10 +5,6 @@ [ { "namespace": "events", - "compiler_options": { - "implemented_in": "chrome/browser/extensions/api/declarative/declarative_api.h", - "generate_type_functions": true - }, "internal": true, "unprivileged": true, "types": [ diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index 85207e7..fc38a24 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -344,6 +344,8 @@ void ExtensionAPI::InitDefaultConfiguration() { CHECK(unloaded_schemas_.empty()); RegisterSchema("app", ReadFromResource( IDR_EXTENSION_API_JSON_APP)); + RegisterSchema("bookmarks", ReadFromResource( + IDR_EXTENSION_API_JSON_BOOKMARKS)); RegisterSchema("bookmarkManagerPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_BOOKMARKMANAGERPRIVATE)); RegisterSchema("browserAction", ReadFromResource( @@ -352,16 +354,30 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_BROWSINGDATA)); RegisterSchema("chromeosInfoPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_CHROMEOSINFOPRIVATE)); + RegisterSchema("cloudPrintPrivate", ReadFromResource( + IDR_EXTENSION_API_JSON_CLOUDPRINTPRIVATE)); RegisterSchema("commands", ReadFromResource( IDR_EXTENSION_API_JSON_COMMANDS)); + RegisterSchema("contentSettings", ReadFromResource( + IDR_EXTENSION_API_JSON_CONTENTSETTINGS)); + RegisterSchema("contextMenus", ReadFromResource( + IDR_EXTENSION_API_JSON_CONTEXTMENUS)); + RegisterSchema("cookies", ReadFromResource( + IDR_EXTENSION_API_JSON_COOKIES)); + RegisterSchema("debugger", ReadFromResource( + IDR_EXTENSION_API_JSON_DEBUGGER)); RegisterSchema("declarativeWebRequest", ReadFromResource( IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST)); RegisterSchema("devtools", ReadFromResource( IDR_EXTENSION_API_JSON_DEVTOOLS)); + RegisterSchema("events", ReadFromResource( + IDR_EXTENSION_API_JSON_EVENTS)); RegisterSchema("experimental.accessibility", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY)); RegisterSchema("experimental.app", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP)); + RegisterSchema("experimental.history", ReadFromResource( + IDR_EXTENSION_API_JSON_EXPERIMENTAL_HISTORY)); RegisterSchema("experimental.infobars", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS)); RegisterSchema("experimental.input.virtualKeyboard", ReadFromResource( @@ -370,6 +386,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXPERIMENTAL_POWER)); RegisterSchema("experimental.processes", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES)); + RegisterSchema("experimental.record", ReadFromResource( + IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD)); RegisterSchema("experimental.rlz", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ)); RegisterSchema("runtime", ReadFromResource( @@ -380,8 +398,16 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXTENSION)); RegisterSchema("fileBrowserHandler", ReadFromResource( IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER)); + RegisterSchema("fileBrowserHandlerInternal", ReadFromResource( + IDR_EXTENSION_API_JSON_FILEBROWSERHANDLERINTERNAL)); RegisterSchema("fileBrowserPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE)); + RegisterSchema("fontSettings", ReadFromResource( + IDR_EXTENSION_API_JSON_FONTSSETTINGS)); + RegisterSchema("history", ReadFromResource( + IDR_EXTENSION_API_JSON_HISTORY)); + RegisterSchema("i18n", ReadFromResource( + IDR_EXTENSION_API_JSON_I18N)); RegisterSchema("idle", ReadFromResource( IDR_EXTENSION_API_JSON_IDLE)); RegisterSchema("input.ime", ReadFromResource( @@ -390,6 +416,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE)); RegisterSchema("managedModePrivate", ReadFromResource( IDR_EXTENSION_API_JSON_MANAGEDMODEPRIVATE)); + RegisterSchema("management", ReadFromResource( + IDR_EXTENSION_API_JSON_MANAGEMENT)); RegisterSchema("mediaPlayerPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_MEDIAPLAYERPRIVATE)); RegisterSchema("metricsPrivate", ReadFromResource( @@ -402,6 +430,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_PAGEACTION)); RegisterSchema("pageActions", ReadFromResource( IDR_EXTENSION_API_JSON_PAGEACTIONS)); + RegisterSchema("pageCapture", ReadFromResource( + IDR_EXTENSION_API_JSON_PAGECAPTURE)); RegisterSchema("permissions", ReadFromResource( IDR_EXTENSION_API_JSON_PERMISSIONS)); RegisterSchema("privacy", ReadFromResource( @@ -410,8 +440,12 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_PROXY)); RegisterSchema("scriptBadge", ReadFromResource( IDR_EXTENSION_API_JSON_SCRIPTBADGE)); + RegisterSchema("storage", ReadFromResource( + IDR_EXTENSION_API_JSON_STORAGE)); RegisterSchema("systemPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_SYSTEMPRIVATE)); + RegisterSchema("tabs", ReadFromResource( + IDR_EXTENSION_API_JSON_TABS)); RegisterSchema("terminalPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_TERMINALPRIVATE)); RegisterSchema("test", ReadFromResource( @@ -426,6 +460,10 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_TYPES)); RegisterSchema("wallpaperPrivate", ReadFromResource( IDR_EXTENSION_API_JSON_WALLPAPERPRIVATE)); + RegisterSchema("webNavigation", ReadFromResource( + IDR_EXTENSION_API_JSON_WEBNAVIGATION)); + RegisterSchema("webRequest", ReadFromResource( + IDR_EXTENSION_API_JSON_WEBREQUEST)); RegisterSchema("webRequestInternal", ReadFromResource( IDR_EXTENSION_API_JSON_WEBREQUESTINTERNAL)); RegisterSchema("webSocketProxyPrivate", ReadFromResource( @@ -434,6 +472,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_WEBSTORE)); RegisterSchema("webstorePrivate", ReadFromResource( IDR_EXTENSION_API_JSON_WEBSTOREPRIVATE)); + RegisterSchema("windows", ReadFromResource( + IDR_EXTENSION_API_JSON_WINDOWS)); // Schemas to be loaded via JSON generated from IDL files. GeneratedSchemas::Get(&unloaded_schemas_); diff --git a/chrome/common/extensions/api/file_browser_handler_internal.json b/chrome/common/extensions/api/file_browser_handler_internal.json index a50a0a8..38fa8d3 100644 --- a/chrome/common/extensions/api/file_browser_handler_internal.json +++ b/chrome/common/extensions/api/file_browser_handler_internal.json @@ -5,9 +5,6 @@ [ { "namespace": "fileBrowserHandlerInternal", - "compiler_options": { - "implemented_in": "chrome/browser/chromeos/extensions/file_browser_handler_api.h" - }, "nodoc": true, "internal": true, "platforms": ["chromeos"], diff --git a/chrome/common/extensions/api/i18n.json b/chrome/common/extensions/api/i18n.json index 765760d..db3c3f6 100644 --- a/chrome/common/extensions/api/i18n.json +++ b/chrome/common/extensions/api/i18n.json @@ -23,7 +23,6 @@ }, { "name": "getMessage", - "nocompile": true, "type": "function", "unprivileged": true, "description": "Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the <code>getMessage()</code> call is wrong — for example, <em>messageName</em> is not a string or the <em>substitutions</em> array has more than 9 elements — this method returns <code>undefined</code>.", diff --git a/chrome/common/extensions/api/storage.json b/chrome/common/extensions/api/storage.json index a75de09..3e02335 100644 --- a/chrome/common/extensions/api/storage.json +++ b/chrome/common/extensions/api/storage.json @@ -6,9 +6,6 @@ { "namespace": "storage", "unprivileged": true, - "compiler_options": { - "generate_type_functions": true - }, "types": [ { "id": "StorageChange", diff --git a/chrome/common/extensions/api/windows.json b/chrome/common/extensions/api/windows.json index ee0702b..dbfe080 100644 --- a/chrome/common/extensions/api/windows.json +++ b/chrome/common/extensions/api/windows.json @@ -5,9 +5,6 @@ [ { "namespace": "windows", - "compiler_options": { - "implemented_in": "chrome/browser/extensions/api/tabs/tabs_api.h" - }, "dependencies": [ "tabs" ], "types": [ { diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py index 5cb8824..8826768 100644 --- a/chrome/common/extensions/docs/server2/api_data_source.py +++ b/chrome/common/extensions/docs/server2/api_data_source.py @@ -14,10 +14,9 @@ import third_party.json_schema_compiler.idl_schema as idl_schema import third_party.json_schema_compiler.idl_parser as idl_parser # Increment this version when there are changes to the data stored in any of -# the caches used by APIDataSource. This would include changes to model.py in -# JSON schema compiler! This allows the cache to be invalidated without having -# to flush memcache on the production server. -_VERSION = 10 +# the caches used by APIDataSource. This allows the cache to be invalidated +# without having to flush memcache on the production server. +_VERSION = 9 def _RemoveNoDocs(item): if json_parse.IsDict(item): diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index 915a1c8..bbf2c0d 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -10,40 +10,57 @@ <release seq="1"> <includes> <include name="IDR_EXTENSION_API_JSON_APP" file="extensions\api\app.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_BOOKMARKS" file="extensions\api\bookmarks.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_BOOKMARKMANAGERPRIVATE" file="extensions\api\bookmark_manager_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_BROWSERACTION" file="extensions\api\browser_action.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_BROWSINGDATA" file="extensions\api\browsing_data.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_CHROMEOSINFOPRIVATE" file="extensions\api\chromeos_info_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_CLOUDPRINTPRIVATE" file="extensions\api\cloud_print_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_COMMANDS" file="extensions\api\commands.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_CONTENTSETTINGS" file="extensions\api\content_settings.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_CONTEXTMENUS" file="extensions\api\context_menus.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_COOKIES" file="extensions\api\cookies.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_DEBUGGER" file="extensions\api\debugger.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST" file="extensions\api\declarative_web_request.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_DEVTOOLS" file="extensions\api\devtools.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_ECHOPRIVATE" file="extensions\api\echo_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_EVENTS" file="extensions\api\events.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental_accessibility.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental_app.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_HISTORY" file="extensions\api\experimental_history.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS" file="extensions\api\experimental_infobars.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD" file="extensions\api\experimental_input_virtual_keyboard.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_POWER" file="extensions\api\experimental_power.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES" file="extensions\api\experimental_processes.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD" file="extensions\api\experimental_record.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ" file="extensions\api\experimental_rlz.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_SPEECHINPUT" file="extensions\api\experimental_speech_input.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXTENSION" file="extensions\api\extension.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER" file="extensions\api\file_browser_handler.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_FILEBROWSERHANDLERINTERNAL" file="extensions\api\file_browser_handler_internal.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE" file="extensions\api\file_browser_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_FONTSSETTINGS" file="extensions\api\font_settings.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_HISTORY" file="extensions\api\history.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_I18N" file="extensions\api\i18n.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_INPUT_IME" file="extensions\api\input_ime.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_IDLE" file="extensions\api\idle.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE" file="extensions\api\input_method_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_MANAGEDMODEPRIVATE" file="extensions\api\managed_mode_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_MANAGEMENT" file="extensions\api\management.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_MEDIAPLAYERPRIVATE" file="extensions\api\media_player_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_METRICSPRIVATE" file="extensions\api\metrics_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_OMNIBOX" file="extensions\api\omnibox.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PAGEACTION" file="extensions\api\page_action.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PAGEACTIONS" file="extensions\api\page_actions.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_PAGECAPTURE" file="extensions\api\page_capture.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PERMISSIONS" file="extensions\api\permissions.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PRIVACY" file="extensions\api\privacy.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PROXY" file="extensions\api\proxy.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_RUNTIME" file="extensions\api\runtime.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_SCRIPTBADGE" file="extensions\api\script_badge.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_STORAGE" file="extensions\api\storage.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_SYSTEMPRIVATE" file="extensions\api\system_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_TABS" file="extensions\api\tabs.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TERMINALPRIVATE" file="extensions\api\terminal_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TEST" file="extensions\api\test.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TOPSITES" file="extensions\api\top_sites.json" type="BINDATA" /> @@ -51,10 +68,13 @@ <include name="IDR_EXTENSION_API_JSON_TTSENGINE" file="extensions\api\tts_engine.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TYPES" file="extensions\api\types.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WALLPAPERPRIVATE" file="extensions\api\wallpaper_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_WEBNAVIGATION" file="extensions\api\web_navigation.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_WEBREQUEST" file="extensions\api\web_request.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBSOCKETPROXYPRIVATE" file="extensions\api\web_socket_proxy_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBREQUESTINTERNAL" file="extensions\api\web_request_internal.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBSTORE" file="extensions\api\webstore.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBSTOREPRIVATE" file="extensions\api\webstore_private.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_WINDOWS" file="extensions\api\windows.json" type="BINDATA" /> </includes> </release> </grit> diff --git a/tools/json_schema_compiler/code.py b/tools/json_schema_compiler/code.py index e4326d4..07f6574 100644 --- a/tools/json_schema_compiler/code.py +++ b/tools/json_schema_compiler/code.py @@ -14,17 +14,15 @@ class Code(object): self._indent_size = indent_size self._comment_length = comment_length - def Append(self, line='', substitute=True, indent_level=None): + def Append(self, line='', substitute=True): """Appends a line of code at the current indent level or just a newline if line is not specified. Trailing whitespace is stripped. substitute: indicated whether this line should be affected by code.Substitute(). """ - if indent_level is None: - indent_level = self._indent_level - self._code.append(Line(((' ' * indent_level) + line).rstrip(), - substitute=substitute)) + self._code.append(Line(((' ' * self._indent_level) + line).rstrip(), + substitute=substitute)) return self def IsEmpty(self): diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py index a347541..ae92373 100755 --- a/tools/json_schema_compiler/compiler.py +++ b/tools/json_schema_compiler/compiler.py @@ -69,16 +69,13 @@ def handle_single_schema(filename, dest_dir, root, root_namespace): referenced_api_defs = json_schema.Load(referenced_schema_path) for namespace in referenced_api_defs: - api_model.AddNamespace( - namespace, + api_model.AddNamespace(namespace, os.path.relpath(referenced_schema_path, opts.root)) # Gets the relative path from opts.root to the schema to correctly determine # the include path. relpath = os.path.relpath(schema, opts.root) - namespace = api_model.AddNamespace(target_namespace, - relpath, - include_compiler_options=True) + namespace = api_model.AddNamespace(target_namespace, relpath) if not namespace: continue @@ -133,9 +130,7 @@ def handle_bundle_schema(filenames, dest_dir, root, root_namespace): relpath = os.path.relpath(os.path.normpath(filenames[0]), root) for target_namespace, schema_filename in zip(api_defs, filenames): - namespace = api_model.AddNamespace(target_namespace, - relpath, - include_compiler_options=True) + namespace = api_model.AddNamespace(target_namespace, relpath) path, filename = os.path.split(schema_filename) short_filename, extension = os.path.splitext(filename) diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py index 36be5a3..b583712 100644 --- a/tools/json_schema_compiler/model.py +++ b/tools/json_schema_compiler/model.py @@ -26,12 +26,10 @@ class Model(object): def __init__(self): self.namespaces = {} - def AddNamespace(self, json, source_file, include_compiler_options=False): + def AddNamespace(self, json, source_file): """Add a namespace's json to the model and returns the namespace. """ - namespace = Namespace(json, - source_file, - include_compiler_options=include_compiler_options) + namespace = Namespace(json, source_file) self.namespaces[namespace.name] = namespace return namespace @@ -44,28 +42,21 @@ class Namespace(object): - |source_file| the file that contained the namespace definition - |source_file_dir| the directory component of |source_file| - |source_file_filename| the filename component of |source_file| - - |platforms| if not None, the list of platforms that the namespace is - available to - |types| a map of type names to their model.Type - |functions| a map of function names to their model.Function - |events| a map of event names to their model.Function - |properties| a map of property names to their model.Property - - |compiler_options| the compiler_options dict, only present if - |include_compiler_options| is True """ - def __init__(self, json, source_file, include_compiler_options=False): + def __init__(self, json, source_file): self.name = json['namespace'] self.unix_name = UnixName(self.name) self.source_file = source_file self.source_file_dir, self.source_file_filename = os.path.split(source_file) self.parent = None - self.platforms = _GetPlatforms(json) _AddTypes(self, json, self) _AddFunctions(self, json, self) _AddEvents(self, json, self) _AddProperties(self, json, self) - if include_compiler_options: - self.compiler_options = json.get('compiler_options', {}) class Type(object): """A Type defined in the json. @@ -136,15 +127,13 @@ class Function(object): Properties: - |name| the function name - - |platforms| if not None, the list of platforms that the function is - available to - |params| a list of parameters to the function (order matters). A separate - parameter is used for each choice of a 'choices' parameter + parameter is used for each choice of a 'choices' parameter. - |description| a description of the function (if provided) - |callback| the callback parameter to the function. There should be exactly - one + one - |optional| whether the Function is "optional"; this only makes sense to be - present when the Function is representing a callback property + present when the Function is representing a callback property. - |simple_name| the name of this Function without a namespace """ def __init__(self, @@ -155,7 +144,6 @@ class Function(object): from_client=False): self.name = json['name'] self.simple_name = _StripNamespace(self.name, namespace) - self.platforms = _GetPlatforms(json) self.params = [] self.description = json.get('description') self.callback = None @@ -369,37 +357,23 @@ class Property(object): unix_name = property(GetUnixName, SetUnixName) -class _Enum(object): - """Superclass for enum types with a "name" field, setting up repr/eq/ne. - Enums need to do this so that equality/non-equality work over pickling. +class _PropertyTypeInfo(object): + """This class is not an inner class of |PropertyType| so it can be pickled. """ - - @staticmethod - def GetAll(cls): - """Yields all _Enum objects declared in |cls|. - """ - for prop_key in dir(cls): - prop_value = getattr(cls, prop_key) - if isinstance(prop_value, _Enum): - yield prop_value - - def __init__(self, name): + def __init__(self, is_fundamental, name): + self.is_fundamental = is_fundamental self.name = name - def __repr(self): + def __repr__(self): return self.name def __eq__(self, other): - return type(other) == type(self) and other.name == self.name + return isinstance(other, _PropertyTypeInfo) and self.name == other.name def __ne__(self, other): + # Yes. You seriously do need this. return not (self == other) -class _PropertyTypeInfo(_Enum): - def __init__(self, is_fundamental, name): - _Enum.__init__(self, name) - self.is_fundamental = is_fundamental - class PropertyType(object): """Enum of different types of properties/parameters. """ @@ -487,27 +461,3 @@ def _AddProperties(model, namespace, from_json=from_json, from_client=from_client) - -class _PlatformInfo(_Enum): - def __init__(self, name): - _Enum.__init__(self, name) - -class Platforms(object): - """Enum of the possible platforms. - """ - CHROMEOS = _PlatformInfo("chromeos") - CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch") - LINUX = _PlatformInfo("linux") - MAC = _PlatformInfo("mac") - WIN = _PlatformInfo("win") - -def _GetPlatforms(json): - if 'platforms' not in json: - return None - platforms = [] - for platform_name in json['platforms']: - for platform_enum in _Enum.GetAll(Platforms): - if platform_name == platform_enum.name: - platforms.append(platform_enum) - break - return platforms diff --git a/tools/json_schema_compiler/schema_bundle_generator.py b/tools/json_schema_compiler/schema_bundle_generator.py index 3272be1..d391ea7 100644 --- a/tools/json_schema_compiler/schema_bundle_generator.py +++ b/tools/json_schema_compiler/schema_bundle_generator.py @@ -4,7 +4,6 @@ import code import cpp_util -from model import Platforms from schema_util import CapitalizeFirstLetter from schema_util import JsFunctionNameToClassName @@ -45,20 +44,6 @@ class SchemaBundleGenerator(object): c.Append() return c - def _GetPlatformIfdefs(self, model_object): - """Generates the "defined" conditional for an #if check if |model_object| - has platform restrictions. Returns None if there are no restrictions. - """ - if model_object.platforms is None: - return None - ifdefs = [] - for platform in model_object.platforms: - if platform == Platforms.CHROMEOS: - ifdefs.append('defined(OS_CHROMEOS)') - else: - raise ValueError("Unsupported platform ifdef: %s" % platform.name) - return ' and '.join(ifdefs) - def GenerateAPIHeader(self): """Generates the header for API registration / declaration""" c = code.Code() @@ -68,19 +53,9 @@ class SchemaBundleGenerator(object): c.Append('#include "base/basictypes.h"') for namespace in self._model.namespaces.values(): - ifdefs = self._GetPlatformIfdefs(namespace) - if ifdefs is not None: - c.Append("#if %s" % ifdefs, indent_level=0) - namespace_name = namespace.unix_name.replace("experimental_", "") - implementation_header = namespace.compiler_options.get( - "implemented_in", - "chrome/browser/extensions/api/%s/%s_api.h" % (namespace_name, - namespace_name)) - c.Append('#include "%s"' % implementation_header) - - if ifdefs is not None: - c.Append("#endif // %s" % ifdefs, indent_level=0) + c.Append('#include "chrome/browser/extensions/api/%s/%s_api.h"' % ( + namespace_name, namespace_name)) c.Append() c.Append("class ExtensionFunctionRegistry;") @@ -95,41 +70,20 @@ class SchemaBundleGenerator(object): c.Append() return self.GenerateHeader('generated_api', c) - def _GetNamespaceFunctions(self, namespace): - functions = list(namespace.functions.values()) - if namespace.compiler_options.get("generate_type_functions", False): - for type_ in namespace.types.values(): - functions += list(type_.functions.values()) - return functions - def GenerateFunctionRegistry(self): c = code.Code() c.Sblock("class GeneratedFunctionRegistry {") - c.Append(" public:") + c.Append("public:") c.Sblock("static void RegisterAll(ExtensionFunctionRegistry* registry) {") for namespace in self._model.namespaces.values(): - namespace_ifdefs = self._GetPlatformIfdefs(namespace) - if namespace_ifdefs is not None: - c.Append("#if %s" % namespace_ifdefs, indent_level=0) - namespace_name = CapitalizeFirstLetter(namespace.name.replace( "experimental.", "")) - for function in self._GetNamespaceFunctions(namespace): + for function in namespace.functions.values(): if function.nocompile: continue - function_ifdefs = self._GetPlatformIfdefs(function) - if function_ifdefs is not None: - c.Append("#if %s" % function_ifdefs, indent_level=0) - function_name = JsFunctionNameToClassName(namespace.name, function.name) c.Append("registry->RegisterFunction<%sFunction>();" % ( function_name)) - - if function_ifdefs is not None: - c.Append("#endif // %s" % function_ifdefs, indent_level=0) - - if namespace_ifdefs is not None: - c.Append("#endif // %s" % namespace_ifdefs, indent_level=0) c.Eblock("}") c.Eblock("};") c.Append() @@ -146,7 +100,7 @@ class SchemaBundleGenerator(object): c.Concat(self._cpp_type_generator.GetRootNamespaceStart()) c.Append() c.Sblock('class GeneratedSchemas {') - c.Append(' public:') + c.Append('public:') c.Append('// Puts all API schemas in |schemas|.') c.Append('static void Get(' 'std::map<std::string, base::StringPiece>* schemas);') diff --git a/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp b/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp index 43ec909..f8e5dc3 100644 --- a/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp +++ b/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp @@ -9,9 +9,9 @@ 'type': 'static_library', 'variables': { 'chromium_code': 1, - 'schema_files': [ - 'additional_properties.json', + 'json_schema_files': [ 'any.json', + 'additional_properties.json', 'arrays.json', 'callbacks.json', 'choices.json', @@ -19,19 +19,22 @@ 'enums.json', 'functions_as_parameters.json', 'functions_on_types.json', - 'idl_basics.idl', - 'idl_object_types.idl', 'objects.json', 'simple_api.json', ], + 'idl_schema_files': [ + 'idl_basics.idl', + 'idl_object_types.idl' + ], 'cc_dir': 'tools/json_schema_compiler/test', 'root_namespace': 'test::api', }, 'inputs': [ - '<@(schema_files)', + '<@(idl_schema_files)', ], 'sources': [ - '<@(schema_files)', + '<@(json_schema_files)', + '<@(idl_schema_files)', ], 'includes': ['../../../build/json_schema_compile.gypi'], }, |